geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r449772 - in /geronimo/server/trunk/modules: geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/ geronimo-client-builder/src/test/java/org/apache/geronimo/client/builder/ geronimo-client-builder/src/test/resources/j2ee...
Date Mon, 25 Sep 2006 18:51:33 GMT
Author: djencks
Date: Mon Sep 25 11:51:31 2006
New Revision: 449772

URL: http://svn.apache.org/viewvc?view=rev&rev=449772
Log:
GERONIMO-2414 move the application client and connector conversions to the app client and
connector module builders

Added:
    geronimo/server/trunk/modules/geronimo-client-builder/src/test/java/org/apache/geronimo/client/builder/SchemaConversionTest.java
  (with props)
    geronimo/server/trunk/modules/geronimo-client-builder/src/test/resources/j2ee_1_3dtd/
    geronimo/server/trunk/modules/geronimo-client-builder/src/test/resources/j2ee_1_3dtd/application-client-13.xml
      - copied unchanged from r449747, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/application-client-13.xml
    geronimo/server/trunk/modules/geronimo-client-builder/src/test/resources/j2ee_1_3dtd/application-client-14.xml
      - copied unchanged from r449747, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/application-client-14.xml
    geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/SchemaConversionTest.java
  (with props)
    geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/j2ee_1_3dtd/
    geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/j2ee_1_3dtd/ra-10.xml
      - copied unchanged from r449747, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/ra-10.xml
    geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/j2ee_1_3dtd/ra-15.xml
      - copied unchanged from r449747, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/ra-15.xml
Removed:
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/application-client-13.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/application-client-14.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/ra-10.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/ra-15.xml
Modified:
    geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/java/org/apache/geronimo/schema/SchemaConversionUtilsTest.java

