Search in sources :

Example 66 with WicketTester

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

the class FormMethodMismatchTest method withButtonFormSubmittedContinuesByDefaultWithMismatchingMethod.

@Test
public void withButtonFormSubmittedContinuesByDefaultWithMismatchingMethod() {
    final WicketTester tester = new WicketTester();
    final boolean[] onSubmitCalled = new boolean[1];
    final Form<Void> underTest = new Form<Void>("underTest") {

        @Override
        protected void onSubmit() {
            onSubmitCalled[0] = true;
        }
    };
    tester.startPage(new FormWithButtonPage(underTest));
    final FormTester formTester = tester.newFormTester("underTest");
    tester.getRequest().setMethod("GET");
    formTester.submit("button");
    assertTrue(onSubmitCalled[0]);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.junit.Test)

Example 67 with WicketTester

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

the class FormMethodMismatchTest method withAjaxButtonFormSubmittedContinuesByWithCorrectMethodWhenDesired.

@Test
public void withAjaxButtonFormSubmittedContinuesByWithCorrectMethodWhenDesired() {
    final WicketTester tester = new WicketTester();
    final boolean[] onSubmitCalled = new boolean[1];
    final Form<Void> underTest = new Form<Void>("underTest") {

        @Override
        protected void onSubmit() {
            onSubmitCalled[0] = true;
        }

        @Override
        protected MethodMismatchResponse onMethodMismatch() {
            return MethodMismatchResponse.ABORT;
        }
    };
    tester.startPage(new FormWithAjaxButtonPage(underTest));
    final FormTester formTester = tester.newFormTester("underTest");
    formTester.submit("button");
    assertTrue(onSubmitCalled[0]);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.junit.Test)

Example 68 with WicketTester

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

the class FormMethodMismatchTest method formSubmittedContinuesWithCorrectMethod.

@Test
public void formSubmittedContinuesWithCorrectMethod() {
    final WicketTester tester = new WicketTester();
    final boolean[] onSubmitCalled = new boolean[1];
    final Form<Void> underTest = new Form<Void>("underTest") {

        @Override
        protected void onSubmit() {
            onSubmitCalled[0] = true;
        }
    };
    tester.startPage(new PlainFormPage(underTest));
    final FormTester formTester = tester.newFormTester("underTest");
    formTester.submit();
    assertTrue(onSubmitCalled[0]);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.junit.Test)

Example 69 with WicketTester

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

the class ChildFirstHeaderRenderStrategyTest method executeCombinedTestPre1_5.

/**
 * @param <T>
 * @param pageClass
 * @param filename
 * @throws Exception
 */
private <T extends Page> void executeCombinedTestPre1_5(final Class<T> pageClass, final String filename) throws Exception {
    // Default Config: parent first header render strategy
    log.error("=== PARENT first header render strategy ===");
    tester.startPage(pageClass);
    tester.assertRenderedPage(pageClass);
    tester.assertResultPage(getClass(), filename);
    // child first header render strategy
    log.error("=== CHILD first header render strategy ===");
    System.setProperty("Wicket_HeaderRenderStrategy", ChildFirstHeaderRenderStrategy.class.getName());
    tester = new WicketTester();
    tester.startPage(pageClass);
    tester.assertRenderedPage(pageClass);
    tester.assertResultPage(getClass(), filename + "_2");
    System.setProperty("Wicket_HeaderRenderStrategy", "");
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester)

Example 70 with WicketTester

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

the class PropertiesResolverTest method resolveProperties.

/**
 */
@Test
public void resolveProperties() {
    WicketTester tester = new WicketTester(new App());
    // all the tests are performed in page
    tester.startPage(MyPage.class);
    tester.assertRenderedPage(MyPage.class);
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) 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