Package org.apache.tiles.request

Examples of org.apache.tiles.request.Request


     * Tests {@link MustacheRenderer#render(String, org.apache.tiles.request.Request)}.
     * @throws IOException If something goes wrong.
     */
    @Test
    public void testRender() throws IOException {
        Request request = createMock(Request.class);
        Writer writer = createMock(Writer.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        ApplicationResource applicationResource = createMock(ApplicationResource.class);
        expect(applicationResource.getInputStream()).andReturn(getClass().getResource("/test.html").openStream());

        Map<String,Object> context = Collections.singletonMap("testKey", (Object)"test value");

        expect(request.getApplicationContext()).andReturn(applicationContext);
        expect(applicationContext.getResource(isA(String.class))).andReturn(applicationResource).anyTimes();
        expect(request.getAvailableScopes()).andReturn(Arrays.asList("request", "session", "application"));
        expect(request.getContext("request")).andReturn(context);
        expect(request.getContext("session")).andReturn(Collections.<String,Object>emptyMap());
        expect(request.getContext("application")).andReturn(Collections.<String,Object>emptyMap());
        expect(request.getWriter()).andReturn(writer);
        writer.write("test template with test value");
        writer.flush();

        replay(request, applicationContext, applicationResource, writer);
        Renderer renderer = new MustacheRenderer();
View Full Code Here


     * Tests {@link MustacheRenderer#render(String, org.apache.tiles.request.Request)}.
     * @throws IOException If something goes wrong.
     */
    @Test(expected = CannotRenderException.class)
    public void testRenderException() throws IOException {
        Request request = createMock(Request.class);
        replay(request);
        Renderer renderer = new MustacheRenderer();
        try {
            renderer.render(null, request);
        } finally {
View Full Code Here

     * @return The servlet-based request context.
     * @throws NotAServletEnvironmentException If a servlet-based request
     * context could not be found.
     */
    public static ServletRequest getServletRequest(Request request) {
        Request currentRequest = request;
        while (true) {
            if (currentRequest == null) {
                throw new NotAServletEnvironmentException("Last Tiles request context is null");
            }

View Full Code Here

        expect(servletContext.getAttribute(ApplicationAccess.APPLICATION_CONTEXT_ATTRIBUTE)).andReturn(applicationContext);

        replay(context, writer, node, viewContext, request, response, servletContext, applicationContext);
        VelocityAutotagRuntime runtime = new VelocityAutotagRuntime();
        runtime.render(context, writer, node);
        Request velocityRequest = runtime.createRequest();
        assertTrue(velocityRequest instanceof VelocityRequest);
        verify(context, writer, node, viewContext, request, response, servletContext, applicationContext);
    }
View Full Code Here

     * Tests {@link MustacheRenderer#render(String, org.apache.tiles.request.Request)}.
     * @throws IOException If something goes wrong.
     */
    @Test
    public void testRender() throws IOException {
        Request request = createMock(Request.class);
        StringWriter writer = new StringWriter();
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        ApplicationResource applicationResource = createMock(ApplicationResource.class);

        Map<String,Object> context = Collections.singletonMap("testKey", (Object)"test value");

        expect(applicationContext.getResource(isA(String.class))).andReturn(applicationResource).anyTimes();
        expect(request.getAvailableScopes()).andReturn(Arrays.asList(Request.REQUEST_SCOPE, "session", Request.APPLICATION_SCOPE));
        expect(request.getContext(Request.REQUEST_SCOPE)).andReturn(context);
        expect(request.getContext("session")).andReturn(Collections.<String,Object>emptyMap());
        expect(request.getContext(Request.APPLICATION_SCOPE)).andReturn(Collections.<String,Object>emptyMap());
        expect(request.getWriter()).andReturn(writer).anyTimes();

        replay(request, applicationContext, applicationResource);
        Renderer renderer = new MustacheRenderer(new DefaultMustacheFactory() {
                @Override
                public Reader getReader(String path) {
View Full Code Here

     * Tests {@link MustacheRenderer#render(String, org.apache.tiles.request.Request)}.
     * @throws IOException If something goes wrong.
     */
    @Test(expected = CannotRenderException.class)
    public void testRenderException() throws IOException {
        Request request = createMock(Request.class);
        replay(request);
        Renderer renderer = new MustacheRenderer();
        try {
            renderer.render(null, request);
        } finally {
View Full Code Here

     * @return The servlet-based request context.
     * @throws NotAServletEnvironmentException If a servlet-based request
     * context could not be found.
     */
    public static ServletRequest getServletRequest(Request request) {
        Request currentRequest = request;
        while (true) {
            if (currentRequest == null) {
                throw new NotAServletEnvironmentException("Last Tiles request context is null");
            }

View Full Code Here

     * @throws IOException If something goes wrong during rendition.
     */
    @Test
    public void testWrite() throws IOException {
        StringWriter writer = new StringWriter();
        Request requestContext = createMock(Request.class);
        RendererListener listener = createMock(RendererListener.class);

        listener.start("Result", requestContext);
        expect(requestContext.getWriter()).andReturn(writer);
        listener.end("Result", requestContext);
        replay(requestContext);

        renderer.addListener(listener);
        renderer.render("Result", requestContext);
View Full Code Here

     * Tests
     * {@link PublisherRenderer#isRenderable(String, Request)}.
     */
    @Test
    public void testIsRenderable() {
        Request requestContext = createMock(Request.class);
        RendererListener listener = createMock(RendererListener.class);
        replay(requestContext);
        renderer.addListener(listener);
        assertTrue(renderer.isRenderable("Result", requestContext));
        verify(requestContext);
View Full Code Here

     *
     * @throws IOException If something goes wrong during rendition.
     */
    @Test
    public void testWriteDefinition() throws IOException {
        Request requestContext = EasyMock
                .createMock(Request.class);

        expect(
                definitionRenderer.isRenderable("my.definition",
                        requestContext)).andReturn(Boolean.TRUE);
View Full Code Here

TOP

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

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.