Search in sources :

Example 31 with MockApplication

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

the class CssUrlReplacerTest method newApplication.

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

        @Override
        protected void init() {
            super.init();
            getResourceSettings().setCachingStrategy(new FilenameWithVersionResourceCachingStrategy("=VER=", new MessageDigestResourceVersion()) {

                @Override
                public void decorateUrl(ResourceUrl url, IStaticCacheableResource resource) {
                    url.setFileName(url.getFileName() + DECORATION_SUFFIX);
                }
            });
        }

        @Override
        public Session newSession(Request request, Response response) {
            Session newSession = super.newSession(request, response);
            newSession.setLocale(Locale.ROOT);
            return newSession;
        }
    };
}
Also used : FilenameWithVersionResourceCachingStrategy(org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy) IStaticCacheableResource(org.apache.wicket.request.resource.caching.IStaticCacheableResource) Response(org.apache.wicket.request.Response) MockApplication(org.apache.wicket.mock.MockApplication) Request(org.apache.wicket.request.Request) MessageDigestResourceVersion(org.apache.wicket.request.resource.caching.version.MessageDigestResourceVersion) ResourceUrl(org.apache.wicket.request.resource.caching.ResourceUrl) Session(org.apache.wicket.Session)

Example 32 with MockApplication

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

the class WebSocketTesterResourceTest method before.

@Before
public void before() {
    TestWebSocketResource.ON_CONNECT_CALLED.set(false);
    TestWebSocketResource.ON_CLOSE_CALLED.set(false);
    ON_OUT_BINARY_CALLED.set(false);
    ON_OUT_TEXT_CALLED.set(false);
    WebApplication application = new MockApplication() {

        @Override
        protected void init() {
            super.init();
            getSharedResources().add(TestWebSocketResource.TEXT, new TestWebSocketResource(EXPECTED_TEXT));
            getSharedResources().add(TestWebSocketResource.BINARY, new TestWebSocketResource(EXPECTED_BINARY, EXPECTED_OFFSET, EXPECTED_LENGTH));
        }
    };
    tester = new WicketTester(application);
}
Also used : MockApplication(org.apache.wicket.mock.MockApplication) WicketTester(org.apache.wicket.util.tester.WicketTester) WebApplication(org.apache.wicket.protocol.http.WebApplication) Before(org.junit.Before)

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