Search in sources :

Example 81 with WicketTester

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

the class ResourceReferenceLambdaTest method newWicketTester.

@Override
protected WicketTester newWicketTester(WebApplication app) {
    WicketTester wicketTester = super.newWicketTester(app);
    IResource res = (attributes) -> attributes.getResponse().write(output);
    ResourceReference resRef = ResourceReference.of("lambdares", () -> res);
    app.mountResource("/test", resRef);
    return wicketTester;
}
Also used : WebApplication(org.apache.wicket.protocol.http.WebApplication) WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.junit.Test) WicketTestCase(org.apache.wicket.util.tester.WicketTestCase) WicketTester(org.apache.wicket.util.tester.WicketTester)

Example 82 with WicketTester

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

the class QueryStringWithVersionResourceCachingStrategyTest method testUrlVersionStoredInRequestCycle.

@Test
public void testUrlVersionStoredInRequestCycle() {
    WicketTester tester = new WicketTester();
    tester.getApplication().getResourceSettings().setCachingStrategy(strategy);
    try {
        PageParameters urlParameters = new PageParameters();
        urlParameters.add(versionParameter, "9A0364B9E99BB480DD25E1F0284C8555", INamedParameters.Type.QUERY_STRING);
        ResourceUrl resourceUrl = new ResourceUrl("some-resource.txt", urlParameters);
        strategy.undecorateUrl(resourceUrl);
        String version = tester.getRequestCycle().getMetaData(IResourceCachingStrategy.URL_VERSION);
        assertEquals("9A0364B9E99BB480DD25E1F0284C8555", version);
    } finally {
        tester.destroy();
    }
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) BaseWicketTester(org.apache.wicket.util.tester.BaseWicketTester) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Test(org.junit.Test)

Example 83 with WicketTester

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

the class PageIdPoliticTest method setUp.

@Before
public void setUp() throws Exception {
    application = new MockApplication();
    dataStore = new InMemoryPageStore() {

        @Override
        public void storeData(String sessionId, int pageId, byte[] pageAsBytes) {
            super.storeData(sessionId, pageId, pageAsBytes);
            storeCount++;
        }
    };
    tester = new WicketTester(application) {

        @Override
        protected IPageManagerProvider newTestPageManagerProvider() {
            return new IPageManagerProvider() {

                @Override
                public IPageManager apply(IPageManagerContext pageManagerContext) {
                    IPageStore pageStore = new DefaultPageStore(new JavaSerializer(application.getApplicationKey()), dataStore, 4);
                    return new PageStoreManager(application.getName(), pageStore, pageManagerContext);
                }
            };
        }
    };
}
Also used : IPageStore(org.apache.wicket.pageStore.IPageStore) IPageManager(org.apache.wicket.page.IPageManager) MockApplication(org.apache.wicket.mock.MockApplication) IPageManagerProvider(org.apache.wicket.IPageManagerProvider) JavaSerializer(org.apache.wicket.serialize.java.JavaSerializer) DefaultPageStore(org.apache.wicket.pageStore.DefaultPageStore) PageStoreManager(org.apache.wicket.page.PageStoreManager) WicketTester(org.apache.wicket.util.tester.WicketTester) IPageManagerContext(org.apache.wicket.page.IPageManagerContext) InMemoryPageStore(org.apache.wicket.versioning.InMemoryPageStore) Before(org.junit.Before)

Example 84 with WicketTester

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

the class ContextRelativeResourceReferenceTest method newWicketTester.

@Override
protected WicketTester newWicketTester(WebApplication app) {
    WicketTester tester = super.newWicketTester(app);
    app.getResourceSettings().setUseMinifiedResources(true);
    return tester;
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester)

Example 85 with WicketTester

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

the class CustomHomePageTest method defaultHomePage.

/**
 * Tests no custom home page. The home page is get from {@link Application#getHomePage()}
 */
@Test
public void defaultHomePage() {
    final WebApplication dummyApplication = new DummyApplication();
    final WicketTester tester = new WicketTester(dummyApplication);
    requestHomePage(tester);
    tester.assertRenderedPage(dummyApplication.getHomePage());
    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)

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