Author: markt
Date: Tue Dec 10 13:16:52 2013
New Revision: 1549836

URL: http://svn.apache.org/r1549836
Log:
Expand validation tests to make sure there are no parsing errors.
Fix parsing errors identified by expanded tests.

Modified:
    
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/descriptor/DigesterFactory.java
    tomcat/tc7.0.x/trunk/test/javax/servlet/resources/TestSchemaValidation.java

Modified: 
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/descriptor/DigesterFactory.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/descriptor/DigesterFactory.java?rev=1549836&r1=1549835&r2=1549836&view=diff
==============================================================================
--- 
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/descriptor/DigesterFactory.java
 (original)
+++ 
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/descriptor/DigesterFactory.java
 Tue Dec 10 13:16:52 2013
@@ -96,6 +96,7 @@ public class DigesterFactory {
     private static void addSelf(Map<String, String> ids, String id) {
         String systemId = idFor(id);
         ids.put(systemId, systemId);
+        ids.put(id, systemId);
     }
 
     private static String idFor(String url) {

Modified: 
tomcat/tc7.0.x/trunk/test/javax/servlet/resources/TestSchemaValidation.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/javax/servlet/resources/TestSchemaValidation.java?rev=1549836&r1=1549835&r2=1549836&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/javax/servlet/resources/TestSchemaValidation.java 
(original)
+++ tomcat/tc7.0.x/trunk/test/javax/servlet/resources/TestSchemaValidation.java 
Tue Dec 10 13:16:52 2013
@@ -24,6 +24,7 @@ import org.junit.Test;
 import org.apache.catalina.deploy.WebXml;
 import org.apache.catalina.startup.WebRuleSet;
 import org.apache.tomcat.util.descriptor.DigesterFactory;
+import org.apache.tomcat.util.descriptor.XmlErrorHandler;
 import org.apache.tomcat.util.descriptor.XmlIdentifiers;
 import org.apache.tomcat.util.digester.Digester;
 
@@ -31,53 +32,73 @@ public class TestSchemaValidation {
 
     @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());
     }
 
     @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());
     }
 
     @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());
     }
 
     @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());
     }
 
     @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());
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to