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 am...@apache.org on 2007/08/13 07:06:04 UTC
svn commit: r565239 [3/5] - in /webservices/axis2/trunk/java: ./
modules/distribution/ modules/distribution/src/main/assembly/
modules/kernel/conf/ modules/rmi/ modules/rmi/src/ modules/rmi/src/org/
modules/rmi/src/org/apache/ modules/rmi/src/org/apach...
Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlElement.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlElement.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlElement.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlElement.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,190 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.metadata.xml;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.apache.axis2.rmi.exception.SchemaGenerationException;
+import org.apache.axis2.rmi.util.Constants;
+
+import java.util.Map;
+
+public class XmlElement {
+
+ /**
+ * namespace for this element if it is an top level element
+ */
+ private String namespace;
+
+ /**
+ * name of this element
+ */
+ private String name;
+
+ /**
+ * is this element nillable
+ */
+ private boolean isNillable;
+
+ /**
+ * is minOccures zero for this element
+ */
+ private boolean isMinOccurs0;
+
+ /**
+ * is Array
+ */
+ private boolean isArray;
+
+ /**
+ * if this is an schema top level element
+ */
+ private boolean isTopElement;
+
+ /**
+ * xmlType of this element
+ */
+ private XmlType type;
+
+ /**
+ * schema element for this element
+ */
+ private Element element;
+
+ public XmlElement(boolean isPrimitiveType) {
+ // set the nillable value to true
+ this.isNillable = !isPrimitiveType;
+ this.isMinOccurs0 = !isPrimitiveType;
+ }
+
+ public void generateWSDLSchema(Document document,
+ Map namespacesToPrefixMap)
+ throws SchemaGenerationException {
+ String xsdPrefix = (String) namespacesToPrefixMap.get(Constants.URI_2001_SCHEMA_XSD);
+ this.element = document.createElementNS(Constants.URI_2001_SCHEMA_XSD, "element");
+ this.element.setPrefix(xsdPrefix);
+ this.element.setAttribute("name", this.name);
+
+
+ if (this.isArray && !this.isTopElement) {
+ this.element.setAttribute("maxOccurs", "unbounded");
+ }
+
+ if (this.namespace == null){
+ this.element.setAttribute("form", "unqualified");
+ }
+
+ // setting the type
+ if (type == null) {
+ // i.e this is corresponds to an void type so generate a empty annony mous complex type
+ Element complexElement = document.createElementNS(Constants.URI_2001_SCHEMA_XSD, "complexType");
+ complexElement.setPrefix(xsdPrefix);
+
+ Element sequenceElement = document.createElementNS(Constants.URI_2001_SCHEMA_XSD, "sequence");
+ sequenceElement.setPrefix(xsdPrefix);
+ complexElement.appendChild(sequenceElement);
+ this.element.appendChild(complexElement);
+ } else if (type.isSimpleType()) {
+ // this is an simple type element
+ this.element.setAttribute("type", xsdPrefix + ":" + type.getQname().getLocalPart());
+ if (this.isNillable) {
+ this.element.setAttribute("nillable", "true");
+ }
+ if (this.isMinOccurs0 && !this.isTopElement){
+ this.element.setAttribute("minOccurs","0");
+ }
+ } else if (!type.isAnonymous()) {
+ String prefix = (String) namespacesToPrefixMap.get(type.getQname().getNamespaceURI());
+ this.element.setAttribute("type", prefix + ":" + type.getQname().getLocalPart());
+ if (this.isNillable) {
+ this.element.setAttribute("nillable", "true");
+ }
+ if (this.isMinOccurs0 && !this.isTopElement){
+ this.element.setAttribute("minOccurs","0");
+ }
+ } else {
+ // i.e this is and annonymous complex type
+ type.generateWSDLSchema(document, namespacesToPrefixMap);
+ this.element.appendChild(type.getComplexElement());
+ }
+
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ public boolean isNillable() {
+ return isNillable;
+ }
+
+ public void setNillable(boolean nillable) {
+ isNillable = nillable;
+ }
+
+ public boolean isArray() {
+ return isArray;
+ }
+
+ public void setArray(boolean array) {
+ isArray = array;
+ }
+
+ public boolean isTopElement() {
+ return isTopElement;
+ }
+
+ public void setTopElement(boolean topElement) {
+ isTopElement = topElement;
+ }
+
+ public XmlType getType() {
+ return type;
+ }
+
+ public void setType(XmlType type) {
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Element getElement() {
+ return element;
+ }
+
+ public void setElement(Element element) {
+ this.element = element;
+ }
+
+ public boolean isMinOccurs0() {
+ return isMinOccurs0;
+ }
+
+ public void setMinOccurs0(boolean minOccurs0) {
+ isMinOccurs0 = minOccurs0;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlImport.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlImport.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlImport.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlImport.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.metadata.xml;
+
+/**
+ * Author: amila
+ * Date: Jun 24, 2007
+ */
+public class XmlImport {
+
+ /**
+ * namespace to import
+ */
+ private String namespace;
+
+ /**
+ * schema location for import schema
+ */
+ private String schemaLocation;
+
+ public XmlImport() {
+ }
+
+ public XmlImport(String namespace) {
+ this.namespace = namespace;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ public String getSchemaLocation() {
+ return schemaLocation;
+ }
+
+ public void setSchemaLocation(String schemaLocation) {
+ this.schemaLocation = schemaLocation;
+ }
+}
Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlSchema.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlSchema.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlSchema.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlSchema.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,220 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.metadata.xml;
+
+import org.apache.axis2.rmi.exception.SchemaGenerationException;
+import org.apache.axis2.rmi.util.Constants;
+import org.apache.axis2.rmi.util.Util;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.extensions.ExtensionRegistry;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.WSDLException;
+import javax.wsdl.Types;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+import java.util.*;
+
+public class XmlSchema {
+
+ /**
+ * target namespace of the schema
+ */
+ private String targetNamespace;
+
+ /**
+ * other declared namespaces
+ */
+ private List namespaces;
+
+ /**
+ * top level elements for this schema
+ */
+ private List elements;
+
+ /**
+ * top level complex types for this schema
+ */
+ private List complexTypes;
+
+ /**
+ * other schema imports
+ */
+ private List imports;
+
+ /**
+ * wsdl schema element corresponding to this schema element
+ */
+ private Schema wsdlSchema;
+
+ /**
+ * default constructor
+ */
+ public XmlSchema() {
+ this.elements = new ArrayList();
+ this.complexTypes = new ArrayList();
+ this.namespaces = new ArrayList();
+ this.imports = new ArrayList();
+ }
+
+ /**
+ * constructor with target namespace
+ * @param targetNamespace
+ */
+ public XmlSchema(String targetNamespace) {
+ this();
+ this.targetNamespace = targetNamespace;
+ }
+
+ /**
+ * sets the wsdl schema for this schema object
+ * @throws SchemaGenerationException
+ */
+ public void generateWSDLSchema()
+ throws SchemaGenerationException {
+ try {
+ ExtensionRegistry extensionRegistry = WSDLFactory.newInstance().newPopulatedExtensionRegistry();
+ this.wsdlSchema = (Schema) extensionRegistry.createExtension(
+ Types.class, new QName(Constants.URI_2001_SCHEMA_XSD, "schema"));
+
+ // create the schema element
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ Document document = documentBuilder.newDocument();
+
+ Element schemaElement = document.createElementNS(Constants.URI_2001_SCHEMA_XSD, "xsd:schema");
+
+ schemaElement.setAttributeNS(Constants.XMLNS_ATTRIBUTE_NS_URI,"xmlns:xsd",Constants.URI_2001_SCHEMA_XSD);
+
+ Map namespacesToPrefixMap = new HashMap();
+ namespacesToPrefixMap.put(Constants.URI_2001_SCHEMA_XSD,"xsd");
+ // set default namespace attribute
+
+ this.wsdlSchema.setElement(schemaElement);
+
+ //set the target namesapce and other namespaces
+ schemaElement.setAttribute("targetNamespace", this.targetNamespace);
+
+ // add other namesapces
+ String namespace;
+ String prefix;
+ for (Iterator iter = this.namespaces.iterator();iter.hasNext();){
+ namespace = (String) iter.next();
+ if (!namespacesToPrefixMap.containsKey(namespace)){
+ prefix = Util.getNextNamespacePrefix();
+ schemaElement.setAttributeNS(Constants.XMLNS_ATTRIBUTE_NS_URI,"xmlns:" + prefix,namespace);
+ namespacesToPrefixMap.put(namespace,prefix);
+ }
+ }
+
+ // create complex type elements
+ XmlType xmlType;
+ for (Iterator iter = this.complexTypes.iterator();iter.hasNext();){
+ xmlType = (XmlType) iter.next();
+ if (!xmlType.isAnonymous() && !xmlType.isSimpleType()){
+ xmlType.generateWSDLSchema(document, namespacesToPrefixMap);
+ schemaElement.appendChild(xmlType.getComplexElement());
+ }
+ }
+
+ // create elements
+ XmlElement xmlElement;
+ for (Iterator iter = this.elements.iterator(); iter.hasNext();){
+ xmlElement = (XmlElement) iter.next();
+ xmlElement.generateWSDLSchema(document, namespacesToPrefixMap);
+ schemaElement.appendChild(xmlElement.getElement());
+ }
+
+ } catch (WSDLException e) {
+ throw new SchemaGenerationException("Error while creating the extension registry",e);
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+
+ public void addElement(XmlElement xmlElement){
+ this.elements.add(xmlElement);
+ }
+
+ public void addComplexType(XmlType xmlType){
+ this.complexTypes.add(xmlType);
+ }
+
+ public void addNamespace(String namespace){
+ this.namespaces.add(namespace);
+ }
+
+ public void addImport(XmlImport xmlImport){
+ this.imports.add(xmlImport);
+ }
+
+ public boolean containsNamespace(String namespace){
+ return this.namespaces.contains(namespace);
+ }
+
+ public String getTargetNamespace() {
+ return targetNamespace;
+ }
+
+ public void setTargetNamespace(String targetNamespace) {
+ this.targetNamespace = targetNamespace;
+ }
+
+ public List getNamespaces() {
+ return namespaces;
+ }
+
+ public void setNamespaces(List namespaces) {
+ this.namespaces = namespaces;
+ }
+
+ public List getElements() {
+ return elements;
+ }
+
+ public void setElements(List elements) {
+ this.elements = elements;
+ }
+
+ public List getComplexTypes() {
+ return complexTypes;
+ }
+
+ public void setComplexTypes(List complexTypes) {
+ this.complexTypes = complexTypes;
+ }
+
+ public List getImports() {
+ return imports;
+ }
+
+ public void setImports(List imports) {
+ this.imports = imports;
+ }
+
+ public Schema getWsdlSchema() {
+ return wsdlSchema;
+ }
+
+ public void setWsdlSchema(Schema wsdlSchema) {
+ this.wsdlSchema = wsdlSchema;
+ }
+}
Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlType.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlType.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlType.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.metadata.xml;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+import org.apache.axis2.rmi.exception.SchemaGenerationException;
+import org.apache.axis2.rmi.util.Constants;
+
+import javax.xml.namespace.QName;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.Iterator;
+
+
+public class XmlType {
+
+ /**
+ * Qualified name of the xmlType
+ */
+ private QName qname;
+
+ /**
+ * is this an anAnonymous type this case qname can be null
+ */
+ private boolean isAnonymous;
+
+ /**
+ * is this is a basic type
+ */
+ private boolean isSimpleType;
+
+ /**
+ * list of child elements
+ */
+ private List elements;
+
+ /**
+ * complex type element for this XmlType
+ */
+ private Element complexElement;
+
+ /**
+ * parent type for this xml type if it is an extension
+ *
+ */
+ private XmlType parentType;
+
+
+ public void addElement(XmlElement xmlElement){
+ this.elements.add(xmlElement);
+ }
+
+ /**
+ * this generates the complex type only if it is annonymous and
+ * is not a simple type
+ * @param document
+ * @param namespacesToPrefixMap
+ * @throws SchemaGenerationException
+ */
+ public void generateWSDLSchema(Document document,
+ Map namespacesToPrefixMap)
+ throws SchemaGenerationException {
+ // here we have to generate the complex type element for this xmlType
+ if (!this.isSimpleType){
+ String xsdPrefix = (String) namespacesToPrefixMap.get(Constants.URI_2001_SCHEMA_XSD);
+ this.complexElement = document.createElementNS(Constants.URI_2001_SCHEMA_XSD,"complexType");
+ this.complexElement.setPrefix(xsdPrefix);
+ if (!this.isAnonymous){
+ this.complexElement.setAttribute("name", this.qname.getLocalPart());
+ }
+
+ Element sequenceElement = document.createElementNS(Constants.URI_2001_SCHEMA_XSD,"sequence");
+ sequenceElement.setPrefix(xsdPrefix);
+
+ // set the extension details if there are
+ if (this.parentType != null){
+
+ // i.e this is an extension type
+ Element complexContent = document.createElementNS(Constants.URI_2001_SCHEMA_XSD,"complexContent");
+ complexContent.setPrefix(xsdPrefix);
+ this.complexElement.appendChild(complexContent);
+
+ Element extension = document.createElementNS(Constants.URI_2001_SCHEMA_XSD,"extension");
+ extension.setPrefix(xsdPrefix);
+ complexContent.appendChild(extension);
+
+ String extensionPrefix =
+ (String) namespacesToPrefixMap.get(this.parentType.getQname().getNamespaceURI());
+ String localPart = this.parentType.getQname().getLocalPart();
+ if ((extensionPrefix == null) || extensionPrefix.equals("")){
+ extension.setAttribute("base",localPart);
+ } else {
+ extension.setAttribute("base",extensionPrefix + ":" + localPart);
+ }
+ extension.appendChild(sequenceElement);
+ } else {
+ this.complexElement.appendChild(sequenceElement);
+ }
+
+ // add the other element children
+ XmlElement xmlElement;
+ for (Iterator iter = this.elements.iterator();iter.hasNext();){
+ xmlElement = (XmlElement) iter.next();
+ xmlElement.generateWSDLSchema(document,namespacesToPrefixMap);
+ sequenceElement.appendChild(xmlElement.getElement());
+ }
+ }
+ }
+
+ public XmlType() {
+ this.elements = new ArrayList();
+ }
+
+ public XmlType(QName qname) {
+ this();
+ this.qname = qname;
+ }
+
+ public QName getQname() {
+ return qname;
+ }
+
+ public void setQname(QName qname) {
+ this.qname = qname;
+ }
+
+ public boolean isAnonymous() {
+ return isAnonymous;
+ }
+
+ public void setAnonymous(boolean anonymous) {
+ isAnonymous = anonymous;
+ }
+
+ public boolean isSimpleType() {
+ return isSimpleType;
+ }
+
+ public void setSimpleType(boolean simpleType) {
+ isSimpleType = simpleType;
+ }
+
+ public List getElements() {
+ return elements;
+ }
+
+ public void setElements(List elements) {
+ this.elements = elements;
+ }
+
+ public Element getComplexElement() {
+ return complexElement;
+ }
+
+ public void setComplexElement(Element complexElement) {
+ this.complexElement = complexElement;
+ }
+
+ public XmlType getParentType() {
+ return parentType;
+ }
+
+ public void setParentType(XmlType parentType) {
+ this.parentType = parentType;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/receiver/RMIMessageReciever.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/receiver/RMIMessageReciever.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/receiver/RMIMessageReciever.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/receiver/RMIMessageReciever.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.receiver;
+
+import org.apache.axis2.rmi.exception.XmlParsingException;
+import org.apache.axis2.rmi.exception.XmlSerializingException;
+import org.apache.axis2.rmi.metadata.*;
+import org.apache.axis2.rmi.metadata.xml.XmlElement;
+import org.apache.axis2.rmi.databind.XmlStreamParser;
+import org.apache.axis2.rmi.databind.RMIDataSource;
+import org.apache.axis2.rmi.databind.JavaObjectSerializer;
+import org.apache.axis2.rmi.util.NamespacePrefix;
+import org.apache.axis2.receivers.AbstractInOutMessageReceiver;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.impl.llom.OMSourcedElementImpl;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPEnvelope;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.namespace.QName;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+
+public class RMIMessageReciever extends AbstractInOutMessageReceiver {
+
+ // this contains all the data regarding the service.
+ private Service service;
+ private JavaObjectSerializer javaObjectSerializer;
+ private XmlStreamParser xmlStreamParser;
+
+ public RMIMessageReciever(Service service) {
+ this.service = service;
+ this.javaObjectSerializer = new JavaObjectSerializer(
+ service.getProcessedTypeMap(),
+ service.getConfigurator(),
+ service.getSchemaMap());
+ this.xmlStreamParser = new XmlStreamParser(
+ service.getProcessedTypeMap(),
+ service.getConfigurator(),
+ service.getSchemaMap());
+ }
+
+ public void invokeBusinessLogic(MessageContext inputMessageContext,
+ MessageContext outputMessageContext) throws AxisFault {
+
+ String operationName = inputMessageContext.getOperationContext().getAxisOperation().getName().getLocalPart();
+ Operation operation = service.getOperation(operationName);
+ XMLStreamReader reader = inputMessageContext.getEnvelope().getBody().getFirstElement().getXMLStreamReaderWithoutCaching();
+ SOAPFactory soapFactory = getSOAPFactory(inputMessageContext);
+ if (operation != null) {
+ // invoke the method
+ try {
+ Object serviceObject = service.getJavaClass().newInstance();
+ Method javaOperation = operation.getJavaMethod();
+ Object returnObject = javaOperation.invoke(serviceObject,
+ this.xmlStreamParser.getInputParameters(reader, operation));
+ OMElement returnOMElement = getOutputOMElement(returnObject, operation, this.javaObjectSerializer, soapFactory);
+ SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope();
+ soapEnvelope.getBody().addChild(returnOMElement);
+ outputMessageContext.setEnvelope(soapEnvelope);
+ // set the out put element to message context
+
+ } catch (InstantiationException e) {
+ throw AxisFault.makeFault(e);
+ } catch (IllegalAccessException e) {
+ throw AxisFault.makeFault(e);
+ } catch (InvocationTargetException e) {
+ Throwable targetException = e.getTargetException();
+ if (targetException != null) {
+ Parameter parameter = this.service.getExceptionParameter(targetException.getClass());
+ if (parameter != null) {
+ AxisFault axisFault = new AxisFault(targetException.getMessage());
+ axisFault.setDetail(getParameterOMElement(targetException,
+ parameter,
+ this.javaObjectSerializer,
+ soapFactory));
+ throw axisFault;
+ }
+ }
+ throw AxisFault.makeFault(e);
+ } catch (XmlParsingException e) {
+ throw AxisFault.makeFault(e);
+ } catch (XMLStreamException e) {
+ throw AxisFault.makeFault(e);
+ }
+
+ } else {
+ throw new AxisFault("Can not find the operation");
+ }
+
+ }
+
+ public OMElement getOutputOMElement(final Object returnObject,
+ final Operation operation,
+ final JavaObjectSerializer javaObjectSerializer,
+ SOAPFactory soapFactory) {
+ OMDataSource omDataSource = new RMIDataSource() {
+
+ public void serialize(MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException {
+ try {
+ javaObjectSerializer.serializeOutputElement(returnObject,
+ operation.getOutPutElement(),
+ operation.getOutputParameter(),
+ xmlWriter);
+ } catch (XmlSerializingException e) {
+ new XMLStreamException("Problem in serializing the return object", e);
+ }
+ }
+ };
+ XmlElement outXmlElement = operation.getOutPutElement();
+ QName outElementQName = new QName(outXmlElement.getNamespace(), outXmlElement.getName());
+ return new OMSourcedElementImpl(outElementQName, soapFactory, omDataSource);
+ }
+
+ public OMElement getParameterOMElement(final Object exceptionObject,
+ final Parameter parameter,
+ final JavaObjectSerializer javaObjectSerializer,
+ SOAPFactory soapFactory){
+ OMDataSource omDataSource = new RMIDataSource(){
+
+ public void serialize(MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException {
+ try {
+ javaObjectSerializer.serializeParameter(exceptionObject,parameter,xmlWriter, new NamespacePrefix());
+ } catch (XmlSerializingException e) {
+ throw new XMLStreamException("problem in serializing the exception object ",e);
+ }
+ }
+ };
+ XmlElement exceptionElement = parameter.getElement();
+ QName outElementQName = new QName(exceptionElement.getNamespace(), exceptionElement.getName());
+ OMElement omElement = new OMSourcedElementImpl(outElementQName, soapFactory, omDataSource);
+ return omElement;
+ }
+
+
+
+
+}
Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/Constants.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/Constants.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/Constants.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,43 @@
+package org.apache.axis2.rmi.util;
+
+import javax.xml.namespace.QName;
+
+
+public interface Constants {
+
+ public static final String XMLNS_ATTRIBUTE_NS_URI = "http://www.w3.org/2000/xmlns/";
+
+ public static final String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema";
+ public static final String URI_2001_SCHEMA_XSI = "http://www.w3.org/2001/XMLSchema-instance";
+
+ public static final String URI_DEFAULT_SCHEMA_XSD = Constants.URI_2001_SCHEMA_XSD;
+ public static final String URI_DEFAULT_SCHEMA_XSI = Constants.URI_2001_SCHEMA_XSI;
+
+ public static final QName XSD_STRING = new QName(URI_DEFAULT_SCHEMA_XSD, "string");
+ public static final QName XSD_BOOLEAN = new QName(URI_DEFAULT_SCHEMA_XSD, "boolean");
+ public static final QName XSD_DOUBLE = new QName(URI_DEFAULT_SCHEMA_XSD, "double");
+ public static final QName XSD_FLOAT = new QName(URI_DEFAULT_SCHEMA_XSD, "float");
+ public static final QName XSD_INT = new QName(URI_DEFAULT_SCHEMA_XSD, "int");
+ public static final QName XSD_INTEGER = new QName(URI_DEFAULT_SCHEMA_XSD, "integer");
+ public static final QName XSD_LONG = new QName(URI_DEFAULT_SCHEMA_XSD, "long");
+ public static final QName XSD_SHORT = new QName(URI_DEFAULT_SCHEMA_XSD, "short");
+ public static final QName XSD_BYTE = new QName(URI_DEFAULT_SCHEMA_XSD, "byte");
+ public static final QName XSD_DECIMAL = new QName(URI_DEFAULT_SCHEMA_XSD, "decimal");
+ public static final QName XSD_BASE64 = new QName(URI_DEFAULT_SCHEMA_XSD, "base64Binary");
+ public static final QName XSD_HEXBIN = new QName(URI_DEFAULT_SCHEMA_XSD, "hexBinary");
+ public static final QName XSD_ANYSIMPLETYPE = new QName(URI_DEFAULT_SCHEMA_XSD, "anySimpleType");
+ public static final QName XSD_ANYTYPE = new QName(URI_DEFAULT_SCHEMA_XSD, "anyType");
+ public static final QName XSD_ANY = new QName(URI_DEFAULT_SCHEMA_XSD, "any");
+ public static final QName XSD_QNAME = new QName(URI_DEFAULT_SCHEMA_XSD, "QName");
+ public static final QName XSD_DATETIME = new QName(URI_DEFAULT_SCHEMA_XSD, "dateTime");
+ public static final QName XSD_DATE = new QName(URI_DEFAULT_SCHEMA_XSD, "date");
+ public static final QName XSD_TIME = new QName(URI_DEFAULT_SCHEMA_XSD, "time");
+
+ // attribute types used in collection api
+ public static final int COLLECTION_TYPE = 0x0001;
+ public static final int LIST_TYPE = 0x0002;
+ public static final int SET_TYPE = 0x0004;
+ public static final int MAP_TYPE = 0x0008;
+ public static final int OTHER_TYPE = 0x0010;
+
+}
Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/JavaTypeToConstructorMap.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/JavaTypeToConstructorMap.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/JavaTypeToConstructorMap.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/JavaTypeToConstructorMap.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.util;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Calendar;
+import java.util.Date;
+import java.lang.reflect.Constructor;
+
+/**
+ * Author: amila
+ * Date: Jul 21, 2007
+ */
+public class JavaTypeToConstructorMap {
+
+ private static Map javaTypeToConstructorMap;
+
+ public static Constructor getConstructor(Class key) {
+ return (Constructor) javaTypeToConstructorMap.get(key);
+ }
+
+ public static boolean containsKey(Class key) {
+ return javaTypeToConstructorMap.containsKey(key);
+ }
+
+ static {
+ javaTypeToConstructorMap = new HashMap();
+ // pupualte the map
+ try {
+ javaTypeToConstructorMap.put(String.class, String.class.getConstructor(new Class[]{String.class}));
+ javaTypeToConstructorMap.put(boolean.class, Boolean.class.getConstructor(new Class[]{String.class}));
+ javaTypeToConstructorMap.put(Boolean.class, Boolean.class.getConstructor(new Class[]{String.class}));
+ javaTypeToConstructorMap.put(double.class, Double.class.getConstructor(new Class[]{String.class}));
+ javaTypeToConstructorMap.put(Double.class, Double.class.getConstructor(new Class[]{String.class}));
+ javaTypeToConstructorMap.put(float.class, Float.class.getConstructor(new Class[]{String.class}));
+ javaTypeToConstructorMap.put(Float.class, Float.class.getConstructor(new Class[]{String.class}));
+ javaTypeToConstructorMap.put(int.class, Integer.class.getConstructor(new Class[]{String.class}));
+ javaTypeToConstructorMap.put(Integer.class, Integer.class.getConstructor(new Class[]{String.class}));
+ javaTypeToConstructorMap.put(long.class, Long.class.getConstructor(new Class[]{String.class}));
+ javaTypeToConstructorMap.put(Long.class, Long.class.getConstructor(new Class[]{String.class}));
+ javaTypeToConstructorMap.put(short.class, Short.class.getConstructor(new Class[]{String.class}));
+ javaTypeToConstructorMap.put(Short.class, Short.class.getConstructor(new Class[]{String.class}));
+ javaTypeToConstructorMap.put(byte.class, Byte.class.getConstructor(new Class[]{String.class}));
+ javaTypeToConstructorMap.put(Byte.class, Byte.class.getConstructor(new Class[]{String.class}));
+ javaTypeToConstructorMap.put(Calendar.class, Constants.XSD_DATETIME);
+ javaTypeToConstructorMap.put(Date.class, Constants.XSD_DATE);
+ } catch (NoSuchMethodException e) {
+ // this exception should not occur since we dealing with know class
+ // print the stacktrace for debuging purposes
+ e.printStackTrace();
+ }
+
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/JavaTypeToQNameMap.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/JavaTypeToQNameMap.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/JavaTypeToQNameMap.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/JavaTypeToQNameMap.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.util;
+
+
+import javax.xml.namespace.QName;
+import java.util.*;
+
+
+public class JavaTypeToQNameMap {
+
+ private static Map javaTypeToQNameMap;
+
+ public static QName getTypeQName(Class key) {
+ return (QName) javaTypeToQNameMap.get(key);
+ }
+
+ public static boolean containsKey(Class key) {
+ return javaTypeToQNameMap.containsKey(key);
+ }
+
+ public static Set getKeys(){
+ return javaTypeToQNameMap.keySet();
+ }
+
+ static {
+ javaTypeToQNameMap = new HashMap();
+ // pupualte the map
+ javaTypeToQNameMap.put(String.class, Constants.XSD_STRING);
+ javaTypeToQNameMap.put(boolean.class, Constants.XSD_BOOLEAN);
+ javaTypeToQNameMap.put(Boolean.class, Constants.XSD_BOOLEAN);
+ javaTypeToQNameMap.put(double.class, Constants.XSD_DOUBLE);
+ javaTypeToQNameMap.put(Double.class, Constants.XSD_DOUBLE);
+ javaTypeToQNameMap.put(float.class, Constants.XSD_FLOAT);
+ javaTypeToQNameMap.put(Float.class, Constants.XSD_FLOAT);
+ javaTypeToQNameMap.put(int.class, Constants.XSD_INT);
+ javaTypeToQNameMap.put(Integer.class, Constants.XSD_INT);
+ javaTypeToQNameMap.put(long.class, Constants.XSD_LONG);
+ javaTypeToQNameMap.put(Long.class, Constants.XSD_LONG);
+ javaTypeToQNameMap.put(short.class, Constants.XSD_SHORT);
+ javaTypeToQNameMap.put(Short.class, Constants.XSD_SHORT);
+ javaTypeToQNameMap.put(byte.class, Constants.XSD_BYTE);
+ javaTypeToQNameMap.put(Byte.class, Constants.XSD_BYTE);
+ javaTypeToQNameMap.put(Calendar.class, Constants.XSD_DATETIME);
+ javaTypeToQNameMap.put(Date.class, Constants.XSD_DATE);
+ javaTypeToQNameMap.put(Object.class, Constants.XSD_ANYTYPE);
+
+
+ }
+
+
+}
Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/NamespacePrefix.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/NamespacePrefix.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/NamespacePrefix.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/NamespacePrefix.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.util;
+
+/**
+ * used to keep the namespace prefixes
+ */
+public class NamespacePrefix {
+
+ private int namespacePrefix = 0;
+
+ public int getNamesapcePrefix(){
+ return ++namespacePrefix;
+ }
+}
Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/Util.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/Util.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/Util.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/util/Util.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.util;
+
+import java.util.*;
+
+
+public class Util {
+ private static int i = 0;
+
+ public synchronized static String getNextNamespacePrefix() {
+ if (i > 1000) {
+ i = 0;
+ }
+ return "ns" + ++i;
+ }
+
+ private static Set primitives;
+
+ static {
+ primitives = new HashSet();
+ primitives.add(int.class);
+ primitives.add(long.class);
+ primitives.add(float.class);
+ primitives.add(double.class);
+ primitives.add(short.class);
+ primitives.add(byte.class);
+ primitives.add(boolean.class);
+ primitives.add(char.class);
+ }
+
+ public boolean isPrimitive(Class type) {
+ return primitives.contains(type);
+ }
+
+ public static int getClassType(Class className)
+ throws IllegalAccessException,
+ InstantiationException {
+ int type = Constants.OTHER_TYPE;
+ // if it is an array then it can not be a collection type
+ if (List.class.isAssignableFrom(className)) {
+ type = Constants.LIST_TYPE | Constants.COLLECTION_TYPE;
+ } else if (Set.class.isAssignableFrom(className)) {
+ type = Constants.SET_TYPE | Constants.COLLECTION_TYPE;
+ } else if (Map.class.isAssignableFrom(className)) {
+ type = Constants.MAP_TYPE;
+ } else if (Collection.class.isAssignableFrom(className)) {
+ type = Constants.COLLECTION_TYPE;
+ }
+ return type;
+ }
+}
Added: webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/client/RMIClientService1Test.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/client/RMIClientService1Test.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/client/RMIClientService1Test.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/client/RMIClientService1Test.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.client;
+
+import org.apache.axis2.rmi.server.services.Service1;
+import org.apache.axis2.AxisFault;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import junit.framework.TestCase;
+
+
+public class RMIClientService1Test extends TestCase {
+
+ public void testMethod11(){
+
+ try {
+ RMIClient rmiClient = new RMIClient(Service1.class,
+ "http://localhost:8085/axis2/services/Service1");
+ List inputObject = new ArrayList();
+ inputObject.add("Hellow world");
+ String returnString = (String) rmiClient.invokeMethod("method1",inputObject);
+ assertEquals(returnString,"Hellow world");
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ public void testMethod12(){
+
+ try {
+ RMIClient rmiClient = new RMIClient(Service1.class,
+ "http://localhost:8085/axis2/services/Service1");
+ List inputObject = new ArrayList();
+ inputObject.add(null);
+ String returnString = (String) rmiClient.invokeMethod("method1",inputObject);
+ assertNull(returnString);
+ } catch (Exception e) {
+ fail();
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/CollectionTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/CollectionTest.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/CollectionTest.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/CollectionTest.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.databind;
+
+import org.apache.axis2.rmi.databind.dto.TestClass11;
+import org.apache.axis2.rmi.metadata.Parameter;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.HashSet;
+
+
+public class CollectionTest extends DataBindTest {
+
+ public void testTestClass111(){
+
+ Class testClass = TestClass11.class;
+ Parameter parameter = new Parameter(testClass, "Param1");
+ TestClass11 testObject = new TestClass11();
+ List testList = new ArrayList();
+ testList.add("Test String");
+ testObject.setParam1(testList);
+ TestClass11 result = (TestClass11) getReturnObject(parameter, testObject);
+ assertEquals(result.getParam1().get(0), "Test String");
+ }
+
+ public void testTestClass112(){
+
+ Class testClass = TestClass11.class;
+ Parameter parameter = new Parameter(testClass, "Param1");
+ TestClass11 testObject = new TestClass11();
+ List testList = new ArrayList();
+ testList.add("Test String0");
+ testList.add("Test String1");
+ testList.add(null);
+ testList.add("Test String3");
+ testList.add(null);
+
+ testObject.setParam1(testList);
+ TestClass11 result = (TestClass11) getReturnObject(parameter, testObject);
+ assertEquals(result.getParam1().get(0), "Test String0");
+ assertEquals(result.getParam1().get(1), "Test String1");
+ assertEquals(result.getParam1().get(2), null);
+ assertEquals(result.getParam1().get(3), "Test String3");
+ assertEquals(result.getParam1().get(4), null);
+ }
+
+ public void testTestClass113(){
+
+ Class testClass = TestClass11.class;
+ Parameter parameter = new Parameter(testClass, "Param1");
+ TestClass11 testObject = new TestClass11();
+ List testList = new ArrayList();
+ testObject.setParam1(testList);
+ TestClass11 result = (TestClass11) getReturnObject(parameter, testObject);
+ assertEquals(result.getParam1(), null);
+
+ }
+
+ public void testTestClass114(){
+
+ Class testClass = TestClass11.class;
+ Parameter parameter = new Parameter(testClass, "Param1");
+ TestClass11 testObject = new TestClass11();
+ testObject.setParam1(null);
+ TestClass11 result = (TestClass11) getReturnObject(parameter, testObject);
+ assertEquals(result.getParam1(), null);
+
+ }
+
+ public void testTestClass115(){
+
+ Class testClass = TestClass11.class;
+ Parameter parameter = new Parameter(testClass, "Param1");
+ TestClass11 testObject = new TestClass11();
+ ArrayList testList = new ArrayList();
+ testList.add("Test String");
+ testObject.setParam2(testList);
+ TestClass11 result = (TestClass11) getReturnObject(parameter, testObject);
+ assertEquals(result.getParam2().get(0), "Test String");
+ }
+
+ public void testTestClass116(){
+
+ Class testClass = TestClass11.class;
+ Parameter parameter = new Parameter(testClass, "Param1");
+ TestClass11 testObject = new TestClass11();
+ ArrayList testList = new ArrayList();
+ testList.add("Test String0");
+ testList.add("Test String1");
+ testList.add(null);
+ testList.add("Test String3");
+ testList.add(null);
+
+ testObject.setParam2(testList);
+ TestClass11 result = (TestClass11) getReturnObject(parameter, testObject);
+ assertEquals(result.getParam2().get(0), "Test String0");
+ assertEquals(result.getParam2().get(1), "Test String1");
+ assertEquals(result.getParam2().get(2), null);
+ assertEquals(result.getParam2().get(3), "Test String3");
+ assertEquals(result.getParam2().get(4), null);
+ }
+
+ public void testTestClass117(){
+
+ Class testClass = TestClass11.class;
+ Parameter parameter = new Parameter(testClass, "Param1");
+ TestClass11 testObject = new TestClass11();
+ ArrayList testList = new ArrayList();
+ testObject.setParam2(testList);
+ TestClass11 result = (TestClass11) getReturnObject(parameter, testObject);
+ assertEquals(result.getParam2(), null);
+
+ }
+
+ public void testTestClass118(){
+
+ Class testClass = TestClass11.class;
+ Parameter parameter = new Parameter(testClass, "Param1");
+ TestClass11 testObject = new TestClass11();
+ testObject.setParam2(null);
+ TestClass11 result = (TestClass11) getReturnObject(parameter, testObject);
+ assertEquals(result.getParam2(), null);
+
+ }
+
+ public void testTestClass119(){
+
+ Class testClass = TestClass11.class;
+ Parameter parameter = new Parameter(testClass, "Param1");
+
+ TestClass11 testObject = new TestClass11();
+ List testList = new ArrayList();
+ testList.add("test string");
+ testList.add(null);
+ testObject.setParam1(testList);
+
+ Set testSet = new HashSet();
+ testSet.add("test string");
+ testSet.add(null);
+ testObject.setParam3(testSet);
+
+ TestClass11 result = (TestClass11) getReturnObject(parameter, testObject);
+ assertEquals(result.getParam1().get(0),"test string");
+ assertEquals(result.getParam1().get(1), null);
+ assertEquals(result.getParam2(), null);
+ assertTrue(result.getParam3().contains("test string"));
+ assertTrue(result.getParam3().contains(null));
+ }
+}
Added: webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ComplexArrayTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ComplexArrayTest.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ComplexArrayTest.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ComplexArrayTest.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,168 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.databind;
+
+import org.apache.axis2.rmi.databind.dto.*;
+import org.apache.axis2.rmi.metadata.Parameter;
+
+
+public class ComplexArrayTest extends DataBindTest {
+
+ public void testTestClass7() {
+ Class testClass = TestClass7.class;
+ Parameter parameter = new Parameter(testClass, "Param1");
+ TestClass7 testObject = null;
+ TestClass7 result = null;
+
+ testObject = new TestClass7();
+ result = (TestClass7) getReturnObject(parameter, testObject);
+ assertEquals(result.getParam1(), null);
+ assertEquals(result.getParam2(), null);
+
+ testObject = new TestClass7();
+ testObject.setParam1(new TestClass4[]{null, null});
+ result = (TestClass7) getReturnObject(parameter, testObject);
+ assertEquals(result.getParam1()[0], null);
+ assertEquals(result.getParam1()[1], null);
+ assertEquals(result.getParam2(), null);
+
+ TestClass4[] teseClassArray = new TestClass4[3];
+ teseClassArray[0] = new TestClass4();
+ teseClassArray[0].setParam1(new int[]{5, 6});
+ teseClassArray[0].setParam2(new Integer[]{new Integer(2), new Integer(3)});
+ teseClassArray[0].setParam3(new String[]{"test String"});
+ teseClassArray[0].setParam4(new float[]{5.56f});
+
+ teseClassArray[1] = null;
+
+ teseClassArray[2] = new TestClass4();
+ teseClassArray[2].setParam1(new int[]{5, 6});
+ teseClassArray[2].setParam2(new Integer[]{new Integer(2), new Integer(3)});
+ teseClassArray[2].setParam3(new String[]{"test String"});
+ teseClassArray[2].setParam4(new float[]{5.56f});
+
+ TestClass3 testClass3 = new TestClass3();
+ testClass3.setParam1(new Integer(2));
+ testClass3.setParam2(new Float(45.6));
+ testClass3.setParam3(new Double(3));
+ testClass3.setParam4("test String");
+
+
+ testObject = new TestClass7();
+ testObject.setParam1(teseClassArray);
+ testObject.setParam2(testClass3);
+ result = (TestClass7) getReturnObject(parameter, testObject);
+
+ assertEquals(result.getParam1()[0].getParam1()[0], 5);
+ assertEquals(result.getParam1()[0].getParam1()[1], 6);
+ assertEquals(result.getParam1()[0].getParam2()[0].intValue(), 2);
+ assertEquals(result.getParam1()[0].getParam2()[1].intValue(), 3);
+ assertEquals(result.getParam1()[0].getParam3()[0], "test String");
+ assertTrue(result.getParam1()[0].getParam4()[0] == 5.56f);
+
+ assertNull(result.getParam1()[1]);
+
+ assertEquals(result.getParam1()[2].getParam1()[0], 5);
+ assertEquals(result.getParam1()[2].getParam1()[1], 6);
+ assertEquals(result.getParam1()[2].getParam2()[0].intValue(), 2);
+ assertEquals(result.getParam1()[2].getParam2()[1].intValue(), 3);
+ assertEquals(result.getParam1()[2].getParam3()[0], "test String");
+ assertTrue(result.getParam1()[2].getParam4()[0] == 5.56f);
+
+ assertEquals(result.getParam2().getParam1().intValue(), 2);
+ assertTrue(result.getParam2().getParam2().floatValue() == 45.6f);
+ assertTrue(result.getParam2().getParam3().doubleValue() == 3);
+ assertEquals(result.getParam2().getParam4(), "test String");
+
+
+ }
+
+ public void testClass91() {
+ Class testClass = TestClass9.class;
+ Parameter parameter = new Parameter(testClass, "Param1");
+
+ TestClass9 testClass9 = new TestClass9();
+
+ TestClass2[] testClass2 = new TestClass2[3];
+ testClass2[0] = new TestClass2();
+ testClass2[0].setParam1(5);
+ testClass2[0].setParam2(23.45f);
+ testClass2[0].setParam3(45);
+
+ testClass2[1] = new TestClass2();
+ testClass2[1].setParam1(5);
+ testClass2[1].setParam2(23.45f);
+ testClass2[1].setParam3(45);
+
+ testClass2[2] = new TestClass2();
+ testClass2[2].setParam1(5);
+ testClass2[2].setParam2(23.45f);
+ testClass2[2].setParam3(45);
+
+ testClass9.setParam1(testClass2);
+
+ TestClass9 returnObject = (TestClass9) getReturnObject(parameter, testClass9);
+
+ assertEquals(returnObject.getParam1()[0].getParam1(), 5);
+ assertTrue(returnObject.getParam1()[0].getParam2() == 23.45f);
+ assertTrue(returnObject.getParam1()[0].getParam3() == 45);
+
+ assertEquals(returnObject.getParam1()[1].getParam1(), 5);
+ assertTrue(returnObject.getParam1()[1].getParam2() == 23.45f);
+ assertTrue(returnObject.getParam1()[1].getParam3() == 45.0d);
+
+ assertEquals(returnObject.getParam1()[2].getParam1(), 5);
+ assertTrue(returnObject.getParam1()[2].getParam2() == 23.45f);
+ assertTrue(returnObject.getParam1()[2].getParam3() == 45.0d);
+
+ }
+
+ public void testClass92() {
+ Class testClass = TestClass9.class;
+ Parameter parameter = new Parameter(testClass, "Param1");
+
+ TestClass9 testClass9 = new TestClass9();
+
+ TestClass2[] testClass2 = new TestClass2[3];
+ testClass2[0] = new TestClass2();
+ testClass2[0].setParam1(5);
+ testClass2[0].setParam2(23.45f);
+ testClass2[0].setParam3(45);
+
+ testClass2[1] = null;
+
+ testClass2[2] = new TestClass2();
+ testClass2[2].setParam1(5);
+ testClass2[2].setParam2(23.45f);
+ testClass2[2].setParam3(45);
+
+ testClass9.setParam1(testClass2);
+
+ TestClass9 returnObject = (TestClass9) getReturnObject(parameter, testClass9);
+
+ assertEquals(returnObject.getParam1()[0].getParam1(), 5);
+ assertTrue(returnObject.getParam1()[0].getParam2() == 23.45f);
+ assertTrue(returnObject.getParam1()[0].getParam3() == 45);
+
+ assertEquals(returnObject.getParam1()[1],null);
+
+ assertEquals(returnObject.getParam1()[2].getParam1(), 5);
+ assertTrue(returnObject.getParam1()[2].getParam2() == 23.45f);
+ assertTrue(returnObject.getParam1()[2].getParam3() == 45.0d);
+
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ComplexDataBindTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ComplexDataBindTest.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ComplexDataBindTest.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ComplexDataBindTest.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.databind;
+
+import org.apache.axis2.rmi.databind.dto.TestClass5;
+import org.apache.axis2.rmi.databind.dto.TestClass1;
+import org.apache.axis2.rmi.databind.dto.TestClass6;
+import org.apache.axis2.rmi.databind.dto.TestClass2;
+import org.apache.axis2.rmi.metadata.Parameter;
+
+
+public class ComplexDataBindTest extends DataBindTest {
+
+ public void testClass5(){
+
+ Class testClass = TestClass5.class;
+ Parameter parameter = new Parameter(testClass,"Param1");
+ TestClass5 testObject = new TestClass5();
+
+ TestClass5 result = null;
+ result = (TestClass5) getReturnObject(parameter,testObject);
+ assertEquals(result.getParam1(),null);
+
+ testObject.setParam1(new TestClass1());
+ result = (TestClass5) getReturnObject(parameter,testObject);
+ assertNotNull(result.getParam1());
+
+ }
+
+ public void testClass6(){
+ Class testClass = TestClass6.class;
+ Parameter parameter = new Parameter(testClass,"Param1");
+
+ TestClass6 result = null;
+
+ TestClass6 testObject = new TestClass6();
+ result = (TestClass6) getReturnObject(parameter,testObject);
+ assertEquals(result.getParam1(),null);
+ assertEquals(result.getParam2(),null);
+ assertEquals(result.getParam3(),0);
+
+ testObject = new TestClass6();
+ testObject.setParam1(new TestClass2());
+ testObject.setParam2("test String");
+ testObject.setParam3(5);
+ result = (TestClass6) getReturnObject(parameter,testObject);
+ assertNotNull(result.getParam1());
+ assertEquals(result.getParam2(),"test String");
+ assertEquals(result.getParam3(),5);
+
+ testObject = new TestClass6();
+
+ testObject.setParam1(new TestClass2());
+ testObject.getParam1().setParam1(5);
+ testObject.getParam1().setParam2(34.5f);
+ testObject.getParam1().setParam3(32.5);
+ testObject.setParam2("test String");
+ testObject.setParam3(5);
+ result = (TestClass6) getReturnObject(parameter,testObject);
+ assertEquals(result.getParam1().getParam1(),5);
+ assertTrue(result.getParam1().getParam2() == 34.5f);
+ assertTrue(result.getParam1().getParam3() == 32.5);
+ assertEquals(result.getParam2(),"test String");
+ assertEquals(result.getParam3(),5);
+ }
+}
Added: webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ComplexRequestResponseTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ComplexRequestResponseTest.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ComplexRequestResponseTest.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ComplexRequestResponseTest.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.databind;
+
+import org.apache.axis2.rmi.metadata.Operation;
+import org.apache.axis2.rmi.databind.service.Service2;
+import org.apache.axis2.rmi.databind.dto.TestClass1;
+import org.apache.axis2.rmi.databind.dto.TestClass2;
+
+import java.util.List;
+import java.util.ArrayList;
+
+
+public class ComplexRequestResponseTest extends RequestResponseTest {
+
+ protected void setUp() throws Exception {
+ this.serviceClass = Service2.class;
+ this.serviceObject = new Service2();
+ super.setUp();
+ }
+
+ public void testMethod1() {
+
+ try {
+ // first create service data
+
+ Operation operation = this.service.getOperation("method1");
+ // get objects after serialization and deserialization.
+ // this returned objects mustbe identical with the original array list elements
+ List inputObjects = new ArrayList();
+ inputObjects.add(new TestClass1());
+ Object[] objects = getInputObject(inputObjects, operation);
+
+ TestClass1 object = (TestClass1) operation.getJavaMethod().invoke(this.serviceObject, objects);
+ TestClass1 returnObject = (TestClass1) getReturnObject(object, operation);
+
+ assertNotNull(returnObject);
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ public void testMethod21() {
+
+ try {
+ // first create service data
+
+ Operation operation = this.service.getOperation("method2");
+ // get objects after serialization and deserialization.
+ // this returned objects mustbe identical with the original array list elements
+ List inputObjects = new ArrayList();
+ inputObjects.add(new TestClass1[]{new TestClass1(), new TestClass1()});
+ Object[] objects = getInputObject(inputObjects, operation);
+
+ TestClass1[] object = (TestClass1[]) operation.getJavaMethod().invoke(this.serviceObject, objects);
+ TestClass1[] returnObject = (TestClass1[]) getReturnObject(object, operation);
+
+ assertNotNull(returnObject[0]);
+ assertNotNull(returnObject[1]);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testMethod22() {
+
+ try {
+ // first create service data
+
+ Operation operation = this.service.getOperation("method2");
+ // get objects after serialization and deserialization.
+ // this returned objects mustbe identical with the original array list elements
+ List inputObjects = new ArrayList();
+ inputObjects.add(new TestClass1[]{new TestClass1(), null, new TestClass1()});
+ Object[] objects = getInputObject(inputObjects, operation);
+
+ TestClass1[] object = (TestClass1[]) operation.getJavaMethod().invoke(this.serviceObject, objects);
+ TestClass1[] returnObject = (TestClass1[]) getReturnObject(object, operation);
+
+ assertNotNull(returnObject[0]);
+ assertNull(returnObject[1]);
+ assertNotNull(returnObject[2]);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testMethod31() {
+
+ try {
+ // first create service data
+
+ Operation operation = this.service.getOperation("method3");
+ // get objects after serialization and deserialization.
+ // this returned objects mustbe identical with the original array list elements
+ List inputObjects = new ArrayList();
+ TestClass2 testClass2 = new TestClass2();
+ testClass2.setParam1(1);
+ testClass2.setParam2(34.5f);
+ testClass2.setParam3(23.5);
+ inputObjects.add(testClass2);
+ Object[] objects = getInputObject(inputObjects, operation);
+
+ TestClass2 object = (TestClass2) operation.getJavaMethod().invoke(this.serviceObject, objects);
+ TestClass2 returnObject = (TestClass2) getReturnObject(object, operation);
+
+ assertEquals(returnObject.getParam1(), 1);
+ assertTrue(returnObject.getParam2() == 34.5f);
+ assertTrue(returnObject.getParam3() == 23.5);
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ public void testMethod32() {
+
+ try {
+ // first create service data
+
+ Operation operation = this.service.getOperation("method3");
+ // get objects after serialization and deserialization.
+ // this returned objects mustbe identical with the original array list elements
+ List inputObjects = new ArrayList();
+ inputObjects.add(null);
+ Object[] objects = getInputObject(inputObjects, operation);
+
+ TestClass2 object = (TestClass2) operation.getJavaMethod().invoke(this.serviceObject, objects);
+ TestClass2 returnObject = (TestClass2) getReturnObject(object, operation);
+
+ assertNull(returnObject);
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ public void testMethod41() {
+
+ try {
+ // first create service data
+
+ Operation operation = this.service.getOperation("method4");
+ // get objects after serialization and deserialization.
+ // this returned objects mustbe identical with the original array list elements
+ List inputObjects = new ArrayList();
+
+ TestClass2 testClass21 = new TestClass2();
+ testClass21.setParam1(1);
+ testClass21.setParam2(34.5f);
+ testClass21.setParam3(23.5);
+
+ TestClass2 testClass22 = new TestClass2();
+ testClass22.setParam1(1);
+ testClass22.setParam2(34.5f);
+ testClass22.setParam3(23.5);
+
+ TestClass2 testClass23 = new TestClass2();
+ testClass23.setParam1(1);
+ testClass23.setParam2(34.5f);
+ testClass23.setParam3(23.5);
+
+ inputObjects.add(new TestClass2[]{testClass21,testClass22,testClass23});
+ Object[] objects = getInputObject(inputObjects, operation);
+
+ TestClass2[] object = (TestClass2[]) operation.getJavaMethod().invoke(this.serviceObject, objects);
+ TestClass2[] returnObject = (TestClass2[]) getReturnObject(object, operation);
+
+ assertEquals(returnObject[0].getParam1(), 1);
+ assertTrue(returnObject[0].getParam2() == 34.5f);
+ assertTrue(returnObject[0].getParam3() == 23.5);
+
+ assertEquals(returnObject[1].getParam1(), 1);
+ assertTrue(returnObject[1].getParam2() == 34.5f);
+ assertTrue(returnObject[1].getParam3() == 23.5);
+
+ assertEquals(returnObject[2].getParam1(), 1);
+ assertTrue(returnObject[2].getParam2() == 34.5f);
+ assertTrue(returnObject[2].getParam3() == 23.5);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+
+}
Added: webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ConfigObjectTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ConfigObjectTest.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ConfigObjectTest.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ConfigObjectTest.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.databind;
+
+import org.apache.axis2.rmi.deploy.config.*;
+import org.apache.axis2.rmi.metadata.Parameter;
+import org.apache.axis2.rmi.exception.MetaDataPopulateException;
+import org.apache.axis2.rmi.exception.SchemaGenerationException;
+import org.apache.axis2.rmi.exception.XmlSerializingException;
+import org.apache.axis2.rmi.exception.XmlParsingException;
+import org.apache.axis2.rmi.util.NamespacePrefix;
+import org.apache.axiom.om.util.StAXUtils;
+
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.io.*;
+
+
+public class ConfigObjectTest extends DataBindTest {
+
+ public void testConfigObject() {
+
+ Config config = new Config();
+
+ Service[] services = new Service[2];
+ services[0] = new Service();
+ services[0].setServiceClass("Service1");
+
+ services[1] = new Service();
+ services[1].setServiceClass("Service2");
+
+ Services testServices = new Services();
+ testServices.setService(services);
+ config.setServices(testServices);
+
+ ExtensionClasses extensionClasses = new ExtensionClasses();
+ extensionClasses.setExtensionClass(new String[]{"extension1", "extension2"});
+ config.setExtensionClasses(extensionClasses);
+
+ PackageToNamespaceMapings packageToNamespaceMapings = new PackageToNamespaceMapings();
+
+ PackageToNamespaceMap[] packageToNamespaceMaps = new PackageToNamespaceMap[2];
+ packageToNamespaceMaps[0] = new PackageToNamespaceMap();
+ packageToNamespaceMaps[0].setNamespace("ns1");
+ packageToNamespaceMaps[0].setPackageName("package1");
+
+ packageToNamespaceMaps[1] = new PackageToNamespaceMap();
+ packageToNamespaceMaps[1].setNamespace("ns2");
+ packageToNamespaceMaps[1].setPackageName("package2");
+ packageToNamespaceMapings.setPackageToNamespaceMap(packageToNamespaceMaps);
+ config.setPackageToNamespaceMapings(packageToNamespaceMapings);
+
+
+ Parameter parameter = new Parameter(Config.class, "config");
+ parameter.setNamespace("http://ws.apache.org/axis2/rmi");
+
+
+ try {
+ this.configurator.addPackageToNamespaceMaping("org.apache.axis2.rmi.deploy.config",
+ "http://ws.apache.org/axis2/rmi");
+ parameter.populateMetaData(configurator, processedMap);
+ parameter.generateSchema(configurator, schemaMap);
+ StringWriter configXmlWriter = new StringWriter();
+ XMLStreamWriter writer = StAXUtils.createXMLStreamWriter(configXmlWriter);
+ JavaObjectSerializer javaObjectSerializer = new JavaObjectSerializer(this.processedMap, this.configurator, this.schemaMap);
+ javaObjectSerializer.serializeParameter(config, parameter, writer, new NamespacePrefix());
+ writer.flush();
+
+ String configXmlString = configXmlWriter.toString();
+
+ XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(configXmlString.getBytes()));
+ XmlStreamParser xmlStreamParser = new XmlStreamParser(this.processedMap, this.configurator, this.schemaMap);
+ Config result = (Config) xmlStreamParser.getObjectForParameter(xmlReader, parameter);
+ System.out.println("OK");
+ } catch (XMLStreamException e) {
+ fail();
+ } catch (SchemaGenerationException e) {
+ fail();
+ } catch (MetaDataPopulateException e) {
+ fail();
+ } catch (XmlSerializingException e) {
+ fail();
+ } catch (XmlParsingException e) {
+ fail();
+ }
+
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/DataBindTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/DataBindTest.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/DataBindTest.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/DataBindTest.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.databind;
+
+import junit.framework.TestCase;
+import org.apache.axis2.rmi.Configurator;
+import org.apache.axis2.rmi.exception.MetaDataPopulateException;
+import org.apache.axis2.rmi.exception.SchemaGenerationException;
+import org.apache.axis2.rmi.exception.XmlSerializingException;
+import org.apache.axis2.rmi.exception.XmlParsingException;
+import org.apache.axis2.rmi.util.NamespacePrefix;
+import org.apache.axis2.rmi.metadata.Parameter;
+import org.apache.axiom.om.util.StAXUtils;
+
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
+import java.util.Map;
+import java.util.HashMap;
+import java.io.StringWriter;
+import java.io.ByteArrayInputStream;
+
+public class DataBindTest extends TestCase {
+
+ protected JavaObjectSerializer javaObjectSerializer;
+ protected XmlStreamParser xmlStreamParser;
+ protected Configurator configurator;
+ protected Map processedMap;
+ protected Map schemaMap;
+
+ protected void setUp() throws Exception {
+ this.configurator = new Configurator();
+ this.processedMap = new HashMap();
+ this.schemaMap = new HashMap();
+ this.javaObjectSerializer = new JavaObjectSerializer(this.processedMap,this.configurator,this.schemaMap);
+ this.xmlStreamParser = new XmlStreamParser(this.processedMap,this.configurator,this.schemaMap);
+ }
+
+ protected Object getReturnObject(Parameter parameter, Object inputObject) {
+
+ Object reutnObject = null;
+ try {
+ parameter.populateMetaData(configurator, processedMap);
+ parameter.generateSchema(configurator, schemaMap);
+
+ StringWriter stringWriter = new StringWriter();
+ XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(stringWriter);
+ javaObjectSerializer.serializeParameter(inputObject, parameter, xmlStreamWriter, new NamespacePrefix());
+ xmlStreamWriter.flush();
+ String xmlString = stringWriter.toString();
+ System.out.println("Xml String ==> " + xmlString);
+ XMLStreamReader reader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(xmlString.getBytes()));
+ reutnObject = xmlStreamParser.getObjectForParameter(reader, parameter);
+ } catch (MetaDataPopulateException e) {
+ fail();
+ } catch (SchemaGenerationException e) {
+ fail();
+ } catch (XMLStreamException e) {
+ fail();
+ } catch (XmlSerializingException e) {
+ fail();
+ } catch (XmlParsingException e) {
+ e.printStackTrace();
+ fail();
+ }
+ return reutnObject;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ExtensionRequestResponseTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ExtensionRequestResponseTest.java?view=auto&rev=565239
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ExtensionRequestResponseTest.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ExtensionRequestResponseTest.java Sun Aug 12 22:05:58 2007
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.databind;
+
+import org.apache.axis2.rmi.Configurator;
+import org.apache.axis2.rmi.databind.dto.ChildClass;
+import org.apache.axis2.rmi.databind.service.Service3;
+import org.apache.axis2.rmi.metadata.Operation;
+import org.apache.axis2.rmi.metadata.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Date;
+
+
+public class ExtensionRequestResponseTest extends RequestResponseTest {
+
+ protected void setUp() throws Exception {
+ this.serviceClass = Service3.class;
+ this.serviceObject = new Service3();
+
+ this.configurator = new Configurator();
+ this.configurator.addExtension(ChildClass.class);
+
+ this.processedMap = new HashMap();
+ this.schemaMap = new HashMap();
+
+ this.service = new Service(this.serviceClass, this.configurator);
+ this.service.populateMetaData();
+ this.service.generateWSDL();
+ this.javaObjectSerializer = new JavaObjectSerializer(service.getProcessedTypeMap(),
+ this.service.getConfigurator(),
+ this.service.getSchemaMap());
+ this.xmlStreamParser = new XmlStreamParser(service.getProcessedTypeMap(),
+ this.service.getConfigurator(),
+ this.service.getSchemaMap());
+
+ }
+
+ public void testMethod1(){
+ try {
+ // first create service data
+
+ Operation operation = this.service.getOperation("method1");
+ // get objects after serialization and deserialization.
+ // this returned objects mustbe identical with the original array list elements
+ List inputObjects = new ArrayList();
+ ChildClass childClass = new ChildClass();
+ childClass.setParam1("test param1");
+ childClass.setParam2(5);
+ childClass.setParam3(23.45f);
+ childClass.setParam4(34.5);
+ inputObjects.add(childClass);
+ Object[] objects = getInputObject(inputObjects, operation);
+
+ ChildClass object = (ChildClass) operation.getJavaMethod().invoke(this.serviceObject, objects);
+ ChildClass returnObject = (ChildClass) getReturnObject(object, operation);
+
+ assertEquals(returnObject.getParam1(),"test param1");
+ assertEquals(returnObject.getParam2(),5);
+ assertTrue(childClass.getParam3() == 23.45f);
+ assertTrue(childClass.getParam4() == 34.5);
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ public void testMethod21(){
+ try {
+ // first create service data
+
+ Operation operation = this.service.getOperation("method2");
+ // get objects after serialization and deserialization.
+ // this returned objects mustbe identical with the original array list elements
+ List inputObjects = new ArrayList();
+ inputObjects.add(new Object());
+ Object[] objects = getInputObject(inputObjects, operation);
+
+ Object object = operation.getJavaMethod().invoke(this.serviceObject, objects);
+ Object returnObject = getReturnObject(object, operation);
+
+ assertNotNull(returnObject);
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ public void testMethod22(){
+ try {
+ // first create service data
+
+ Operation operation = this.service.getOperation("method2");
+ // get objects after serialization and deserialization.
+ // this returned objects mustbe identical with the original array list elements
+ List inputObjects = new ArrayList();
+ Date date = new Date();
+ inputObjects.add(date);
+ Object[] objects = getInputObject(inputObjects, operation);
+
+ Date object = (Date) operation.getJavaMethod().invoke(this.serviceObject, objects);
+ Date returnObject = (Date) getReturnObject(object, operation);
+
+ assertEquals(returnObject.getDate(),date.getDate());
+ } catch (Exception e) {
+ fail();
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org