axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r328254 - in /webservices/axis2/trunk/java/modules/codegen: ./ src/org/apache/axis2/databinding/schema/ test-resources/xsd/ test/org/apache/axis2/databinding/schema/ test/org/apache/axis2/databinding/schema/compile/ test/org/apache/axis2/da...
Date Tue, 25 Oct 2005 04:29:56 GMT
Author: ajith
Date: Mon Oct 24 21:28:50 2005
New Revision: 328254

URL: http://svn.apache.org/viewcvs?rev=328254&view=rev
Log:
1. Added a new post goal to the maven build that generates schemas
2. Added some test cases (based on reflection) to populate the generated beans
3. Refactored some test cases

Added:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/XSD2Java.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/AbstractSchemaCompilerTester.java
      - copied, changed from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/AbstractSchemaCompilerTester.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/AnonymousComplexTypeTest.java
      - copied, changed from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/AnonymousComplexTypeTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/ComplexAllTest.java
      - copied, changed from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/ComplexAllTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleAnyAttribTest.java
      - copied, changed from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleAnyAttribTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleAnyTest.java
      - copied, changed from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleAnyTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleAttributeTest.java
      - copied, changed from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleAttributeTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleElementTest.java
      - copied, changed from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleElementTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleSequence2Test.java
      - copied, changed from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleSequence2Test.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleSequenceTest.java
      - copied, changed from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleSequenceTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/XmlMaxOccurs2Test.java
      - copied, changed from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/XmlMaxOccurs2Test.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/XmlmaxOccursTest.java
      - copied, changed from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/XmlmaxOccursTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/populate/
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/populate/PopulateAnonComplexTypeTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/populate/PopulateArrayInArrayTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/populate/PopulateArrayTest.java
Removed:
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/AnonymousComplexTypeTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/ComplexAllTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleAnyAttribTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleAnyTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleAttributeTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleElementTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleSequence2Test.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleSequenceTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/XmlMaxOccurs2Test.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/XmlmaxOccursTest.java
Modified:
    webservices/axis2/trunk/java/modules/codegen/maven.xml
    webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/anonymous_complexType.xsd
    webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/simple_maxOccurs.xsd

Modified: webservices/axis2/trunk/java/modules/codegen/maven.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/maven.xml?rev=328254&r1=328253&r2=328254&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/maven.xml (original)
+++ webservices/axis2/trunk/java/modules/codegen/maven.xml Mon Oct 24 21:28:50 2005
@@ -8,10 +8,55 @@
     xmlns:maven="jelly:maven"
     xmlns:deploy="deploy"
     xmlns:ant="jelly:ant">
+
     <preGoal name="itest:compile">
         <u:file var="file" name="${maven.itest.src}"/>
         <j:if test="${!file.exists()}">
             <j:expr value="${context.setVariable('maven.itest.skip', 'true')}"/>
         </j:if>
     </preGoal>
