Search in sources :

Example 21 with MockApplication

use of org.apache.wicket.mock.MockApplication in project wicket by apache.

the class ApplicationSettingsTest method testLocalizer.

/**
 */
@Test
public void testLocalizer() {
    MockApplication dummy = new MockApplication();
    dummy.setName("test-app");
    dummy.setServletContext(new MockServletContext(dummy, ""));
    ThreadContext.setApplication(dummy);
    dummy.initApplication();
    Localizer localizer = dummy.getResourceSettings().getLocalizer();
    Assert.assertNotNull("Localizer should be available", localizer);
    dummy.internalDestroy();
}
Also used : MockApplication(org.apache.wicket.mock.MockApplication) MockServletContext(org.apache.wicket.protocol.http.mock.MockServletContext) Test(org.junit.Test)

Example 22 with MockApplication

use of org.apache.wicket.mock.MockApplication in project wicket by apache.

the class ApplicationSettingsTest method testFrameworkVersion.

/**
 */
@Test
public void testFrameworkVersion() {
    FrameworkSettings settings = new FrameworkSettings(new MockApplication());
    assertEquals("n/a", settings.getVersion());
}
Also used : MockApplication(org.apache.wicket.mock.MockApplication) FrameworkSettings(org.apache.wicket.settings.FrameworkSettings) Test(org.junit.Test)

Example 23 with MockApplication

use of org.apache.wicket.mock.MockApplication in project wicket by apache.

the class RestartResponseAtInterceptPageExceptionTest method newApplication.

@Override
protected WebApplication newApplication() {
    return new MockApplication() {

        @Override
        protected void init() {
            super.init();
            getSecuritySettings().setAuthorizationStrategy(new AbstractPageAuthorizationStrategy() {

                @Override
                protected <T extends Page> boolean isPageAuthorized(Class<T> pageClass) {
                    if (pageClass != RedirectPage.class) {
                        RedirectPage intercept = new RedirectPage("http://example.com/path");
                        throw new RestartResponseAtInterceptPageException(intercept);
                    }
                    return true;
                }
            });
        }
    };
}
Also used : MockApplication(org.apache.wicket.mock.MockApplication) AbstractPageAuthorizationStrategy(org.apache.wicket.authorization.strategies.page.AbstractPageAuthorizationStrategy) RedirectPage(org.apache.wicket.markup.html.pages.RedirectPage)

Example 24 with MockApplication

use of org.apache.wicket.mock.MockApplication in project wicket by apache.

the class AjaxEnclosureTest method newApplication.

@Override
protected WebApplication newApplication() {
    WebApplication webApplication = new MockApplication() {

        @Override
        protected void init() {
            super.init();
            getMarkupSettings().setStripWicketTags(true);
        }
    };
    return webApplication;
}
Also used : MockApplication(org.apache.wicket.mock.MockApplication) WebApplication(org.apache.wicket.protocol.http.WebApplication)

Example 25 with MockApplication

use of org.apache.wicket.mock.MockApplication in project wicket by apache.

the class TogglePageTest method newApplication.

@Override
protected WebApplication newApplication() {
    WebApplication webApplication = new MockApplication() {

        @Override
        protected void init() {
            super.init();
            getMarkupSettings().setStripWicketTags(true);
        }
    };
    return webApplication;
}
Also used : MockApplication(org.apache.wicket.mock.MockApplication) WebApplication(org.apache.wicket.protocol.http.WebApplication)

Aggregations

MockApplication (org.apache.wicket.mock.MockApplication)32 Test (org.junit.Test)14 ResourceSettings (org.apache.wicket.settings.ResourceSettings)6 WicketTester (org.apache.wicket.util.tester.WicketTester)6 Request (org.apache.wicket.request.Request)4 Response (org.apache.wicket.request.Response)4 Before (org.junit.Before)4 FilterChain (javax.servlet.FilterChain)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)3 Session (org.apache.wicket.Session)3 IAuthorizationStrategy (org.apache.wicket.authorization.IAuthorizationStrategy)3 WebApplication (org.apache.wicket.protocol.http.WebApplication)3 MockHttpServletRequest (org.apache.wicket.protocol.http.mock.MockHttpServletRequest)3 IOException (java.io.IOException)2 Locale (java.util.Locale)2 ServletException (javax.servlet.ServletException)2 ServletRequest (javax.servlet.ServletRequest)2 ServletResponse (javax.servlet.ServletResponse)2 Application (org.apache.wicket.Application)2