djencks 2004/08/04 14:48:32
Modified: specs/schema/src/java/org/apache/geronimo/schema SchemaConversionUtils.java specs/schema/src/test/org/apache/geronimo/schema SchemaConversionUtilsTest.java Added: specs/schema/src/test-data/j2ee_1_3dtd mdb-ejb-jar-20.xml mdb-ejb-jar-21.xml Log: fixed GERONIMO-169 (again:-) issue with mdb dds Revision Changes Path 1.6 +4 -3 incubator-geronimo/specs/schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java Index: SchemaConversionUtils.java =================================================================== RCS file: /home/cvs/incubator-geronimo/specs/schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- SchemaConversionUtils.java 1 Aug 2004 20:14:20 -0000 1.5 +++ SchemaConversionUtils.java 4 Aug 2004 21:48:31 -0000 1.6 @@ -221,7 +221,8 @@ cursor.beginElement("activation-config", J2EE_NAMESPACE); hasProperties |= addActivationConfigProperty(moveable, cursor, "message-selector", "messageSelector"); hasProperties |= addActivationConfigProperty(moveable, cursor, "acknowledge-mode", "acknowledgeMode"); - if (moveable.toNextSibling(J2EE_NAMESPACE, "message-driven-destination")) { + 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"); @@ -291,7 +292,7 @@ private static void moveElements(String localName, XmlCursor moveable, XmlCursor toHere) { QName name = new QName(J2EE_NAMESPACE, localName); //skip elements already in the correct order. - while (toHere.getName().equals(name) && toHere.toNextSibling()) { + while (name.equals(toHere.getName()) && toHere.toNextSibling()) { } moveable.toCursor(toHere); while (moveable.toNextSibling(name)) { 1.3 +30 -1 incubator-geronimo/specs/schema/src/test/org/apache/geronimo/schema/SchemaConversionUtilsTest.java Index: SchemaConversionUtilsTest.java =================================================================== RCS file: /home/cvs/incubator-geronimo/specs/schema/src/test/org/apache/geronimo/schema/SchemaConversionUtilsTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- SchemaConversionUtilsTest.java 1 Aug 2004 20:14:20 -0000 1.2 +++ SchemaConversionUtilsTest.java 4 Aug 2004 21:48:32 -0000 1.3 @@ -111,6 +111,35 @@ assertTrue("Differences after reconverting to ejb schema: " + problems, ok3); } + public void testMDB20To21Transform() throws Exception { + File srcXml = new File("src/test-data/j2ee_1_3dtd/mdb-ejb-jar-20.xml"); + File expectedOutputXml = new File("src/test-data/j2ee_1_3dtd/mdb-ejb-jar-21.xml"); + XmlObject xmlObject = XmlObject.Factory.parse(srcXml); + XmlObject expected = XmlObject.Factory.parse(expectedOutputXml); + SchemaConversionUtils.validateDD(expected); + xmlObject = SchemaConversionUtils.convertToEJBSchema(xmlObject); +// System.out.println(xmlObject.toString()); +// System.out.println(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, 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 { File srcXml = new File("src/test-data/j2ee_1_3dtd/DescriptionGroupTestSource.xml"); File expectedOutputXml = new File("src/test-data/j2ee_1_3dtd/DescriptionGroupTestExpected.xml"); 1.1 incubator-geronimo/specs/schema/src/test-data/j2ee_1_3dtd/mdb-ejb-jar-20.xml Index: mdb-ejb-jar-20.xml =================================================================== <?xml version="1.0" encoding="UTF-8"?> <!-- Copyright 2003-2004 The Apache Software Foundation Licensed 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. --> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd"> <ejb-jar id="ejb-jar_ID"> <enterprise-beans> <message-driven> <ejb-name>BasicMessageBean</ejb-name> <ejb-class>org.acme.BasicMessageBean</ejb-class> <transaction-type>Container</transaction-type> <message-driven-destination> <destination-type>javax.jms.Queue</destination-type> </message-driven-destination> </message-driven> </enterprise-beans> </ejb-jar> 1.1 incubator-geronimo/specs/schema/src/test-data/j2ee_1_3dtd/mdb-ejb-jar-21.xml Index: mdb-ejb-jar-21.xml =================================================================== <?xml version="1.0" encoding="UTF-8"?> <!-- Copyright 2003-2004 The Apache Software Foundation Licensed 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. --> <ejb-jar xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" version="2.1" id="ejb-jar_ID" > <enterprise-beans> <message-driven> <ejb-name>BasicMessageBean</ejb-name> <ejb-class>org.acme.BasicMessageBean</ejb-class> <messaging-type>javax.jms.MessageListener</messaging-type> <transaction-type>Container</transaction-type> <activation-config> <activation-config-property> <activation-config-property-name>destinationType</activation-config-property-name> <activation-config-property-value>javax.jms.Queue</activation-config-property-value> </activation-config-property> </activation-config> </message-driven> </enterprise-beans> </ejb-jar>