Search in sources :

Example 1 with EmptyRequestHandler

use of org.apache.wicket.request.handler.EmptyRequestHandler in project wicket by apache.

the class WebApplicationTest method testUnmountComplex.

/**
 * See https://issues.apache.org/jira/browse/WICKET-5698
 */
@Test
public void testUnmountComplex() {
    CompoundRequestMapper nestedCompound = new CompoundRequestMapper();
    nestedCompound.add(tester.getApplication().getRootRequestMapper());
    nestedCompound.add(new MountMapper(MOUNT_PATH_1, new EmptyRequestHandler()));
    nestedCompound.add(new MountMapper(MOUNT_PATH_2, new EmptyRequestHandler()));
    CompoundRequestMapper rootCompound = new CompoundRequestMapper();
    rootCompound.add(new SimpleRequestMapperDelegate(nestedCompound));
    rootCompound.add(new MountMapper(MOUNT_PATH_3, new EmptyRequestHandler()));
    rootCompound.add(new MountMapper(MOUNT_PATH_4, new EmptyRequestHandler()));
    tester.getApplication().setRootRequestMapper(new SimpleRequestMapperDelegate(rootCompound));
    tester.getApplication().unmount(MOUNT_PATH_1);
    assertEquals("Compound size should be 2", 2, getCompoundRequestMapperSize(nestedCompound));
    assertNull("Mount path 1 should not be mounted", tester.getApplication().getRootRequestMapper().mapRequest(createMockRequest(MOUNT_PATH_1)));
    assertTrue("Mount path 2 should match", tester.getApplication().getRootRequestMapper().mapRequest(createMockRequest(MOUNT_PATH_2)) instanceof EmptyRequestHandler);
    assertTrue("Mount path 3 should match", tester.getApplication().getRootRequestMapper().mapRequest(createMockRequest(MOUNT_PATH_3)) instanceof EmptyRequestHandler);
    assertTrue("Mount path 4 should match", tester.getApplication().getRootRequestMapper().mapRequest(createMockRequest(MOUNT_PATH_4)) instanceof EmptyRequestHandler);
    tester.getApplication().unmount(MOUNT_PATH_3);
    assertNull("Mount path 1 should not be mounted", tester.getApplication().getRootRequestMapper().mapRequest(createMockRequest(MOUNT_PATH_1)));
    assertTrue("Mount path 2 should match", tester.getApplication().getRootRequestMapper().mapRequest(createMockRequest(MOUNT_PATH_2)) instanceof EmptyRequestHandler);
    assertNull("Mount path 3 should not be mounted", tester.getApplication().getRootRequestMapper().mapRequest(createMockRequest(MOUNT_PATH_3)));
    assertTrue("Mount path 4 should match", tester.getApplication().getRootRequestMapper().mapRequest(createMockRequest(MOUNT_PATH_4)) instanceof EmptyRequestHandler);
}
Also used : EmptyRequestHandler(org.apache.wicket.request.handler.EmptyRequestHandler) ICompoundRequestMapper(org.apache.wicket.request.mapper.ICompoundRequestMapper) CompoundRequestMapper(org.apache.wicket.request.mapper.CompoundRequestMapper) Test(org.junit.Test)

Example 2 with EmptyRequestHandler

use of org.apache.wicket.request.handler.EmptyRequestHandler in project wicket by apache.

the class WebApplicationTest method testUnmountSimple.

/**
 * Test basic unmounting from a compound mapper.
 */
@Test
public void testUnmountSimple() {
    CompoundRequestMapper compound = new CompoundRequestMapper();
    compound.add(tester.getApplication().getRootRequestMapper());
    compound.add(new MountMapper(MOUNT_PATH_1, new EmptyRequestHandler()));
    compound.add(new MountMapper(MOUNT_PATH_2, new EmptyRequestHandler()));
    compound.add(new MountMapper(MOUNT_PATH_3, new EmptyRequestHandler()));
    tester.getApplication().setRootRequestMapper(compound);
    tester.getApplication().unmount(MOUNT_PATH_1);
    assertEquals("Compound size should be 3", 3, getCompoundRequestMapperSize(compound));
    assertNull("Mount path 1 should not be mounted", tester.getApplication().getRootRequestMapper().mapRequest(createMockRequest(MOUNT_PATH_1)));
    assertTrue("Mount path 2 should match", tester.getApplication().getRootRequestMapper().mapRequest(createMockRequest(MOUNT_PATH_2)) instanceof EmptyRequestHandler);
    assertTrue("Mount path 3 should match", tester.getApplication().getRootRequestMapper().mapRequest(createMockRequest(MOUNT_PATH_3)) instanceof EmptyRequestHandler);
}
Also used : EmptyRequestHandler(org.apache.wicket.request.handler.EmptyRequestHandler) ICompoundRequestMapper(org.apache.wicket.request.mapper.ICompoundRequestMapper) CompoundRequestMapper(org.apache.wicket.request.mapper.CompoundRequestMapper) Test(org.junit.Test)

Aggregations

EmptyRequestHandler (org.apache.wicket.request.handler.EmptyRequestHandler)2 CompoundRequestMapper (org.apache.wicket.request.mapper.CompoundRequestMapper)2 ICompoundRequestMapper (org.apache.wicket.request.mapper.ICompoundRequestMapper)2 Test (org.junit.Test)2