Search in sources :

Example 1 with WicketTester

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

the class PageTest method testBasicRender.

@Test
public void testBasicRender() {
    WicketTester tester = new WicketTester();
    tester.startPage(page);
    tester.assertRenderedPage(page);
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.testng.annotations.Test)

Example 2 with WicketTester

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

the class PageUserTest method testBasicRender.

@Test(enabled = false)
public void testBasicRender() {
    WicketTester tester = new WicketTester();
    PageUser page = tester.startPage(PageUser.class);
    tester.assertRenderedPage(PageUser.class);
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) PageUser(com.evolveum.midpoint.web.page.admin.users.PageUser) Test(org.testng.annotations.Test)

Example 3 with WicketTester

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

the class AjaxBehaviorEnabledTest method before.

/**
 */
@Before
public void before() {
    final IAuthorizationStrategy strategy = new CustomStrategy();
    tester = new WicketTester(new MockApplication() {

        @Override
        public Session newSession(Request request, Response response) {
            return new WebSession(request) {

                private static final long serialVersionUID = 1L;

                @Override
                public IAuthorizationStrategy getAuthorizationStrategy() {
                    return strategy;
                }
            };
        }
    });
}
Also used : Response(org.apache.wicket.request.Response) WebSession(org.apache.wicket.protocol.http.WebSession) MockApplication(org.apache.wicket.mock.MockApplication) Request(org.apache.wicket.request.Request) WicketTester(org.apache.wicket.util.tester.WicketTester) IAuthorizationStrategy(org.apache.wicket.authorization.IAuthorizationStrategy) Before(org.junit.Before)

Example 4 with WicketTester

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

the class InternalErrorCallsAjaxOnFailureTest method callsOnFailure.

/**
 * Setup {@link org.apache.wicket.settings.ExceptionSettings.AjaxErrorStrategy#INVOKE_FAILURE_HANDLER}
 * so Wicket will not redirect to the configured {@link InternalErrorPage}/{@link ExceptionErrorPage}
 * but will preserve the current page and send http status 500 to wicket-ajax.js
 */
@Test
public void callsOnFailure() {
    WicketTester tester = new WicketTester(new DummyApplication() {

        /**
         * @see org.apache.wicket.protocol.http.WebApplication#init()
         */
        @Override
        protected void init() {
            super.init();
            getExceptionSettings().setAjaxErrorHandlingStrategy(ExceptionSettings.AjaxErrorStrategy.INVOKE_FAILURE_HANDLER);
        }
    });
    tester.setExposeExceptions(false);
    tester.startPage(InternalErrorCallsAjaxOnFailurePage.class);
    tester.clickLink("failure-link", true);
    MockHttpServletResponse errorPageResponse = tester.getLastResponse();
    assertEquals(500, errorPageResponse.getStatus());
    // assert that the original page is still the last rendered one
    tester.assertRenderedPage(InternalErrorCallsAjaxOnFailurePage.class);
    tester.destroy();
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) BaseWicketTester(org.apache.wicket.util.tester.BaseWicketTester) DummyApplication(org.apache.wicket.resource.DummyApplication) MockHttpServletResponse(org.apache.wicket.protocol.http.mock.MockHttpServletResponse) Test(org.junit.Test)

Example 5 with WicketTester

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

the class RequestEncodingTest method setUp.

@Before
public void setUp() {
    application = new RedirectApplication();
    tester = new WicketTester(application);
    tester.startPage(RedirectHomePage.class);
    tester.assertRenderedPage(RedirectHomePage.class);
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) 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