1 17 package org.apache.geronimo.j2ee.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.deployment.xmlbeans.XmlBeansUtil; 26 import org.apache.geronimo.schema.SchemaConversionUtils; 27 import org.apache.geronimo.testsupport.XmlBeansTestSupport; 28 import org.apache.xmlbeans.XmlCursor; 29 import org.apache.xmlbeans.XmlObject; 30 31 37 public class SchemaConversionTest extends XmlBeansTestSupport { 38 private static final Log log = LogFactory.getLog(SchemaConversionTest.class); 39 40 private ClassLoader classLoader = this.getClass().getClassLoader(); 41 42 43 public void testApplication13ToApplication14Transform() throws Exception { 44 URL srcXml = classLoader.getResource("j2ee_1_3dtd/application-13.xml"); 45 URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/application-14.xml"); 46 XmlObject xmlObject = XmlObject.Factory.parse(srcXml); 47 XmlObject expected = XmlObject.Factory.parse(expectedOutputXml); 48 XmlBeansUtil.validateDD(expected); 49 xmlObject = EARConfigBuilder.convertToApplicationSchema(xmlObject); 50 List problems = new ArrayList (); 53 boolean ok = compareXmlObjects(xmlObject, expected, problems); 54 assertTrue("Differences: " + problems, ok); 55 XmlCursor cursor2 = xmlObject.newCursor(); 57 try { 58 String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"; 59 String version = "1.4"; 60 assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version)); 61 } finally { 62 cursor2.dispose(); 63 } 64 boolean ok2 = compareXmlObjects(xmlObject, expected, problems); 65 assertTrue("Differences after reconverting to schema: " + problems, ok2); 66 xmlObject = EARConfigBuilder.convertToApplicationSchema(xmlObject); 68 boolean ok3 = compareXmlObjects(xmlObject, expected, problems); 69 assertTrue("Differences after reconverting to application schema: " + problems, ok3); 70 } 71 72 } 73 | Popular Tags |