1 17 package org.apache.geronimo.connector.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 public void testConnector10ToConnector15Transform() throws Exception { 43 URL srcXml = classLoader.getResource("j2ee_1_3dtd/ra-10.xml"); 44 URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/ra-15.xml"); 45 XmlObject xmlObject = XmlObject.Factory.parse(srcXml); 46 XmlObject expected = XmlObject.Factory.parse(expectedOutputXml); 47 XmlBeansUtil.validateDD(expected); 48 xmlObject = ConnectorModuleBuilder.convertToConnectorSchema(xmlObject); 49 List problems = new ArrayList (); 52 boolean ok = compareXmlObjects(xmlObject, expected, problems); 53 assertTrue("Differences: " + problems, ok); 54 XmlCursor cursor2 = xmlObject.newCursor(); 56 try { 57 String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"; 58 String version = "1.4"; 59 assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version)); 60 } finally { 61 cursor2.dispose(); 62 } 63 boolean ok2 = compareXmlObjects(xmlObject, expected, problems); 64 assertTrue("Differences after reconverting to schema: " + problems, ok2); 65 xmlObject = ConnectorModuleBuilder.convertToConnectorSchema(xmlObject); 67 boolean ok3 = compareXmlObjects(xmlObject, expected, problems); 68 assertTrue("Differences after reconverting to application schema: " + problems, ok3); 69 } 70 71 } 72 | Popular Tags |