Search in sources :

Example 6 with WicketTester

use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.

the class XForwardedRequestWrapperTest method test7.

/**
 * @throws Exception
 */
@Test
public void test7() throws Exception {
    MyApplication app = new MyApplication();
    tester = new WicketTester(app);
    app.factory.getConfig().setAllowedInternalProxies("192\\.168\\.0\\.10, 192\\.168\\.0\\.11");
    app.factory.getConfig().setRemoteIPHeader("x-forwarded-for");
    app.factory.getConfig().setProxiesHeader("x-forwarded-by");
    app.factory.getConfig().setTrustedProxies("proxy1, proxy2");
    request.setRemoteAddr("192.168.0.10");
    request.addHeader("x-forwarded-for", "140.211.11.130, untrusted-proxy, proxy1");
    tester.startPage(SimplePage.class);
    tester.assertRenderedPage(SimplePage.class);
    tester.assertResultPage(SimplePage.class, "SimplePageExpectedResult.html");
    MockHttpServletResponse resp = tester.getResponse();
// @TODO should there be any header in the response ????
// assertEquals("140.211.11.130", resp.getHeader("x-forwarded-for"));
// assertEquals("proxy1", resp.getHeader("x-forwarded-by"));
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) MockHttpServletResponse(org.apache.wicket.protocol.http.mock.MockHttpServletResponse) Test(org.junit.Test)

Example 7 with WicketTester

use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.

the class HttpsMapperApplicationTest method switchHttpToHttpsWithCustomPorts.

@Test
public void switchHttpToHttpsWithCustomPorts() {
    WicketTester tester = new WicketTester(new HttpsMapperApplication(123, 456));
    tester.getRequest().setScheme("http");
    tester.getRequest().setServerPort(123);
    requestPage(tester, HttpsPage.class);
    assertEquals("https", tester.getLastRequest().getScheme());
    assertEquals(456, tester.getLastRequest().getServerPort());
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.junit.Test)

Example 8 with WicketTester

use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.

the class HttpsMapperApplicationTest method switchHttpToHttpsWithDefaultPorts.

@Test
public void switchHttpToHttpsWithDefaultPorts() {
    WicketTester tester = new WicketTester(new HttpsMapperApplication());
    tester.getRequest().setScheme("http");
    requestPage(tester, HttpsPage.class);
    assertEquals("https", tester.getLastRequest().getScheme());
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.junit.Test)

Example 9 with WicketTester

use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.

the class HttpsMapperApplicationTest method switchHttpsToHttpWithDefaultPorts.

@Test
public void switchHttpsToHttpWithDefaultPorts() {
    WicketTester tester = new WicketTester(new HttpsMapperApplication());
    tester.getRequest().setScheme("https");
    tester.getRequest().setServerPort(443);
    requestPage(tester, HttpPage.class);
    assertEquals("http", tester.getLastRequest().getScheme());
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.junit.Test)

Example 10 with WicketTester

use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.

the class ResponseIOExceptionTest method before.

/**
 * @throws Exception
 */
@Before
public void before() throws Exception {
    tester = new WicketTester() {

        @Override
        protected Response newServletWebResponse(ServletWebRequest servletWebRequest) {
            return new ProblematicResponse(servletWebRequest, getResponse());
        }
    };
    tester.setExposeExceptions(false);
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) ServletWebResponse(org.apache.wicket.protocol.http.servlet.ServletWebResponse) Response(org.apache.wicket.request.Response) WicketTester(org.apache.wicket.util.tester.WicketTester) ServletWebRequest(org.apache.wicket.protocol.http.servlet.ServletWebRequest) Before(org.junit.Before)

Aggregations

WicketTester (org.apache.wicket.util.tester.WicketTester)89 Test (org.junit.Test)54 Before (org.junit.Before)26 FormTester (org.apache.wicket.util.tester.FormTester)14 WebApplication (org.apache.wicket.protocol.http.WebApplication)9 MockApplication (org.apache.wicket.mock.MockApplication)6 AbstractDeploymentTest (org.apache.wicket.arquillian.testing.deployment.AbstractDeploymentTest)5 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)5 IPageManagerProvider (org.apache.wicket.IPageManagerProvider)4 IPageManagerContext (org.apache.wicket.page.IPageManagerContext)4 DummyApplication (org.apache.wicket.resource.DummyApplication)4 Component (org.apache.wicket.Component)3 Response (org.apache.wicket.request.Response)3 WicketApplication (sandbox.WicketApplication)3 TestWicketJavaEEApplication (org.apache.wicket.arquillian.testing.TestWicketJavaEEApplication)2 IAuthorizationStrategy (org.apache.wicket.authorization.IAuthorizationStrategy)2 RoleAuthorizationStrategy (org.apache.wicket.authroles.authorization.strategies.role.RoleAuthorizationStrategy)2 MockPageManager (org.apache.wicket.mock.MockPageManager)2 IManageablePage (org.apache.wicket.page.IManageablePage)2 IPageManager (org.apache.wicket.page.IPageManager)2