use of org.apache.tomcat.util.descriptor.web.WebXml in project tomcat by apache.
the class TestSchemaValidation method testWebapp_2_2.
@Test
public void testWebapp_2_2() throws Exception {
XmlErrorHandler handler = new XmlErrorHandler();
Digester digester = DigesterFactory.newDigester(true, true, new WebRuleSet(false), true);
digester.setErrorHandler(handler);
digester.push(new WebXml());
WebXml desc = (WebXml) digester.parse(new File("test/webapp-2.2/WEB-INF/web.xml"));
Assert.assertEquals("2.2", desc.getVersion());
Assert.assertEquals(XmlIdentifiers.WEB_22_PUBLIC, desc.getPublicId());
Assert.assertEquals(0, handler.getErrors().size());
Assert.assertEquals(0, handler.getWarnings().size());
}
use of org.apache.tomcat.util.descriptor.web.WebXml in project tomcat by apache.
the class TestSchemaValidation method testWebapp_2_4.
@Test
public void testWebapp_2_4() throws Exception {
XmlErrorHandler handler = new XmlErrorHandler();
Digester digester = DigesterFactory.newDigester(true, true, new WebRuleSet(false), true);
digester.setErrorHandler(handler);
digester.push(new WebXml());
WebXml desc = (WebXml) digester.parse(new File("test/webapp-2.4/WEB-INF/web.xml"));
Assert.assertEquals("2.4", desc.getVersion());
Assert.assertEquals(0, handler.getErrors().size());
Assert.assertEquals(0, handler.getWarnings().size());
}
use of org.apache.tomcat.util.descriptor.web.WebXml in project tomcat by apache.
the class TestSchemaValidation method testWebapp_3_0.
@Test
public void testWebapp_3_0() throws Exception {
XmlErrorHandler handler = new XmlErrorHandler();
Digester digester = DigesterFactory.newDigester(true, true, new WebRuleSet(false), true);
digester.setErrorHandler(handler);
digester.push(new WebXml());
WebXml desc = (WebXml) digester.parse(new File("test/webapp-3.0/WEB-INF/web.xml"));
Assert.assertEquals("3.0", desc.getVersion());
Assert.assertEquals(0, handler.getErrors().size());
Assert.assertEquals(0, handler.getWarnings().size());
}
use of org.apache.tomcat.util.descriptor.web.WebXml in project tomcat by apache.
the class TestSchemaValidation method testWebapp_2_5.
@Test
public void testWebapp_2_5() throws Exception {
XmlErrorHandler handler = new XmlErrorHandler();
Digester digester = DigesterFactory.newDigester(true, true, new WebRuleSet(false), true);
digester.setErrorHandler(handler);
digester.push(new WebXml());
WebXml desc = (WebXml) digester.parse(new File("test/webapp-2.5/WEB-INF/web.xml"));
Assert.assertEquals("2.5", desc.getVersion());
Assert.assertEquals(0, handler.getErrors().size());
Assert.assertEquals(0, handler.getWarnings().size());
}
use of org.apache.tomcat.util.descriptor.web.WebXml in project tomcat by apache.
the class TestContextConfigAnnotation method testSetupWebXMLNoMapping.
@Test
public void testSetupWebXMLNoMapping() throws Exception {
WebXml webxml = new WebXml();
Map<String, JavaClassCacheEntry> javaClassCache = new HashMap<>();
ServletDef servletDef = new ServletDef();
servletDef.setServletName("param1");
servletDef.setServletClass("org.apache.catalina.startup.NoMappingParamServlet");
servletDef.addInitParameter("foo", "tomcat");
webxml.addServlet(servletDef);
webxml.addServletMapping("/param", "param1");
ContextConfig config = new ContextConfig();
File pFile = paramClassResource("org/apache/catalina/startup/NoMappingParamServlet");
Assert.assertTrue(pFile.exists());
config.processAnnotationsFile(pFile, webxml, false, javaClassCache);
Assert.assertEquals("tomcat", servletDef.getParameterMap().get("foo"));
Assert.assertEquals("World!", servletDef.getParameterMap().get("bar"));
ServletDef servletDef1 = webxml.getServlets().get("param1");
Assert.assertNotNull(servletDef1);
Assert.assertEquals(servletDef, servletDef1);
}
Aggregations