You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/12/10 14:14:04 UTC
svn commit: r1549832 -
/tomcat/trunk/test/javax/servlet/resources/TestSchemaValidation.java
Author: markt
Date: Tue Dec 10 13:14:04 2013
New Revision: 1549832
URL: http://svn.apache.org/r1549832
Log:
Expand validation tests to make sure there are no parsing errors.
Modified:
tomcat/trunk/test/javax/servlet/resources/TestSchemaValidation.java
Modified: tomcat/trunk/test/javax/servlet/resources/TestSchemaValidation.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/javax/servlet/resources/TestSchemaValidation.java?rev=1549832&r1=1549831&r2=1549832&view=diff
==============================================================================
--- tomcat/trunk/test/javax/servlet/resources/TestSchemaValidation.java (original)
+++ tomcat/trunk/test/javax/servlet/resources/TestSchemaValidation.java Tue Dec 10 13:14:04 2013
@@ -22,6 +22,7 @@ import org.junit.Assert;
import org.junit.Test;
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.descriptor.web.WebRuleSet;
import org.apache.tomcat.util.descriptor.web.WebXml;
@@ -31,73 +32,101 @@ public class TestSchemaValidation {
@Test
public void testWebapp() 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/WEB-INF/web.xml"));
Assert.assertEquals("3.1", desc.getVersion());
+ Assert.assertEquals(0, handler.getErrors().size());
+ Assert.assertEquals(0, handler.getWarnings().size());
}
@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());
}
@Test
public void testWebapp_3_1() 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.1/WEB-INF/web.xml"));
Assert.assertEquals("3.1", desc.getVersion());
+ Assert.assertEquals(0, handler.getErrors().size());
+ Assert.assertEquals(0, handler.getWarnings().size());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org