Package org.apache.tiles.request

Examples of org.apache.tiles.request.DispatchRequest


    /**
      * Tests {@link FreemarkerRequest#getNativeScopes()}.
      */
    @Test
    public void testGetAvailableScopes() {
        DispatchRequest enclosedRequest = createMock(DispatchRequest.class);
        expect(enclosedRequest.getAvailableScopes()).andReturn(Collections.singletonList("parent"));
        replay(enclosedRequest);
        context = new VelocityRequest(enclosedRequest, velocityContext, writer);
        assertArrayEquals(new String[] {"parent", "page"}, context.getAvailableScopes().toArray());
        verify(enclosedRequest);
    }
View Full Code Here


    /**
     * Tests {@link VelocityRequest#getPrintWriter()}.
     */
    @Test
    public void testGetPrintWriter() {
        DispatchRequest enclosedRequest = createMock(DispatchRequest.class);
        expect(enclosedRequest.getAvailableScopes()).andReturn(Collections.singletonList("parent"));

        replay(velocityContext, enclosedRequest);
        context = new VelocityRequest(enclosedRequest, velocityContext, writer);
        assertNotNull(context.getPrintWriter());
        verify(velocityContext, enclosedRequest);
View Full Code Here

    /**
     * Tests {@link VelocityRequest#getPrintWriter()}.
     */
    @Test
    public void testGetPrintWriterPrintWriter() {
        DispatchRequest enclosedRequest = createMock(DispatchRequest.class);
        expect(enclosedRequest.getAvailableScopes()).andReturn(Collections.singletonList("parent"));

        PrintWriter printWriter = new PrintWriter(writer);
        replay(velocityContext, enclosedRequest);
        context = new VelocityRequest(enclosedRequest, velocityContext, printWriter);
        assertEquals(printWriter, context.getPrintWriter());
View Full Code Here

    /**
     * Tests {@link VelocityRequest#getPrintWriter()}.
     */
    @Test(expected = IllegalStateException.class)
    public void testGetPrintWriterNoWriter() {
        DispatchRequest enclosedRequest = createMock(DispatchRequest.class);
        expect(enclosedRequest.getAvailableScopes()).andReturn(Collections.singletonList("parent"));

        replay(velocityContext, enclosedRequest);
        context = new VelocityRequest(enclosedRequest, velocityContext, null);
        context.getPrintWriter();
        verify(velocityContext, enclosedRequest);
View Full Code Here

    /**
     * Tests {@link VelocityRequest#getWriter()}.
     */
    @Test
    public void testGetWriter() {
        DispatchRequest enclosedRequest = createMock(DispatchRequest.class);
        expect(enclosedRequest.getAvailableScopes()).andReturn(Collections.singletonList("parent"));

        replay(velocityContext, enclosedRequest);
        context = new VelocityRequest(enclosedRequest, velocityContext, writer);
        assertEquals(writer, context.getWriter());
        verify(velocityContext, enclosedRequest);
View Full Code Here

    /**
     * Tests {@link VelocityRequest#getWriter()}.
     */
    @Test(expected = IllegalStateException.class)
    public void testGetWriterNoWriter() {
        DispatchRequest enclosedRequest = createMock(DispatchRequest.class);
        expect(enclosedRequest.getAvailableScopes()).andReturn(Collections.singletonList("parent"));

        replay(velocityContext, enclosedRequest);
        context = new VelocityRequest(enclosedRequest, velocityContext, null);
        context.getWriter();
        verify(velocityContext, enclosedRequest);
View Full Code Here

    /**
     * Tests {@link VelocityRequest#getPageScope()}.
     */
    @Test
    public void testGetPageScope() {
        DispatchRequest enclosedRequest = createMock(DispatchRequest.class);
        expect(enclosedRequest.getAvailableScopes()).andReturn(Collections.singletonList("parent"));

        replay(velocityContext, enclosedRequest);
        context = new VelocityRequest(enclosedRequest, velocityContext, writer);
        assertTrue(context.getPageScope() instanceof VelocityScopeMap);
        verify(velocityContext, enclosedRequest);
View Full Code Here

     * @return The request.
     */
    public static VelocityRequest createVelocityRequest(
            ApplicationContext applicationContext, HttpServletRequest request,
            HttpServletResponse response, Context velocityContext, Writer writer) {
        DispatchRequest servletRequest = new ServletRequest(
                applicationContext, request, response);
        VelocityRequest velocityRequest = new VelocityRequest(
                servletRequest, velocityContext, writer);
        return velocityRequest;
    }
View Full Code Here

            ApplicationContext applicationContext, Environment env) {
        HttpRequestHashModel requestModel = FreemarkerRequestUtil
                .getRequestHashModel(env);
        HttpServletRequest request = requestModel.getRequest();
        HttpServletResponse response = requestModel.getResponse();
        DispatchRequest enclosedRequest = new ServletRequest(
                applicationContext, request, response);
        return new FreemarkerRequest(enclosedRequest, env);
    }
View Full Code Here

     *
     * @throws IOException If something goes wrong during rendition.
     */
    @Test
    public void testWrite() throws IOException {
        DispatchRequest requestContext = createMock(DispatchRequest.class);
        requestContext.dispatch("/myTemplate.jsp");
        replay(requestContext);
        renderer.render("/myTemplate.jsp", requestContext);
        verify(requestContext);
    }
View Full Code Here

TOP

Related Classes of org.apache.tiles.request.DispatchRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.