assertEquals("Servlet says: ",fdef.getParameterMap().get("message"));
}
public void testOverwriteFilterMapping() throws Exception {
WebXml webxml = new WebXml();
FilterDef filterDef = new FilterDef();
filterDef.setFilterName("paramFilter");
filterDef.setFilterClass("org.apache.catalina.startup.ParamFilter");
filterDef.addInitParameter("message", "tomcat");
filterDef.setDescription("Description");
filterDef.setDisplayName("DisplayName");
filterDef.setLargeIcon("LargeIcon");
filterDef.setSmallIcon("SmallIcon");
filterDef.setAsyncSupported("true");
webxml.addFilter(filterDef);
FilterMap filterMap = new FilterMap();
filterMap.addURLPattern("/param1");
filterMap.setFilterName("paramFilter");
webxml.addFilterMapping(filterMap);
ContextConfig config = new ContextConfig();
File sFile = paramClassResource(
"org/apache/catalina/startup/ParamServlet");
config.processAnnotationsFile(sFile, webxml);
File fFile = paramClassResource(
"org/apache/catalina/startup/ParamFilter");
config.processAnnotationsFile(fFile, webxml);
FilterDef fdef = webxml.getFilters().get("paramFilter");
assertNotNull(fdef);
assertEquals(filterDef,fdef);
assertEquals("tomcat",fdef.getParameterMap().get("message"));
Set<FilterMap> filterMappings = webxml.getFilterMappings();
assertTrue(filterMappings.contains(filterMap));
// annotation mapping not added s. Servlet Spec 3.0 (Nov 2009)
// 8.2.3.3.vi page 81
String[] urlPatterns = filterMap.getURLPatterns();
assertNotNull(urlPatterns);
assertEquals(1,urlPatterns.length);
assertEquals("/param1",urlPatterns[0]);
// check simple Parameter
assertEquals("Description", fdef.getDescription());
assertEquals("DisplayName", fdef.getDisplayName());
assertEquals("LargeIcon", fdef.getLargeIcon());
assertEquals("SmallIcon", fdef.getSmallIcon());
// FIXME: Strange why servletDef is Boolean and FilterDef is String?
assertEquals("true", fdef.getAsyncSupported());
String[] dis = filterMap.getDispatcherNames();
assertEquals(2, dis.length);
assertEquals(DispatcherType.ERROR.toString(),dis[0]);
assertEquals(DispatcherType.ASYNC.toString(),dis[1]);