StandardContext ctx = (StandardContext) tomcat.addWebapp(null, "/test",
appDir.getAbsolutePath());
LifecycleListener[] listener = ctx.findLifecycleListeners();
assertEquals(3,listener.length);
assertTrue(listener[1] instanceof ContextConfig);
ContextConfig config = new ContextConfig() {
@Override
protected WebXml createWebXml() {
WebXml wxml = new WebXml();
wxml.addAbsoluteOrdering("resources");
wxml.addAbsoluteOrdering("resources2");
return wxml;
}
};
// prevent it from looking ( if it finds one - it'll have dup error )
config.setDefaultWebXml("org/apache/catalin/startup/NO_DEFAULT_XML");
listener[1] = config;
Tomcat.addServlet(ctx, "getresource", new GetResourceServlet());
ctx.addServletMapping("/getresource", "getresource");
tomcat.start();
assertPageContains("/test/getresource?path=/resourceF.jsp",
"<p>resourceF.jsp in resources2.jar</p>");
assertPageContains("/test/getresource?path=/resourceB.jsp",
"<p>resourceB.jsp in resources.jar</p>");
ctx.stop();
LifecycleListener[] listener1 = ctx.findLifecycleListeners();
// change ordering and reload
ContextConfig config1 = new ContextConfig() {
@Override
protected WebXml createWebXml() {
WebXml wxml = new WebXml();
wxml.addAbsoluteOrdering("resources2");
wxml.addAbsoluteOrdering("resources");
return wxml;
}
};
// prevent it from looking ( if it finds one - it'll have dup error )
config1.setDefaultWebXml("org/apache/catalin/startup/NO_DEFAULT_XML");
listener1[1] = config1;
Tomcat.addServlet(ctx, "getresource", new GetResourceServlet());
ctx.addServletMapping("/getresource", "getresource");
ctx.start();