Search in sources :

Example 1 with MockPropertyDefGenerator

use of org.apache.sling.jcr.js.nodetypes.mock.MockPropertyDefGenerator in project sling by apache.

the class DownloadDefaultBinaryValueTest method setUp.

@Before
public void setUp() throws RepositoryException, IOException {
    // create mocks
    request = mock(SlingHttpServletRequest.class);
    response = mock(SlingHttpServletResponse.class);
    resourceResolver = mock(ResourceResolver.class);
    resource = mock(Resource.class);
    rootNode = mock(Node.class);
    session = mock(Session.class);
    workspace = mock(Workspace.class);
    ntManager = mock(NodeTypeManager.class);
    outStream = new ByteArrayOutputStream();
    // stubbing
    when(request.getMethod()).thenReturn(HttpConstants.METHOD_GET);
    when(request.getResourceResolver()).thenReturn(resourceResolver);
    when(resourceResolver.getResource("/")).thenReturn(resource);
    when(resource.adaptTo(Node.class)).thenReturn(rootNode);
    when(rootNode.getSession()).thenReturn(session);
    when(session.getWorkspace()).thenReturn(workspace);
    when(workspace.getNodeTypeManager()).thenReturn(ntManager);
    when(response.getWriter()).thenReturn(new PrintWriter(outStream, true));
    propDefGenerator = new MockPropertyDefGenerator();
}
Also used : SlingHttpServletResponse(org.apache.sling.api.SlingHttpServletResponse) MockPropertyDefGenerator(org.apache.sling.jcr.js.nodetypes.mock.MockPropertyDefGenerator) NodeTypeManager(javax.jcr.nodetype.NodeTypeManager) Node(javax.jcr.Node) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) Resource(org.apache.sling.api.resource.Resource) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SlingHttpServletRequest(org.apache.sling.api.SlingHttpServletRequest) Session(javax.jcr.Session) Workspace(javax.jcr.Workspace) PrintWriter(java.io.PrintWriter) Before(org.junit.Before)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintWriter (java.io.PrintWriter)1 Node (javax.jcr.Node)1 Session (javax.jcr.Session)1 Workspace (javax.jcr.Workspace)1 NodeTypeManager (javax.jcr.nodetype.NodeTypeManager)1 SlingHttpServletRequest (org.apache.sling.api.SlingHttpServletRequest)1 SlingHttpServletResponse (org.apache.sling.api.SlingHttpServletResponse)1 Resource (org.apache.sling.api.resource.Resource)1 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)1 MockPropertyDefGenerator (org.apache.sling.jcr.js.nodetypes.mock.MockPropertyDefGenerator)1 Before (org.junit.Before)1