org.apache.tomcat.util.descriptor.XmlIdentifiers Java Examples
The following examples show how to use
org.apache.tomcat.util.descriptor.XmlIdentifiers.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebXml.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
public void setPublicId(String publicId) { // Update major and minor version if (publicId == null) { return; } if (XmlIdentifiers.WEB_22_PUBLIC.equals(publicId)) { majorVersion = 2; minorVersion = 2; this.publicId = publicId; } else if (XmlIdentifiers.WEB_23_PUBLIC.equals(publicId)) { majorVersion = 2; minorVersion = 3; this.publicId = publicId; } else { log.warn(sm.getString("webXml.unrecognisedPublicId", publicId)); } }
Example #2
Source File: WebXml.java From tomcatsrc with Apache License 2.0 | 6 votes |
public void setPublicId(String publicId) { // Update major and minor version if (publicId == null) { return; } if (XmlIdentifiers.WEB_22_PUBLIC.equals(publicId)) { majorVersion = 2; minorVersion = 2; this.publicId = publicId; } else if (XmlIdentifiers.WEB_23_PUBLIC.equals(publicId)) { majorVersion = 2; minorVersion = 3; this.publicId = publicId; } else { log.warn(sm.getString("webXml.unrecognisedPublicId", publicId)); } }
Example #3
Source File: WebXml.java From Tomcat8-Source-Read with MIT License | 6 votes |
public void setPublicId(String publicId) { // Update major and minor version if (publicId == null) { return; } switch (publicId) { case XmlIdentifiers.WEB_22_PUBLIC: majorVersion = 2; minorVersion = 2; this.publicId = publicId; break; case XmlIdentifiers.WEB_23_PUBLIC: majorVersion = 2; minorVersion = 3; this.publicId = publicId; break; default: log.warn(sm.getString("webXml.unrecognisedPublicId", publicId)); break; } }
Example #4
Source File: TestWebXml.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
private void doTestValidateVersion(String version) throws IOException, SAXException { WebXml webxml = new WebXml(); // Special cases if ("2.2".equals(version)) { webxml.setPublicId(XmlIdentifiers.WEB_22_PUBLIC); } else if ("2.3".equals(version)) { webxml.setPublicId(XmlIdentifiers.WEB_23_PUBLIC); } else { webxml.setVersion(version); } // Merged web.xml that is published as MERGED_WEB_XML context attribute // in the simplest case consists of webapp's web.xml file // plus the default conf/web.xml one. Set<WebXml> defaults = new HashSet<WebXml>(); defaults.add(getDefaultWebXmlFragment()); webxml.merge(defaults); Digester digester = DigesterFactory.newDigester(true, true, new WebRuleSet(), true); XmlErrorHandler handler = new XmlErrorHandler(); digester.setErrorHandler(handler); InputSource is = new InputSource(new StringReader(webxml.toXml())); WebXml webxmlResult = new WebXml(); digester.push(webxmlResult); digester.parse(is); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); Assert.assertEquals(version, webxml.getVersion()); Assert.assertEquals(version, webxmlResult.getVersion()); }
Example #5
Source File: TestSchemaValidation.java From tomcatsrc with Apache License 2.0 | 5 votes |
@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()); }
Example #6
Source File: TestSchemaValidation.java From tomcatsrc with Apache License 2.0 | 5 votes |
@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()); }
Example #7
Source File: TestWebXml.java From tomcatsrc with Apache License 2.0 | 5 votes |
private void doTestValidateVersion(String version) throws IOException, SAXException { WebXml webxml = new WebXml(); // Special cases if ("2.2".equals(version)) { webxml.setPublicId(XmlIdentifiers.WEB_22_PUBLIC); } else if ("2.3".equals(version)) { webxml.setPublicId(XmlIdentifiers.WEB_23_PUBLIC); } else { webxml.setVersion(version); } // Merged web.xml that is published as MERGED_WEB_XML context attribute // in the simplest case consists of webapp's web.xml file // plus the default conf/web.xml one. Set<WebXml> defaults = new HashSet<WebXml>(); defaults.add(getDefaultWebXmlFragment()); webxml.merge(defaults); Digester digester = DigesterFactory.newDigester(true, true, new WebRuleSet(), true); XmlErrorHandler handler = new XmlErrorHandler(); digester.setErrorHandler(handler); InputSource is = new InputSource(new StringReader(webxml.toXml())); WebXml webxmlResult = new WebXml(); digester.push(webxmlResult); digester.parse(is); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); Assert.assertEquals(version, webxml.getVersion()); Assert.assertEquals(version, webxmlResult.getVersion()); }
Example #8
Source File: TestWebXml.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Test public void testParsePublicIdVersion23() { WebXml webxml = new WebXml(); webxml.setPublicId(XmlIdentifiers.WEB_23_PUBLIC); Assert.assertEquals(2, webxml.getMajorVersion()); Assert.assertEquals(3, webxml.getMinorVersion()); Assert.assertEquals("2.3", webxml.getVersion()); }
Example #9
Source File: TestWebXml.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Test public void testParsePublicIdVersion22() { WebXml webxml = new WebXml(); webxml.setPublicId(XmlIdentifiers.WEB_22_PUBLIC); Assert.assertEquals(2, webxml.getMajorVersion()); Assert.assertEquals(2, webxml.getMinorVersion()); Assert.assertEquals("2.2", webxml.getVersion()); }
Example #10
Source File: TestSchemaValidation.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@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()); }
Example #11
Source File: TestSchemaValidation.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@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()); }
Example #12
Source File: TestWebXml.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Test public void testParsePublicIdVersion23() { WebXml webxml = new WebXml(); webxml.setPublicId(XmlIdentifiers.WEB_23_PUBLIC); Assert.assertEquals(2, webxml.getMajorVersion()); Assert.assertEquals(3, webxml.getMinorVersion()); Assert.assertEquals("2.3", webxml.getVersion()); }
Example #13
Source File: TestWebXml.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Test public void testParsePublicIdVersion22() { WebXml webxml = new WebXml(); webxml.setPublicId(XmlIdentifiers.WEB_22_PUBLIC); Assert.assertEquals(2, webxml.getMajorVersion()); Assert.assertEquals(2, webxml.getMinorVersion()); Assert.assertEquals("2.2", webxml.getVersion()); }
Example #14
Source File: TestSchemaValidation.java From Tomcat8-Source-Read with MIT License | 5 votes |
@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()); }
Example #15
Source File: TestSchemaValidation.java From Tomcat8-Source-Read with MIT License | 5 votes |
@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()); }
Example #16
Source File: TestWebXml.java From Tomcat8-Source-Read with MIT License | 5 votes |
private void doTestValidateVersion(String version) throws IOException, SAXException { WebXml webxml = new WebXml(); // Special cases if ("2.2".equals(version)) { webxml.setPublicId(XmlIdentifiers.WEB_22_PUBLIC); } else if ("2.3".equals(version)) { webxml.setPublicId(XmlIdentifiers.WEB_23_PUBLIC); } else { webxml.setVersion(version); } // Merged web.xml that is published as MERGED_WEB_XML context attribute // in the simplest case consists of webapp's web.xml file // plus the default conf/web.xml one. Set<WebXml> defaults = new HashSet<>(); defaults.add(getDefaultWebXmlFragment()); webxml.merge(defaults); Digester digester = DigesterFactory.newDigester(true, true, new WebRuleSet(), true); XmlErrorHandler handler = new XmlErrorHandler(); digester.setErrorHandler(handler); InputSource is = new InputSource(new StringReader(webxml.toXml())); WebXml webxmlResult = new WebXml(); digester.push(webxmlResult); digester.parse(is); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); Assert.assertEquals(version, webxml.getVersion()); Assert.assertEquals(version, webxmlResult.getVersion()); }
Example #17
Source File: TestWebXml.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Test public void testParsePublicIdVersion23() { WebXml webxml = new WebXml(); webxml.setPublicId(XmlIdentifiers.WEB_23_PUBLIC); Assert.assertEquals(2, webxml.getMajorVersion()); Assert.assertEquals(3, webxml.getMinorVersion()); Assert.assertEquals("2.3", webxml.getVersion()); }
Example #18
Source File: TestWebXml.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Test public void testParsePublicIdVersion22() { WebXml webxml = new WebXml(); webxml.setPublicId(XmlIdentifiers.WEB_22_PUBLIC); Assert.assertEquals(2, webxml.getMajorVersion()); Assert.assertEquals(2, webxml.getMinorVersion()); Assert.assertEquals("2.2", webxml.getVersion()); }