Search in sources :

Example 26 with WicketTester

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

the class NodeBorderTest method properlyClosed.

/**
 * WICKET-5447
 */
@Test
public void properlyClosed() throws Exception {
    WicketTester tester = new WicketTester();
    Label label = new Label("label");
    label.add(new NodeBorder(new boolean[] { true, false, true }));
    tester.startComponentInPage(label);
    tester.assertResultPage("<div class=\"tree-branch tree-branch-mid\"><div class=\"tree-subtree\"><div class=\"tree-branch tree-branch-last\"><div class=\"tree-subtree\"><div class=\"tree-branch tree-branch-mid\"><span wicket:id=\"label\" class=\"tree-node\"></span></div></div></div></div></div>");
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.junit.Test)

Example 27 with WicketTester

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

the class CryptoMapperTest method before.

/**
 * Creates the {@link CryptoMapper}
 *
 * @throws Exception
 */
@Before
public void before() throws Exception {
    tester = new WicketTester(HomePage.class);
    WebApplication application = tester.getApplication();
    application.mountPage(MOUNTED_URL, Page1.class);
    /**
     * Use explicit crypt provider to prevent crypt warning output, see
     * SecuritySettings#getCryptFactory()
     */
    Supplier<ICrypt> cryptProvider = new Supplier<ICrypt>() {

        private ICryptFactory cryptFactory = new CachingSunJceCryptFactory(SecuritySettings.DEFAULT_ENCRYPTION_KEY);

        @Override
        public ICrypt get() {
            return cryptFactory.newCrypt();
        }
    };
    mapper = new CryptoMapper(application.getRootRequestMapper(), cryptProvider);
}
Also used : ICryptFactory(org.apache.wicket.util.crypt.ICryptFactory) ICrypt(org.apache.wicket.util.crypt.ICrypt) CachingSunJceCryptFactory(org.apache.wicket.util.crypt.CachingSunJceCryptFactory) Supplier(java.util.function.Supplier) WicketTester(org.apache.wicket.util.tester.WicketTester) WebApplication(org.apache.wicket.protocol.http.WebApplication) Before(org.junit.Before)

Example 28 with WicketTester

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

the class MoreSpecificResourceMountPathTest method can_use_resource_mounted_without_parameter.

@Test
public void can_use_resource_mounted_without_parameter() {
    WicketTester browser = new WicketTester(new WicketApplication());
    browser.executeUrl(WicketApplication.urlFor("howdy"));
    Assert.assertThat(browser.getLastResponseAsString(), is(equalTo("howdy")));
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.junit.Test)

Example 29 with WicketTester

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

the class HtmlImportHeaderItemTest method wicketPageUrl.

@Test
public void wicketPageUrl() throws Exception {
    WicketTester tester = new WicketTester();
    PageParameters parameters = new PageParameters();
    parameters.add("foo", "foo");
    parameters.add("bar", "bar");
    CharSequence pageUrl = tester.getRequestCycle().urlFor(SimplePage.class, parameters);
    MetaDataHeaderItem importLink = HtmlImportHeaderItem.forImportLinkTag(SimplePage.class, parameters, "monitor", true);
    assertEquals("<link rel=\"import\" href=\"" + pageUrl + "\" media=\"monitor\" async />\n", importLink.generateString());
}
Also used : WicketTester(org.apache.wicket.util.tester.WicketTester) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Test(org.junit.Test)

Example 30 with WicketTester

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

the class SendPayloadWithContextTest method before.

@Before
public void before() {
    tester = new WicketTester();
    WebSocketSettings webSocketSettings = WebSocketSettings.Holder.get(tester.getApplication());
    webSocketSettings.setSendPayloadExecutor(new WebSocketSettings.SameThreadExecutor() {

        @Override
        public void run(Runnable command) {
            context.set(true);
            super.run(command);
            context.set(false);
        }
    });
}
Also used : WebSocketSettings(org.apache.wicket.protocol.ws.WebSocketSettings) WicketTester(org.apache.wicket.util.tester.WicketTester) 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