You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by sa...@apache.org on 2012/05/31 12:39:08 UTC
svn commit: r1344643 [4/4] - in /axis/axis2/java/core/trunk/modules/kernel:
./ test-resources/schemas/ test-resources/schemas/custom_schemas/
test-resources/schemas/default_generator/
test-resources/schemas/doc_lit_generator/ test-resources/schemas/map...
Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/RunTimeExceptionCheck-1.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/RunTimeExceptionCheck-1.xml?rev=1344643&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/RunTimeExceptionCheck-1.xml (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/RunTimeExceptionCheck-1.xml Thu May 31 10:39:04 2012
@@ -0,0 +1,40 @@
+<!--
+ ~ 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.
+ -->
+
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ex="http://example.org" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://example.org">
+ <xs:element name="nullInterruptedException">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="InterruptedException" nillable="true" type="xs:anyType"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="toStringResult" nillable="true" type="xs:string"/>
+ <xs:element name="nullRuntimeException">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="RuntimeException" nillable="true" type="xs:anyType"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="hashCodeResult" nillable="true" type="xs:int"/>
+ <xs:element name="getClassResult" nillable="true" type="xs:anyType"/>
+ <xs:element name="args0" nillable="true" type="xs:anyType"/>
+ <xs:element name="equalsResult" nillable="true" type="xs:boolean"/>
+</xs:schema>
Propchange: axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/RunTimeExceptionCheck-1.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/StringAsReturnType-1.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/StringAsReturnType-1.xml?rev=1344643&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/StringAsReturnType-1.xml (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/StringAsReturnType-1.xml Thu May 31 10:39:04 2012
@@ -0,0 +1,34 @@
+<!--
+ ~ 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.
+ -->
+
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ex="http://example.org" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://example.org">
+ <xs:element name="nullInterruptedException">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="InterruptedException" nillable="true" type="xs:anyType"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="toStringResult" nillable="true" type="xs:string"/>
+ <xs:element name="hashCodeResult" nillable="true" type="xs:int"/>
+ <xs:element name="getClassResult" nillable="true" type="xs:anyType"/>
+ <xs:element name="args0" nillable="true" type="xs:anyType"/>
+ <xs:element name="equalsResult" nillable="true" type="xs:boolean"/>
+ <xs:element name="TestStringReturnTypeResult" nillable="true" type="xs:string"/>
+</xs:schema>
Propchange: axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/StringAsReturnType-1.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/charAsReturnType-1.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/charAsReturnType-1.xml?rev=1344643&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/charAsReturnType-1.xml (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/charAsReturnType-1.xml Thu May 31 10:39:04 2012
@@ -0,0 +1,34 @@
+<!--
+ ~ 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.
+ -->
+
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ex="http://example.org" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://example.org">
+ <xs:element name="nullInterruptedException">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="InterruptedException" nillable="true" type="xs:anyType"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="toStringResult" nillable="true" type="xs:string"/>
+ <xs:element name="testCharAsResultResult" nillable="true" type="xs:unsignedShort"/>
+ <xs:element name="hashCodeResult" nillable="true" type="xs:int"/>
+ <xs:element name="getClassResult" nillable="true" type="xs:anyType"/>
+ <xs:element name="args0" nillable="true" type="xs:anyType"/>
+ <xs:element name="equalsResult" nillable="true" type="xs:boolean"/>
+</xs:schema>
Propchange: axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/charAsReturnType-1.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/doubleAsReturnType-1.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/doubleAsReturnType-1.xml?rev=1344643&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/doubleAsReturnType-1.xml (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/doubleAsReturnType-1.xml Thu May 31 10:39:04 2012
@@ -0,0 +1,34 @@
+<!--
+ ~ 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.
+ -->
+
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ex="http://example.org" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://example.org">
+ <xs:element name="nullInterruptedException">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="InterruptedException" nillable="true" type="xs:anyType"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="toStringResult" nillable="true" type="xs:string"/>
+ <xs:element name="testDoubleAsResultResult" nillable="true" type="xs:double"/>
+ <xs:element name="hashCodeResult" nillable="true" type="xs:int"/>
+ <xs:element name="getClassResult" nillable="true" type="xs:anyType"/>
+ <xs:element name="args0" nillable="true" type="xs:anyType"/>
+ <xs:element name="equalsResult" nillable="true" type="xs:boolean"/>
+</xs:schema>
Propchange: axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/doubleAsReturnType-1.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/intAsReturnType-1.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/intAsReturnType-1.xml?rev=1344643&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/intAsReturnType-1.xml (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/intAsReturnType-1.xml Thu May 31 10:39:04 2012
@@ -0,0 +1,34 @@
+<!--
+ ~ 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.
+ -->
+
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ex="http://example.org" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://example.org">
+ <xs:element name="nullInterruptedException">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="InterruptedException" nillable="true" type="xs:anyType"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="toStringResult" nillable="true" type="xs:string"/>
+ <xs:element name="testIntAsResultResult" nillable="true" type="xs:int"/>
+ <xs:element name="hashCodeResult" nillable="true" type="xs:int"/>
+ <xs:element name="getClassResult" nillable="true" type="xs:anyType"/>
+ <xs:element name="args0" nillable="true" type="xs:anyType"/>
+ <xs:element name="equalsResult" nillable="true" type="xs:boolean"/>
+</xs:schema>
Propchange: axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/doc_lit_generator/intAsReturnType-1.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/mapping_files/mapping1.txt
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/mapping_files/mapping1.txt?rev=1344643&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/mapping_files/mapping1.txt (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/mapping_files/mapping1.txt Thu May 31 10:39:04 2012
@@ -0,0 +1,2 @@
+org.apache.axis2.description.java2wsdl.DummyClass|http://www.abc.com/soaframework/common/types|ErrorMessage
+
Propchange: axis/axis2/java/core/trunk/modules/kernel/test-resources/schemas/mapping_files/mapping1.txt
------------------------------------------------------------------------------
svn:eol-style = native
Modified: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java?rev=1344643&r1=1344642&r2=1344643&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java Thu May 31 10:39:04 2012
@@ -19,21 +19,26 @@
package org.apache.axis2.description;
-import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+
+import javax.xml.namespace.QName;
+
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.context.ServiceContext;
import org.apache.axis2.context.ServiceGroupContext;
import org.apache.axis2.deployment.DeploymentConstants;
+import org.apache.axis2.description.java2wsdl.XMLSchemaTest;
import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.ws.commons.schema.XmlSchema;
-import javax.xml.namespace.QName;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectOutputStream;
-
-public class AxisServiceTest extends TestCase {
+public class AxisServiceTest extends XMLSchemaTest {
public static final String PARAM_NAME = "CustomParameter";
public static final Object PARAM_VALUE = new Object();
+ private AxisService service;
+ private ArrayList<XmlSchema> sampleSchemas;
class MyObserver implements ParameterObserver {
public boolean gotIt = false;
@@ -45,9 +50,26 @@ public class AxisServiceTest extends Tes
}
}
}
+
+
+
+ @Override
+ protected void setUp() throws Exception {
+ service = new AxisService();
+ sampleSchemas=new ArrayList<XmlSchema>();
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ service=null;
+ sampleSchemas=null;
+ super.tearDown();
+ }
+
+
public void testAddMessageElementQNameToOperationMappingBasic() {
- AxisService service = new AxisService();
AxisOperation op1 = new InOnlyAxisOperation();
QName opName = new QName("foo");
@@ -70,7 +92,6 @@ public class AxisServiceTest extends Tes
}
public void testAddMessageElementQNameToOperationMappingOverloading() {
- AxisService service = new AxisService();
AxisOperation op1 = new InOnlyAxisOperation();
AxisOperation op2 = new InOnlyAxisOperation();
@@ -95,7 +116,6 @@ public class AxisServiceTest extends Tes
}
public void testParameterObserver() throws Exception {
- AxisService service = new AxisService();
MyObserver observer = new MyObserver();
service.addParameterObserver(observer);
@@ -176,9 +196,7 @@ public class AxisServiceTest extends Tes
assertTrue("SUCCESSFUL".equals(mc.getProperty("MESSAGE_PROPERTY")));
}
- public void testOperationActionMapping() throws Exception {
- AxisService service = new AxisService();
-
+ public void testOperationActionMapping() throws Exception {
AxisOperation op1 = new InOutAxisOperation();
AxisOperation op2 = new InOutAxisOperation();
op2.addParameter(DeploymentConstants.TAG_ALLOWOVERRIDE, "true");
Modified: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/DefaultSchemaGeneratorTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/DefaultSchemaGeneratorTest.java?rev=1344643&r1=1344642&r2=1344643&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/DefaultSchemaGeneratorTest.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/DefaultSchemaGeneratorTest.java Thu May 31 10:39:04 2012
@@ -19,29 +19,59 @@
package org.apache.axis2.description.java2wsdl;
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.management.RuntimeErrorException;
+import javax.xml.namespace.QName;
+
import org.apache.axis2.description.AxisService;
import org.apache.ws.commons.schema.XmlSchema;
+import org.w3c.dom.Document;
-import junit.framework.TestCase;
+public class DefaultSchemaGeneratorTest extends XMLSchemaTest {
-import javax.xml.namespace.QName;
+ protected AxisService axisService;
+ private DefaultSchemaGenerator generator;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
+ public DefaultSchemaGenerator getGenerator() {
+ return generator;
+ }
+
+ public void setGenerator(DefaultSchemaGenerator generator) {
+ this.generator = generator;
+ }
-public class DefaultSchemaGeneratorTest extends TestCase {
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ axisService = new AxisService();
+
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ axisService = null;
+ generator = null;
+ super.tearDown();
+ }
public static class TestWebService {
}
public void testGeneratesExtraClass() throws Exception {
-
- AxisService axisService = new AxisService();
-
- DefaultSchemaGenerator generator = new DefaultSchemaGenerator(getClass().getClassLoader(),
- TestWebService.class.getName(), "http://example.org", "ex", axisService);
+
+ generator = new DefaultSchemaGenerator(getClass().getClassLoader(),
+ TestWebService.class.getName(), "http://example.org", "ex",
+ axisService);
ArrayList<String> extraClasses = new ArrayList<String>();
extraClasses.add(ExtraClass.class.getName());
generator.setExtraClasses(extraClasses);
@@ -59,4 +89,954 @@ public class DefaultSchemaGeneratorTest
}
assertTrue(foundExtra);
}
+
+ public void testGenerateSchema() throws Exception {
+ AxisService axisService = new AxisService();
+ generator = new DefaultSchemaGenerator(getClass().getClassLoader(),
+ TestWebService.class.getName(), "http://example.org", "ex",
+ axisService);
+ Collection<XmlSchema> schemas = generator.generateSchema();
+ for (int i = 0; i < 50; i++) {
+ System.out.println(schemas.size());
+ }
+ assertNotNull(schemas);
+ }
+
+ private void testClass(Class<?> c) throws Exception {
+ generator = getGenerator(c);
+ Collection<XmlSchema> schemaColl = generator.generateSchema();
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ Iterator<XmlSchema> iterator = schemaColl.iterator();
+ int i = 0;
+ for (XmlSchema xmlSchema : schemaColl) {
+ i++;
+ byteArrayOutputStream = new ByteArrayOutputStream();
+ xmlSchema.write(byteArrayOutputStream);
+ String XML1 = byteArrayOutputStream.toString();
+ String XML2 = readSchema(c, i);
+
+ assertSimilarXML(XML1, XML2);
+ assertIdenticalXML(XML1, XML2);
+ }
+
+ }
+
+ private void testClass(Class<?> c, String customSchemaLocation)
+ throws Exception {
+ generator = getGenerator(c);
+ generator.setCustomSchemaLocation(customSchemaLocation);
+ Collection<XmlSchema> schemaColl = generator.generateSchema();
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ int i = 0;
+ for (XmlSchema xmlSchema : schemaColl) {
+ i++;
+ byteArrayOutputStream = new ByteArrayOutputStream();
+ xmlSchema.write(byteArrayOutputStream);
+ String XML1 = byteArrayOutputStream.toString();
+ String XML2 = readSchemaWithCustomSchema(c, i);
+ assertSimilarXML(XML1, XML2);
+ assertIdenticalXML(XML1, XML2);
+ }
+
+ }
+
+ private void testClassWithMapping(Class<?> c, String mappingLocation)
+ throws Exception {
+ generator = getGenerator(c);
+ generator.setMappingFileLocation(mappingLocation);
+ Collection<XmlSchema> schemaColl = generator.generateSchema();
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ int i = 0;
+ for (XmlSchema xmlSchema : schemaColl) {
+ i++;
+ byteArrayOutputStream = new ByteArrayOutputStream();
+ xmlSchema.write(byteArrayOutputStream);
+ String XML1 = byteArrayOutputStream.toString();
+ String XML2 = readSchemaWithMappingSchema(c, i);
+ XML1 = prepareForMapping(XML1);
+ assertSimilarXML(XML1, XML2);
+ assertIdenticalXML(XML1, XML2);
+ }
+
+ }
+
+ private String prepareForMapping(String XML1) {
+ XML1 = XML1.replaceAll(XMLSchemaNameSpace, "#temporory_replacement1#");
+ XML1 = XML1
+ .replaceAll(
+ "targetNamespace=\"http://java2wsdl.description.axis2.apache.org/xsd\"",
+ "#temporory_replacement2#");
+ XML1 = XML1
+ .replaceAll(
+ "xmlns:.*=\"http://java2wsdl.description.axis2.apache.org/xsd\"",
+ "xmlns:mapping=\"http://java2wsdl.description.axis2.apache.org/xsd\"");
+ XML1 = XML1
+ .replaceAll(
+ "xmlns:.*=\"http://www.abc.com/soaframework/common/types\"",
+ "xmlns:mapping2=\"http://www.abc.com/soaframework/common/types\"");
+ XML1 = XML1.replaceAll("#temporory_replacement1#", XMLSchemaNameSpace);
+ XML1 = XML1
+ .replaceAll(
+ "<xs:element name=\"MappingTestResult\" nillable=\"true\" type=\".*:ErrorMessage\"/>",
+ "<xs:element name=\"MappingTestResult\" nillable=\"true\" type=\"mapping:ErrorMessage\"/>");
+ XML1 = XML1
+ .replaceAll(
+ "<xs:element minOccurs=\"0\" name=\"return\" nillable=\"true\" type=\".*:ErrorMessage\"/>",
+ "<xs:element minOccurs=\"0\" name=\"return\" nillable=\"true\" type=\"mapping:ErrorMessage\"/>");
+ XML1 = XML1
+ .replaceAll("#temporory_replacement2#",
+ "targetNamespace=\"http://java2wsdl.description.axis2.apache.org/xsd\"");
+ return XML1;
+ }
+
+ public DefaultSchemaGenerator getGenerator(Class<?> c) throws Exception {
+ return new DefaultSchemaGenerator(getClass().getClassLoader(),
+ c.getName(), "http://example.org", "ex", axisService);
+ }
+
+ public String readSchema(Class<?> c, int i) throws Exception {
+ return readFile("test-resources" + File.separator + "schemas"
+ + File.separator + "default_generator" + File.separator
+ + c.getSimpleName() + "-" + i + ".xml");
+ }
+
+ public String readSchemaWithCustomSchema(Class<?> c, int i)
+ throws Exception {
+ return readFile("test-resources" + File.separator + "schemas"
+ + File.separator + "default_generator" + File.separator
+ + c.getSimpleName() + "with_custom_schema-" + i + ".xml");
+ }
+
+ public String readSchemaWithMappingSchema(Class<?> c, int i)
+ throws Exception {
+ return readFile("test-resources" + File.separator + "schemas"
+ + File.separator + "default_generator" + File.separator
+ + c.getSimpleName() + "with_custom_mapping-" + i + ".xml");
+ }
+
+ public void testDOMClass(Class<?> c) throws Exception {
+ generator = getGenerator(c);
+ Collection<XmlSchema> schemaColl = generator.generateSchema();
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ Iterator<XmlSchema> iterator = schemaColl.iterator();
+ int i = 0;
+ for (XmlSchema xmlSchema : schemaColl) {
+ i++;
+ byteArrayOutputStream = new ByteArrayOutputStream();
+ xmlSchema.write(byteArrayOutputStream);
+ String XML1 = byteArrayOutputStream.toString();
+ XML1 = prepareForDOM(XML1);
+ String XML2 = readSchema(c, i);
+ assertSimilarXML(XML1, XML2);
+ assertIdenticalXML(XML1, XML2);
+ }
+
+ }
+
+ private String prepareForDOM(String XML1) {
+ XML1 = XML1.replaceAll(XMLSchemaNameSpace, "#temporory_replacement1#");
+ XML1 = XML1
+ .replaceAll(
+ "targetNamespace=\"http://java2wsdl.description.axis2.apache.org\"",
+ "#temporory_replacement2#");
+ XML1 = XML1.replaceAll(
+ "xmlns:.*=\"http://java2wsdl.description.axis2.apache.org\"",
+ "xmlns:DOM=\"http://java2wsdl.description.axis2.apache.org\"");
+ XML1 = XML1.replaceAll("#temporory_replacement1#", XMLSchemaNameSpace);
+ XML1 = XML1
+ .replaceAll("#temporory_replacement2#",
+ "targetNamespace=\"http://java2wsdl.description.axis2.apache.org\"");
+ return XML1;
+ }
+
+ // to test classes which involves java.util.map
+ public void testMapClass(Class<?> c) throws Exception {
+ generator = getGenerator(c);
+ Collection<XmlSchema> schemaColl = generator.generateSchema();
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ Iterator<XmlSchema> iterator = schemaColl.iterator();
+ int i = 0;
+ for (XmlSchema xmlSchema : schemaColl) {
+ i++;
+ byteArrayOutputStream = new ByteArrayOutputStream();
+ xmlSchema.write(byteArrayOutputStream);
+ String XML1 = byteArrayOutputStream.toString();
+ if (XML1.contains("\"http://ws.apache.org/namespaces/axis2/map\"")) {
+ XML1 = prepareForMap(XML1);
+ }
+ String XML2 = readSchema(c, i);
+ assertSimilarXML(XML1, XML2);
+ assertIdenticalXML(XML1, XML2);
+ }
+
+ }
+
+ public String prepareForMap(String XML1) {
+ XML1 = XML1.replaceAll(XMLSchemaNameSpace, "#temporory_replacement1#");
+ XML1 = XML1
+ .replaceAll(
+ "targetNamespace=\"http://ws.apache.org/namespaces/axis2/map\"",
+ "#temporory_replacement2#");
+ XML1 = XML1.replaceAll(
+ "xmlns:.*=\"http://ws.apache.org/namespaces/axis2/map\"",
+ "xmlns:map=\"http://ws.apache.org/namespaces/axis2/map\"");
+ XML1 = XML1
+ .replaceAll(
+ " <xs:element maxOccurs=\"unbounded\" minOccurs=\"0\" name=\"entry\" nillable=\"true\" type=\".*:entry1\"/>",
+ " <xs:element maxOccurs=\"unbounded\" minOccurs=\"0\" name=\"entry\" nillable=\"true\" type=\"map:entry1\"/>");
+ XML1 = XML1.replaceAll("#temporory_replacement1#", XMLSchemaNameSpace);
+ XML1 = XML1
+ .replaceAll("#temporory_replacement2#",
+ "targetNamespace=\"http://ws.apache.org/namespaces/axis2/map\"");
+ XML1 = XML1
+ .replaceAll(
+ "<xs:element minOccurs=\"0\" name=\"map\" nillable=\"true\" type=\".*:map1\"/>",
+ "<xs:element minOccurs=\"0\" name=\"map\" nillable=\"true\" type=\"map:map1\"/>");
+ XML1 = XML1
+ .replaceAll(
+ "<xs:element minOccurs=\"0\" name=\"return\" nillable=\"true\" type=\".*:map1\"/>",
+ "<xs:element minOccurs=\"0\" name=\"return\" nillable=\"true\" type=\"map:map1\"/>");
+ return XML1;
+ }
+
+ // to test classes which involves POJO objects
+ public void testPOJOClass(Class<?> c) throws Exception {
+ generator = getGenerator(c);
+ Collection<XmlSchema> schemaColl = generator.generateSchema();
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ Iterator<XmlSchema> iterator = schemaColl.iterator();
+ int i = 0;
+ for (XmlSchema xmlSchema : schemaColl) {
+ i++;
+ // /XmlSchema schema = schemaColl.iterator().next();
+ byteArrayOutputStream = new ByteArrayOutputStream();
+ xmlSchema.write(byteArrayOutputStream);
+ String XML1 = byteArrayOutputStream.toString();
+
+ // map has differences when generating schema files
+ if (XML1.contains("http://java2wsdl.description.axis2.apache.org/xsd")) {
+ XML1 = prepareForPOJO(XML1);
+ }
+ String XML2 = readSchema(c, i);
+ assertSimilarXML(XML1, XML2);
+ assertIdenticalXML(XML1, XML2);
+ }
+
+ }
+
+ public String prepareForPOJO(String XML1) {
+ XML1 = XML1.replaceAll(XMLSchemaNameSpace, "#temporory_replacement1#");
+ XML1 = XML1
+ .replaceAll(
+ "targetNamespace=\"http://java2wsdl.description.axis2.apache.org/xsd\"",
+ "#temporory_replacement2#");
+ XML1 = XML1.replaceAll(
+ "type=\".*:DefaultSchemaGeneratorTest_SimplePOJO\"",
+ "type=\"pojo:DefaultSchemaGeneratorTest_SimplePOJO\"");
+ XML1 = XML1
+ .replaceAll(
+ "xmlns:.*=\"http://java2wsdl.description.axis2.apache.org/xsd\"",
+ "xmlns:pojo=\"http://java2wsdl.description.axis2.apache.org/xsd\"");
+ XML1 = XML1.replaceAll("#temporory_replacement1#", XMLSchemaNameSpace);
+ XML1 = XML1
+ .replaceAll("#temporory_replacement2#",
+ "targetNamespace=\"http://java2wsdl.description.axis2.apache.org/xsd\"");
+ return XML1;
+ }
+
+ // to test classes which involves Custom Exceptions
+ public void testExcClass(Class<?> c) throws Exception {
+ generator = getGenerator(c);
+ Collection<XmlSchema> schemaColl = generator.generateSchema();
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ Iterator<XmlSchema> iterator = schemaColl.iterator();
+ int i = 0;
+ for (XmlSchema xmlSchema : schemaColl) {
+ i++;
+ byteArrayOutputStream = new ByteArrayOutputStream();
+ xmlSchema.write(byteArrayOutputStream);
+ String XML1 = byteArrayOutputStream.toString();
+
+ if (XML1.contains("http://java2wsdl.description.axis2.apache.org/xsd")) {
+ XML1 = prepareForExc(XML1);
+ }
+ String XML2 = readSchema(c, i);
+ assertSimilarXML(XML1, XML2);
+ assertIdenticalXML(XML1, XML2);
+ }
+
+ }
+
+ public String prepareForExc(String XML1) {
+ XML1 = XML1.replaceAll(XMLSchemaNameSpace, "#temporory_replacement1#");
+ XML1 = XML1
+ .replaceAll(
+ "targetNamespace=\"http://java2wsdl.description.axis2.apache.org/xsd\"",
+ "#temporory_replacement2#");
+ XML1 = XML1.replaceAll(
+ "type=\".*:DefaultSchemaGeneratorTest_CustomException\"",
+ "type=\"exc:DefaultSchemaGeneratorTest_CustomException\"");
+ XML1 = XML1
+ .replaceAll(
+ "xmlns:.*=\"http://java2wsdl.description.axis2.apache.org/xsd\"",
+ "xmlns:exc=\"http://java2wsdl.description.axis2.apache.org/xsd\"");
+ XML1 = XML1.replaceAll("#temporory_replacement1#", XMLSchemaNameSpace);
+ XML1 = XML1
+ .replaceAll("#temporory_replacement2#",
+ "targetNamespace=\"http://java2wsdl.description.axis2.apache.org/xsd\"");
+ return XML1;
+ }
+
+ // to test classes which involves enums
+ public void testEnumClass(Class<?> c) throws Exception {
+ generator = getGenerator(c);
+ Collection<XmlSchema> schemaColl = generator.generateSchema();
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ Iterator<XmlSchema> iterator = schemaColl.iterator();
+ int i = 0;
+ for (XmlSchema xmlSchema : schemaColl) {
+ i++;
+ // /XmlSchema schema = schemaColl.iterator().next();
+ byteArrayOutputStream = new ByteArrayOutputStream();
+ xmlSchema.write(byteArrayOutputStream);
+ String XML1 = byteArrayOutputStream.toString();
+
+ // Enum has differences when generating schema files
+ if (XML1.contains("\"http://ws.apache.org/namespaces/axis2/enum\"")) {
+ XML1 = prepareForEnum(XML1);
+ }
+ XML1 = prepareForEnum(XML1);
+ String XML2 = readSchema(c, i);
+ assertSimilarXML(XML1, XML2);
+ assertIdenticalXML(XML1, XML2);
+ }
+ }
+
+ public String prepareForEnum(String XML1) {
+ XML1 = XML1.replaceAll(XMLSchemaNameSpace, "#temporory_replacement1#");
+ XML1 = XML1
+ .replaceAll(
+ "targetNamespace=\"http://ws.apache.org/namespaces/axis2/enum\"",
+ "#temporory_replacement2#");
+ XML1 = XML1.replaceAll(
+ "xmlns:.*=\"http://ws.apache.org/namespaces/axis2/enum\"",
+ "xmlns:enum=\"http://ws.apache.org/namespaces/axis2/enum\"");
+
+ XML1 = XML1.replaceAll("#temporory_replacement1#", XMLSchemaNameSpace);
+ XML1 = XML1
+ .replaceAll("#temporory_replacement2#",
+ "targetNamespace=\"http://ws.apache.org/namespaces/axis2/enum\"");
+ XML1 = XML1
+ .replaceAll(
+ "<xs:element minOccurs=\"0\" name=\"e\" nillable=\"true\" type=\".*:SimpleEnum\"/>",
+ "<xs:element minOccurs=\"0\" name=\"e\" nillable=\"true\" type=\"enum:SimpleEnum\"/>");
+
+ XML1 = XML1
+ .replaceAll(
+ "<xs:element minOccurs=\"0\" name=\"return\" nillable=\"true\" type=\".*:SimpleEnum\"/>",
+ "<xs:element minOccurs=\"0\" name=\"return\" nillable=\"true\" type=\"enum:SimpleEnum\"/>");
+ return XML1;
+ }
+
+ public String readFile(String fileName) throws Exception {
+ File file = new File(fileName);
+ char[] buffer = null;
+ BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
+ buffer = new char[(int) file.length()];
+ int i = 0;
+ int c = bufferedReader.read();
+ while (c != -1) {
+ buffer[i++] = (char) c;
+ c = bufferedReader.read();
+ }
+ return new String(buffer);
+ }
+
+ public void testNoParameter() throws Exception {
+ testClass(NoParameterOrReturnType.class);
+ }
+
+ public void testNoParameterWithDefaultShchema() throws Exception {
+ testClass(NoParameterOrReturnType.class, CustomSchemaLocation);
+
+ }
+
+ public void testParametersWithDefaultSchema() throws Exception {
+ testClass(PrimitivesAsParameters.class, CustomSchemaLocation);
+ }
+
+ public void testWithMappingSchema() throws Exception {
+ testClassWithMapping(MappingCheck.class, MappingFileLocation);
+ }
+
+ public void testPrimitivesAsParameters() throws Exception {
+ testClass(PrimitivesAsParameters.class);
+ }
+
+ public void testCollectionsAsParameters() throws Exception {
+ testClass(ColectionAsParameter.class);
+ }
+
+ public void testPrimitiveArrraysAsParaameters() throws Exception {
+ testClass(PrimitiveArraysAsParametrs.class);
+ }
+
+ public void testMapAsParameter() throws Exception {
+ testMapClass(MapAsParameter.class);
+ }
+
+ public void testPojoAsParameter() throws Exception {
+ testPOJOClass(PojoAsParameter.class);
+ }
+
+ public void TestStringAsReturnType() throws Exception {
+ testClass(StringAsReturnType.class);
+ }
+
+ public void testCollectionAsReturnType() throws Exception {
+ testClass(CollectionAsReturnType.class);
+ }
+
+ public void testMapAsReturnType() throws Exception {
+ testMapClass(MapAsReturnType.class);
+ }
+
+ public void testPojoAsReturnType() throws Exception {
+ testPOJOClass(POJOAsReturnType.class);
+ }
+
+ public void testIntAsReturnType() throws Exception {
+ testClass(intAsReturnType.class);
+ }
+
+ public void testDoubleAsReturnType() throws Exception {
+ testClass(doubleAsReturnType.class);
+ }
+
+ public void testCharAsReturnType() throws Exception {
+ testClass(charAsReturnType.class);
+ }
+
+ public void testRunTimeException() throws Exception {
+ testClass(RunTimeExceptionCheck.class);
+ }
+
+ public void testCustomExcepion() throws Exception {
+ testExcClass(CustomExceptionCheck.class);
+ }
+
+ public void testIntArrayAsReturnType() throws Exception {
+ testClass(IntArrayAsReturnType.class);
+ }
+
+ public void testDoubleArrayAsReturnType() throws Exception {
+ testClass(DoubleArrayAsReturnType.class);
+ }
+
+ public void testCharArrayAsReturnType() throws Exception {
+ testClass(CharArrayAsReturnType.class);
+ }
+
+ public void testEnumAsParameter() throws Exception {
+ testEnumClass(EnumAsParameter.class);
+ }
+
+ public void testEnumAsReturnTYpe() throws Exception {
+ testEnumClass(EnumAsReturnType.class);
+ }
+
+ // public void testComplexPOJO() throws Exception{
+ // testPOJOClass(ComplexPOJO.class); // }
+
+ public void testExtendedPOJO() throws Exception {
+ testClass(ExtendedPOJO.class);
+ }
+
+ public void testAbstractPOJO() throws Exception {
+ testClass(AbstractPOJO.class);
+ }
+
+ public void testConcretePOJO() throws Exception {
+ testClass(ConcretePOJO.class);
+ }
+
+ public void testDOMAsParameter() throws Exception {
+ testDOMClass(DOMasParameter.class);
+ }
+
+ public void testDOMAsReturnType() throws Exception {
+ testDOMClass(DomAsReturnType.class);
+ }
+
+ public void testListAsParameter() throws Exception {
+ testClass(ListAsParameter.class);
+ }
+
+ public void testListAsReturnType() throws Exception {
+ testClass(ListAsReturnType.class);
+ }
+
+ class NoParameterOrReturnType {
+ public void testNoParamiters() {
+
+ }
+ }
+
+ class StringAsParameter {
+ public void testStringParameter(String s) {
+
+ }
+ }
+
+ class PrimitivesAsParameters {
+ public void testPrimitiveTypes(byte b, short s, int i, long l, float f,
+ double d, boolean isTrue, char c) {
+
+ }
+ }
+
+ class ColectionAsParameter {
+ public void testCollecttionAsPParameter(List<Object> l) {
+
+ }
+ }
+
+ class PrimitiveArraysAsParametrs {
+ public void testPrimitiveTypes(byte[] b, short[] s, int[] i, long[] l,
+ float[] f, double[] d, boolean[] isTrue, char[] c) {
+
+ }
+ }
+
+ class MapAsParameter {
+ public void testMapAsParameter(Map<Object, Object> map) {
+
+ }
+ }
+
+ class PojoAsParameter {
+ public void testPojoAsParameter(SimplePOJO o) {
+
+ }
+ }
+
+ class StringAsReturnType {
+ public String testStringReturnType() {
+ return null;
+ }
+ }
+
+ class CollectionAsReturnType {
+ public Collection<Object> TestCollectionReturnType() {
+ return null;
+ }
+ }
+
+ class ListAsParameter {
+ public void testList(List l) {
+
+ }
+ }
+
+ class ListAsReturnType {
+ public List testListAsReturnType() {
+ return null;
+ }
+ }
+
+ class MapAsReturnType {
+ public Map<Object, Object> testMapAsReturnType() {
+ return null;
+ }
+ }
+
+ class POJOAsReturnType {
+ public SimplePOJO testPOJOAsReturnType() {
+ return null;
+ }
+ }
+
+ class intAsReturnType {
+ public int testIntAsResult() {
+ return -1;
+ }
+ }
+
+ class doubleAsReturnType {
+ public double testDoubleAsResult() {
+ return 1.84984398;
+
+ }
+ }
+
+ class charAsReturnType {
+ public char testCharAsResult() {
+ return 'c';
+ }
+ }
+
+ class RunTimeExceptionCheck {
+ public void testRunTImeException() throws RuntimeException {
+ throw new RuntimeErrorException(null, "message");
+ }
+ }
+
+ class CustomExceptionCheck {
+ public void testCustomException() throws CustomException {
+ throw new CustomException("message");
+ }
+ }
+
+ class IntArrayAsReturnType {
+ public int[] testIntArrayAsReturnType() {
+ return null;
+ }
+
+ }
+
+ class CharArrayAsReturnType {
+ public char[] testCharArrayAsReturnType() {
+ return null;
+ }
+ }
+
+ class DoubleArrayAsReturnType {
+ public double[] testDoubleArrayAsReturnType() {
+ return null;
+ }
+ }
+
+ class EnumAsParameter {
+ public void testEnumAsParameter(SimpleEnum e) {
+
+ }
+ }
+
+ class EnumAsReturnType {
+ public SimpleEnum testEnumAsReturnType() {
+ return null;
+ }
+ }
+
+ class DOMasParameter {
+ public void testDOM(Document document) {
+
+ }
+ }
+
+ class DomAsReturnType {
+ public Document testDOM() {
+ return null;
+ }
+ }
+
+ class MappingCheck {
+ public DummyClass MappingTest() {
+ return null;
+ }
+ }
+
+ final class CustomException extends Exception {
+ String mistake;
+
+ public CustomException() {
+ super();
+ mistake = "unknown";
+ }
+
+ public CustomException(String err) {
+ super(err);
+ mistake = err; // save message
+ }
+
+ public String getError() {
+ return mistake;
+ }
+ }
+
+ class SimplePOJO {
+
+ private int i;
+ private double d;
+ private String s;
+ private char c;
+ private byte b;
+ private boolean bool;
+ private long l;
+
+ public int getI() {
+ return i;
+ }
+
+ public void setI(int i) {
+ this.i = i;
+ }
+
+ public double getD() {
+ return d;
+ }
+
+ public void setD(double d) {
+ this.d = d;
+ }
+
+ public String getS() {
+ return s;
+ }
+
+ public void setS(String s) {
+ this.s = s;
+ }
+
+ public char getC() {
+ return c;
+ }
+
+ public void setC(char c) {
+ this.c = c;
+ }
+
+ public byte getB() {
+ return b;
+ }
+
+ public void setB(byte b) {
+ this.b = b;
+ }
+
+ public boolean isBool() {
+ return bool;
+ }
+
+ public void setBool(boolean bool) {
+ this.bool = bool;
+ }
+
+ public long getL() {
+ return l;
+ }
+
+ public void setL(long l) {
+ this.l = l;
+ }
+
+ }
+
+ final class ComplexPOJO {
+ private List list;
+ private String[] strings;
+ private Map<Object, Object> map;
+ private SimplePOJO simplePOJO;
+ private int[] i;
+ private double[] d;
+ private char[] c;
+ private byte[] b;
+ private boolean bool;
+ private long[] l;
+
+ public List getList() {
+ return list;
+ }
+
+ public void setList(List list) {
+ this.list = list;
+ }
+
+ public String[] getStrings() {
+ return strings;
+ }
+
+ public void setStrings(String[] strings) {
+ this.strings = strings;
+ }
+
+ public Map<Object, Object> getMap() {
+ return map;
+ }
+
+ public void setMap(Map<Object, Object> map) {
+ this.map = map;
+ }
+
+ public SimplePOJO getSimplePOJO() {
+ return simplePOJO;
+ }
+
+ public void setSimplePOJO(SimplePOJO simplePOJO) {
+ this.simplePOJO = simplePOJO;
+ }
+
+ public int[] getI() {
+ return i;
+ }
+
+ public void setI(int[] i) {
+ this.i = i;
+ }
+
+ public double[] getD() {
+ return d;
+ }
+
+ public void setD(double[] d) {
+ this.d = d;
+ }
+
+ public char[] getC() {
+ return c;
+ }
+
+ public void setC(char[] c) {
+ this.c = c;
+ }
+
+ public byte[] getB() {
+ return b;
+ }
+
+ public void setB(byte[] b) {
+ this.b = b;
+ }
+
+ public boolean isBool() {
+ return bool;
+ }
+
+ public void setBool(boolean bool) {
+ this.bool = bool;
+ }
+
+ public long[] getL() {
+ return l;
+ }
+
+ public void setL(long[] l) {
+ this.l = l;
+ }
+
+ }
+
+ abstract class AbstractPOJO {
+
+ private int i;
+ private double d;
+ private String s;
+ private char c;
+
+ public int getI() {
+ return i;
+ }
+
+ public void setI(int i) {
+ this.i = i;
+ }
+
+ public double getD() {
+ return d;
+ }
+
+ public void setD(double d) {
+ this.d = d;
+ }
+
+ public String getS() {
+ return s;
+ }
+
+ public void setS(String s) {
+ this.s = s;
+ }
+
+ public char getC() {
+ return c;
+ }
+
+ public void setC(char c) {
+ this.c = c;
+ }
+ }
+
+ final class ConcretePOJO extends AbstractPOJO {
+ private byte b;
+ private boolean bool;
+ private long l;
+
+ public byte getB() {
+ return b;
+ }
+
+ public void setB(byte b) {
+ this.b = b;
+ }
+
+ public boolean isBool() {
+ return bool;
+ }
+
+ public void setBool(boolean bool) {
+ this.bool = bool;
+ }
+
+ public long getL() {
+ return l;
+ }
+
+ public void setL(long l) {
+ this.l = l;
+ }
+
+ }
+
+ final class ExtendedPOJO extends SimplePOJO {
+ private int j;
+ private double dd;
+ private String sss;
+ private char cc;
+ private byte bb;
+
+ public int getJ() {
+ return j;
+ }
+
+ public void setJ(int j) {
+ this.j = j;
+ }
+
+ public double getDd() {
+ return dd;
+ }
+
+ public void setDd(double dd) {
+ this.dd = dd;
+ }
+
+ public String getSss() {
+ return sss;
+ }
+
+ public void setSss(String sss) {
+ this.sss = sss;
+ }
+
+ public char getCc() {
+ return cc;
+ }
+
+ public void setCc(char cc) {
+ this.cc = cc;
+ }
+
+ public byte getBb() {
+ return bb;
+ }
+
+ public void setBb(byte bb) {
+ this.bb = bb;
+ }
+
+ }
+
+ public enum SimpleEnum {
+ WHITE, BLACK, RED, YELLOW, BLUE;
+ }
}
Added: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGeneratorTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGeneratorTest.java?rev=1344643&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGeneratorTest.java (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGeneratorTest.java Thu May 31 10:39:04 2012
@@ -0,0 +1,144 @@
+/*
+ * 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.axis2.description.java2wsdl;
+
+import java.io.File;
+
+import org.apache.axis2.description.AxisService;
+
+public class DocLitBareSchemaGeneratorTest extends DefaultSchemaGeneratorTest {
+
+ @Override
+ protected void setUp() throws Exception {
+ axisService = new AxisService();
+
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ this.setGenerator(null);
+ super.tearDown();
+ }
+
+ @Override
+ public String readSchema(Class<?> c, int i) throws Exception {
+ return readFile("test-resources" + File.separator + "schemas"
+ + File.separator + "doc_lit_generator" + File.separator
+ + c.getSimpleName() + "-" + i + ".xml");
+ }
+
+ @Override
+ public String readSchemaWithCustomSchema(Class<?> c, int i)
+ throws Exception {
+ return readFile("test-resources" + File.separator + "schemas"
+ + File.separator + "doc_lit_generator" + File.separator
+ + c.getSimpleName() + "with_custom_schema" + "-" + i + ".xml");
+ }
+
+ @Override
+ public String readSchemaWithMappingSchema(Class<?> c, int i)
+ throws Exception {
+ return readFile("test-resources" + File.separator + "schemas"
+ + File.separator + "doc_lit_generator" + File.separator
+ + c.getSimpleName() + "with_custom_mapping" + "-" + i + ".xml");
+ }
+
+ @Override
+ public DefaultSchemaGenerator getGenerator(Class<?> c) throws Exception {
+ return new DocLitBareSchemaGenerator(getClass().getClassLoader(),
+ c.getName(), "http://example.org", "ex", axisService);
+ }
+
+ @Override
+ public String prepareForMap(String XML1) {
+ String XML = super.prepareForMap(XML1);
+ XML = XML
+ .replaceAll(
+ "<xs:element maxOccurs=\"unbounded\" minOccurs=\"0\" name=\"entry\" nillable=\"true\" type=\".*:entry1\"/>",
+ "<xs:element maxOccurs=\"unbounded\" minOccurs=\"0\" name=\"entry\" nillable=\"true\" type=\"map:entry1\"/>");
+ XML = XML
+ .replaceAll(
+ "<xs:element name=\"map\" nillable=\"true\" type=\".*:map1\"/>",
+ "<xs:element name=\"map\" nillable=\"true\" type=\"map:map1\"/>");
+
+ XML = XML
+ .replaceAll(
+ "<xs:element name=\"testMapAsReturnTypeResult\" nillable=\"true\" type=\".*:map1\"/>",
+ "<xs:element name=\"testMapAsReturnTypeResult\" nillable=\"true\" type=\"map:map1\"/>");
+
+ return XML;
+
+ }
+
+ @Override
+ public String prepareForPOJO(String XML1) {
+ String XML = super.prepareForPOJO(XML1);
+ XML = XML
+ .replaceAll(
+ "<xs:element name=\"o\" nillable=\"true\" type=\".*:DefaultSchemaGeneratorTest_SimplePOJO\"/>",
+ "<xs:element name=\"o\" nillable=\"true\" type=\"pojo:DefaultSchemaGeneratorTest_SimplePOJO\"/>");
+ XML = XML
+ .replaceAll(
+ "<xs:element name=\"testPOJOAsReturnTypeResult\" nillable=\"true\" type=\".*:DefaultSchemaGeneratorTest_SimplePOJO\"/>",
+ "<xs:element name=\"testPOJOAsReturnTypeResult\" nillable=\"true\" type=\"pojo:DefaultSchemaGeneratorTest_SimplePOJO\"/>");
+ return XML;
+ }
+
+ @Override
+ public String prepareForEnum(String XML1) {
+ XML1 = XML1.replaceAll("xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"",
+ "#temporory_replacement1#");
+ XML1 = XML1
+ .replaceAll(
+ "targetNamespace=\"http://java2wsdl.description.axis2.apache.org/xsd\"",
+ "#temporory_replacement2#");
+ XML1 = XML1
+ .replaceAll(
+ "xmlns:.*=\"http://java2wsdl.description.axis2.apache.org/xsd\"",
+ "xmlns:enum=\"http://java2wsdl.description.axis2.apache.org/xsd\"");
+ XML1 = XML1
+ .replaceAll(
+ "<xs:element name=\"e\" nillable=\"true\" type=\".*:DefaultSchemaGeneratorTest_SimpleEnum\"/>",
+ "<xs:element name=\"e\" nillable=\"true\" type=\"enum:DefaultSchemaGeneratorTest_SimpleEnum\"/>");
+ XML1 = XML1
+ .replaceAll(
+ "<xs:element name=\"testEnumAsReturnTypeResult\" nillable=\"true\" type=\".*:DefaultSchemaGeneratorTest_SimpleEnum\"/>",
+ "<xs:element name=\"testEnumAsReturnTypeResult\" nillable=\"true\" type=\"enum:DefaultSchemaGeneratorTest_SimpleEnum\"/>");
+ XML1 = XML1.replaceAll("#temporory_replacement1#",
+ "xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"");
+ XML1 = XML1
+ .replaceAll("#temporory_replacement2#",
+ "targetNamespace=\"http://java2wsdl.description.axis2.apache.org/xsd\"");
+ return XML1;
+ }
+
+ @Override
+ public void testGeneratesExtraClass() throws Exception {
+ // No need to run these inherited methods
+
+ }
+
+ @Override
+ public void testGenerateSchema() throws Exception {
+ // No need to run these inherited methods
+
+ }
+
+}
Propchange: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/DummyClass.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/DummyClass.java?rev=1344643&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/DummyClass.java (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/DummyClass.java Thu May 31 10:39:04 2012
@@ -0,0 +1,27 @@
+/*
+ * 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.axis2.description.java2wsdl;
+
+//THis class is used to test generating schemas with custom mapping
+public class DummyClass {
+ public void test() {
+
+ }
+}
Propchange: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/DummyClass.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/XMLSchemaTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/XMLSchemaTest.java?rev=1344643&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/XMLSchemaTest.java (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/XMLSchemaTest.java Thu May 31 10:39:04 2012
@@ -0,0 +1,76 @@
+/*
+ * 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.axis2.description.java2wsdl;
+
+import java.io.File;
+import java.util.ArrayList;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.custommonkey.xmlunit.Diff;
+import org.w3c.dom.Document;
+
+import junit.framework.TestCase;
+
+public abstract class XMLSchemaTest extends TestCase {
+
+ public final String XMLSchemaNameSpace = "xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"";
+
+ public final String CustomSchemaLocation = "test-resources" + File.separator + "schemas"
+ + File.separator + "custom_schemas" + File.separator + "note.xsd";
+
+ public final String SampleSchemasDirectory = "test-resources" + File.separator + "schemas"
+ + File.separator + "custom_schemas" + File.separator;
+
+ public final String MappingFileLocation = "test-resources" + File.separator + "schemas"
+ + File.separator + "mapping_files" + File.separator + "mapping1.txt";
+
+ public void assertSimilarXML(String XML1, String XML2) throws Exception {
+ Diff myDiff = new Diff(XML1, XML2);
+ assertTrue("XML similar " + myDiff.toString(), myDiff.similar());
+
+ }
+
+ public void assertIdenticalXML(String XML1, String XML2) throws Exception {
+ Diff myDiff = new Diff(XML1, XML2);
+ assertTrue("XML similar " + myDiff.toString(), myDiff.identical());
+
+ }
+
+ public void loadSampleSchemaFile(ArrayList<XmlSchema> schemas) throws Exception {
+ XmlSchemaCollection xmlSchemaCollection = new XmlSchemaCollection();
+ File file = null;
+ int i = 1;
+
+ file = new File(SampleSchemasDirectory + "sampleSchema" + i + ".xsd");
+ while (file.exists()) {
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ Document doc = documentBuilderFactory.newDocumentBuilder().parse(file);
+ schemas.add(xmlSchemaCollection.read(doc, null));
+ i++;
+ file = new File(SampleSchemasDirectory + "sampleSchema" + i + ".xsd");
+ }
+
+ }
+
+}
Propchange: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/java2wsdl/XMLSchemaTest.java
------------------------------------------------------------------------------
svn:eol-style = native