Search in sources :

Example 36 with WicketTester

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

the class FilenameWithVersionResourceCachingStrategyTest method testUrlVersionStoredInRequestCycle.

@Test
public void testUrlVersionStoredInRequestCycle() {
    WicketTester tester = new WicketTester();
    tester.getApplication().getResourceSettings().setCachingStrategy(strategy);
    try {
        ResourceUrl resourceUrl = new ResourceUrl("some-resource--vers--" + TEST_RESOURCE_VERSION + ".txt", new PageParameters());
        strategy.undecorateUrl(resourceUrl);
        String version = tester.getRequestCycle().getMetaData(IResourceCachingStrategy.URL_VERSION);
        assertEquals(TEST_RESOURCE_VERSION, 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 37 with WicketTester

use of org.apache.wicket.util.tester.WicketTester 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 38 with WicketTester

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

the class StringResourceLoaderTestBase method before.

/**
 * @throws Exception
 */
@Before
public void before() throws Exception {
    tester = new WicketTester(new DummyApplication());
    component = new DummyComponent("test", tester.getApplication());
    DummyPage page = new DummyPage();
    page.add(component);
    loader = createLoader();
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) Before(org.junit.Before)

Example 39 with WicketTester

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

the class WicketOrientDbFilterTesterScope method apply.

@Override
public Statement apply(final Statement base, Description description) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            WicketTester tester = create();
            List<OClass> testClasses = Lists.newArrayList();
            try {
                testClasses = initTestClasses();
                base.evaluate();
            } finally {
                deleteClassesAndDocuments(testClasses);
                tester.destroy();
            }
        }
    };
}
Also used : Statement(org.junit.runners.model.Statement) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) WicketTester(org.apache.wicket.util.tester.WicketTester)

Example 40 with WicketTester

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

the class AbstractWicketTester method getWicketTester.

public static WicketTester getWicketTester(Application app, long langId) {
    // to ensure WebSession is attached
    ensureApplication(langId);
    WicketTester tester = new WicketTester(app, app.getServletContext(), false);
    return tester;
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester)

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