Modified: geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java?view=diff&rev=449772&r1=449771&r2=449772
==============================================================================
--- geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
Mon Sep 25 11:51:31 2006
@@ -84,6 +84,7 @@
 import org.apache.geronimo.xbeans.j2ee.ApplicationClientType;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlCursor;
 
 
 /**
@@ -216,7 +217,7 @@
         try {
             // parse it
             XmlObject xmlObject = XmlBeansUtil.parse(specDD);
-            ApplicationClientDocument appClientDoc = SchemaConversionUtils.convertToApplicationClientSchema(xmlObject);
+            ApplicationClientDocument appClientDoc = convertToApplicationClientSchema(xmlObject);
             appClient = appClientDoc.getApplicationClient();
         } catch (XmlException e) {
             throw new DeploymentException("Unable to parse application-client.xml", e);
@@ -367,6 +368,35 @@
 //            geronimoAppClient.setConfigId(id);
 //        }
         return geronimoAppClient;
+    }
+
+    static ApplicationClientDocument convertToApplicationClientSchema(XmlObject xmlObject)
throws XmlException {
+        if (ApplicationClientDocument.type.equals(xmlObject.schemaType())) {
+            XmlBeansUtil.validateDD(xmlObject);
+            return (ApplicationClientDocument) xmlObject;
+        }
+        XmlCursor cursor = xmlObject.newCursor();
+        XmlCursor moveable = xmlObject.newCursor();
+        String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/application-client_1_4.xsd";
+        String version = "1.4";
+        try {
+            SchemaConversionUtils.convertToSchema(cursor, SchemaConversionUtils.J2EE_NAMESPACE,
schemaLocationURL, version);
+            cursor.toStartDoc();
+            cursor.toChild(SchemaConversionUtils.J2EE_NAMESPACE, "application-client");
+            cursor.toFirstChild();
+            SchemaConversionUtils.convertToDescriptionGroup(SchemaConversionUtils.J2EE_NAMESPACE,
cursor, moveable);
+        } finally {
+            cursor.dispose();
+            moveable.dispose();
+        }
+        XmlObject result = xmlObject.changeType(ApplicationClientDocument.type);
+        if (result != null) {
+            XmlBeansUtil.validateDD(result);
+            return (ApplicationClientDocument) result;
+        }
+        XmlBeansUtil.validateDD(xmlObject);
+        return (ApplicationClientDocument) xmlObject;
+
     }
 
     public void installModule(JarFile earFile, EARContext earContext, Module module, Collection
configurationStores, ConfigurationStore targetConfigurationStore, Collection repositories)
throws DeploymentException {

Added: geronimo/server/trunk/modules/geronimo-client-builder/src/test/java/org/apache/geronimo/client/builder/SchemaConversionTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-client-builder/src/test/java/org/apache/geronimo/client/builder/SchemaConversionTest.java?view=auto&rev=449772
==============================================================================
--- geronimo/server/trunk/modules/geronimo-client-builder/src/test/java/org/apache/geronimo/client/builder/SchemaConversionTest.java
(added)
+++ geronimo/server/trunk/modules/geronimo-client-builder/src/test/java/org/apache/geronimo/client/builder/SchemaConversionTest.java
Mon Sep 25 11:51:31 2006
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.client.builder;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.geronimo.schema.SchemaConversionUtils;
+import org.apache.geronimo.testsupport.XmlBeansTestSupport;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * ejb 1.1 dtd appears to be a subset of ejb 2.0 dtd so the same xsl should
+ * work for both.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SchemaConversionTest extends XmlBeansTestSupport {
+    private static final Log log = LogFactory.getLog(SchemaConversionTest.class);
+
+    private ClassLoader classLoader = this.getClass().getClassLoader();
+
+    public void testApplicationClient13ToApplicationClient14Transform() throws Exception
{
+        URL srcXml = classLoader.getResource("j2ee_1_3dtd/application-client-13.xml");
+        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/application-client-14.xml");
+        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
+        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
+        XmlBeansUtil.validateDD(expected);
+        xmlObject = AppClientModuleBuilder.convertToApplicationClientSchema(xmlObject);
+//        log.debug(xmlObject.toString());
+//        log.debug(expected.toString());
+        List problems = new ArrayList();
+        boolean ok = compareXmlObjects(xmlObject, expected, problems);
+        assertTrue("Differences: " + problems, ok);
+        //make sure trying to convert twice has no bad effects
+        XmlCursor cursor2 = xmlObject.newCursor();
+        try {
+            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/application_1_4.xsd";
+            String version = "1.4";
+            assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE,
schemaLocationURL, version));
+        } finally {
+            cursor2.dispose();
+        }
+        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
+        assertTrue("Differences after reconverting to schema: " + problems, ok2);
+        //do the whole transform twice...
+        xmlObject = AppClientModuleBuilder.convertToApplicationClientSchema(xmlObject);
+        boolean ok3 = compareXmlObjects(xmlObject, expected, problems);
+        assertTrue("Differences after reconverting to application client schema: " + problems,
ok3);
+    }
+
+}

Propchange: geronimo/server/trunk/modules/geronimo-client-builder/src/test/java/org/apache/geronimo/client/builder/SchemaConversionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-client-builder/src/test/java/org/apache/geronimo/client/builder/SchemaConversionTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-client-builder/src/test/java/org/apache/geronimo/client/builder/SchemaConversionTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java?view=diff&rev=449772&r1=449771&r2=449772
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
Mon Sep 25 11:51:31 2006
@@ -62,8 +62,8 @@
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.XATransactions;
 import org.apache.geronimo.deployment.ModuleIDBuilder;
-import org.apache.geronimo.deployment.NamespaceDrivenBuilderCollection;
 import org.apache.geronimo.deployment.NamespaceDrivenBuilder;
+import org.apache.geronimo.deployment.NamespaceDrivenBuilderCollection;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 import org.apache.geronimo.deployment.util.DeploymentUtil;
 import org.apache.geronimo.deployment.xbeans.EnvironmentType;
@@ -76,11 +76,11 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.InvalidConfigurationException;
+import org.apache.geronimo.j2ee.deployment.ActivationSpecInfoLocator;
 import org.apache.geronimo.j2ee.deployment.ConnectorModule;
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
-import org.apache.geronimo.j2ee.deployment.ActivationSpecInfoLocator;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
@@ -115,6 +115,7 @@
 import org.apache.geronimo.xbeans.j2ee.MessagelistenerType;
 import org.apache.geronimo.xbeans.j2ee.ResourceadapterType;
 import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlDocumentProperties;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 
@@ -133,6 +134,7 @@
     private final boolean defaultXAThreadCaching;
     private final Environment defaultEnvironment;
     private final NamespaceDrivenBuilderCollection serviceBuilders;
+    private static final QName RESOURCE_ADAPTER_VERSION = new QName(SchemaConversionUtils.J2EE_NAMESPACE,
"resourceadapter-version");
 
     public ConnectorModuleBuilder(Environment defaultEnvironment,
             int defaultMaxSize,
@@ -184,7 +186,7 @@
         try {
             // parse it
             XmlObject xmlObject = XmlBeansUtil.parse(specDD);
-            ConnectorDocument connectorDoc = SchemaConversionUtils.convertToConnectorSchema(xmlObject);
+            ConnectorDocument connectorDoc = convertToConnectorSchema(xmlObject);
             connector = connectorDoc.getConnector();
         } catch (XmlException e) {
             throw new DeploymentException("Could not parse ra.xml descriptor", e);
@@ -259,6 +261,77 @@
         return new ConnectorModule(standAlone, moduleName, environment, moduleFile, targetPath,
connector, gerConnector, specDD);
     }
 
+    static ConnectorDocument convertToConnectorSchema(XmlObject xmlObject) throws XmlException
{
+        if (ConnectorDocument.type.equals(xmlObject.schemaType())) {
+            XmlBeansUtil.validateDD(xmlObject);
+            return (ConnectorDocument) xmlObject;
+        }
+        XmlCursor cursor = xmlObject.newCursor();
+        XmlDocumentProperties xmlDocumentProperties = cursor.documentProperties();
+        String publicId = xmlDocumentProperties.getDoctypePublicId();
+        try {
+            if ("-//Sun Microsystems, Inc.//DTD Connector 1.0//EN".equals(publicId)) {
+                XmlCursor moveable = xmlObject.newCursor();
+                try {
+                    String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd";
+                    String version = "1.5";
+                    SchemaConversionUtils.convertToSchema(cursor, SchemaConversionUtils.J2EE_NAMESPACE,
schemaLocationURL, version);
+                    cursor.toStartDoc();
+                    cursor.toChild(SchemaConversionUtils.J2EE_NAMESPACE, "connector");
+                    cursor.toFirstChild();
+                    SchemaConversionUtils.convertToDescriptionGroup(SchemaConversionUtils.J2EE_NAMESPACE,
cursor, moveable);
+                    cursor.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "spec-version");
+                    cursor.removeXml();
+                    cursor.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "version");
+                    cursor.setName(RESOURCE_ADAPTER_VERSION);
+                    cursor.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "resourceadapter");
+                    moveable.toCursor(cursor);
+                    cursor.toFirstChild();
+                    cursor.beginElement("outbound-resourceadapter", SchemaConversionUtils.J2EE_NAMESPACE);
+                    cursor.beginElement("connection-definition", SchemaConversionUtils.J2EE_NAMESPACE);
+                    moveable.toChild(SchemaConversionUtils.J2EE_NAMESPACE, "managedconnectionfactory-class");
+                    moveable.push();
+                    //from moveable to cursor
+                    moveable.moveXml(cursor);
+                    while (moveable.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "config-property"))
{
+                        moveable.moveXml(cursor);
+                    }
+                    moveable.pop();
+                    moveable.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "connectionfactory-interface");
+                    moveable.moveXml(cursor);
+                    moveable.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "connectionfactory-impl-class");
+                    moveable.moveXml(cursor);
+                    moveable.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "connection-interface");
+                    moveable.moveXml(cursor);
+                    moveable.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "connection-impl-class");
+                    moveable.moveXml(cursor);
+                    //get out of connection-definition element
+                    cursor.toNextToken();
+                    moveable.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "transaction-support");
+                    moveable.moveXml(cursor);
+                    while (moveable.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "authentication-mechanism"))
{
+                        moveable.moveXml(cursor);
+                    }
+                    moveable.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "reauthentication-support");
+                    moveable.moveXml(cursor);
+                } finally {
+                    moveable.dispose();
+                }
+
+            }
+        } finally {
+            cursor.dispose();
+        }
+        XmlObject result = xmlObject.changeType(ConnectorDocument.type);
+        if (result != null) {
+            XmlBeansUtil.validateDD(result);
+            return (ConnectorDocument) result;
+        }
+        XmlBeansUtil.validateDD(xmlObject);
+        return (ConnectorDocument) xmlObject;
+
+    }
+
     public void installModule(JarFile earFile, EARContext earContext, Module module, Collection
configurationStores, ConfigurationStore targetConfigurationStore, Collection repository) throws
DeploymentException {
         try {
             JarFile moduleFile = module.getModuleFile();
@@ -891,4 +964,5 @@
     public static GBeanInfo getGBeanInfo() {
         return GBEAN_INFO;
     }
+
 }

Added: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/SchemaConversionTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/SchemaConversionTest.java?view=auto&rev=449772
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/SchemaConversionTest.java
(added)
+++ geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/SchemaConversionTest.java
Mon Sep 25 11:51:31 2006
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.connector.deployment;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.geronimo.schema.SchemaConversionUtils;
+import org.apache.geronimo.testsupport.XmlBeansTestSupport;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * ejb 1.1 dtd appears to be a subset of ejb 2.0 dtd so the same xsl should
+ * work for both.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SchemaConversionTest extends XmlBeansTestSupport {
+    private static final Log log = LogFactory.getLog(SchemaConversionTest.class);
+
+    private ClassLoader classLoader = this.getClass().getClassLoader();
+
+    public void testConnector10ToConnector15Transform() throws Exception {
+        URL srcXml = classLoader.getResource("j2ee_1_3dtd/ra-10.xml");
+        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/ra-15.xml");
+        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
+        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
+        XmlBeansUtil.validateDD(expected);
+        xmlObject = ConnectorModuleBuilder.convertToConnectorSchema(xmlObject);
+//        log.debug(xmlObject.toString());
+//        log.debug(expected.toString());
+        List problems = new ArrayList();
+        boolean ok = compareXmlObjects(xmlObject, expected, problems);
+        assertTrue("Differences: " + problems, ok);
+        //make sure trying to convert twice has no bad effects
+        XmlCursor cursor2 = xmlObject.newCursor();
+        try {
+            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd";
+            String version = "1.4";
+            assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE,
schemaLocationURL, version));
+        } finally {
+            cursor2.dispose();
+        }
+        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
+        assertTrue("Differences after reconverting to schema: " + problems, ok2);
+        //do the whole transform twice...
+        xmlObject = ConnectorModuleBuilder.convertToConnectorSchema(xmlObject);
+        boolean ok3 = compareXmlObjects(xmlObject, expected, problems);
+        assertTrue("Differences after reconverting to application schema: " + problems, ok3);
+    }
+
+}

Propchange: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/SchemaConversionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/SchemaConversionTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/SchemaConversionTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/modules/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java?view=diff&rev=449772&r1=449771&r2=449772
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java
(original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java
Mon Sep 25 11:51:31 2006
@@ -45,7 +45,6 @@
     private static final String GERONIMO_SECURITY_NAMESPACE = "http://geronimo.apache.org/xml/ns/security-1.2";
     private static final String GERONIMO_SERVICE_NAMESPACE = "http://geronimo.apache.org/xml/ns/deployment-1.2";
 
-    private static final QName RESOURCE_ADAPTER_VERSION = new QName(J2EE_NAMESPACE, "resourceadapter-version");
     private static final QName CMP_VERSION = new QName(J2EE_NAMESPACE, "cmp-version");
 
     private static final Map GERONIMO_SCHEMA_CONVERSIONS = new HashMap();
@@ -78,106 +77,6 @@
 
     public static void registerNamespaceConversions(Map conversions) {
         GERONIMO_SCHEMA_CONVERSIONS.putAll(conversions);
-    }
-
-    public static ApplicationClientDocument convertToApplicationClientSchema(XmlObject xmlObject)
throws XmlException {
-        if (ApplicationClientDocument.type.equals(xmlObject.schemaType())) {
-            XmlBeansUtil.validateDD(xmlObject);
-            return (ApplicationClientDocument) xmlObject;
-        }
-        XmlCursor cursor = xmlObject.newCursor();
-        XmlCursor moveable = xmlObject.newCursor();
-        String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/application-client_1_4.xsd";
-        String version = "1.4";
-        try {
-            convertToSchema(cursor, J2EE_NAMESPACE, schemaLocationURL, version);
-            cursor.toStartDoc();
-            cursor.toChild(J2EE_NAMESPACE, "application-client");
-            cursor.toFirstChild();
-            convertToDescriptionGroup(J2EE_NAMESPACE, cursor, moveable);
-        } finally {
-            cursor.dispose();
-            moveable.dispose();
-        }
-        XmlObject result = xmlObject.changeType(ApplicationClientDocument.type);
-        if (result != null) {
-            XmlBeansUtil.validateDD(result);
-            return (ApplicationClientDocument) result;
-        }
-        XmlBeansUtil.validateDD(xmlObject);
-        return (ApplicationClientDocument) xmlObject;
-
-    }
-
-    public static ConnectorDocument convertToConnectorSchema(XmlObject xmlObject) throws
XmlException {
-        if (ConnectorDocument.type.equals(xmlObject.schemaType())) {
-            XmlBeansUtil.validateDD(xmlObject);
-            return (ConnectorDocument) xmlObject;
-        }
-        XmlCursor cursor = xmlObject.newCursor();
-        XmlDocumentProperties xmlDocumentProperties = cursor.documentProperties();
-        String publicId = xmlDocumentProperties.getDoctypePublicId();
-        try {
-            if ("-//Sun Microsystems, Inc.//DTD Connector 1.0//EN".equals(publicId)) {
-                XmlCursor moveable = xmlObject.newCursor();
-                try {
-                    String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd";
-                    String version = "1.5";
-                    convertToSchema(cursor, J2EE_NAMESPACE, schemaLocationURL, version);
-                    cursor.toStartDoc();
-                    cursor.toChild(J2EE_NAMESPACE, "connector");
-                    cursor.toFirstChild();
-                    convertToDescriptionGroup(J2EE_NAMESPACE, cursor, moveable);
-                    cursor.toNextSibling(J2EE_NAMESPACE, "spec-version");
-                    cursor.removeXml();
-                    cursor.toNextSibling(J2EE_NAMESPACE, "version");
-                    cursor.setName(RESOURCE_ADAPTER_VERSION);
-                    cursor.toNextSibling(J2EE_NAMESPACE, "resourceadapter");
-                    moveable.toCursor(cursor);
-                    cursor.toFirstChild();
-                    cursor.beginElement("outbound-resourceadapter", J2EE_NAMESPACE);
-                    cursor.beginElement("connection-definition", J2EE_NAMESPACE);
-                    moveable.toChild(J2EE_NAMESPACE, "managedconnectionfactory-class");
-                    moveable.push();
-                    //from moveable to cursor
-                    moveable.moveXml(cursor);
-                    while (moveable.toNextSibling(J2EE_NAMESPACE, "config-property")) {
-                        moveable.moveXml(cursor);
-                    }
-                    moveable.pop();
-                    moveable.toNextSibling(J2EE_NAMESPACE, "connectionfactory-interface");
-                    moveable.moveXml(cursor);
-                    moveable.toNextSibling(J2EE_NAMESPACE, "connectionfactory-impl-class");
-                    moveable.moveXml(cursor);
-                    moveable.toNextSibling(J2EE_NAMESPACE, "connection-interface");
-                    moveable.moveXml(cursor);
-                    moveable.toNextSibling(J2EE_NAMESPACE, "connection-impl-class");
-                    moveable.moveXml(cursor);
-                    //get out of connection-definition element
-                    cursor.toNextToken();
-                    moveable.toNextSibling(J2EE_NAMESPACE, "transaction-support");
-                    moveable.moveXml(cursor);
-                    while (moveable.toNextSibling(J2EE_NAMESPACE, "authentication-mechanism"))
{
-                        moveable.moveXml(cursor);
-                    }
-                    moveable.toNextSibling(J2EE_NAMESPACE, "reauthentication-support");
-                    moveable.moveXml(cursor);
-                } finally {
-                    moveable.dispose();
-                }
-
-            }
-        } finally {
-            cursor.dispose();
-        }
-        XmlObject result = xmlObject.changeType(ConnectorDocument.type);
-        if (result != null) {
-            XmlBeansUtil.validateDD(result);
-            return (ConnectorDocument) result;
-        }
-        XmlBeansUtil.validateDD(xmlObject);
-        return (ConnectorDocument) xmlObject;
-
     }
 
     public static EjbJarDocument convertToEJBSchema(XmlObject xmlObject) throws XmlException
{

Modified: geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/java/org/apache/geronimo/schema/SchemaConversionUtilsTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/java/org/apache/geronimo/schema/SchemaConversionUtilsTest.java?view=diff&rev=449772&r1=449771&r2=449772
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/java/org/apache/geronimo/schema/SchemaConversionUtilsTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/java/org/apache/geronimo/schema/SchemaConversionUtilsTest.java
Mon Sep 25 11:51:31 2006
@@ -64,64 +64,6 @@
 
     //The schemas have been fixed by sun, we can use the official schemas.
 
-    public void testApplicationClient13ToApplicationClient14Transform() throws Exception
{
-        URL srcXml = classLoader.getResource("j2ee_1_3dtd/application-client-13.xml");
-        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/application-client-14.xml");
-        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
-        XmlBeansUtil.validateDD(expected);
-        xmlObject = SchemaConversionUtils.convertToApplicationClientSchema(xmlObject);
-//        log.debug(xmlObject.toString());
-//        log.debug(expected.toString());
-        List problems = new ArrayList();
-        boolean ok = compareXmlObjects(xmlObject, expected, problems);
-        assertTrue("Differences: " + problems, ok);
-        //make sure trying to convert twice has no bad effects
-        XmlCursor cursor2 = xmlObject.newCursor();
-        try {
-            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/application_1_4.xsd";
-            String version = "1.4";
-            assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE,
schemaLocationURL, version));
-        } finally {
-            cursor2.dispose();
-        }
-        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
-        assertTrue("Differences after reconverting to schema: " + problems, ok2);
-        //do the whole transform twice...
-        xmlObject = SchemaConversionUtils.convertToApplicationClientSchema(xmlObject);
-        boolean ok3 = compareXmlObjects(xmlObject, expected, problems);
-        assertTrue("Differences after reconverting to application client schema: " + problems,
ok3);
-    }
-
-    public void testConnector10ToConnector15Transform() throws Exception {
-        URL srcXml = classLoader.getResource("j2ee_1_3dtd/ra-10.xml");
-        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/ra-15.xml");
-        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
-        XmlBeansUtil.validateDD(expected);
-        xmlObject = SchemaConversionUtils.convertToConnectorSchema(xmlObject);
-//        log.debug(xmlObject.toString());
-//        log.debug(expected.toString());
-        List problems = new ArrayList();
-        boolean ok = compareXmlObjects(xmlObject, expected, problems);
-        assertTrue("Differences: " + problems, ok);
-        //make sure trying to convert twice has no bad effects
-        XmlCursor cursor2 = xmlObject.newCursor();
-        try {
-            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd";
-            String version = "1.4";
-            assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE,
schemaLocationURL, version));
-        } finally {
-            cursor2.dispose();
-        }
-        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
-        assertTrue("Differences after reconverting to schema: " + problems, ok2);
-        //do the whole transform twice...
-        xmlObject = SchemaConversionUtils.convertToConnectorSchema(xmlObject);
-        boolean ok3 = compareXmlObjects(xmlObject, expected, problems);
-        assertTrue("Differences after reconverting to application schema: " + problems, ok3);
-    }
-
     public void testEJB11ToEJB21Transform() throws Exception {
         URL srcXml = classLoader.getResource("j2ee_1_2dtd/ejb-1-11.xml");
         URL expectedOutputXml = classLoader.getResource("j2ee_1_2dtd/ejb-1-21.xml");



Mime
View raw message