Search in sources :

Example 1 with DummyApplication

use of org.apache.wicket.resource.DummyApplication 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 2 with DummyApplication

use of org.apache.wicket.resource.DummyApplication in project wicket by apache.

the class LocalizerTest method setUp.

/**
 * @throws Exception
 */
@Before
public void setUp() throws Exception {
    tester = new WicketTester(new DummyApplication());
    settings = tester.getApplication().getResourceSettings();
    localizer = tester.getApplication().getResourceSettings().getLocalizer();
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) DummyApplication(org.apache.wicket.resource.DummyApplication) Before(org.junit.Before)

Example 3 with DummyApplication

use of org.apache.wicket.resource.DummyApplication in project wicket by apache.

the class ResponseFilterTest method newApplication.

@Override
protected WebApplication newApplication() {
    final IResponseFilter responseFilter = new IResponseFilter() {

        @Override
        public AppendingStringBuffer filter(AppendingStringBuffer responseBuffer) {
            counter.getAndIncrement();
            return responseBuffer;
        }
    };
    final WebApplication application = new DummyApplication() {

        @Override
        protected void init() {
            super.init();
            getRequestCycleSettings().addResponseFilter(responseFilter);
            getRequestCycleSettings().addResponseFilter(AppendCommentFilter.INSTANCE);
        }
    };
    return application;
}
Also used : AppendingStringBuffer(org.apache.wicket.util.string.AppendingStringBuffer) DummyApplication(org.apache.wicket.resource.DummyApplication) WebApplication(org.apache.wicket.protocol.http.WebApplication)

Example 4 with DummyApplication

use of org.apache.wicket.resource.DummyApplication in project wicket by apache.

the class CustomHomePageTest method customHomePage.

/**
 * Tests mounting of a custom home page via {@link WebApplication#mountPage(String, Class)}
 */
@Test
public void customHomePage() {
    final WebApplication dummyApplication = new DummyApplication() {

        /**
         * @see org.apache.wicket.protocol.http.WebApplication#init()
         */
        @Override
        protected void init() {
            super.init();
            // the following two lines do identical things
            // getRootRequestMapperAsCompound().add(new HomePageMapper(CustomHomePage.class));
            mountPage("/", CustomHomePage.class);
        }
    };
    final WicketTester tester = new WicketTester(dummyApplication);
    requestHomePage(tester);
    tester.assertRenderedPage(CustomHomePage.class);
    tester.destroy();
}
Also used : DummyApplication(org.apache.wicket.resource.DummyApplication) WicketTester(org.apache.wicket.util.tester.WicketTester) WebApplication(org.apache.wicket.protocol.http.WebApplication) Test(org.junit.Test)

Example 5 with DummyApplication

use of org.apache.wicket.resource.DummyApplication in project wicket by apache.

the class RequestCycleListenerTest method setUp.

/**
 */
@Before
public void setUp() {
    DummyApplication application = new DummyApplication();
    application.setName("dummyTestApplication");
    ThreadContext.setApplication(application);
    application.setServletContext(new MockServletContext(application, "/"));
    application.initApplication();
    errorCode = 0;
}
Also used : DummyApplication(org.apache.wicket.resource.DummyApplication) MockServletContext(org.apache.wicket.protocol.http.mock.MockServletContext) Before(org.junit.Before)

Aggregations

DummyApplication (org.apache.wicket.resource.DummyApplication)6 WicketTester (org.apache.wicket.util.tester.WicketTester)4 WebApplication (org.apache.wicket.protocol.http.WebApplication)3 Test (org.junit.Test)3 Before (org.junit.Before)2 MockHttpServletResponse (org.apache.wicket.protocol.http.mock.MockHttpServletResponse)1 MockServletContext (org.apache.wicket.protocol.http.mock.MockServletContext)1 AppendingStringBuffer (org.apache.wicket.util.string.AppendingStringBuffer)1 BaseWicketTester (org.apache.wicket.util.tester.BaseWicketTester)1