Search in sources :

Example 1 with MockPage

use of org.apache.wicket.MockPage in project wicket by apache.

the class AbstractPageStoreTest method storePage2.

/**
 * Assert that storing a page twice won't keep two entries
 */
@Test
public void storePage2() {
    int maxEntries = 10;
    pageStore = createPageStore(serializer, dataStore, maxEntries);
    pageStore.storePage(sessionId, new MockPage(pageId));
    pageStore.storePage(sessionId, new MockPage(pageId));
    assertNotNull(pageStore.getPage(sessionId, pageId));
    pageStore.removePage(sessionId, pageId);
    assertNull(pageStore.getPage(sessionId, pageId));
}
Also used : MockPage(org.apache.wicket.MockPage) Test(org.junit.Test)

Example 2 with MockPage

use of org.apache.wicket.MockPage in project wicket by apache.

the class AbstractPageStoreTest method storePage.

/**
 * Assert that a stored page is available to be read
 */
@Test
public void storePage() {
    pageStore.storePage(sessionId, new MockPage(pageId));
    assertNotNull(pageStore.getPage(sessionId, pageId));
}
Also used : MockPage(org.apache.wicket.MockPage) Test(org.junit.Test)

Example 3 with MockPage

use of org.apache.wicket.MockPage in project wicket by apache.

the class AbstractPageStoreTest method maxSizeDifferentSessions.

/**
 * Verify that it is OK to store more pages than {@code maxEntries}
 * if they are in different sessions
 */
@Test
public void maxSizeDifferentSessions() {
    String sessionId2 = "0987654321";
    pageStore.storePage(sessionId, new MockPage(pageId));
    assertNotNull(pageStore.getPage(sessionId, pageId));
    pageStore.storePage(sessionId2, new MockPage(pageId));
    assertNull(pageStore.getPage(sessionId, pageId));
    assertNotNull(pageStore.getPage(sessionId2, pageId));
}
Also used : MockPage(org.apache.wicket.MockPage) Test(org.junit.Test)

Example 4 with MockPage

use of org.apache.wicket.MockPage 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 5 with MockPage

use of org.apache.wicket.MockPage in project wicket by apache.

the class BookmarkableMapperTest method encode5.

/**
 */
@Test
public void encode5() {
    MockPage page = new MockPage(15);
    page.getPageParameters().set(0, "i1");
    page.getPageParameters().set(1, "i2");
    page.getPageParameters().set("a", "b", INamedParameters.Type.QUERY_STRING);
    page.getPageParameters().set("b", "c", INamedParameters.Type.QUERY_STRING);
    page.setCreatedBookmarkable(false);
    IPageProvider provider = new PageProvider(page);
    IRequestHandler handler = new RenderPageRequestHandler(provider);
    Url url = encoder.mapHandler(handler);
    // never allow bookmarkable render url for page that has not been
    // created by bookmarkable
    // URL
    assertNull(url);
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) MockPage(org.apache.wicket.MockPage) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Aggregations

MockPage (org.apache.wicket.MockPage)33 Test (org.junit.Test)30 IRequestHandler (org.apache.wicket.request.IRequestHandler)23 Url (org.apache.wicket.request.Url)22 PageProvider (org.apache.wicket.core.request.handler.PageProvider)13 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)13 IPageProvider (org.apache.wicket.core.request.handler.IPageProvider)12 PageAndComponentProvider (org.apache.wicket.core.request.handler.PageAndComponentProvider)10 IRequestableComponent (org.apache.wicket.request.component.IRequestableComponent)10 BookmarkableListenerRequestHandler (org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler)9 ListenerRequestHandler (org.apache.wicket.core.request.handler.ListenerRequestHandler)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 WicketRuntimeException (org.apache.wicket.WicketRuntimeException)1 RequestSettingRequestHandler (org.apache.wicket.core.request.handler.RequestSettingRequestHandler)1 MockPageManager (org.apache.wicket.mock.MockPageManager)1 PageLock (org.apache.wicket.page.PageAccessSynchronizer.PageLock)1 Request (org.apache.wicket.request.Request)1 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)1