use of org.apache.wicket.request.mapper.CompoundRequestMapper 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);
}
use of org.apache.wicket.request.mapper.CompoundRequestMapper 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);
}
use of org.apache.wicket.request.mapper.CompoundRequestMapper in project wicket by apache.
the class CryptedUrlWebRequestCodingStrategyTest method newApplication.
@Override
protected WebApplication newApplication() {
return new MockApplication() {
@Override
protected void init() {
super.init();
// install crypto mapper to encrypt all application urls
getSecuritySettings().setCryptFactory(new TestCryptFactory());
CompoundRequestMapper root = new CompoundRequestMapper();
root.add(new CryptoMapper(getRootRequestMapper(), this));
setRootRequestMapper(root);
}
};
}
Aggregations