User: jung
Date: 00/12/04 04:36:19
Modified: src/org/zoap/soap/test Soap.java test.dfPackage
Log:
adopted to latest jboss container,
added decimal and date
removed some problems due to forward-referencing in meta-data
added serialisation policy
Revision Changes Path
1.4 +927 -890 zoap/src/org/zoap/soap/test/Soap.java
Index: Soap.java
===================================================================
RCS file: /products/cvs/ejboss/zoap/src/org/zoap/soap/test/Soap.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Soap.java 2000/09/04 16:43:45 1.3
+++ Soap.java 2000/12/04 12:36:19 1.4
@@ -1,894 +1,928 @@
-/*
- * $Id: Soap.java,v 1.3 2000/09/04 16:43:45 jung Exp $
- * Copyright (c) 2000 infor:business solutions AG, Hauerstrasse 12,
- * D-66299 Friedrichsthal, Germany. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-package org.zoap.soap.test;
-
-import org.zoap.soap.HttpServer;
-import org.zoap.soap.HttpRequest;
-import org.zoap.soap.HttpResponse;
-import org.zoap.soap.Envelope;
-import org.zoap.soap.SoapException;
-import org.zoap.soap.SoapTie;
-import org.zoap.soap.SoapInvocationHandler;
-import org.zoap.soap.SoapStringInvocationHandler;
-
-import org.zoap.soap.meta.RequestElement;
-import org.zoap.soap.meta.ResponseElement;
-import org.zoap.soap.meta.ReturnElement;
-import org.zoap.soap.meta.ArgumentElement;
-import org.zoap.soap.meta.RequestType;
-import org.zoap.soap.meta.ResponseType;
-import org.zoap.soap.meta.SoapBinding;
-
-import org.zoap.soap.meta.builtin.DefaultBinding;
-import org.zoap.soap.meta.builtin.DefaultMetaBinding;
-
-import org.zoap.xml.XmlObjectReader;
-import org.zoap.xml.XmlObjectWriter;
-import org.zoap.xml.URNResolver;
-import org.zoap.xml.Schema;
-import org.zoap.xml.XmlException;
-import org.zoap.xml.Element;
-import org.zoap.xml.Attribute;
-import org.zoap.xml.Type;
-
-import org.zoap.xml.meta.BooleanType;
-import org.zoap.xml.meta.StringType;
-import org.zoap.xml.meta.builtin.ClassType;
-import org.zoap.xml.meta.builtin.NameAttribute;
-import org.zoap.xml.meta.builtin.RefAttribute;
-import org.zoap.xml.meta.builtin.FieldAttribute;
-import org.zoap.xml.meta.builtin.FieldElement;
-
-import java.util.Collection;
-
-import java.net.URL;
-
-import de.infor.ce.http.HttpException;
-
-import de.infor.ce.util.URN;
-
-import de.infor.businessobjects.test.TestObject;
-import de.infor.businessobjects.test.TestObject1;
-import de.infor.businessobjects.test.TestObject2;
-import de.infor.businessobjects.test.TestObject3;
-
-import de.infor.businessservices.test.TestSuperInterface;
-import de.infor.businessservices.test.TestInterface;
-import de.infor.businessservices.test.TestException;
-
-import de.infor.businessservices.implementations.test.TestService;
-
-/**
- * A unit test for checking low-level features of the soap service
- * @see <related>
- * @author $Author: jung $
- * @version $Revision: 1.3 $
- */
-
-public class Soap extends junit.framework.TestCase {
-
-
- public Soap(String name) {
- super(name);
- }
-
- public static void main(String[] args) {
-
- junit.textui.TestRunner runner = new junit.textui.TestRunner();
-
- try {
- runner.run(suite());
- } catch (Exception e) {
- }
- }
-
- public static junit.framework.Test suite() {
-
- return new junit.framework.TestSuite(Soap.class);
-
- }
-
- HttpServer server;
- static int currentPort=4241;
-
- public void setUp() {
-
- try {
- server = new HttpServer(++currentPort);
- server.start();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-
- public void testSoapHttpServer() throws java.io.IOException, HttpException,
SoapException {
-
- java.net.URL proxyUrl = new
java.net.URL("http://localhost:"+currentPort+"/");
-
- java.net.URL targetUrl = new java.net.URL(proxyUrl, "");
-
- HttpRequest request = new HttpRequest(proxyUrl, targetUrl);
-
- request.setEnvelope(new Envelope(null, null));
-
- HttpResponse response = (HttpResponse)request.send();
-
- response = (HttpResponse)request.send();
-
- response = (HttpResponse)request.send();
-
- } // testSoapHttpServer
-
- public void testSoapProxyString() throws java.io.IOException, HttpException,
SoapException {
-
- TestService service = new TestService();
-
- SoapTie serviceInterceptor = new SoapTie(server, service);
-
- java.net.URL proxyUrl = new
java.net.URL("http://localhost:"+currentPort+"/");
-
- java.net.URL targetUrl = new java.net.URL(proxyUrl,
serviceInterceptor.getHandle());
-
- SoapInvocationHandler testProxy = new SoapInvocationHandler(server,
proxyUrl, targetUrl);
-
- TestInterface remoteProxy = (TestInterface)java.lang.reflect.Proxy.
- newProxyInstance(Thread.currentThread().getContextClassLoader(),
- new Class[] { TestInterface.class }, testProxy);
-
- assert("Asserting String call",
"42".equals(remoteProxy.testString("42")));
-
- } // testSoapProxyString
-
-
- public void testSoapProxyNormal() throws java.io.IOException, HttpException,
SoapException {
-
- TestService service = new TestService();
-
- SoapTie serviceInterceptor = new SoapTie(server, service, new
DefaultBinding());
-
- java.net.URL proxyUrl = new
java.net.URL("http://localhost:"+currentPort+"/");
-
- java.net.URL targetUrl = new java.net.URL(proxyUrl,
serviceInterceptor.getHandle());
-
- SoapInvocationHandler testProxy = new SoapInvocationHandler(server,
proxyUrl,
- targetUrl, new DefaultBinding());
-
- TestInterface remoteProxy = (TestInterface)java.lang.reflect.Proxy.
- newProxyInstance(Thread.currentThread().getContextClassLoader(),
- new Class[] { TestInterface.class }, testProxy);
-
- TestObject2 testObject = new TestObject2();
- TestObject3 testObject2 = new TestObject3();
-
- testObject.setTestInherited(true);
-
- testObject.setTestBoolean(true);
-
- testObject.setTestPublic(true);
-
- testObject.setTestProtected(true);
-
- testObject.setTestPrivate(true);
-
- testObject.setTestStatic(true);
-
- testObject.setTestTransient(true);
-
- testObject.setTestByte((byte)42);
-
- testObject.setTestInteger(42);
-
- testObject.setTestShort((short)42);
-
- testObject.setTestCharacter('z');
-
- testObject.setTestLong((long)42);
-
- testObject.setTestFloat((float)42.0);
-
- testObject.setTestDouble((double)42.0);
-
- testObject.setTestString("42");
-
- testObject.setTestReference(testObject2);
-
- testObject.setTestArray(new TestObject3[] { testObject2 });
-
- testObject.setTestCollection(new java.util.Vector());
-
- testObject.getTestCollection().add(testObject2);
-
- testObject.setTestExtension(true);
-
- testObject2.setTestReturn(testObject);
-
- TestObject2 testObject3 =
(TestObject2)remoteProxy.testObject(testObject);
-
- assert("Asserting inherited attribute", testObject3.getTestInherited()
!=
- testObject.getTestInherited());
-
- assert("Asserting private attribute", testObject3.isTestPrivate() ==
- testObject.isTestPrivate());
-
- assert("Asserting protected attribute", testObject3.isTestProtected()
==
- testObject.isTestProtected());
-
- assert("Asserting public attribute", testObject3.isTestPublic() ==
- testObject.isTestPublic());
-
- assert("Asserting static attribute", testObject3.isTestStatic() ==
- testObject.isTestStatic());
-
- assert("Asserting transient attribute", testObject3.isTestTransient()
!=
- testObject.isTestTransient());
-
- assert("Asserting boolean attribute", testObject3.isTestBoolean() ==
- testObject.isTestBoolean());
-
- assert("Asserting byte attribute", testObject3.getTestByte() ==
- testObject.getTestByte());
-
- assert("Asserting char attribute", testObject3.getTestCharacter() ==
- testObject.getTestCharacter());
-
- assert("Asserting integer attribute", testObject3.getTestInteger() ==
- testObject.getTestInteger());
-
- assert("Asserting short attribute", testObject3.getTestShort() ==
- testObject.getTestShort());
-
- assert("Asserting long attribute", testObject3.getTestLong() ==
- testObject.getTestLong());
-
- assert("Asserting float attribute", testObject3.getTestFloat() ==
- testObject.getTestFloat());
-
- assert("Asserting double attribute", testObject3.getTestDouble() ==
- testObject.getTestDouble());
-
- assert("Asserting string attribute", testObject.getTestString().
- equals(testObject3.getTestString()));
-
- assert("Asserting reference attribute", testObject3.getTestReference().
- getTestReturn() == testObject3);
-
- assert("Asserting array element", testObject3.getTestArray() != null &&
- testObject3.getTestArray().length == 1 && testObject3.getTestArray()
[0] ==
- testObject3.getTestReference());
-
- assert("Asserting collection element", testObject3.getTestCollection()
!= null &&
- testObject3.getTestCollection().size() == 1 &&
testObject3.getTestCollection().get(0) ==
- testObject3.getTestReference());
-
- assert("Asserting extension attribute", testObject3.isTestExtension()
==
- testObject.isTestExtension());
-
- } // testSoapHttpServer
-
-
- public void testSoapProxyException() throws java.io.IOException,
- HttpException, SoapException {
-
- TestService service = new TestService();
-
- SoapTie serviceInterceptor = new SoapTie(server, service, new
DefaultBinding());
-
- java.net.URL proxyUrl = new
java.net.URL("http://localhost:"+currentPort+"/");
-
- java.net.URL targetUrl = new java.net.URL(proxyUrl,
serviceInterceptor.getHandle());
-
- SoapInvocationHandler testProxy = new SoapInvocationHandler(server,
proxyUrl, targetUrl,
- new DefaultBinding());
-
- TestInterface remoteProxy = (TestInterface)java.lang.reflect.Proxy.
- newProxyInstance(Thread.currentThread().getContextClassLoader(),
- new Class[] { TestInterface.class }, testProxy);
-
- try {
- remoteProxy.testException();
- fail("Testing unsuccessful remote call did not produce any
exception");
- } catch (TestException e) {
- }
-
-
- } // testSoapHttpServer
-
- public void testSoapStringProxy() throws java.io.IOException, HttpException,
SoapException, Throwable {
-
- TestService service = new TestService();
-
- SoapTie serviceInterceptor = new SoapTie(server, service, new
DefaultBinding());
-
- java.net.URL proxyUrl = new
java.net.URL("http://localhost:"+currentPort+"/");
-
- java.net.URL targetUrl = new java.net.URL(proxyUrl,
serviceInterceptor.getHandle());
-
- SoapStringInvocationHandler testProxy =
- new SoapStringInvocationHandler(TestInterface.class, server,
- proxyUrl, targetUrl, new
org.zoap.soap.meta.builtin.string.DefaultBinding());
-
- testProxy.invoke("testString", new Class[] { String.class },
- new String[] {
- "<arbitraryTag>42</arbitraryTag>"
- });
-
- } // testSoapProxyString
-
- public void testSeperateTags() {
-
- String[] seperate =
org.zoap.soap.Environment.seperateTags("blablablabl hhhhssgdghf <testTag>" +
- "<sickContent> jjjjdddhhhs <testTag> moreSickContent </testTag>
jhjhjfhfkjsfh </sickContent> </testTag>" +
- "intermediateshhit" +
- "<secondTestTag blablablabla> jjjddssds </secondTestTag shishishit>
kickickicki");
-
- assert("Testing seperation of tags", seperate != null &&
seperate.length == 2);
-
- assert("Testing first result tag", ("<testTag><sickContent>
jjjjdddhhhs <testTag>" +
- " moreSickContent </testTag> jhjhjfhfkjsfh </sickContent>
</testTag>").equals(seperate[0]));
-
- assert("Testing second result tag", "<secondTestTag blablablabla>
jjjddssds </secondTestTag shishishit>".
- equals(seperate[1]));
-
- }
-
- public void testMeta() throws XmlException, java.io.IOException,
NoSuchMethodException {
-
- URL resource = Thread.currentThread().getContextClassLoader().
- getResource("META-INF/contract.scl");
-
- URN firstUrn = new URN(resource.toString());
-
- XmlObjectReader xmlObjectReader = new XmlObjectReader(new
- java.io.InputStreamReader(resource.openStream()), firstUrn, new
DefaultMetaBinding());
-
- Schema testSchema = (Schema)xmlObjectReader.readObject();
-
- testSchema = xmlObjectReader.getBinding().
- getSchema(new
URN("http://schemas.infor.de/businessservices/test/TestInterface"));
-
- Schema superSchema = (Schema)xmlObjectReader.getBinding().
- getSchema(new
URN("http://schemas.infor.de/businessservices/test/TestSuperInterface"));
-
- assert("Testing side effect 2", superSchema != null);
-
- /* test testBoolean request */
-
- Element firstElement = superSchema.getElement("testBoolean-0-Request");
-
- assert("Testing first method request", firstElement instanceof
RequestElement);
-
- assert("Testing first method request name",
- "testBoolean-0-Request".equals(firstElement.getAppearanceName()));
-
- assert("Testing first method request schema",
- superSchema.equals(firstElement.getAppearanceSchema()));
-
- Type firstElementType = firstElement.getType();
-
- assert("Testing first method request type", firstElementType
instanceof RequestType);
-
- assert("Testing first method request type name",
"testBoolean-0-RequestMessage".
- equals(firstElementType.getTypeName()));
-
- assert("Testing first method request type schema", superSchema.
- equals(firstElementType.getTypeSchema()));
-
- assert("Testing first method request type associated method",
-
de.infor.businessservices.test.TestSuperInterface.class.getMethod("testBoolean", new
Class[0]).
- equals(((RequestType)firstElementType).getAssociatedMethod()));
-
- Element[] subElements = firstElementType.getElements(null);
- Attribute[] subAttributes = firstElementType.getAttributes(null);
-
- assert("Testing first method request type elements", subElements ==
null || subElements.length == 0);
- assert("Testing first method request type attributes", subAttributes
== null || subAttributes.length == 0);
-
- /* test testBoolean response */
-
- Element secondElement =
superSchema.getElement("testBoolean-0-Response");
-
- assert("Testing first method response", secondElement instanceof
ResponseElement);
-
- assert("Testing first method response name",
- "testBoolean-0-Response".equals(secondElement.getAppearanceName()));
-
- assert("Testing first method response schema",
- superSchema.equals(secondElement.getAppearanceSchema()));
-
- Type secondElementType = secondElement.getType();
-
- assert("Testing first method response type", secondElementType
instanceof ResponseType);
-
- assert("Testing first method response type name",
"testBoolean-0-ResponseMessage".
- equals(secondElementType.getTypeName()));
-
- assert("Testing first method reponse type schema", superSchema.
- equals(secondElementType.getTypeSchema()));
-
- assert("Testing first method request type associated method",
-
de.infor.businessservices.test.TestSuperInterface.class.getMethod("testBoolean", new
Class[0]).
- equals(((ResponseType)secondElementType).getAssociatedMethod()));
-
- subElements = secondElementType.getElements(null);
- subAttributes = secondElementType.getAttributes(null);
-
- assert("Testing first method response type elements", subElements !=
null || subElements.length == 1);
- assert("Testing first method response type attributes", subAttributes
== null || subAttributes.length == 0);
-
- Element secondElementTypeFirstElement =
secondElementType.getElement(superSchema, "testBoolean-0-Return");
-
- assert("Testing first method response type first element",
- secondElementTypeFirstElement instanceof ReturnElement);
-
- assert("Testing first method response type first element name",
"testBoolean-0-Return".equals(
- secondElementTypeFirstElement.getAppearanceName()));
-
- assert("Testing first method response type first element schema",
superSchema.equals(
- secondElementTypeFirstElement.getAppearanceSchema()));
-
- assert("Testing first method response type first element type",
BooleanType.getBooleanType().equals(
- secondElementTypeFirstElement.getType()));
-
- /* test testString request */
-
- Element thirdElement = testSchema.getElement("testString-0-Request");
-
- assert("Testing second method request", thirdElement instanceof
RequestElement);
-
- assert("Testing second method request name",
- "testString-0-Request".equals(thirdElement.getAppearanceName()));
-
- assert("Testing second method request schema",
- testSchema.equals(thirdElement.getAppearanceSchema()));
-
- Type thirdElementType = thirdElement.getType();
-
- assert("Testing second method request type", thirdElementType
instanceof RequestType);
-
- assert("Testing second method request type name",
"testString-0-RequestMessage".
- equals(thirdElementType.getTypeName()));
-
- assert("Testing second method request type schema", testSchema.
- equals(thirdElementType.getTypeSchema()));
-
- assert("Testing second method request type associated method",
-
de.infor.businessservices.test.TestInterface.class.getMethod("testString", new Class[]
{ String.class }).
- equals(((RequestType)thirdElementType).getAssociatedMethod()));
-
- subElements = thirdElementType.getElements(null);
- subAttributes = thirdElementType.getAttributes(null);
-
- assert("Testing second method request type elements", subElements !=
null || subElements.length == 1);
- assert("Testing second method request type attributes", subAttributes
== null || subAttributes.length == 0);
-
- Element thirdElementTypeFirstElement = thirdElementType.
- getElement(testSchema, "testString-0-in");
-
- assert("Testing second method request type first element",
- thirdElementTypeFirstElement instanceof ArgumentElement);
-
- assert("Testing second method request type first element name",
"testString-0-in".equals(
- thirdElementTypeFirstElement.getAppearanceName()));
-
- assert("Testing second method request type first element schema",
testSchema.equals(
- thirdElementTypeFirstElement.getAppearanceSchema()));
-
- assert("Testing second method request type first element type",
StringType.getStringType().equals(
- thirdElementTypeFirstElement.getType()));
-
- assert("Testing second method request type first element type arity",
((ArgumentElement)
- thirdElementTypeFirstElement).getArity() == 0);
-
- /* test testString response */
-
- Element fourthElement = testSchema.getElement("testString-0-Response");
-
- assert("Testing second method response", fourthElement instanceof
ResponseElement);
-
- assert("Testing second method response name",
- "testString-0-Response".equals(fourthElement.getAppearanceName()));
-
- assert("Testing second method response schema",
- testSchema.equals(fourthElement.getAppearanceSchema()));
-
- Type fourthElementType = fourthElement.getType();
-
- assert("Testing second method response type", fourthElementType
instanceof ResponseType);
-
- assert("Testing second method response type name",
"testString-0-ResponseMessage".
- equals(fourthElementType.getTypeName()));
-
- assert("Testing second method response type schema", testSchema.
- equals(fourthElementType.getTypeSchema()));
-
- assert("Testing second method response type associated method",
-
de.infor.businessservices.test.TestInterface.class.getMethod("testString", new Class[]
{ String.class }).
- equals(((ResponseType)fourthElementType).getAssociatedMethod()));
-
- subElements = fourthElementType.getElements(null);
- subAttributes = fourthElementType.getAttributes(null);
-
- assert("Testing second method response type elements", subElements !=
null || subElements.length == 1);
- assert("Testing second method response type attributes", subAttributes
== null || subAttributes.length == 0);
-
- Element fourthElementTypeFirstElement = fourthElementType.
- getElement(testSchema, "testString-0-Return");
-
- assert("Testing second method response type first element",
- fourthElementTypeFirstElement instanceof ReturnElement);
-
- assert("Testing second method response type first element name",
"testString-0-Return".equals(
- fourthElementTypeFirstElement.getAppearanceName()));
-
- assert("Testing second method response type first element schema",
testSchema.equals(
- fourthElementTypeFirstElement.getAppearanceSchema()));
-
- assert("Testing second method response type first element type",
StringType.getStringType().equals(
- fourthElementTypeFirstElement.getType()));
-
- /* test testObject request */
-
- Element fifthElement = testSchema.getElement("testObject-0-Request");
-
- assert("Testing third method request", fifthElement instanceof
RequestElement);
-
- assert("Testing third method request name",
- "testObject-0-Request".equals(fifthElement.getAppearanceName()));
-
- assert("Testing third method request schema",
- testSchema.equals(fifthElement.getAppearanceSchema()));
-
- Type fifthElementType = fifthElement.getType();
-
- assert("Testing third method request type", fifthElementType
instanceof RequestType);
-
- assert("Testing third method request type name",
"testObject-0-RequestMessage".
- equals(fifthElementType.getTypeName()));
-
- assert("Testing third method request type schema", testSchema.
- equals(fifthElementType.getTypeSchema()));
-
- assert("Testing third method request type associated method",
-
de.infor.businessservices.test.TestInterface.class.getMethod("testObject", new Class[]
{
- de.infor.businessobjects.test.TestObject1.class
- }).
- equals(((RequestType)fifthElementType).getAssociatedMethod()));
-
- subElements = fifthElementType.getElements(null);
- subAttributes = fifthElementType.getAttributes(null);
-
- assert("Testing third method request type elements", subElements !=
null || subElements.length == 1);
- assert("Testing third method request type attributes", subAttributes
== null || subAttributes.length == 0);
-
- Element fifthElementTypeFirstElement = fifthElementType.
- getElement(testSchema, "testObject-0-in");
-
- assert("Testing third method request type first element",
- fifthElementTypeFirstElement instanceof ArgumentElement);
-
- assert("Testing third method request type first element name",
"testObject-0-in".equals(
- fifthElementTypeFirstElement.getAppearanceName()));
-
- assert("Testing third method request type first element schema",
testSchema.equals(
- fifthElementTypeFirstElement.getAppearanceSchema()));
-
- Type fifthElementTypeFirstElementType =
fifthElementTypeFirstElement.getType();
-
- Schema fifthElementTypeFirstElementTypeSchema =
fifthElementTypeFirstElementType.getTypeSchema();
-
- assert("Testing third method request type first element type",
fifthElementTypeFirstElementType instanceof ClassType &&
-
"TestObject1Type".equals(fifthElementTypeFirstElementType.getTypeName()) &&
- fifthElementTypeFirstElementTypeSchema.
- equals(xmlObjectReader.getBinding().
- getSchema(new
URN("http://schemas.infor.de/businessobjects/test/TestObject1"))));
-
-
- /* back with normal stuff */
-
- assert("Testing third method request type first element type",
de.infor.businessobjects.test.TestObject1.class.
-
equals(((ClassType)fifthElementTypeFirstElementType).getAssociatedClass()));
-
- assert("Testing third method request type first element type arity",
((ArgumentElement)
- fifthElementTypeFirstElement).getArity() == 0);
-
- /* test testObject response */
-
- Element sixthElement = testSchema.getElement("testObject-0-Response");
-
- assert("Testing third method response", sixthElement instanceof
ResponseElement);
-
- assert("Testing third method response name",
- "testObject-0-Response".equals(sixthElement.getAppearanceName()));
-
- assert("Testing third method response schema",
- testSchema.equals(sixthElement.getAppearanceSchema()));
-
- Type sixthElementType = sixthElement.getType();
-
- assert("Testing third method response type", sixthElementType
instanceof ResponseType);
-
- assert("Testing third method response type name",
"testObject-0-ResponseMessage".
- equals(sixthElementType.getTypeName()));
-
- assert("Testing third method response type schema", testSchema.
- equals(sixthElementType.getTypeSchema()));
-
- assert("Testing third method response type associated method",
-
de.infor.businessservices.test.TestInterface.class.getMethod("testObject",
- new Class[] { de.infor.businessobjects.test.TestObject1.class
}).equals(((ResponseType)
- sixthElementType).getAssociatedMethod()));
-
- subElements = sixthElementType.getElements(null);
- subAttributes = sixthElementType.getAttributes(null);
-
- assert("Testing third method response type elements", subElements !=
null || subElements.length == 1);
- assert("Testing third method response type attributes", subAttributes
== null || subAttributes.length == 0);
-
- Element sixthElementTypeFirstElement = sixthElementType.
- getElement(testSchema, "testObject-0-Return");
-
- assert("Testing third method response type first element",
- sixthElementTypeFirstElement instanceof ReturnElement);
-
- assert("Testing third method response type first element name",
"testObject-0-Return".equals(
- sixthElementTypeFirstElement.getAppearanceName()));
-
- assert("Testing third method response type first element schema",
testSchema.equals(
- sixthElementTypeFirstElement.getAppearanceSchema()));
-
- Type sixthElementTypeFirstElementType =
sixthElementTypeFirstElement.getType();
-
- assert("Testing third method response type first element type",
sixthElementTypeFirstElementType
- instanceof ClassType);
-
- assert("Testing third method response type first element type
equality", fifthElementTypeFirstElementType.
- equals(sixthElementTypeFirstElementType));
-
- /* test testString request */
-
- Element seventhElement =
testSchema.getElement("testException-0-Request");
-
- assert("Testing fourth method request", seventhElement instanceof
RequestElement);
-
- assert("Testing fourth method request name",
- "testException-0-Request".equals(seventhElement.getAppearanceName()));
-
- assert("Testing fourth method request schema",
- testSchema.equals(seventhElement.getAppearanceSchema()));
-
- Type seventhElementType = seventhElement.getType();
-
- assert("Testing fourth method request type", seventhElementType
instanceof RequestType);
-
- assert("Testing fourth method request type name",
"testException-0-RequestMessage".
- equals(seventhElementType.getTypeName()));
-
- assert("Testing fourth method request type schema", testSchema.
- equals(seventhElementType.getTypeSchema()));
-
- assert("Testing fourth method request type associated method",
-
de.infor.businessservices.test.TestInterface.class.getMethod("testException", new
Class[0]).
- equals(((RequestType)seventhElementType).getAssociatedMethod()));
-
- subElements = seventhElementType.getElements(null);
- subAttributes = seventhElementType.getAttributes(null);
-
- assert("Testing fourth method request type elements", subElements ==
null || subElements.length == 0);
- assert("Testing fourth method request type attributes", subAttributes
== null || subAttributes.length == 0);
-
- /* test testString response */
-
- Element eightsElement =
testSchema.getElement("testException-0-Response");
-
- assert("Testing fourth method response", eightsElement instanceof
ResponseElement);
-
- assert("Testing fourth method response name",
- "testException-0-Response".equals(eightsElement.getAppearanceName()));
-
- assert("Testing fourth method response schema",
- testSchema.equals(eightsElement.getAppearanceSchema()));
-
- Type eightsElementType = eightsElement.getType();
-
- assert("Testing fourth method response type", eightsElementType
instanceof ResponseType);
-
- assert("Testing fourth method response type name",
"testException-0-ResponseMessage".
- equals(eightsElementType.getTypeName()));
-
- assert("Testing fourth method response type schema", testSchema.
- equals(eightsElementType.getTypeSchema()));
-
- assert("Testing fourth method response type associated method",
-
de.infor.businessservices.test.TestInterface.class.getMethod("testException", new
Class[0]).
- equals(((ResponseType)eightsElementType).getAssociatedMethod()));
-
- subElements = eightsElementType.getElements(null);
- subAttributes = eightsElementType.getAttributes(null);
-
- assert("Testing fourth method response type elements", subElements ==
null || subElements.length == 0);
- assert("Testing fourth method response type attributes", subAttributes
== null || subAttributes.length == 0);
-
- }
-
- public void testMetaProxy() throws java.io.IOException, HttpException,
SoapException {
-
- URL resource = Thread.currentThread().getContextClassLoader().
- getResource("META-INF/contract.scl");
-
- URN firstUrn = new URN(resource.toString());
-
- SoapBinding binding = new DefaultMetaBinding();
-
- XmlObjectReader xmlObjectReader = new XmlObjectReader(new
-
- java.io.InputStreamReader(resource.openStream()), firstUrn, binding);
-
- xmlObjectReader.readObject();
-
- TestService service = new TestService();
-
- SoapTie serviceInterceptor = new SoapTie(server, service, binding);
-
- java.net.URL proxyUrl = new
java.net.URL("http://localhost:"+currentPort+"/");
-
- java.net.URL targetUrl = new java.net.URL(proxyUrl,
serviceInterceptor.getHandle());
-
- SoapInvocationHandler testProxy = new SoapInvocationHandler(server,
proxyUrl, targetUrl, binding);
-
- TestInterface remoteProxy = (TestInterface)java.lang.reflect.Proxy.
- newProxyInstance(Thread.currentThread().getContextClassLoader(),
- new Class[] { TestInterface.class }, testProxy);
-
- TestObject2 testObject = new TestObject2();
- TestObject3 testObject2 = new TestObject3();
-
- testObject.setTestInherited(true);
-
- testObject.setTestBoolean(true);
-
- testObject.setTestPublic(true);
-
- testObject.setTestProtected(true);
-
- testObject.setTestPrivate(true);
-
- testObject.setTestStatic(true);
-
- testObject.setTestTransient(true);
-
- testObject.setTestByte((byte)42);
-
- testObject.setTestInteger(42);
-
- testObject.setTestShort((short)42);
-
- testObject.setTestCharacter('z');
-
- testObject.setTestLong((long)42);
-
- testObject.setTestFloat((float)42.0);
-
- testObject.setTestDouble((double)42.0);
-
- testObject.setTestString("42");
-
- testObject.setTestReference(testObject2);
-
- testObject.setTestArray(new TestObject3[] { testObject2 });
-
- testObject.setTestCollection(new java.util.Vector());
-
- testObject.getTestCollection().add(testObject2);
-
- testObject.setTestExtension(true);
-
- testObject2.setTestReturn(testObject);
-
- TestObject2 testObject3 =
(TestObject2)remoteProxy.testObject(testObject);
-
- assert("Asserting inherited attribute", testObject3.getTestInherited()
!=
- testObject.getTestInherited());
-
- assert("Asserting private attribute", testObject3.isTestPrivate() ==
- testObject.isTestPrivate());
-
- assert("Asserting protected attribute", testObject3.isTestProtected()
==
- testObject.isTestProtected());
-
- assert("Asserting public attribute", testObject3.isTestPublic() ==
- testObject.isTestPublic());
-
- assert("Asserting static attribute", testObject3.isTestStatic() ==
- testObject.isTestStatic());
-
- assert("Asserting transient attribute", testObject3.isTestTransient()
!=
- testObject.isTestTransient());
-
- assert("Asserting boolean attribute", testObject3.isTestBoolean() ==
- testObject.isTestBoolean());
-
- assert("Asserting byte attribute", testObject3.getTestByte() ==
- testObject.getTestByte());
-
- assert("Asserting char attribute", testObject3.getTestCharacter() ==
- testObject.getTestCharacter());
-
- assert("Asserting integer attribute", testObject3.getTestInteger() ==
- testObject.getTestInteger());
-
- assert("Asserting short attribute", testObject3.getTestShort() ==
- testObject.getTestShort());
-
- assert("Asserting long attribute", testObject3.getTestLong() ==
- testObject.getTestLong());
-
- assert("Asserting float attribute", testObject3.getTestFloat() ==
- testObject.getTestFloat());
-
- assert("Asserting double attribute", testObject3.getTestDouble() ==
- testObject.getTestDouble());
-
- assert("Asserting string attribute", testObject.getTestString().
- equals(testObject3.getTestString()));
-
- assert("Asserting reference attribute", testObject3.getTestReference().
- getTestReturn() == testObject3);
-
- assert("Asserting array element", testObject3.getTestArray() != null &&
- testObject3.getTestArray().length == 1 && testObject3.getTestArray()
[0] ==
- testObject3.getTestReference());
-
- assert("Asserting collection element", testObject3.getTestCollection()
!= null &&
- testObject3.getTestCollection().size() == 1 &&
testObject3.getTestCollection().get(0) ==
- testObject3.getTestReference());
-
- assert("Asserting extension attribute", testObject3.isTestExtension()
==
- testObject.isTestExtension());
-
- } // testSoapHttpServer
-
- public void tearDown() {
-
- server.stop();
-
- /*try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }*/
-
-
- }
-
-} // Soap
-
-/**
- * $Log: Soap.java,v $
- * Revision 1.3 2000/09/04 16:43:45 jung
- * GPL header
+/*
+ * $Id: Soap.java,v 1.4 2000/12/04 12:36:19 jung Exp $
+ * Copyright (c) 2000 infor:business solutions AG, Hauerstrasse 12,
+ * D-66299 Friedrichsthal, Germany. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
*
- * Revision 1.2 2000/09/04 13:02:13 jung
- * each test run now creates its http-server on a fresh port
- * such that the address_in_use errors under linux disappear.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * Revision 1.1.1.1 2000/08/10 21:07:24 jung
- * Initial import.
- */
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package org.zoap.soap.test;
+
+import org.zoap.soap.HttpServer;
+import org.zoap.soap.HttpRequest;
+import org.zoap.soap.HttpResponse;
+import org.zoap.soap.Envelope;
+import org.zoap.soap.SoapException;
+import org.zoap.soap.SoapTie;
+import org.zoap.soap.SoapInvocationHandler;
+import org.zoap.soap.SoapStringInvocationHandler;
+
+import org.zoap.soap.meta.RequestElement;
+import org.zoap.soap.meta.ResponseElement;
+import org.zoap.soap.meta.ReturnElement;
+import org.zoap.soap.meta.ArgumentElement;
+import org.zoap.soap.meta.RequestType;
+import org.zoap.soap.meta.ResponseType;
+import org.zoap.soap.meta.SoapBinding;
+
+import org.zoap.soap.meta.builtin.DefaultBinding;
+import org.zoap.soap.meta.builtin.DefaultMetaBinding;
+
+import org.zoap.xml.XmlObjectReader;
+import org.zoap.xml.XmlObjectWriter;
+import org.zoap.xml.URNResolver;
+import org.zoap.xml.Schema;
+import org.zoap.xml.XmlException;
+import org.zoap.xml.Element;
+import org.zoap.xml.Attribute;
+import org.zoap.xml.Type;
+
+import org.zoap.xml.meta.BooleanType;
+import org.zoap.xml.meta.StringType;
+import org.zoap.xml.meta.builtin.ClassType;
+import org.zoap.xml.meta.builtin.NameAttribute;
+import org.zoap.xml.meta.builtin.RefAttribute;
+import org.zoap.xml.meta.builtin.FieldAttribute;
+import org.zoap.xml.meta.builtin.FieldElement;
+
+import java.util.Date;
+
+import java.util.Collection;
+
+import java.net.URL;
+
+import de.infor.ce.http.HttpException;
+
+import de.infor.ce.util.URN;
+
+import java.math.BigDecimal;
+
+import de.infor.businessobjects.test.TestObject;
+import de.infor.businessobjects.test.TestObject1;
+import de.infor.businessobjects.test.TestObject2;
+import de.infor.businessobjects.test.TestObject3;
+
+import de.infor.businessservices.test.TestSuperInterface;
+import de.infor.businessservices.test.TestInterface;
+import de.infor.businessservices.test.TestException;
+
+import de.infor.businessservices.implementations.test.TestService;
+
+/**
+ * A unit test for checking low-level features of the soap service
+ * @see <related>
+ * @author $Author: jung $
+ * @version $Revision: 1.4 $
+ */
+
+public class Soap extends junit.framework.TestCase {
+
+
+ public Soap(String name) {
+ super(name);
+ }
+
+ public static void main(String[] args) {
+
+ junit.textui.TestRunner runner = new junit.textui.TestRunner();
+
+ try {
+ runner.run(suite());
+ } catch (Exception e) {
+ }
+ }
+
+ public static junit.framework.Test suite() {
+
+ return new junit.framework.TestSuite(Soap.class);
+
+ }
+
+ HttpServer server;
+ static int currentPort=3000;
+
+ public void setUp() {
+
+ try {
+ server = new HttpServer(++currentPort);
+ server.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public void testSoapHttpServer() throws java.io.IOException, HttpException,
SoapException {
+
+ java.net.URL proxyUrl = new
java.net.URL("http://localhost:"+currentPort+"/");
+
+ java.net.URL targetUrl = new java.net.URL(proxyUrl, "");
+
+ HttpRequest request = new HttpRequest(proxyUrl, targetUrl);
+
+ request.putHeader("SOAPAction","test");
+
+ request.setEnvelope(new Envelope(null, null));
+
+ HttpResponse response = (HttpResponse)request.send();
+
+ response = (HttpResponse)request.send();
+
+ response = (HttpResponse)request.send();
+
+ } // testSoapHttpServer
+
+ public void testSoapProxyString() throws java.io.IOException, HttpException,
SoapException {
+
+ TestService service = new TestService();
+
+ SoapTie serviceInterceptor = new SoapTie(server, service);
+
+ java.net.URL proxyUrl = new
java.net.URL("http://localhost:"+currentPort+"/");
+
+ java.net.URL targetUrl = new java.net.URL(proxyUrl,
serviceInterceptor.getHandle());
+
+ SoapInvocationHandler testProxy = new SoapInvocationHandler(server,
proxyUrl, targetUrl);
+
+ TestInterface remoteProxy = (TestInterface)java.lang.reflect.Proxy.
+ newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[] { TestInterface.class }, testProxy);
+
+ assert("Asserting String call",
"42���</>\'&\"".equals(remoteProxy.testString("42���</>\'&\"")));
+
+ } // testSoapProxyString
+
+
+ public void testSoapProxyNullString() throws java.io.IOException,
HttpException, SoapException {
+
+ TestService service = new TestService();
+
+ SoapTie serviceInterceptor = new SoapTie(server, service);
+
+ java.net.URL proxyUrl = new
java.net.URL("http://localhost:"+currentPort+"/");
+
+ java.net.URL targetUrl = new java.net.URL(proxyUrl,
serviceInterceptor.getHandle());
+
+ SoapInvocationHandler testProxy = new SoapInvocationHandler(server,
proxyUrl, targetUrl);
+
+ TestInterface remoteProxy = (TestInterface)java.lang.reflect.Proxy.
+ newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[] { TestInterface.class }, testProxy);
+
+ assertNull("Asserting String call", remoteProxy.testString(null));
+
+ } // testSoapProxyString
+
+ public void testSoapProxyNormal() throws java.io.IOException, HttpException,
SoapException {
+
+ TestService service = new TestService();
+
+ SoapTie serviceInterceptor = new SoapTie(server, service, new
DefaultBinding());
+
+ java.net.URL proxyUrl = new
java.net.URL("http://localhost:"+currentPort+"/");
+
+ java.net.URL targetUrl = new java.net.URL(proxyUrl,
serviceInterceptor.getHandle());
+
+ SoapInvocationHandler testProxy = new SoapInvocationHandler(server,
proxyUrl,
+ targetUrl, new DefaultBinding());
+
+ TestInterface remoteProxy = (TestInterface)java.lang.reflect.Proxy.
+ newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[] { TestInterface.class }, testProxy);
+
+ TestObject2 testObject = new TestObject2();
+ TestObject3 testObject2 = new TestObject3();
+
+ testObject.setTestInherited(true);
+
+ testObject.setTestBoolean(true);
+
+ testObject.setTestPublic(true);
+
+ testObject.setTestProtected(true);
+
+ testObject.setTestPrivate(true);
+
+ testObject.setTestStatic(true);
+
+ testObject.setTestDecimal(new BigDecimal("42.0"));
+
+ testObject.setTestDate(new Date((long) 42));
+
+ testObject.setTestTransient(true);
+
+ testObject.setTestByte((byte)42);
+
+ testObject.setTestInteger(42);
+
+ testObject.setTestShort((short)42);
+
+ testObject.setTestCharacter('z');
+
+ testObject.setTestLong((long)42);
+
+ testObject.setTestFloat((float)42.0);
+
+ testObject.setTestDouble((double)42.0);
+
+ testObject.setTestString("42���</>\'&\"");
+
+ testObject.setTestReference(testObject2);
+
+ testObject.setTestArray(new TestObject3[] { testObject2 });
+
+ testObject.setTestCollection(new java.util.Vector());
+
+ testObject.getTestCollection().add(testObject2);
+
+ testObject.setTestExtension(true);
+
+ testObject2.setTestReturn(testObject);
+
+ TestObject2 testObject3 =
(TestObject2)remoteProxy.testObject(testObject);
+
+ assert("Asserting inherited attribute", testObject3.getTestInherited()
!=
+ testObject.getTestInherited());
+
+ assert("Asserting private attribute", testObject3.isTestPrivate() ==
+ testObject.isTestPrivate());
+
+ assert("Asserting protected attribute", testObject3.isTestProtected()
==
+ testObject.isTestProtected());
+
+ assert("Asserting public attribute", testObject3.isTestPublic() ==
+ testObject.isTestPublic());
+
+ assert("Asserting static attribute", testObject3.isTestStatic() ==
+ testObject.isTestStatic());
+
+ assert("Asserting transient attribute", testObject3.isTestTransient()
!=
+ testObject.isTestTransient());
+
+ assert("Asserting boolean attribute", testObject3.isTestBoolean() ==
+ testObject.isTestBoolean());
+
+ assert("Asserting byte attribute", testObject3.getTestByte() ==
+ testObject.getTestByte());
+
+ assert("Asserting char attribute", testObject3.getTestCharacter() ==
+ testObject.getTestCharacter());
+
+ assert("Asserting integer attribute", testObject3.getTestInteger() ==
+ testObject.getTestInteger());
+
+ assert("Asserting short attribute", testObject3.getTestShort() ==
+ testObject.getTestShort());
+
+ assert("Asserting long attribute", testObject3.getTestLong() ==
+ testObject.getTestLong());
+
+ assert("Asserting float attribute", testObject3.getTestFloat() ==
+ testObject.getTestFloat());
+
+ assert("Asserting double attribute", testObject3.getTestDouble() ==
+ testObject.getTestDouble());
+
+ assert("Asserting string attribute", testObject.getTestString().
+ equals(testObject3.getTestString()));
+
+ assert("Asserting decimal attribute", testObject.getTestDecimal().
+ equals(testObject3.getTestDecimal()));
+
+ assert("Asserting date attribute", testObject.getTestDate().
+ equals(testObject3.getTestDate()));
+
+ assert("Asserting reference attribute", testObject3.getTestReference().
+ getTestReturn() == testObject3);
+
+ assert("Asserting array element", testObject3.getTestArray() != null &&
+ testObject3.getTestArray().length == 1 && testObject3.getTestArray()
[0] ==
+ testObject3.getTestReference());
+
+ assert("Asserting collection element", testObject3.getTestCollection()
!= null &&
+ testObject3.getTestCollection().size() == 1 &&
testObject3.getTestCollection().get(0) ==
+ testObject3.getTestReference());
+
+ assert("Asserting extension attribute", testObject3.isTestExtension()
==
+ testObject.isTestExtension());
+
+ } // testSoapHttpServer
+
+
+ public void testSoapProxyException() throws java.io.IOException,
+ HttpException, SoapException {
+
+ TestService service = new TestService();
+
+ SoapTie serviceInterceptor = new SoapTie(server, service, new
DefaultBinding());
+
+ java.net.URL proxyUrl = new
java.net.URL("http://localhost:"+currentPort+"/");
+
+ java.net.URL targetUrl = new java.net.URL(proxyUrl,
serviceInterceptor.getHandle());
+
+ SoapInvocationHandler testProxy = new SoapInvocationHandler(server,
proxyUrl, targetUrl,
+ new DefaultBinding());
+
+ TestInterface remoteProxy = (TestInterface)java.lang.reflect.Proxy.
+ newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[] { TestInterface.class }, testProxy);
+
+ try {
+ remoteProxy.testException();
+ fail("Testing unsuccessful remote call did not produce any
exception");
+ } catch (TestException e) {
+ }
+
+
+ } // testSoapHttpServer
+
+ public void testSoapStringProxy() throws java.io.IOException, HttpException,
SoapException, Throwable {
+
+ TestService service = new TestService();
+
+ SoapTie serviceInterceptor = new SoapTie(server, service, new
DefaultBinding());
+
+ java.net.URL proxyUrl = new
java.net.URL("http://localhost:"+currentPort+"/");
+
+ java.net.URL targetUrl = new java.net.URL(proxyUrl,
serviceInterceptor.getHandle());
+
+ SoapStringInvocationHandler testProxy =
+ new SoapStringInvocationHandler(TestInterface.class, server,
+ proxyUrl, targetUrl, new
org.zoap.soap.meta.builtin.string.DefaultBinding());
+
+ testProxy.invoke("testString", new Class[] { String.class },
+ new String[] {
+ "<arbitraryTag>42���</>'&"</arbitraryTag>"
+ });
+
+ } // testSoapProxyString
+
+ public void testSeperateTags() {
+
+ String[] seperate =
org.zoap.soap.Environment.seperateTags("blablablabl hhhhssgdghf <testTag>" +
+ "<sickContent> jjjjdddhhhs <testTag> moreSickContent </testTag>
jhjhjfhfkjsfh </sickContent> </testTag>" +
+ "intermediateshhit" +
+ "<secondTestTag blablablabla> jjjddssds </secondTestTag shishishit>
kickickicki");
+
+ assert("Testing seperation of tags", seperate != null &&
seperate.length == 2);
+
+ assert("Testing first result tag", ("<testTag><sickContent>
jjjjdddhhhs <testTag>" +
+ " moreSickContent </testTag> jhjhjfhfkjsfh </sickContent>
</testTag>").equals(seperate[0]));
+
+ assert("Testing second result tag", "<secondTestTag blablablabla>
jjjddssds </secondTestTag shishishit>".
+ equals(seperate[1]));
+
+ }
+
+ public void testMeta() throws XmlException, java.io.IOException,
NoSuchMethodException {
+
+ URL resource = Thread.currentThread().getContextClassLoader().
+ getResource("META-INF/contract.scl");
+
+ URN firstUrn = new URN(resource.toString());
+
+ XmlObjectReader xmlObjectReader = new XmlObjectReader(new
+ java.io.InputStreamReader(resource.openStream()), firstUrn, new
DefaultMetaBinding());
+
+ Schema testSchema = (Schema)xmlObjectReader.readObject();
+
+ testSchema = xmlObjectReader.getBinding().
+ getSchema(new
URN("http://schemas.infor.de/businessservices/test/TestInterface"));
+
+ Schema superSchema = (Schema)xmlObjectReader.getBinding().
+ getSchema(new
URN("http://schemas.infor.de/businessservices/test/TestSuperInterface"));
+
+ assert("Testing side effect 2", superSchema != null);
+
+ /* test testBoolean request */
+
+ Element firstElement = superSchema.getElement("testBoolean-0-Request");
+
+ assert("Testing first method request", firstElement instanceof
RequestElement);
+
+ assert("Testing first method request name",
+ "testBoolean-0-Request".equals(firstElement.getAppearanceName()));
+
+ assert("Testing first method request schema",
+ superSchema.equals(firstElement.getAppearanceSchema()));
+
+ Type firstElementType = firstElement.getType();
+
+ assert("Testing first method request type", firstElementType
instanceof RequestType);
+
+ assert("Testing first method request type name",
"testBoolean-0-RequestMessage".
+ equals(firstElementType.getTypeName()));
+
+ assert("Testing first method request type schema", superSchema.
+ equals(firstElementType.getTypeSchema()));
+
+ assert("Testing first method request type associated method",
+
de.infor.businessservices.test.TestSuperInterface.class.getMethod("testBoolean", new
Class[0]).
+ equals(((RequestType)firstElementType).getAssociatedMethod()));
+
+ Element[] subElements = firstElementType.getElements(null);
+ Attribute[] subAttributes = firstElementType.getAttributes(null);
+
+ assert("Testing first method request type elements", subElements ==
null || subElements.length == 0);
+ assert("Testing first method request type attributes", subAttributes
== null || subAttributes.length == 0);
+
+ /* test testBoolean response */
+
+ Element secondElement =
superSchema.getElement("testBoolean-0-Response");
+
+ assert("Testing first method response", secondElement instanceof
ResponseElement);
+
+ assert("Testing first method response name",
+ "testBoolean-0-Response".equals(secondElement.getAppearanceName()));
+
+ assert("Testing first method response schema",
+ superSchema.equals(secondElement.getAppearanceSchema()));
+
+ Type secondElementType = secondElement.getType();
+
+ assert("Testing first method response type", secondElementType
instanceof ResponseType);
+
+ assert("Testing first method response type name",
"testBoolean-0-ResponseMessage".
+ equals(secondElementType.getTypeName()));
+
+ assert("Testing first method reponse type schema", superSchema.
+ equals(secondElementType.getTypeSchema()));
+
+ assert("Testing first method request type associated method",
+
de.infor.businessservices.test.TestSuperInterface.class.getMethod("testBoolean", new
Class[0]).
+ equals(((ResponseType)secondElementType).getAssociatedMethod()));
+
+ subElements = secondElementType.getElements(null);
+ subAttributes = secondElementType.getAttributes(null);
+
+ assert("Testing first method response type elements", subElements !=
null || subElements.length == 1);
+ assert("Testing first method response type attributes", subAttributes
== null || subAttributes.length == 0);
+
+ Element secondElementTypeFirstElement =
secondElementType.getElement(superSchema, "testBoolean-0-Return");
+
+ assert("Testing first method response type first element",
+ secondElementTypeFirstElement instanceof ReturnElement);
+
+ assert("Testing first method response type first element name",
"testBoolean-0-Return".equals(
+ secondElementTypeFirstElement.getAppearanceName()));
+
+ assert("Testing first method response type first element schema",
superSchema.equals(
+ secondElementTypeFirstElement.getAppearanceSchema()));
+
+ assert("Testing first method response type first element type",
BooleanType.getBooleanType().equals(
+ secondElementTypeFirstElement.getType()));
+
+ /* test testString request */
+
+ Element thirdElement = testSchema.getElement("testString-0-Request");
+
+ assert("Testing second method request", thirdElement instanceof
RequestElement);
+
+ assert("Testing second method request name",
+ "testString-0-Request".equals(thirdElement.getAppearanceName()));
+
+ assert("Testing second method request schema",
+ testSchema.equals(thirdElement.getAppearanceSchema()));
+
+ Type thirdElementType = thirdElement.getType();
+
+ assert("Testing second method request type", thirdElementType
instanceof RequestType);
+
+ assert("Testing second method request type name",
"testString-0-RequestMessage".
+ equals(thirdElementType.getTypeName()));
+
+ assert("Testing second method request type schema", testSchema.
+ equals(thirdElementType.getTypeSchema()));
+
+ assert("Testing second method request type associated method",
+
de.infor.businessservices.test.TestInterface.class.getMethod("testString", new Class[]
{ String.class }).
+ equals(((RequestType)thirdElementType).getAssociatedMethod()));
+
+ subElements = thirdElementType.getElements(null);
+ subAttributes = thirdElementType.getAttributes(null);
+
+ assert("Testing second method request type elements", subElements !=
null || subElements.length == 1);
+ assert("Testing second method request type attributes", subAttributes
== null || subAttributes.length == 0);
+
+ Element thirdElementTypeFirstElement = thirdElementType.
+ getElement(testSchema, "testString-0-in");
+
+ assert("Testing second method request type first element",
+ thirdElementTypeFirstElement instanceof ArgumentElement);
+
+ assert("Testing second method request type first element name",
"testString-0-in".equals(
+ thirdElementTypeFirstElement.getAppearanceName()));
+
+ assert("Testing second method request type first element schema",
testSchema.equals(
+ thirdElementTypeFirstElement.getAppearanceSchema()));
+
+ assert("Testing second method request type first element type",
StringType.getStringType().equals(
+ thirdElementTypeFirstElement.getType()));
+
+ assert("Testing second method request type first element type arity",
((ArgumentElement)
+ thirdElementTypeFirstElement).getArity() == 0);
+
+ /* test testString response */
+
+ Element fourthElement = testSchema.getElement("testString-0-Response");
+
+ assert("Testing second method response", fourthElement instanceof
ResponseElement);
+
+ assert("Testing second method response name",
+ "testString-0-Response".equals(fourthElement.getAppearanceName()));
+
+ assert("Testing second method response schema",
+ testSchema.equals(fourthElement.getAppearanceSchema()));
+
+ Type fourthElementType = fourthElement.getType();
+
+ assert("Testing second method response type", fourthElementType
instanceof ResponseType);
+
+ assert("Testing second method response type name",
"testString-0-ResponseMessage".
+ equals(fourthElementType.getTypeName()));
+
+ assert("Testing second method response type schema", testSchema.
+ equals(fourthElementType.getTypeSchema()));
+
+ assert("Testing second method response type associated method",
+
de.infor.businessservices.test.TestInterface.class.getMethod("testString", new Class[]
{ String.class }).
+ equals(((ResponseType)fourthElementType).getAssociatedMethod()));
+
+ subElements = fourthElementType.getElements(null);
+ subAttributes = fourthElementType.getAttributes(null);
+
+ assert("Testing second method response type elements", subElements !=
null || subElements.length == 1);
+ assert("Testing second method response type attributes", subAttributes
== null || subAttributes.length == 0);
+
+ Element fourthElementTypeFirstElement = fourthElementType.
+ getElement(testSchema, "testString-0-Return");
+
+ assert("Testing second method response type first element",
+ fourthElementTypeFirstElement instanceof ReturnElement);
+
+ assert("Testing second method response type first element name",
"testString-0-Return".equals(
+ fourthElementTypeFirstElement.getAppearanceName()));
+
+ assert("Testing second method response type first element schema",
testSchema.equals(
+ fourthElementTypeFirstElement.getAppearanceSchema()));
+
+ assert("Testing second method response type first element type",
StringType.getStringType().equals(
+ fourthElementTypeFirstElement.getType()));
+
+ /* test testObject request */
+
+ Element fifthElement = testSchema.getElement("testObject-0-Request");
+
+ assert("Testing third method request", fifthElement instanceof
RequestElement);
+
+ assert("Testing third method request name",
+ "testObject-0-Request".equals(fifthElement.getAppearanceName()));
+
+ assert("Testing third method request schema",
+ testSchema.equals(fifthElement.getAppearanceSchema()));
+
+ Type fifthElementType = fifthElement.getType();
+
+ assert("Testing third method request type", fifthElementType
instanceof RequestType);
+
+ assert("Testing third method request type name",
"testObject-0-RequestMessage".
+ equals(fifthElementType.getTypeName()));
+
+ assert("Testing third method request type schema", testSchema.
+ equals(fifthElementType.getTypeSchema()));
+
+ assert("Testing third method request type associated method",
+
de.infor.businessservices.test.TestInterface.class.getMethod("testObject", new Class[]
{
+ de.infor.businessobjects.test.TestObject1.class
+ }).
+ equals(((RequestType)fifthElementType).getAssociatedMethod()));
+
+ subElements = fifthElementType.getElements(null);
+ subAttributes = fifthElementType.getAttributes(null);
+
+ assert("Testing third method request type elements", subElements !=
null || subElements.length == 1);
+ assert("Testing third method request type attributes", subAttributes
== null || subAttributes.length == 0);
+
+ Element fifthElementTypeFirstElement = fifthElementType.
+ getElement(testSchema, "testObject-0-in");
+
+ assert("Testing third method request type first element",
+ fifthElementTypeFirstElement instanceof ArgumentElement);
+
+ assert("Testing third method request type first element name",
"testObject-0-in".equals(
+ fifthElementTypeFirstElement.getAppearanceName()));
+
+ assert("Testing third method request type first element schema",
testSchema.equals(
+ fifthElementTypeFirstElement.getAppearanceSchema()));
+
+ Type fifthElementTypeFirstElementType =
fifthElementTypeFirstElement.getType();
+
+ Schema fifthElementTypeFirstElementTypeSchema =
fifthElementTypeFirstElementType.getTypeSchema();
+
+ assert("Testing third method request type first element type",
fifthElementTypeFirstElementType instanceof ClassType &&
+
"TestObject1Type".equals(fifthElementTypeFirstElementType.getTypeName()) &&
+ fifthElementTypeFirstElementTypeSchema.
+ equals(xmlObjectReader.getBinding().
+ getSchema(new
URN("http://schemas.infor.de/businessobjects/test/TestObject1"))));
+
+
+ /* back with normal stuff */
+
+ assert("Testing third method request type first element type",
de.infor.businessobjects.test.TestObject1.class.
+
equals(((ClassType)fifthElementTypeFirstElementType).getAssociatedClass()));
+
+ assert("Testing third method request type first element type arity",
((ArgumentElement)
+ fifthElementTypeFirstElement).getArity() == 0);
+
+ /* test testObject response */
+
+ Element sixthElement = testSchema.getElement("testObject-0-Response");
+
+ assert("Testing third method response", sixthElement instanceof
ResponseElement);
+
+ assert("Testing third method response name",
+ "testObject-0-Response".equals(sixthElement.getAppearanceName()));
+
+ assert("Testing third method response schema",
+ testSchema.equals(sixthElement.getAppearanceSchema()));
+
+ Type sixthElementType = sixthElement.getType();
+
+ assert("Testing third method response type", sixthElementType
instanceof ResponseType);
+
+ assert("Testing third method response type name",
"testObject-0-ResponseMessage".
+ equals(sixthElementType.getTypeName()));
+
+ assert("Testing third method response type schema", testSchema.
+ equals(sixthElementType.getTypeSchema()));
+
+ assert("Testing third method response type associated method",
+
de.infor.businessservices.test.TestInterface.class.getMethod("testObject",
+ new Class[] { de.infor.businessobjects.test.TestObject1.class
}).equals(((ResponseType)
+ sixthElementType).getAssociatedMethod()));
+
+ subElements = sixthElementType.getElements(null);
+ subAttributes = sixthElementType.getAttributes(null);
+
+ assert("Testing third method response type elements", subElements !=
null || subElements.length == 1);
+ assert("Testing third method response type attributes", subAttributes
== null || subAttributes.length == 0);
+
+ Element sixthElementTypeFirstElement = sixthElementType.
+ getElement(testSchema, "testObject-0-Return");
+
+ assert("Testing third method response type first element",
+ sixthElementTypeFirstElement instanceof ReturnElement);
+
+ assert("Testing third method response type first element name",
"testObject-0-Return".equals(
+ sixthElementTypeFirstElement.getAppearanceName()));
+
+ assert("Testing third method response type first element schema",
testSchema.equals(
+ sixthElementTypeFirstElement.getAppearanceSchema()));
+
+ Type sixthElementTypeFirstElementType =
sixthElementTypeFirstElement.getType();
+
+ assert("Testing third method response type first element type",
sixthElementTypeFirstElementType
+ instanceof ClassType);
+
+ assert("Testing third method response type first element type
equality", fifthElementTypeFirstElementType.
+ equals(sixthElementTypeFirstElementType));
+
+ /* test testString request */
+
+ Element seventhElement =
testSchema.getElement("testException-0-Request");
+
+ assert("Testing fourth method request", seventhElement instanceof
RequestElement);
+
+ assert("Testing fourth method request name",
+ "testException-0-Request".equals(seventhElement.getAppearanceName()));
+
+ assert("Testing fourth method request schema",
+ testSchema.equals(seventhElement.getAppearanceSchema()));
+
+ Type seventhElementType = seventhElement.getType();
+
+ assert("Testing fourth method request type", seventhElementType
instanceof RequestType);
+
+ assert("Testing fourth method request type name",
"testException-0-RequestMessage".
+ equals(seventhElementType.getTypeName()));
+
+ assert("Testing fourth method request type schema", testSchema.
+ equals(seventhElementType.getTypeSchema()));
+
+ assert("Testing fourth method request type associated method",
+
de.infor.businessservices.test.TestInterface.class.getMethod("testException", new
Class[0]).
+ equals(((RequestType)seventhElementType).getAssociatedMethod()));
+
+ subElements = seventhElementType.getElements(null);
+ subAttributes = seventhElementType.getAttributes(null);
+
+ assert("Testing fourth method request type elements", subElements ==
null || subElements.length == 0);
+ assert("Testing fourth method request type attributes", subAttributes
== null || subAttributes.length == 0);
+
+ /* test testString response */
+
+ Element eightsElement =
testSchema.getElement("testException-0-Response");
+
+ assert("Testing fourth method response", eightsElement instanceof
ResponseElement);
+
+ assert("Testing fourth method response name",
+ "testException-0-Response".equals(eightsElement.getAppearanceName()));
+
+ assert("Testing fourth method response schema",
+ testSchema.equals(eightsElement.getAppearanceSchema()));
+
+ Type eightsElementType = eightsElement.getType();
+
+ assert("Testing fourth method response type", eightsElementType
instanceof ResponseType);
+
+ assert("Testing fourth method response type name",
"testException-0-ResponseMessage".
+ equals(eightsElementType.getTypeName()));
+
+ assert("Testing fourth method response type schema", testSchema.
+ equals(eightsElementType.getTypeSchema()));
+
+ assert("Testing fourth method response type associated method",
+
de.infor.businessservices.test.TestInterface.class.getMethod("testException", new
Class[0]).
+ equals(((ResponseType)eightsElementType).getAssociatedMethod()));
+
+ subElements = eightsElementType.getElements(null);
+ subAttributes = eightsElementType.getAttributes(null);
+
+ assert("Testing fourth method response type elements", subElements ==
null || subElements.length == 0);
+ assert("Testing fourth method response type attributes", subAttributes
== null || subAttributes.length == 0);
+
+ }
+
+ public void testMetaProxy() throws java.io.IOException, HttpException,
SoapException {
+
+ URL resource = Thread.currentThread().getContextClassLoader().
+ getResource("META-INF/contract.scl");
+
+ URN firstUrn = new URN(resource.toString());
+
+ SoapBinding binding = new DefaultMetaBinding();
+
+ XmlObjectReader xmlObjectReader = new XmlObjectReader(new
+
+ java.io.InputStreamReader(resource.openStream()), firstUrn, binding);
+
+ xmlObjectReader.readObject();
+
+ TestService service = new TestService();
+
+ SoapTie serviceInterceptor = new SoapTie(server, service, binding);
+
+ java.net.URL proxyUrl = new
java.net.URL("http://localhost:"+currentPort+"/");
+
+ java.net.URL targetUrl = new java.net.URL(proxyUrl,
serviceInterceptor.getHandle());
+
+ SoapInvocationHandler testProxy = new SoapInvocationHandler(server,
proxyUrl, targetUrl, binding);
+
+ TestInterface remoteProxy = (TestInterface)java.lang.reflect.Proxy.
+ newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[] { TestInterface.class }, testProxy);
+
+ TestObject2 testObject = new TestObject2();
+ TestObject3 testObject2 = new TestObject3();
+
+ testObject.setTestInherited(true);
+
+ testObject.setTestBoolean(true);
+
+ testObject.setTestDecimal(new BigDecimal("42.0"));
+
+ testObject.setTestDate(new Date((long) 42));
+
+ testObject.setTestPublic(true);
+
+ testObject.setTestProtected(true);
+
+ testObject.setTestPrivate(true);
+
+ testObject.setTestStatic(true);
+
+ testObject.setTestTransient(true);
+
+ testObject.setTestByte((byte)42);
+
+ testObject.setTestInteger(42);
+
+ testObject.setTestShort((short)42);
+
+ testObject.setTestCharacter('z');
+
+ testObject.setTestLong((long)42);
+
+ testObject.setTestFloat((float)42.0);
+
+ testObject.setTestDouble((double)42.0);
+
+ testObject.setTestString("42���</>\'&\"");
+
+ testObject.setTestReference(testObject2);
+
+ testObject.setTestArray(new TestObject3[] { testObject2 });
+
+ testObject.setTestCollection(new java.util.Vector());
+
+ testObject.getTestCollection().add(testObject2);
+
+ testObject.setTestExtension(true);
+
+ testObject2.setTestReturn(testObject);
+
+ TestObject2 testObject3 =
(TestObject2)remoteProxy.testObject(testObject);
+
+ assert("Asserting inherited attribute", testObject3.getTestInherited()
!=
+ testObject.getTestInherited());
+
+ assert("Asserting private attribute", testObject3.isTestPrivate() ==
+ testObject.isTestPrivate());
+
+ assert("Asserting protected attribute", testObject3.isTestProtected()
==
+ testObject.isTestProtected());
+
+ assert("Asserting public attribute", testObject3.isTestPublic() ==
+ testObject.isTestPublic());
+
+ assert("Asserting static attribute", testObject3.isTestStatic() ==
+ testObject.isTestStatic());
+
+ assert("Asserting transient attribute", testObject3.isTestTransient()
!=
+ testObject.isTestTransient());
+
+ assert("Asserting boolean attribute", testObject3.isTestBoolean() ==
+ testObject.isTestBoolean());
+
+ assert("Asserting byte attribute", testObject3.getTestByte() ==
+ testObject.getTestByte());
+
+ assert("Asserting decimal attribute",
testObject3.getTestDecimal().equals(
+ testObject.getTestDecimal()));
+
+ assert("Asserting date attribute", testObject3.getTestDate().equals(
+ testObject.getTestDate()));
+
+ assert("Asserting char attribute", testObject3.getTestCharacter() ==
+ testObject.getTestCharacter());
+
+ assert("Asserting integer attribute", testObject3.getTestInteger() ==
+ testObject.getTestInteger());
+
+ assert("Asserting short attribute", testObject3.getTestShort() ==
+ testObject.getTestShort());
+
+ assert("Asserting long attribute", testObject3.getTestLong() ==
+ testObject.getTestLong());
+
+ assert("Asserting float attribute", testObject3.getTestFloat() ==
+ testObject.getTestFloat());
+
+ assert("Asserting double attribute", testObject3.getTestDouble() ==
+ testObject.getTestDouble());
+
+ assert("Asserting string attribute", testObject.getTestString().
+ equals(testObject3.getTestString()));
+
+ assert("Asserting reference attribute", testObject3.getTestReference().
+ getTestReturn() == testObject3);
+
+ assert("Asserting array element", testObject3.getTestArray() != null &&
+ testObject3.getTestArray().length == 1 && testObject3.getTestArray()
[0] ==
+ testObject3.getTestReference());
+
+ assert("Asserting collection element", testObject3.getTestCollection()
!= null &&
+ testObject3.getTestCollection().size() == 1 &&
testObject3.getTestCollection().get(0) ==
+ testObject3.getTestReference());
+
+ assert("Asserting extension attribute", testObject3.isTestExtension()
==
+ testObject.isTestExtension());
+
+ } // testSoapHttpServer
+
+ public void tearDown() {
+
+ server.stop();
+
+ /*try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }*/
+
+
+ }
+
+} // Soap
+
1.2 +27 -27 zoap/src/org/zoap/soap/test/test.dfPackage
Index: test.dfPackage
===================================================================
RCS file: /products/cvs/ejboss/zoap/src/org/zoap/soap/test/test.dfPackage,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- test.dfPackage 2000/08/10 21:07:24 1.1
+++ test.dfPackage 2000/12/04 12:36:19 1.2
@@ -1,27 +1,27 @@
-package id1k6kqc9pgodo2c9pqksrr;
-
-/**
-@version 2.0
-@physicalPackage
-@__modelType diagram
-*/
-class diagram {
-/**
-@__ref <oiref:java#Class#org.zoap.soap.test.Soap:oiref><oihard>
-@__modelType reference
-*/
-class reference44 {
-}}/**
-@__tags
-@shapeType ClassDiagram
-*/
-class __tags {
-}/**
-@__options
-*/
-class __options {
-}/**
-@__positions
-*/
-class __positions {
-}
\ No newline at end of file
+package id1k6kqc9pgodo2c9pqksrr;
+
+/**
+@version 2.0
+@physicalPackage
+@__modelType diagram
+*/
+class diagram {
+/**
+@__ref <oiref:java#Class#org.zoap.soap.test.Soap:oiref><oihard>
+@__modelType reference
+*/
+class reference44 {
+}}/**
+@__tags
+@shapeType ClassDiagram
+*/
+class __tags {
+}/**
+@__options
+*/
+class __options {
+}/**
+@__positions
+*/
+class __positions {
+}