Package net.sourceforge.stripes.mock

Examples of net.sourceforge.stripes.mock.MockHttpServletResponse


    }

    @Test(groups = "fast")
    public void testPermanantRedirect() throws Exception {
        RedirectResolution resolution = new RedirectResolution("http://www.stripesframework.org", false).setPermanent(true);
        MockHttpServletResponse response = new MockHttpServletResponse();
        resolution.execute(buildMockServletRequest(), response);
       
        Assert.assertEquals(response.getStatus(), HttpServletResponse.SC_MOVED_PERMANENTLY);
        Assert.assertEquals(response.getHeaderMap().get("Location").iterator().next(), "http://www.stripesframework.org");
    }
View Full Code Here


    }

    @Test(groups = "fast")
    public void testTemporaryRedirect() throws Exception {
        RedirectResolution resolution = new RedirectResolution("http://www.stripesframework.org", false);
        MockHttpServletResponse response = new MockHttpServletResponse();
        resolution.execute(buildMockServletRequest(), response);
       
        Assert.assertEquals(response.getStatus(), HttpServletResponse.SC_MOVED_TEMPORARILY);
        Assert.assertEquals(response.getRedirectUrl(), "http://www.stripesframework.org");
    }
View Full Code Here

    }
   
    @Test(groups = "fast")
    public void testPermanantRedirectWithParameters() throws Exception {
        RedirectResolution resolution = new RedirectResolution("http://www.stripesframework.org", false).setPermanent(true).addParameter("test", "test");
        MockHttpServletResponse response = new MockHttpServletResponse();
        resolution.execute(buildMockServletRequest(), response);
       
        Assert.assertEquals(response.getStatus(), HttpServletResponse.SC_MOVED_PERMANENTLY);
        Assert.assertEquals(response.getHeaderMap().get("Location").iterator().next(), "http://www.stripesframework.org?test=test");
    }
View Full Code Here

    }

    @Test(groups = "fast")
    public void testTemporaryRedirectWithParameters() throws Exception {
        RedirectResolution resolution = new RedirectResolution("http://www.stripesframework.org", false).addParameter("test", "test");
        MockHttpServletResponse response = new MockHttpServletResponse();
        resolution.execute(buildMockServletRequest(), response);
       
        Assert.assertEquals(response.getStatus(), HttpServletResponse.SC_MOVED_TEMPORARILY);
        Assert.assertEquals(response.getRedirectUrl(), "http://www.stripesframework.org?test=test");
    }
View Full Code Here

        resolution.setAttachment(attachment);
        if (filename != null) {
            resolution.setFilename(filename);
        }

        MockHttpServletResponse response = new MockHttpServletResponse();
        resolution.applyHeaders(response);
        resolution.stream(response);
        Assert.assertEquals(data, response.getOutputBytes());

        ContentDisposition disposition = getContentDisposition(response);
        if (attachment) {
            if (filename == null) {
                Assert.assertNotNull(disposition);
View Full Code Here

    }

    @Test(groups = "fast")
    public void testPermanantRedirect() throws Exception {
        RedirectResolution resolution = new RedirectResolution("http://www.stripesframework.org", false).setPermanent(true);
        MockHttpServletResponse response = new MockHttpServletResponse();
        resolution.execute(buildMockServletRequest(), response);
       
        Assert.assertEquals(response.getStatus(), HttpServletResponse.SC_MOVED_PERMANENTLY);
        Assert.assertEquals(response.getHeaderMap().get("Location").iterator().next(), "http://www.stripesframework.org");
    }
View Full Code Here

    }

    @Test(groups = "fast")
    public void testTemporaryRedirect() throws Exception {
        RedirectResolution resolution = new RedirectResolution("http://www.stripesframework.org", false);
        MockHttpServletResponse response = new MockHttpServletResponse();
        resolution.execute(buildMockServletRequest(), response);
       
        Assert.assertEquals(response.getStatus(), HttpServletResponse.SC_MOVED_TEMPORARILY);
        Assert.assertEquals(response.getRedirectUrl(), "http://www.stripesframework.org");
    }
View Full Code Here

    }
   
    @Test(groups = "fast")
    public void testPermanantRedirectWithParameters() throws Exception {
        RedirectResolution resolution = new RedirectResolution("http://www.stripesframework.org", false).setPermanent(true).addParameter("test", "test");
        MockHttpServletResponse response = new MockHttpServletResponse();
        resolution.execute(buildMockServletRequest(), response);
       
        Assert.assertEquals(response.getStatus(), HttpServletResponse.SC_MOVED_PERMANENTLY);
        Assert.assertEquals(response.getHeaderMap().get("Location").iterator().next(), "http://www.stripesframework.org?test=test");
    }
View Full Code Here

    }

    @Test(groups = "fast")
    public void testTemporaryRedirectWithParameters() throws Exception {
        RedirectResolution resolution = new RedirectResolution("http://www.stripesframework.org", false).addParameter("test", "test");
        MockHttpServletResponse response = new MockHttpServletResponse();
        resolution.execute(buildMockServletRequest(), response);
       
        Assert.assertEquals(response.getStatus(), HttpServletResponse.SC_MOVED_TEMPORARILY);
        Assert.assertEquals(response.getRedirectUrl(), "http://www.stripesframework.org?test=test");
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.stripes.mock.MockHttpServletResponse

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.