geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akulshresh...@apache.org
Subject svn commit: r496305 - in /geronimo/server/trunk/modules/geronimo-client-builder/src: main/java/org/apache/geronimo/client/builder/ test/java/org/apache/geronimo/client/builder/ test/resources/j2ee_1_3dtd/
Date Mon, 15 Jan 2007 13:01:57 GMT
Author: akulshreshtha
Date: Mon Jan 15 05:01:56 2007
New Revision: 496305

URL: http://svn.apache.org/viewvc?view=rev&rev=496305
Log:
GERONIMO-2723 Upgrade client-builder to use javaee 5 schemas

Added:
    geronimo/server/trunk/modules/geronimo-client-builder/src/test/resources/j2ee_1_3dtd/application-client-5.xml
  (with props)
Modified:
    geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-client-builder/src/test/java/org/apache/geronimo/client/builder/SchemaConversionTest.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=496305&r1=496304&r2=496305
==============================================================================
--- 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 Jan 15 05:01:56 2007
@@ -81,8 +81,8 @@
 import org.apache.geronimo.xbeans.geronimo.client.GerApplicationClientType;
 import org.apache.geronimo.xbeans.geronimo.client.GerResourceType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerAbstractNamingEntryDocument;
-import org.apache.geronimo.xbeans.j2ee.ApplicationClientDocument;
-import org.apache.geronimo.xbeans.j2ee.ApplicationClientType;
+import org.apache.geronimo.xbeans.javaee.ApplicationClientDocument;
+import org.apache.geronimo.xbeans.javaee.ApplicationClientType;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlCursor;
@@ -377,14 +377,24 @@
         }
         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";
+        String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/application-client_5.xsd";
+        String version = "5";
         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);
