geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r449797 - in /geronimo/server/trunk/modules/geronimo-j2ee-schema/src: main/java/org/apache/geronimo/schema/ test/java/org/apache/geronimo/schema/ test/resources/j2ee_1_2dtd/ test/resources/j2ee_1_3dtd/ test/resources/j2ee_1_4schema/
Date Mon, 25 Sep 2006 20:05:15 GMT
Author: djencks
Date: Mon Sep 25 13:05:13 2006
New Revision: 449797

URL: http://svn.apache.org/viewvc?view=rev&rev=449797
Log:
GERONIMO-2414 move the ejb conversions to the openejb module builders

Removed:
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_2dtd/
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/ejb-jar-21.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/ejb-jar.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/mdb-ejb-jar-20-GERONIMO-1649.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/mdb-ejb-jar-20.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/mdb-ejb-jar-21-GERONIMO-1649.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/mdb-ejb-jar-21.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/tmp.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_4schema/
Modified:
    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-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=449797&r1=449796&r2=449797
==============================================================================
--- 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 13:05:13 2006
@@ -45,8 +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 CMP_VERSION = new QName(J2EE_NAMESPACE, "cmp-version");
-
     private static final Map GERONIMO_SCHEMA_CONVERSIONS = new HashMap();
 
     static {
@@ -79,51 +77,6 @@
         GERONIMO_SCHEMA_CONVERSIONS.putAll(conversions);
     }
 