+
+     <!-- run the schema compiler -->
+   <postGoal name="test:compile">
+        <j:set var="compiled.classes.dir" value="target/classes"/>   <!-- Theres
got to be a better way to do this -->
+        <j:set var="schema.source.dir" value="test-resources/xsd"/>
+        <j:set var="schema.output.base.dir" value="target/schema"/>
+        <j:set var="schema.generated.src.dir" value="${schema.output.base.dir}/src"/>
+        <j:set var="schema.generated.classes.dir" value="${schema.output.base.dir}/classes"/>
+        <!-- make the dirs -->
+        <mkdir dir="${schema.output.base.dir}"/>
+        <mkdir dir="${schema.generated.src.dir}"/>
+        <mkdir dir="${schema.generated.classes.dir}"/>
+       <!-- Run schema compiler with designated schemas -->
+       <!-- simple max occurs 2 xsd -->
+        <java classname="org.apache.axis2.databinding.schema.XSD2Java" fork="true">
+			<classpath refid="maven.dependency.classpath"/>
+			<classpath location="${compiled.classes.dir}"/>
+            <arg file="${schema.source.dir}/simple_maxOccurs2.xsd"/>
+            <arg file="${schema.generated.src.dir}"/>
+        </java>
+         <!-- anon complex type xsd -->
+        <java classname="org.apache.axis2.databinding.schema.XSD2Java" fork="true">
+			<classpath refid="maven.dependency.classpath"/>
+			<classpath location="${compiled.classes.dir}"/>
+            <arg file="${schema.source.dir}/anonymous_complexType.xsd"/>
+            <arg file="${schema.generated.src.dir}"/>
+        </java>
+        <!-- simple max occurs xsd -->
+        <java classname="org.apache.axis2.databinding.schema.XSD2Java" fork="true">
+			<classpath refid="maven.dependency.classpath"/>
+			<classpath location="${compiled.classes.dir}"/>
+            <arg file="${schema.source.dir}/simple_maxOccurs.xsd"/>
+            <arg file="${schema.generated.src.dir}"/>
+        </java>
+       <!-- Compile the generated classes -->
+        <javac destdir="${schema.generated.classes.dir}" srcdir="${schema.generated.src.dir}">
+            <classpath refid="maven.dependency.classpath"></classpath>
+            <classpath location="${compiled.classes.dir}"></classpath>
+        </javac>
+
+        <ant:path id="schema.generated.classes.dir" location="${schema.generated.classes.dir}"/>
+        <maven:addPath id="maven.dependency.classpath" refid="schema.generated.classes.dir"/>
+    </postGoal>
+
 </project>

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/XSD2Java.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/XSD2Java.java?rev=328254&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/XSD2Java.java
(added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/XSD2Java.java
Mon Oct 24 21:28:50 2005
@@ -0,0 +1,79 @@
+package org.apache.axis2.databinding.schema;
+
+import org.w3c.dom.Document;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.File;
+import java.io.IOException;
+/*
+ * Copyright 2004,2005 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.
+ */
+
+public class XSD2Java {
+    //for now the arguments this main method accepts is the source schema and the output
+    //location
+    public static void main(String[] args) {
+        //todo do some validation here
+        compile(args[0],args[1]);
+    }
+
+    /**
+     *
+     * @param xsdName
+     * @param outputLocation
+     */
+    private static void compile(String xsdName,String outputLocation) {
+        try {
+            //load the current Schema through a file
+            //first read the file into a DOM
+            DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+            documentBuilderFactory.setNamespaceAware(true);
+
+            DocumentBuilder builder =  documentBuilderFactory.newDocumentBuilder();
+            Document doc = builder.parse(new File(xsdName));
+
+            //now read it to a schema
+            XmlSchemaCollection schemaCol =  new XmlSchemaCollection();
+            XmlSchema currentSchema = schemaCol.read(doc,null);
+
+            File outputFolder = new File(outputLocation);
+            if (outputFolder.exists()){
+                if (outputFolder.isFile())  {
+                    throw new IOException("specified location is a folder!");
+                }
+            }else{
+                outputFolder.mkdirs();
+            }
+
+            SchemaCompiler compiler = new SchemaCompiler(new CompilerOptions().setOutputLocation(
+                    outputFolder));
+            compiler.compile(currentSchema);
+
+        } catch (ParserConfigurationException e) {
+            e.printStackTrace();
+        } catch (SAXException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } catch (SchemaCompilationException e) {
+            e.printStackTrace();
+        }
+    }
+}

Modified: webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/anonymous_complexType.xsd
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/anonymous_complexType.xsd?rev=328254&r1=328253&r2=328254&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/anonymous_complexType.xsd
(original)
+++ webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/anonymous_complexType.xsd
Mon Oct 24 21:28:50 2005
@@ -1,9 +1,7 @@
 <schema xmlns="http://www.w3.org/2001/XMLSchema"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-        xmlns:tns="http://soapinterop.org/types"
-        targetNamespace="http://soapinterop.org/types">
-    <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
-
+        xmlns:tns="http://soapinterop.org1/types"
+        targetNamespace="http://soapinterop.org1/types">
     <element name="tempElt">
         <complexType>
             <sequence>

Modified: webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/simple_maxOccurs.xsd
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/simple_maxOccurs.xsd?rev=328254&r1=328253&r2=328254&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/simple_maxOccurs.xsd (original)
+++ webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/simple_maxOccurs.xsd Mon
Oct 24 21:28:50 2005
@@ -1,8 +1,7 @@
-<schema targetNamespace="http://soapinterop.org/xsd"
+<schema targetNamespace="http://soapinterop.org2/xsd"
         xmlns="http://www.w3.org/2001/XMLSchema"
-        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-        xmlns:xsd1="http://soapinterop.org/xsd"
+        xmlns:xsd1="http://soapinterop.org2/xsd"
         elementFormDefault="qualified">
     <complexType name="SOAPStruct">
         <sequence>

Copied: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/AbstractSchemaCompilerTester.java
(from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/AbstractSchemaCompilerTester.java)
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/AbstractSchemaCompilerTester.java?p2=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/AbstractSchemaCompilerTester.java&p1=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/AbstractSchemaCompilerTester.java&r1=326859&r2=328254&rev=328254&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/AbstractSchemaCompilerTester.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/AbstractSchemaCompilerTester.java
Mon Oct 24 21:28:50 2005
@@ -1,8 +1,10 @@
-package org.apache.axis2.databinding.schema;
+package org.apache.axis2.databinding.schema.compile;
 
 import junit.framework.TestCase;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.axis2.databinding.schema.SchemaCompiler;
+import org.apache.axis2.databinding.schema.CompilerOptions;
 import org.w3c.dom.Document;
 
 import javax.xml.parsers.DocumentBuilder;
@@ -66,6 +68,7 @@
     public void testSchema() throws Exception{
         SchemaCompiler compiler = new SchemaCompiler( new CompilerOptions().setOutputLocation(outputFolder));
         compiler.compile(currentSchema);
+       
     }
 
     protected void tearDown() throws Exception {

Copied: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/AnonymousComplexTypeTest.java
(from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/AnonymousComplexTypeTest.java)
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/AnonymousComplexTypeTest.java?p2=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/AnonymousComplexTypeTest.java&p1=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/AnonymousComplexTypeTest.java&r1=326859&r2=328254&rev=328254&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/AnonymousComplexTypeTest.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/AnonymousComplexTypeTest.java
Mon Oct 24 21:28:50 2005
@@ -1,4 +1,6 @@
-package org.apache.axis2.databinding.schema;
+package org.apache.axis2.databinding.schema.compile;
+
+import org.apache.axis2.databinding.schema.compile.AbstractSchemaCompilerTester;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -15,7 +17,7 @@
  * limitations under the License.
  */
 
-public class AnonymousComplexTypeTest extends AbstractSchemaCompilerTester{
+public class AnonymousComplexTypeTest extends AbstractSchemaCompilerTester {
     protected void setUp() throws Exception {
         this.fileName = "test-resources/xsd/anonymous_complexType.xsd";
         super.setUp();

Copied: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/ComplexAllTest.java
(from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/ComplexAllTest.java)
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/ComplexAllTest.java?p2=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/ComplexAllTest.java&p1=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/ComplexAllTest.java&r1=326859&r2=328254&rev=328254&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/ComplexAllTest.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/ComplexAllTest.java
Mon Oct 24 21:28:50 2005
@@ -1,4 +1,6 @@
-package org.apache.axis2.databinding.schema;
+package org.apache.axis2.databinding.schema.compile;
+
+import org.apache.axis2.databinding.schema.compile.AbstractSchemaCompilerTester;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -15,7 +17,7 @@
  * limitations under the License.
  */
 
-public class ComplexAllTest extends AbstractSchemaCompilerTester{
+public class ComplexAllTest extends AbstractSchemaCompilerTester {
      protected void setUp() throws Exception {
          this.fileName = "test-resources/xsd/complex_all.xsd";
         super.setUp();

Copied: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleAnyAttribTest.java
(from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleAnyAttribTest.java)
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleAnyAttribTest.java?p2=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleAnyAttribTest.java&p1=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleAnyAttribTest.java&r1=326859&r2=328254&rev=328254&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleAnyAttribTest.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleAnyAttribTest.java
Mon Oct 24 21:28:50 2005
@@ -1,4 +1,6 @@
-package org.apache.axis2.databinding.schema;
+package org.apache.axis2.databinding.schema.compile;
+
+import org.apache.axis2.databinding.schema.compile.AbstractSchemaCompilerTester;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -15,7 +17,7 @@
  * limitations under the License.
  */
 
-public class SimpleAnyAttribTest extends AbstractSchemaCompilerTester{
+public class SimpleAnyAttribTest extends AbstractSchemaCompilerTester {
       protected void setUp() throws Exception {
          this.fileName = "test-resources/xsd/simple_any_attribute.xsd";
         super.setUp();

Copied: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleAnyTest.java
(from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleAnyTest.java)
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleAnyTest.java?p2=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleAnyTest.java&p1=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleAnyTest.java&r1=326859&r2=328254&rev=328254&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleAnyTest.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleAnyTest.java
Mon Oct 24 21:28:50 2005
@@ -1,4 +1,6 @@
-package org.apache.axis2.databinding.schema;
+package org.apache.axis2.databinding.schema.compile;
+
+import org.apache.axis2.databinding.schema.compile.AbstractSchemaCompilerTester;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -15,7 +17,7 @@
  * limitations under the License.
  */
 
-public class SimpleAnyTest extends AbstractSchemaCompilerTester{
+public class SimpleAnyTest extends AbstractSchemaCompilerTester {
     protected void setUp() throws Exception {
          this.fileName = "test-resources/xsd/simple_any.xsd";
         super.setUp();

Copied: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleAttributeTest.java
(from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleAttributeTest.java)
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleAttributeTest.java?p2=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleAttributeTest.java&p1=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleAttributeTest.java&r1=326859&r2=328254&rev=328254&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleAttributeTest.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleAttributeTest.java
Mon Oct 24 21:28:50 2005
@@ -1,4 +1,6 @@
-package org.apache.axis2.databinding.schema;
+package org.apache.axis2.databinding.schema.compile;
+
+import org.apache.axis2.databinding.schema.compile.AbstractSchemaCompilerTester;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -15,7 +17,7 @@
  * limitations under the License.
  */
 
-public class SimpleAttributeTest extends AbstractSchemaCompilerTester{
+public class SimpleAttributeTest extends AbstractSchemaCompilerTester {
 
     protected void setUp() throws Exception {
         this.fileName = "test-resources/xsd/simple_attrib.xsd";

Copied: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleElementTest.java
(from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleElementTest.java)
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleElementTest.java?p2=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleElementTest.java&p1=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleElementTest.java&r1=326859&r2=328254&rev=328254&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleElementTest.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleElementTest.java
Mon Oct 24 21:28:50 2005
@@ -1,4 +1,6 @@
-package org.apache.axis2.databinding.schema;
+package org.apache.axis2.databinding.schema.compile;
+
+import org.apache.axis2.databinding.schema.compile.AbstractSchemaCompilerTester;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *

Copied: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleSequence2Test.java
(from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleSequence2Test.java)
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleSequence2Test.java?p2=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleSequence2Test.java&p1=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleSequence2Test.java&r1=326859&r2=328254&rev=328254&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleSequence2Test.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleSequence2Test.java
Mon Oct 24 21:28:50 2005
@@ -1,4 +1,6 @@
-package org.apache.axis2.databinding.schema;
+package org.apache.axis2.databinding.schema.compile;
+
+import org.apache.axis2.databinding.schema.compile.AbstractSchemaCompilerTester;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -15,7 +17,7 @@
  * limitations under the License.
  */
 
-public class SimpleSequence2Test extends AbstractSchemaCompilerTester{
+public class SimpleSequence2Test extends AbstractSchemaCompilerTester {
      protected void setUp() throws Exception {
         this.fileName = "test-resources/xsd/simple_sequence_2.xsd";
         super.setUp();

Copied: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleSequenceTest.java
(from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleSequenceTest.java)
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleSequenceTest.java?p2=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleSequenceTest.java&p1=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleSequenceTest.java&r1=326859&r2=328254&rev=328254&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/SimpleSequenceTest.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/SimpleSequenceTest.java
Mon Oct 24 21:28:50 2005
@@ -1,4 +1,6 @@
-package org.apache.axis2.databinding.schema;
+package org.apache.axis2.databinding.schema.compile;
+
+import org.apache.axis2.databinding.schema.compile.AbstractSchemaCompilerTester;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *

Copied: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/XmlMaxOccurs2Test.java
(from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/XmlMaxOccurs2Test.java)
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/XmlMaxOccurs2Test.java?p2=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/XmlMaxOccurs2Test.java&p1=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/XmlMaxOccurs2Test.java&r1=326859&r2=328254&rev=328254&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/XmlMaxOccurs2Test.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/XmlMaxOccurs2Test.java
Mon Oct 24 21:28:50 2005
@@ -1,4 +1,6 @@
-package org.apache.axis2.databinding.schema;
+package org.apache.axis2.databinding.schema.compile;
+
+import org.apache.axis2.databinding.schema.compile.AbstractSchemaCompilerTester;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -15,7 +17,7 @@
  * limitations under the License.
  */
 
-public class XmlMaxOccurs2Test extends AbstractSchemaCompilerTester{
+public class XmlMaxOccurs2Test extends AbstractSchemaCompilerTester {
     protected void setUp() throws Exception {
         this.fileName = "test-resources/xsd/simple_maxOccurs2.xsd";
         super.setUp();

Copied: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/XmlmaxOccursTest.java
(from r326859, webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/XmlmaxOccursTest.java)
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/XmlmaxOccursTest.java?p2=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/XmlmaxOccursTest.java&p1=webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/XmlmaxOccursTest.java&r1=326859&r2=328254&rev=328254&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/XmlmaxOccursTest.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/compile/XmlmaxOccursTest.java
Mon Oct 24 21:28:50 2005
@@ -1,4 +1,6 @@
-package org.apache.axis2.databinding.schema;
+package org.apache.axis2.databinding.schema.compile;
+
+import org.apache.axis2.databinding.schema.compile.AbstractSchemaCompilerTester;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -15,7 +17,7 @@
  * limitations under the License.
  */
 
-public class XmlmaxOccursTest extends AbstractSchemaCompilerTester{
+public class XmlmaxOccursTest extends AbstractSchemaCompilerTester {
        protected void setUp() throws Exception {
         this.fileName = "test-resources/xsd/simple_maxOccurs.xsd";
         super.setUp();

Added: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/populate/PopulateAnonComplexTypeTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/populate/PopulateAnonComplexTypeTest.java?rev=328254&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/populate/PopulateAnonComplexTypeTest.java
(added)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/populate/PopulateAnonComplexTypeTest.java
Mon Oct 24 21:28:50 2005
@@ -0,0 +1,70 @@
+package org.apache.axis2.databinding.schema.populate;
+
+import junit.framework.TestCase;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.namespace.QName;
+import java.io.ByteArrayInputStream;
+import java.lang.reflect.Method;
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+
+
+/*
+ * Copyright 2004,2005 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.
+ */
+
+public class PopulateAnonComplexTypeTest extends TestCase {
+    private String xmlString = "<tempElt>" +
+            "<varInt>5</varInt>" +
+            "<varString>Hello</varString>" +
+            "<varFloat>3.3</varFloat>" +
+            "</tempElt>";
+
+    public void testPopulate() throws Exception{
+
+        XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new
ByteArrayInputStream(xmlString.getBytes()));
+        Class clazz = Class.forName("org1.soapinterop.tempElt");
+        Method parseMethod = clazz.getMethod("parse",new Class[]{XMLStreamReader.class});
+        Object obj = parseMethod.invoke(null,new Object[]{reader});
+
+
+        BeanInfo beanInfo =  Introspector.getBeanInfo(obj.getClass());
+        PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+        Method readMethod;
+        for (int i = 0; i < propertyDescriptors.length; i++) {
+            PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
+            if ("varInt".equals(propertyDescriptor.getDisplayName())){
+                readMethod = propertyDescriptor.getReadMethod();
+                assertEquals(new Integer(5),readMethod.invoke(obj,null));
+            } else if ("varFloat".equals(propertyDescriptor.getDisplayName())){
+                readMethod = propertyDescriptor.getReadMethod();
+                assertEquals(new Float(3.3),readMethod.invoke(obj,null));
+            }  else if ("varString".equals(propertyDescriptor.getDisplayName())){
+                readMethod = propertyDescriptor.getReadMethod();
+                assertEquals("Hello",readMethod.invoke(obj,null));
+            }
+
+        }
+
+    }
+
+
+
+}
+

Added: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/populate/PopulateArrayInArrayTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/populate/PopulateArrayInArrayTest.java?rev=328254&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/populate/PopulateArrayInArrayTest.java
(added)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/populate/PopulateArrayInArrayTest.java
Mon Oct 24 21:28:50 2005
@@ -0,0 +1,93 @@
+package org.apache.axis2.databinding.schema.populate;
+
+import junit.framework.TestCase;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.namespace.QName;
+
+
+
+import java.io.ByteArrayInputStream;
+import java.beans.Introspector;
+import java.beans.BeanInfo;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.lang.reflect.Array;
+import java.util.Arrays;
+/*
+ * Copyright 2004,2005 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.
+ */
+
+public class PopulateArrayInArrayTest extends TestCase{
+    private String xmlString = "<myobject>" +
+            "<soapStructures>" +
+            "<varFloat>3.3</varFloat>" +
+            "<varInt>5</varInt>" +
+            "<varString>Hello11</varString>" +
+            "<varString>Hello11</varString>" +
+            "<varString>Hello12</varString>" +
+            "<varString>Hello13</varString>" +
+            "</soapStructures>" +
+            "<soapStructures>" +
+            "<varFloat>3.31</varFloat>" +
+            "<varInt>51</varInt>" +
+            "<varString>Hello21</varString>" +
+            "<varString>Hello21</varString>" +
+            "<varString>Hello22</varString>" +
+            "<varString>Hello23</varString>" +
+            "</soapStructures>" +
+            "</myobject>";
+
+    public void testPopulate() throws Exception{
+
+            XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new
ByteArrayInputStream(xmlString.getBytes()));
+            Class clazz = Class.forName("org.soapinterop.myobject");
+            Method parseMethod = clazz.getMethod("parse",new Class[]{XMLStreamReader.class});
+            Object obj = parseMethod.invoke(null,new Object[]{reader});
+
+
+            Object myObject = null ;
+            BeanInfo beanInfo =  Introspector.getBeanInfo(obj.getClass());
+            PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+            for (int i = 0; i < propertyDescriptors.length; i++) {
+                PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
+                if ("myobject".equals(propertyDescriptor.getDisplayName())){
+                    Method readMethod = propertyDescriptor.getReadMethod();
+                    myObject = readMethod.invoke(obj,new Object[]{});
+                    break;
+                }
+
+
+            }
+
+            assertNotNull(myObject);
+
+//            int length = Array.getLength(myObject);
+//            for (int i = 0; i < length; i++) {
+//                System.out.println(Array.get(myObject,i));
+//
+//            }
+
+
+
+
+
+    }
+
+
+
+}

Added: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/populate/PopulateArrayTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/populate/PopulateArrayTest.java?rev=328254&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/populate/PopulateArrayTest.java
(added)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/populate/PopulateArrayTest.java
Mon Oct 24 21:28:50 2005
@@ -0,0 +1,87 @@
+package org.apache.axis2.databinding.schema.populate;
+
+import junit.framework.TestCase;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import java.io.ByteArrayInputStream;
+import java.lang.reflect.Method;
+import java.lang.reflect.Array;
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+/*
+ * Copyright 2004,2005 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.
+ */
+
+public class PopulateArrayTest extends TestCase {
+    private String xmlString = "<myobject>" +
+            "<varFloat>3.3</varFloat>" +
+            "<varInt>5</varInt>" +
+            "<varString>Hello</varString>" +
+            "<varString>Hello2</varString>" +
+            "<varString>Hello3</varString>" +
+            "</myobject>";
+
+    public void testPopulate() throws Exception{
+
+        XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new
ByteArrayInputStream(xmlString.getBytes()));
+        Class clazz = Class.forName("org2.soapinterop.myobject");
+        Method parseMethod = clazz.getMethod("parse",new Class[]{XMLStreamReader.class});
+        Object obj = parseMethod.invoke(null,new Object[]{reader});
+
+        Object soapStruct = null;
+        BeanInfo beanInfo =  Introspector.getBeanInfo(obj.getClass());
+        PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+        Method readMethod;
+        for (int i = 0; i < propertyDescriptors.length; i++) {
+            PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
+            if ("myobject".equals(propertyDescriptor.getDisplayName())){
+                readMethod = propertyDescriptor.getReadMethod();
+                soapStruct = readMethod.invoke(obj,null);
+                break;
+            }
+        }
+
+        assertNotNull(soapStruct);
+
+        BeanInfo structBeanInfo =  Introspector.getBeanInfo(soapStruct.getClass());
+        PropertyDescriptor[] structPropertyDescriptors = structBeanInfo.getPropertyDescriptors();
+        for (int i = 0; i < structPropertyDescriptors.length; i++) {
+            PropertyDescriptor propertyDescriptor = structPropertyDescriptors[i];
+            if ("varInt".equals(propertyDescriptor.getDisplayName())){
+                readMethod = propertyDescriptor.getReadMethod();
+                assertEquals("varInt is not properly set",new Integer(5),readMethod.invoke(soapStruct,null));
+            } else if ("varFloat".equals(propertyDescriptor.getDisplayName())){
+                readMethod = propertyDescriptor.getReadMethod();
+                assertEquals("varFloat is not properly set",new Float(3.3),readMethod.invoke(soapStruct,null));
+            }  else if ("varString".equals(propertyDescriptor.getDisplayName())){
+                readMethod = propertyDescriptor.getReadMethod();
+                assertTrue("String array is not set",readMethod.getReturnType().isArray());
+                Object array = readMethod.invoke(soapStruct, null);
+                int length = Array.getLength(array);
+                assertEquals("Array length is not correct",length,3);
+
+                //check the items here
+            }
+
+        }
+
+
+    }
+
+
+
+}



Mime
View raw message