+            if ("http://java.sun.com/xml/ns/j2ee".equals(cursor.getName().getNamespaceURI()))
{
+                SchemaConversionUtils.convertSchemaVersion(cursor, SchemaConversionUtils.JAVAEE_NAMESPACE,
schemaLocationURL, version);
+                XmlObject result = xmlObject.changeType(ApplicationClientDocument.type);
+                XmlBeansUtil.validateDD(result);
+                return (ApplicationClientDocument) result;
+            }
+            
+            // otherwise assume DTD
+            SchemaConversionUtils.convertToSchema(cursor, SchemaConversionUtils.JAVAEE_NAMESPACE,
schemaLocationURL, version);
+            cursor.toStartDoc();
+            cursor.toChild(SchemaConversionUtils.JAVAEE_NAMESPACE, "application-client");
+            cursor.toFirstChild();
+            SchemaConversionUtils.convertToDescriptionGroup(SchemaConversionUtils.JAVAEE_NAMESPACE,
cursor, moveable);
         } finally {
             cursor.dispose();
             moveable.dispose();
@@ -484,7 +494,7 @@
             }
             String classPath = manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
             if (module.isStandAlone() && classPath != null) {
-                throw new DeploymentException("Manifest class path entry is not allowed in
a standalone jar (J2EE 1.4 Section 8.2)");
+                throw new DeploymentException("Manifest class path entry is not allowed in
a standalone jar (JAVAEE 5 Section 8.2)");
             }
         } catch (IOException e) {
             throw new DeploymentException("Could not get manifest from app client module:
" + moduleFile.getName());
@@ -656,10 +666,10 @@
             }
 
             if (!pathUri.getPath().endsWith(".jar")) {
-                throw new DeploymentException("Manifest class path entries must end with
the .jar extension (J2EE 1.4 Section 8.2): jarFile=" + jarFileLocation + ", path=" + path);
+                throw new DeploymentException("Manifest class path entries must end with
the .jar extension (JAVAEE 5 Section 8.2): jarFile=" + jarFileLocation + ", path=" + path);
             }
             if (pathUri.isAbsolute()) {
-                throw new DeploymentException("Manifest class path entries must be relative
(J2EE 1.4 Section 8.2): jarFile=" + jarFileLocation + ", path=" + path);
+                throw new DeploymentException("Manifest class path entries must be relative
(JAVAEE 5 Section 8.2): jarFile=" + jarFileLocation + ", path=" + path);
             }
 
             // determine the target file
@@ -686,7 +696,7 @@
                 try {
                     classPathJarFile = new JarFile(classPathFile);
                 } catch (IOException e) {
-                    throw new DeploymentException("Manifest class path entries must be a
valid jar file (J2EE 1.4 Section 8.2): jarFile=" + jarFileLocation + ", path=" + path, e);
+                    throw new DeploymentException("Manifest class path entries must be a
valid jar file (JAVAEE 5 Section 8.2): jarFile=" + jarFileLocation + ", path=" + path, e);
                 }
 
                 // add the client jars of this class path jar

Modified: 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=diff&rev=496305&r1=496304&r2=496305
==============================================================================
--- geronimo/server/trunk/modules/geronimo-client-builder/src/test/java/org/apache/geronimo/client/builder/SchemaConversionTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-client-builder/src/test/java/org/apache/geronimo/client/builder/SchemaConversionTest.java
Mon Jan 15 05:01:56 2007
@@ -39,9 +39,9 @@
 
     private ClassLoader classLoader = this.getClass().getClassLoader();
 
-    public void testApplicationClient13ToApplicationClient14Transform() throws Exception
{
+    public void testApplicationClient13ToApplicationClient5Transform() throws Exception {
         URL srcXml = classLoader.getResource("j2ee_1_3dtd/application-client-13.xml");
-        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/application-client-14.xml");
+        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/application-client-5.xml");
         XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
         XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
         XmlBeansUtil.validateDD(expected);
@@ -54,9 +54,9 @@
         //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));
+            String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/application_5.xsd";
+            String version = "5";
+            assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.JAVAEE_NAMESPACE,
schemaLocationURL, version));
         } finally {
             cursor2.dispose();
         }
@@ -68,4 +68,32 @@
         assertTrue("Differences after reconverting to application client schema: " + problems,
ok3);
     }
 
+    public void testApplicationClient14ToApplicationClient5Transform() throws Exception {
+        URL srcXml = classLoader.getResource("j2ee_1_3dtd/application-client-14.xml");
+        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/application-client-5.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/javaee/application_5.xsd";
+            String version = "5";
+            assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.JAVAEE_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);
+    }
 }

Added: geronimo/server/trunk/modules/geronimo-client-builder/src/test/resources/j2ee_1_3dtd/application-client-5.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-client-builder/src/test/resources/j2ee_1_3dtd/application-client-5.xml?view=auto&rev=496305
==============================================================================
--- geronimo/server/trunk/modules/geronimo-client-builder/src/test/resources/j2ee_1_3dtd/application-client-5.xml
(added)
+++ geronimo/server/trunk/modules/geronimo-client-builder/src/test/resources/j2ee_1_3dtd/application-client-5.xml
Mon Jan 15 05:01:56 2007
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   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.
+-->
+
+
+<application-client xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/j2ee/application-client_5.xsd"
version="5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee">
+    <description>it's like this, see?</description>
+    <display-name>display me!</display-name>
+    <resource-ref>
+        <res-ref-name>jdbc/DefaultDatasource</res-ref-name>
+        <res-type>javax.sql.DataSource</res-type>
+        <res-auth>Container</res-auth>
+        <res-sharing-scope>Shareable</res-sharing-scope>
+    </resource-ref>
+    <resource-ref>
+        <res-ref-name>jms/JMSConnectionFactory</res-ref-name>
+        <res-type>javax.jms.ConnectionFactory</res-type>
+        <res-auth>Container</res-auth>
+        <res-sharing-scope>Shareable</res-sharing-scope>
+    </resource-ref>
+    <resource-env-ref>
+        <resource-env-ref-name>jms/Queue</resource-env-ref-name>
+        <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
+    </resource-env-ref>
+</application-client>

Propchange: geronimo/server/trunk/modules/geronimo-client-builder/src/test/resources/j2ee_1_3dtd/application-client-5.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-client-builder/src/test/resources/j2ee_1_3dtd/application-client-5.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-client-builder/src/test/resources/j2ee_1_3dtd/application-client-5.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message