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.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);
        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

     * @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

     * @throws IOException If something goes wrong during rendition.
     */
    @Test(expected = NullPointerException.class)
    public void testWriteNull() throws IOException {
        StringWriter writer = new StringWriter();
        Request requestContext = EasyMock
                .createMock(Request.class);

        replay(requestContext, stringRenderer, templateRenderer,
                definitionRenderer);
        try {
View Full Code Here

     * @throws IOException If something goes wrong during rendition.
     */
    @Test(expected = CannotRenderException.class)
    public void testWriteNotRenderable() throws IOException {
        StringWriter writer = new StringWriter();
        Request requestContext = EasyMock
                .createMock(Request.class);

        expect(
                definitionRenderer.isRenderable("Result",
                        requestContext)).andReturn(Boolean.FALSE);
View Full Code Here

     *
     * @throws IOException If something goes wrong during rendition.
     */
    @Test
    public void testWriteString() throws IOException {
        Request requestContext = EasyMock
                .createMock(Request.class);
        expect(
                definitionRenderer.isRenderable("Result",
                        requestContext)).andReturn(Boolean.FALSE);
        expect(
View Full Code Here

     * @throws IOException If something goes wrong during rendition.
     */
    @Test
    public void testWriteTemplate() throws IOException {
        StringWriter writer = new StringWriter();
        Request requestContext = EasyMock
                .createMock(Request.class);
        templateRenderer.render("/myTemplate.jsp", requestContext);
        expect(
                definitionRenderer.isRenderable("/myTemplate.jsp",
                        requestContext)).andReturn(Boolean.FALSE);
View Full Code Here

     * Tests
     * {@link DispatchRenderer#isRenderable(String, DispatchRequest)}.
     */
    @Test
    public void testIsRenderable() {
        Request requestContext = createMock(DispatchRequest.class);
        replay(requestContext);
        assertTrue(renderer.isRenderable("/myTemplate.jsp", requestContext));
        assertFalse(renderer.isRenderable(null, requestContext));
        verify(requestContext);
    }
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.