Search in sources :

Example 46 with WicketTester

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

the class FormMethodMismatchTest method withButtonFormSubmittedAbortsByWithMismatchingMethodWhenDesired.

@Test
public void withButtonFormSubmittedAbortsByWithMismatchingMethodWhenDesired() {
    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 FormWithButtonPage(underTest));
    final FormTester formTester = tester.newFormTester("underTest");
    tester.getRequest().setMethod("GET");
    formTester.submit("button");
    assertFalse(onSubmitCalled[0]);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.junit.Test)

Example 47 with WicketTester

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

the class FormMethodMismatchTest method withAjaxButtonFormSubmittedContinuesWithCorrectMethod.

@Test
public void withAjaxButtonFormSubmittedContinuesWithCorrectMethod() {
    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 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 48 with WicketTester

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

the class FormMethodMismatchTest method withAjaxButtonFormSubmittedContinuesByDefaultWithMismatchingMethod.

@Test
public void withAjaxButtonFormSubmittedContinuesByDefaultWithMismatchingMethod() {
    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 FormWithAjaxButtonPage(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 49 with WicketTester

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

the class TransparentWebMarkupContainerTest method ajaxUpdate.

/**
 * Test case for <a href="https://issues.apache.org/jira/browse/WICKET-3719">WICKET-3719</a>
 */
@Test
public void ajaxUpdate() {
    WicketTester wicketTester = new WicketTester() {

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

                @Override
                public IPageManager apply(IPageManagerContext context) {
                    return new MockPageManager() {

                        @Override
                        public void touchPage(IManageablePage page) {
                            page = WicketObjects.cloneObject(page);
                            super.touchPage(page);
                        }
                    };
                }
            };
        }
    };
    wicketTester.startPage(TransparentWithAjaxUpdatePage.class);
    wicketTester.clickLink("link", true);
    wicketTester.destroy();
}
Also used : MockPageManager(org.apache.wicket.mock.MockPageManager) WicketTester(org.apache.wicket.util.tester.WicketTester) IPageManagerProvider(org.apache.wicket.IPageManagerProvider) IManageablePage(org.apache.wicket.page.IManageablePage) IPageManagerContext(org.apache.wicket.page.IPageManagerContext) Test(org.junit.Test)

Example 50 with WicketTester

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

the class AutoLinkInPanelsTest method setUp.

@Before
public void setUp() {
    tester = new WicketTester(new WebApplication() {

        @Override
        public Class<? extends Page> getHomePage() {
            return TestPage.class;
        }

        @Override
        protected void init() {
            super.init();
            getMarkupSettings().setAutomaticLinking(true);
        }
    });
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) WebApplication(org.apache.wicket.protocol.http.WebApplication) Before(org.junit.Before)

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