1 17 package org.apache.geronimo.web.deployment; 18 19 import java.net.URL ; 20 import java.util.ArrayList ; 21 import java.util.List ; 22 23 import org.apache.commons.logging.Log; 24 import org.apache.commons.logging.LogFactory; 25 import org.apache.geronimo.testsupport.XmlBeansTestSupport; 26 import org.apache.xmlbeans.XmlException; 27 import org.apache.xmlbeans.XmlObject; 28 29 35 public class SchemaConversionTest extends XmlBeansTestSupport { 36 private static final Log log = LogFactory.getLog(SchemaConversionTest.class); 37 38 private ClassLoader classLoader = this.getClass().getClassLoader(); 39 40 public void testWeb23To24Transform() throws Exception { 41 URL srcXml = classLoader.getResource("j2ee_1_3dtd/web-23.xml"); 42 URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/web-24.xml"); 43 XmlObject xmlObject = XmlObject.Factory.parse(srcXml); 44 xmlObject = AbstractWebModuleBuilder.convertToServletSchema(xmlObject); 45 XmlObject expected = XmlObject.Factory.parse(expectedOutputXml); 46 List problems = new ArrayList (); 49 boolean ok = compareXmlObjects(xmlObject, expected, problems); 50 assertTrue("Differences: " + problems, ok); 51 xmlObject = AbstractWebModuleBuilder.convertToServletSchema(xmlObject); 52 boolean ok2 = compareXmlObjects(xmlObject, expected, problems); 53 assertTrue("Differences: " + problems, ok2); 54 } 55 56 public void testWeb23To24OtherTransform() throws Exception { 57 URL srcXml = classLoader.getResource("j2ee_1_3dtd/web-1-23.xml"); 58 URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/web-1-24.xml"); 59 XmlObject xmlObject = XmlObject.Factory.parse(srcXml); 60 xmlObject = AbstractWebModuleBuilder.convertToServletSchema(xmlObject); 61 XmlObject expected = XmlObject.Factory.parse(expectedOutputXml); 63 List problems = new ArrayList (); 64 boolean ok = compareXmlObjects(xmlObject, expected, problems); 65 assertTrue("Differences: " + problems, ok); 66 xmlObject = AbstractWebModuleBuilder.convertToServletSchema(xmlObject); 67 boolean ok2 = compareXmlObjects(xmlObject, expected, problems); 68 assertTrue("Differences: " + problems, ok2); 69 } 70 71 public void testWeb22To24Transform1() throws Exception { 72 URL srcXml = classLoader.getResource("j2ee_1_2dtd/web-1-22.xml"); 73 URL expectedOutputXml = classLoader.getResource("j2ee_1_2dtd/web-1-24.xml"); 74 XmlObject xmlObject = XmlObject.Factory.parse(srcXml); 75 xmlObject = AbstractWebModuleBuilder.convertToServletSchema(xmlObject); 76 XmlObject expected = XmlObject.Factory.parse(expectedOutputXml); 77 List problems = new ArrayList (); 80 boolean ok = compareXmlObjects(xmlObject, expected, problems); 81 assertTrue("Differences: " + problems, ok); 82 xmlObject = AbstractWebModuleBuilder.convertToServletSchema(xmlObject); 83 boolean ok2 = compareXmlObjects(xmlObject, expected, problems); 84 assertTrue("Differences: " + problems, ok2); 85 } 86 87 public void testWebRejectBad24() throws Exception { 88 URL srcXml = classLoader.getResource("j2ee_1_4schema/web-1-24.xml"); 89 XmlObject xmlObject = XmlObject.Factory.parse(srcXml); 90 try { 91 AbstractWebModuleBuilder.convertToServletSchema(xmlObject); 92 fail("doc src/test-data/j2ee_1_4schema/web-1-24.xml is invalid, should not have validated"); 93 } catch (XmlException e) { 94 } 96 } 97 98 public void testParseWeb24() throws Exception { 99 URL srcXml = classLoader.getResource("j2ee_1_4schema/web-2-24.xml"); 100 XmlObject xmlObject = XmlObject.Factory.parse(srcXml); 101 xmlObject = AbstractWebModuleBuilder.convertToServletSchema(xmlObject); 102 assertNotNull(xmlObject); 103 } 104 105 } 106 | Popular Tags |