You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ow...@apache.org on 2002/11/14 17:39:25 UTC
cvs commit: xml-axis-wsif/java/test/schema SchemaTest.java
owenb 2002/11/14 08:39:25
Modified: java/test/schema SchemaTest.java
Log:
Added checks to make sure that the mappings generated are the same as those expected
Revision Changes Path
1.3 +89 -8 xml-axis-wsif/java/test/schema/SchemaTest.java
Index: SchemaTest.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/schema/SchemaTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SchemaTest.java 8 Nov 2002 16:54:02 -0000 1.2
+++ SchemaTest.java 14 Nov 2002 16:39:25 -0000 1.3
@@ -81,6 +81,9 @@
String wsdlLocation1 = TestUtilities.getWsdlPath("java\\test\\schema") + "SchemaTest1.wsdl";
String wsdlLocation2 = TestUtilities.getWsdlPath("java\\test\\schema") + "SchemaTest2.wsdl";
String wsdlLocation3 = TestUtilities.getWsdlPath("java\\test\\schema") + "SchemaTest3.wsdl";
+
+ Hashtable expectedA = new Hashtable();
+ Hashtable expectedB = new Hashtable();
public SchemaTest(String name) {
super(name);
@@ -96,16 +99,69 @@
public void setUp() {
TestUtilities.setUpExtensionsAndProviders();
+ expectedA.put(
+ new QName("http://types.wsiftest/", "addresses"),
+ "[Lwsiftest.types.Address;");
+ expectedA.put(
+ new QName("http://types.wsiftest/", "InfoResponse"),
+ "wsiftest.types.InfoResponseElement");
+ expectedA.put(
+ new QName("http://types.wsiftest/", "ArrayOfArrayOfAddress"),
+ "[[Lwsiftest.types.Address;");
+ expectedA.put(
+ new QName("http://types.wsiftest/", "phone"),
+ "wsiftest.types.Phone");
+ expectedA.put(
+ new QName("http://types.wsiftest/", "ArrayOfLong"),
+ "[[J");
+ expectedA.put(
+ new QName("http://types.wsiftest/", "address"),
+ "wsiftest.types.Address");
+ expectedA.put(
+ new QName("http://types.wsiftest/", "InfoRequest"),
+ "wsiftest.types.InfoRequestElement");
+ expectedA.put(new QName("http://types.wsiftest/", "ArrayOfInt"), "[I");
+ expectedA.put(
+ new QName("http://types.wsiftest/", "ArrayOfAddress"),
+ "[Lwsiftest.types.Address;");
+
+
+ // For nested xsd files namepsaces/results are slightly different
+ expectedB.put(
+ new QName("http://types.wsiftest/", "addresses"),
+ "[Lwsiftest.types2.Address;");
+ expectedB.put(
+ new QName("http://types.wsiftest/", "InfoResponse"),
+ "wsiftest.types.InfoResponseElement");
+ expectedB.put(
+ new QName("http://types2.wsiftest/", "ArrayOfArrayOfAddress"),
+ "[[Lwsiftest.types2.Address;");
+ expectedB.put(
+ new QName("http://types2.wsiftest/", "phone"),
+ "wsiftest.types2.Phone");
+ expectedB.put(
+ new QName("http://types.wsiftest/", "ArrayOfLong"),
+ "[[J");
+ expectedB.put(
+ new QName("http://types2.wsiftest/", "address"),
+ "wsiftest.types2.Address");
+ expectedB.put(
+ new QName("http://types.wsiftest/", "InfoRequest"),
+ "wsiftest.types.InfoRequestElement");
+ expectedB.put(new QName("http://types.wsiftest/", "ArrayOfInt"), "[I");
+ expectedB.put(
+ new QName("http://types2.wsiftest/", "ArrayOfAddress"),
+ "[Lwsiftest.types2.Address;");
}
public void testParsing() {
- doIt(wsdlLocation1);
- doIt(wsdlLocation2);
- doIt(wsdlLocation3);
+ doIt(wsdlLocation1, expectedA);
+ doIt(wsdlLocation2, expectedA);
+ doIt(wsdlLocation3, expectedB);
}
- private void doIt(String wsdl) {
+ private void doIt(String wsdl, Hashtable expectedResults) {
try {
System.out.println("*** " + wsdl + " ***\n");
Definition def = WSIFUtils.readWSDL(null, wsdl);
@@ -121,11 +177,13 @@
}
} else {
System.out.println("WITHOUT STANDARD MAPPINGS RETURNED NULL!!");
+ assertTrue("With wsdl "+wsdl+", table without standard mappings was null", false);
}
+ checkResult(wsdl, table, expectedResults);
System.out.println("- - - -");
Hashtable table2 = new Hashtable();
Parser.getTypeMappings(def, table2);
- if (table != null) {
+ if (table2 != null) {
System.out.println("WITH STANDARD MAPPINGS:");
Enumeration k = table2.keys();
while(k.hasMoreElements()) {
@@ -135,7 +193,9 @@
}
} else {
System.out.println("WITH STANDARD MAPPINGS RETURNED NULL!!");
+ assertTrue("With wsdl "+wsdl+", table with standard mappings was null", false);
}
+ checkResult(wsdl, table2, expectedResults);
System.out.println("-----------------------------------------------------\n");
} catch (Exception e) {
System.err.println(
@@ -147,7 +207,7 @@
}
}
- private void doItWithClassLoader(String wsdl) {
+ private void doItWithClassLoader(String wsdl, Hashtable expectedResults) {
try {
System.out.println("*** " + wsdl + " ***\n");
ClassLoader loader = this.getClass().getClassLoader();
@@ -164,11 +224,13 @@
}
} else {
System.out.println("WITHOUT STANDARD MAPPINGS RETURNED NULL!!");
+ assertTrue("With wsdl "+wsdl+" and using a classloader, table without standard mappings was null", false);
}
+ checkResult(wsdl, table, expectedResults);
System.out.println("- - - -");
Hashtable table2 = new Hashtable();
Parser.getTypeMappings(def, table2, loader, true);
- if (table != null) {
+ if (table2 != null) {
System.out.println("WITH STANDARD MAPPINGS:");
Enumeration k = table2.keys();
while(k.hasMoreElements()) {
@@ -178,7 +240,9 @@
}
} else {
System.out.println("WITH STANDARD MAPPINGS RETURNED NULL!!");
+ assertTrue("With wsdl "+wsdl+" and using a classloader, table with standard mappings was null", false);
}
+ checkResult(wsdl, table2, expectedResults);
System.out.println("-----------------------------------------------------\n");
} catch (Exception e) {
System.err.println(
@@ -188,5 +252,22 @@
} finally {
TestUtilities.resetDefaultProviders();
}
- }
+ }
+
+ private void checkResult(String wsdl, Hashtable results, Hashtable expected) {
+ Enumeration enum = expected.keys();
+ while(enum.hasMoreElements()) {
+ QName key = (QName) enum.nextElement();
+ String value = (String) expected.get(key);
+ if (results.containsKey(key)) {
+ String resultVal = (String) results.get(key);
+ if (!value.equals(resultVal)) {
+ assertTrue("Using wsdl "+wsdl+" results did not contain correct value for type "+key
+ + ", value should be "+value+" but result was "+resultVal, false);
+ }
+ } else {
+ assertTrue("Using wsdl "+wsdl+" results did not contain type "+key, false);
+ }
+ }
+ }
}