Search in sources :

Example 6 with WebXml

use of org.apache.catalina.deploy.WebXml in project tomcat70 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());
}
Also used : WebXml(org.apache.catalina.deploy.WebXml) Digester(org.apache.tomcat.util.digester.Digester) XmlErrorHandler(org.apache.tomcat.util.descriptor.XmlErrorHandler) WebRuleSet(org.apache.catalina.startup.WebRuleSet) File(java.io.File) Test(org.junit.Test)

Example 7 with WebXml

use of org.apache.catalina.deploy.WebXml in project tomcat70 by apache.

the class TestSchemaValidation method testWebapp_2_3.

@Test
public void testWebapp_2_3() 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.3/WEB-INF/web.xml"));
    Assert.assertEquals("2.3", desc.getVersion());
    Assert.assertEquals(XmlIdentifiers.WEB_23_PUBLIC, desc.getPublicId());
    Assert.assertEquals(0, handler.getErrors().size());
    Assert.assertEquals(0, handler.getWarnings().size());
}
Also used : WebXml(org.apache.catalina.deploy.WebXml) Digester(org.apache.tomcat.util.digester.Digester) XmlErrorHandler(org.apache.tomcat.util.descriptor.XmlErrorHandler) WebRuleSet(org.apache.catalina.startup.WebRuleSet) File(java.io.File) Test(org.junit.Test)

Example 8 with WebXml

use of org.apache.catalina.deploy.WebXml in project tomcat70 by apache.

the class TestWebRuleSet method testSingleOrderingInWebXml.

@Test
public void testSingleOrderingInWebXml() throws Exception {
    WebXml webXml = new WebXml();
    parse(webXml, "web-1ordering.xml", false, true);
    Assert.assertEquals(1, webXml.getAbsoluteOrdering().size());
    Assert.assertTrue(webXml.getAbsoluteOrdering().contains("bar"));
}
Also used : WebXml(org.apache.catalina.deploy.WebXml) Test(org.junit.Test)

Example 9 with WebXml

use of org.apache.catalina.deploy.WebXml in project tomcat70 by apache.

the class TestWebRuleSet method testSingleOrderingInWebFragmentXml.

@Test
public void testSingleOrderingInWebFragmentXml() throws Exception {
    WebXml webXml = new WebXml();
    parse(webXml, "web-fragment-1ordering.xml", true, true);
    Assert.assertEquals(1, webXml.getBeforeOrdering().size());
    Assert.assertTrue(webXml.getBeforeOrdering().contains("bar"));
}
Also used : WebXml(org.apache.catalina.deploy.WebXml) Test(org.junit.Test)

Example 10 with WebXml

use of org.apache.catalina.deploy.WebXml in project tomcat70 by apache.

the class TestWebRuleSet method testRecycle.

@Test
public void testRecycle() throws Exception {
    // Name
    parse(new WebXml(), "web-fragment-2name.xml", true, false);
    parse(new WebXml(), "web-fragment-1name.xml", true, true);
    parse(new WebXml(), "web-fragment-2name.xml", true, false);
    parse(new WebXml(), "web-fragment-1name.xml", true, true);
    // Relative ordering
    parse(new WebXml(), "web-fragment-2ordering.xml", true, false);
    parse(new WebXml(), "web-fragment-1ordering.xml", true, true);
    parse(new WebXml(), "web-fragment-2ordering.xml", true, false);
    parse(new WebXml(), "web-fragment-1ordering.xml", true, true);
    // Absolute ordering
    parse(new WebXml(), "web-2ordering.xml", false, false);
    parse(new WebXml(), "web-1ordering.xml", false, true);
    parse(new WebXml(), "web-2ordering.xml", false, false);
    parse(new WebXml(), "web-1ordering.xml", false, true);
}
Also used : WebXml(org.apache.catalina.deploy.WebXml) Test(org.junit.Test)

Aggregations

WebXml (org.apache.catalina.deploy.WebXml)26 Test (org.junit.Test)20 File (java.io.File)17 ServletDef (org.apache.catalina.deploy.ServletDef)5 WebRuleSet (org.apache.catalina.startup.WebRuleSet)5 XmlErrorHandler (org.apache.tomcat.util.descriptor.XmlErrorHandler)5 Digester (org.apache.tomcat.util.digester.Digester)5 URL (java.net.URL)4 FilterDef (org.apache.catalina.deploy.FilterDef)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 NamingException (javax.naming.NamingException)2 ServletContainerInitializer (javax.servlet.ServletContainerInitializer)2 StandardContext (org.apache.catalina.core.StandardContext)2 FilterMap (org.apache.catalina.deploy.FilterMap)2 FileDirContext (org.apache.naming.resources.FileDirContext)2 InputSource (org.xml.sax.InputSource)2 JarURLConnection (java.net.JarURLConnection)1 MalformedURLException (java.net.MalformedURLException)1