-    public static EjbJarDocument convertToEJBSchema(XmlObject xmlObject) throws XmlException
{
-        if (EjbJarDocument.type.equals(xmlObject.schemaType())) {
-            XmlBeansUtil.validateDD(xmlObject);
-            return (EjbJarDocument) xmlObject;
-        }
-        XmlCursor cursor = xmlObject.newCursor();
-        XmlCursor moveable = xmlObject.newCursor();
-        //cursor is intially located before the logical STARTDOC token
-        try {
-            cursor.toFirstChild();
-            if ("http://java.sun.com/xml/ns/j2ee".equals(cursor.getName().getNamespaceURI()))
{
-                XmlObject result = xmlObject.changeType(EjbJarDocument.type);
-                XmlBeansUtil.validateDD(result);
-                return (EjbJarDocument) result;
-            }
-            // deployment descriptor is probably in EJB 1.1 or 2.0 format
-            XmlDocumentProperties xmlDocumentProperties = cursor.documentProperties();
-            String publicId = xmlDocumentProperties.getDoctypePublicId();
-            String cmpVersion;
-            if ("-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN".equals(publicId))
{
-                cmpVersion = "1.x";
-            } else if ("-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN".equals(publicId))
{
-                cmpVersion = null;//2.x is the default "2.x";
-            } else {
-                throw new XmlException("Unrecognized document type: " + publicId);
-            }
-            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";
-            String version = "2.1";
-            convertToSchema(cursor, J2EE_NAMESPACE, schemaLocationURL, version);
-            //play with message-driven
-            cursor.toStartDoc();
-            convertBeans(cursor, moveable, cmpVersion);
-        } finally {
-            cursor.dispose();
-            moveable.dispose();
-        }
-        XmlObject result = xmlObject.changeType(EjbJarDocument.type);
-        if (result != null) {
-            XmlBeansUtil.validateDD(result);
-            return (EjbJarDocument) result;
-        }
-        XmlBeansUtil.validateDD(xmlObject);
-        return (EjbJarDocument) xmlObject;
-    }
-
     public static void convertToGeronimoSubSchemas(XmlCursor cursor) {
         cursor.toStartDoc();
         XmlCursor end = cursor.newCursor();
@@ -284,98 +237,6 @@
 
 
         return true;
-    }
-
-    public static void convertBeans(XmlCursor cursor, XmlCursor moveable, String cmpVersion)
{
-        cursor.toChild(J2EE_NAMESPACE, "ejb-jar");
-        cursor.toChild(J2EE_NAMESPACE, "enterprise-beans");
-        if (cursor.toFirstChild()) {
-            //there's at least one ejb...
-            do {
-                cursor.push();
-                String type = cursor.getName().getLocalPart();
-                if ("session".equals(type)) {
-                    cursor.toChild(J2EE_NAMESPACE, "transaction-type");
-                    cursor.toNextSibling();
-                    convertToJNDIEnvironmentRefsGroup(J2EE_NAMESPACE, cursor, moveable);
-                } else if ("entity".equals(type)) {
-                    cursor.toChild(J2EE_NAMESPACE, "persistence-type");
-                    String persistenceType = cursor.getTextValue();
-                    //reentrant is the last required tag before jndiEnvironmentRefsGroup
-                    cursor.toNextSibling(J2EE_NAMESPACE, "reentrant");
-                    //Convert 2.0 True/False to true/false for 2.1
-                    cursor.setTextValue(cursor.getTextValue().toLowerCase());
-                    if (cmpVersion != null && !cursor.toNextSibling(CMP_VERSION)
&& "Container".equals(persistenceType)) {
-                        cursor.toNextSibling();
-                        cursor.insertElementWithText(CMP_VERSION, cmpVersion);
-                    }
-
-                    cursor.toNextSibling(J2EE_NAMESPACE, "abstract-schema-name");
-                    while (cursor.toNextSibling(J2EE_NAMESPACE, "cmp-field")) {
-                    }
-                    cursor.toNextSibling(J2EE_NAMESPACE, "primkey-field");
-                    cursor.toNextSibling();
-                    convertToJNDIEnvironmentRefsGroup(J2EE_NAMESPACE, cursor, moveable);
-                } else if ("message-driven".equals(type)) {
-                    cursor.toFirstChild();
-                    if (cursor.toNextSibling(J2EE_NAMESPACE, "messaging-type")) {
-                        cursor.toNextSibling(J2EE_NAMESPACE, "transaction-type");
-                    } else {
-                        cursor.toNextSibling(J2EE_NAMESPACE, "transaction-type");
-                        //insert messaging-type (introduced in EJB 2.1 spec) before transaction-type
-                        cursor.insertElementWithText("messaging-type", J2EE_NAMESPACE, "javax.jms.MessageListener");
-                        //cursor still on transaction-type
-                    }
-                    if (!cursor.toNextSibling(J2EE_NAMESPACE, "activation-config")) {
-                        //skip transaction-type
-                        cursor.toNextSibling();
-                        //convert EJB 2.0 elements to activation-config-properties.
-                        moveable.toCursor(cursor);
-                        cursor.push();
-                        cursor.beginElement("activation-config", J2EE_NAMESPACE);
-                        boolean hasProperties = addActivationConfigProperty(moveable, cursor,
"message-selector", "messageSelector");
-                        hasProperties |= addActivationConfigProperty(moveable, cursor, "acknowledge-mode",
"acknowledgeMode");
-                        if (new QName(J2EE_NAMESPACE, "message-driven-destination").equals(moveable.getName())
||
-                                moveable.toNextSibling(J2EE_NAMESPACE, "message-driven-destination"))
{
-                            moveable.push();
-                            moveable.toFirstChild();
-                            hasProperties |= addActivationConfigProperty(moveable, cursor,
"destination-type", "destinationType");
-                            hasProperties |= addActivationConfigProperty(moveable, cursor,
"subscription-durability", "subscriptionDurability");
-                            moveable.pop();
-                            moveable.removeXml();
-                        }
-                        cursor.pop();
-                        if (!hasProperties) {
-                            //the activation-config element that we created is empty so delete
it
-                            cursor.toPrevSibling();
-                            cursor.removeXml();
-                            //cursor should now be at first element in JNDIEnvironmentRefsGroup
-                        }
-                    } else {
-                        //cursor pointing at activation-config
-                        cursor.toNextSibling();
-                        //cursor should now be at first element in JNDIEnvironmentRefsGroup
-                    }
-                    convertToJNDIEnvironmentRefsGroup(J2EE_NAMESPACE, cursor, moveable);
-                }
-                cursor.pop();
-            } while (cursor.toNextSibling());
-        }
-    }
-
-    private static boolean addActivationConfigProperty(XmlCursor moveable, XmlCursor cursor,
String elementName, String propertyName) {
-        QName name = new QName(J2EE_NAMESPACE, elementName);
-        if (name.equals(moveable.getName()) || moveable.toNextSibling(name)) {
-            cursor.push();
-            cursor.beginElement("activation-config-property", J2EE_NAMESPACE);
-            cursor.insertElementWithText("activation-config-property-name", J2EE_NAMESPACE,
propertyName);
-            cursor.insertElementWithText("activation-config-property-value", J2EE_NAMESPACE,
moveable.getTextValue());
-            moveable.removeXml();
-            cursor.pop();
-            cursor.toNextSibling();
-            return true;
-        }
-        return false;
     }
 
     /**

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=449797&r1=449796&r2=449797
==============================================================================
--- 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 13:05:13 2006
@@ -64,122 +64,6 @@
 
     //The schemas have been fixed by sun, we can use the official schemas.
 
-    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");
-        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
-        XmlBeansUtil.validateDD(expected);
-        xmlObject = SchemaConversionUtils.convertToEJBSchema(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/ejb-jar_2_1.xsd";
-            String version = "2.1";
-            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.convertToEJBSchema(xmlObject);
-        boolean ok3 = compareXmlObjects(xmlObject, expected, problems);
-        assertTrue("Differences after reconverting to ejb schema: " + problems, ok3);
-    }
-
-    public void testEJB20ToEJB21Transform() throws Exception {
-        URL srcXml = classLoader.getResource("j2ee_1_3dtd/ejb-jar.xml");
-        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/ejb-jar-21.xml");
-        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
-        XmlBeansUtil.validateDD(expected);
-        xmlObject = SchemaConversionUtils.convertToEJBSchema(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/ejb-jar_2_1.xsd";
-            String version = "2.1";
-            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.convertToEJBSchema(xmlObject);
-        boolean ok3 = compareXmlObjects(xmlObject, expected, problems);
-        assertTrue("Differences after reconverting to ejb schema: " + problems, ok3);
-    }
-
-    public void testMDB20ToEJB21TransformBugGERONIMO_1649() throws Exception {
-        URL srcXml = classLoader.getResource("j2ee_1_3dtd/mdb-ejb-jar-20-GERONIMO-1649.xml");
-        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/mdb-ejb-jar-21-GERONIMO-1649.xml");
-        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
-        XmlBeansUtil.validateDD(expected);
-        xmlObject = SchemaConversionUtils.convertToEJBSchema(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/ejb-jar_2_1.xsd";
-            String version = "2.1";
-            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.convertToEJBSchema(xmlObject);
-        boolean ok3 = compareXmlObjects(xmlObject, expected, problems);
-        assertTrue("Differences after reconverting to ejb schema: " + problems, ok3);
-    }
-
-    public void testMDB20To21Transform() throws Exception {
-        URL srcXml = classLoader.getResource("j2ee_1_3dtd/mdb-ejb-jar-20.xml");
-        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/mdb-ejb-jar-21.xml");
-        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
-        XmlBeansUtil.validateDD(expected);
-        xmlObject = SchemaConversionUtils.convertToEJBSchema(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/ejb-jar_2_1.xsd";
-            String version = "2.1";
-            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.convertToEJBSchema(xmlObject);
-        boolean ok3 = compareXmlObjects(xmlObject, expected, problems);
-        assertTrue("Differences after reconverting to ejb schema: " + problems, ok3);
-    }
-
     public void testOrderDescriptionGroup() throws Exception {
         URL srcXml = classLoader.getResource("j2ee_1_3dtd/DescriptionGroupTestSource.xml");
         URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/DescriptionGroupTestExpected.xml");
@@ -232,17 +116,6 @@
         XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
         List problems = new ArrayList();
         boolean ok = compareXmlObjects(srcObject, expected, problems);
-        assertTrue("Differences: " + problems, ok);
-    }
-
-    public void testEJB21To21DoesNothing() throws Exception {
-        URL srcXml = classLoader.getResource("j2ee_1_4schema/ejb-jar.xml");
-        URL expectedOutputXml = classLoader.getResource("j2ee_1_4schema/ejb-jar.xml");
-        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        xmlObject = SchemaConversionUtils.convertToEJBSchema(xmlObject);
-        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
-        List problems = new ArrayList();
-        boolean ok = compareXmlObjects(xmlObject, expected, problems);
         assertTrue("Differences: " + problems, ok);
     }
 



Mime
View raw message