Search in sources :

Example 21 with WebXml

use of org.apache.tomcat.util.descriptor.web.WebXml in project tomcat by apache.

the class TestContextConfigAnnotation method testNoMapping.

@Test
public void testNoMapping() throws Exception {
    WebXml webxml = new WebXml();
    Map<String, JavaClassCacheEntry> javaClassCache = new HashMap<>();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource("org/apache/catalina/startup/NoMappingParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false, javaClassCache);
    ServletDef servletDef = webxml.getServlets().get("param1");
    assertNull(servletDef);
    webxml.addServletMapping("/param", "param1");
    config.processAnnotationsFile(pFile, webxml, false, javaClassCache);
    servletDef = webxml.getServlets().get("param1");
    assertNull(servletDef);
}
Also used : WebXml(org.apache.tomcat.util.descriptor.web.WebXml) HashMap(java.util.HashMap) ServletDef(org.apache.tomcat.util.descriptor.web.ServletDef) JavaClassCacheEntry(org.apache.catalina.startup.ContextConfig.JavaClassCacheEntry) File(java.io.File) Test(org.junit.Test)

Example 22 with WebXml

use of org.apache.tomcat.util.descriptor.web.WebXml in project tomcat by apache.

the class TestContextConfigAnnotation method testDuplicateFilterMapping.

@Test
public void testDuplicateFilterMapping() throws Exception {
    WebXml webxml = new WebXml();
    Map<String, JavaClassCacheEntry> javaClassCache = new HashMap<>();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource("org/apache/catalina/startup/DuplicateMappingParamFilter");
    assertTrue(pFile.exists());
    try {
        config.processAnnotationsFile(pFile, webxml, false, javaClassCache);
        fail();
    } catch (IllegalArgumentException ex) {
    // ignore
    }
    FilterDef filterDef = webxml.getFilters().get("paramD");
    assertNull(filterDef);
}
Also used : WebXml(org.apache.tomcat.util.descriptor.web.WebXml) FilterDef(org.apache.tomcat.util.descriptor.web.FilterDef) HashMap(java.util.HashMap) JavaClassCacheEntry(org.apache.catalina.startup.ContextConfig.JavaClassCacheEntry) File(java.io.File) Test(org.junit.Test)

Aggregations

WebXml (org.apache.tomcat.util.descriptor.web.WebXml)22 File (java.io.File)18 Test (org.junit.Test)17 HashMap (java.util.HashMap)10 JavaClassCacheEntry (org.apache.catalina.startup.ContextConfig.JavaClassCacheEntry)9 XmlErrorHandler (org.apache.tomcat.util.descriptor.XmlErrorHandler)8 WebRuleSet (org.apache.tomcat.util.descriptor.web.WebRuleSet)8 Digester (org.apache.tomcat.util.digester.Digester)8 ServletDef (org.apache.tomcat.util.descriptor.web.ServletDef)5 URL (java.net.URL)4 IOException (java.io.IOException)3 FilterDef (org.apache.tomcat.util.descriptor.web.FilterDef)3 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 ServletContainerInitializer (javax.servlet.ServletContainerInitializer)2 FilterMap (org.apache.tomcat.util.descriptor.web.FilterMap)2 WebXmlParser (org.apache.tomcat.util.descriptor.web.WebXmlParser)2 InputSource (org.xml.sax.InputSource)2 URISyntaxException (java.net.URISyntaxException)1 URLConnection (java.net.URLConnection)1