Search in sources :

Example 1 with MockPageManager

use of org.apache.wicket.mock.MockPageManager in project wicket by apache.

the class PageAccessSynchronizerTest method unlockIfNoSuchPage.

/**
 * https://issues.apache.org/jira/browse/WICKET-4009
 */
@Test
public void unlockIfNoSuchPage() {
    PageAccessSynchronizer synchronizer = new PageAccessSynchronizer(Duration.seconds(2));
    IPageManager pageManager = new MockPageManager();
    IPageManager synchronizedPageManager = synchronizer.adapt(pageManager);
    synchronizedPageManager.getPage(0);
    ConcurrentMap<Integer, PageLock> locks = synchronizer.getLocks().get();
    PageLock pageLock = locks.get(Integer.valueOf(0));
    assertNull(pageLock);
    int pageId = 1;
    IManageablePage page = new MockPage(pageId);
    synchronizedPageManager.touchPage(page);
    synchronizedPageManager.getPage(pageId);
    PageLock pageLock2 = locks.get(Integer.valueOf(pageId));
    assertNotNull(pageLock2);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MockPageManager(org.apache.wicket.mock.MockPageManager) PageLock(org.apache.wicket.page.PageAccessSynchronizer.PageLock) MockPage(org.apache.wicket.MockPage) Test(org.junit.Test)

Example 2 with MockPageManager

use of org.apache.wicket.mock.MockPageManager 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 3 with MockPageManager

use of org.apache.wicket.mock.MockPageManager in project wicket by apache.

the class DontStoreNotRenderedPageTestCase method newWicketTester.

@Override
protected WicketTester newWicketTester(WebApplication app) {
    app.getComponentInstantiationListeners().add(new IComponentInstantiationListener() {

        @Override
        public void onInstantiation(Component component) {
            // WICKET-5546 behavior added before Page#init()
            component.add(new Behavior() {
            });
        }
    });
    return new WicketTester(app) {

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

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

                        @Override
                        public void touchPage(IManageablePage page) {
                            Assert.assertFalse("PageB should not be touched!", page instanceof PageB);
                            super.touchPage(page);
                        }
                    };
                }
            };
        }
    };
}
Also used : MockPageManager(org.apache.wicket.mock.MockPageManager) Behavior(org.apache.wicket.behavior.Behavior) WicketTester(org.apache.wicket.util.tester.WicketTester) Component(org.apache.wicket.Component) IPageManagerProvider(org.apache.wicket.IPageManagerProvider) IManageablePage(org.apache.wicket.page.IManageablePage) IPageManagerContext(org.apache.wicket.page.IPageManagerContext) IComponentInstantiationListener(org.apache.wicket.application.IComponentInstantiationListener)

Aggregations

MockPageManager (org.apache.wicket.mock.MockPageManager)3 IPageManagerProvider (org.apache.wicket.IPageManagerProvider)2 IManageablePage (org.apache.wicket.page.IManageablePage)2 IPageManagerContext (org.apache.wicket.page.IPageManagerContext)2 WicketTester (org.apache.wicket.util.tester.WicketTester)2 Test (org.junit.Test)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Component (org.apache.wicket.Component)1 MockPage (org.apache.wicket.MockPage)1 IComponentInstantiationListener (org.apache.wicket.application.IComponentInstantiationListener)1 Behavior (org.apache.wicket.behavior.Behavior)1 PageLock (org.apache.wicket.page.PageAccessSynchronizer.PageLock)1