Search in sources :

Example 1 with PageLock

use of org.apache.wicket.page.PageAccessSynchronizer.PageLock 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)

Aggregations

AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 MockPage (org.apache.wicket.MockPage)1 MockPageManager (org.apache.wicket.mock.MockPageManager)1 PageLock (org.apache.wicket.page.PageAccessSynchronizer.PageLock)1 Test (org.junit.Test)1