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 di...@apache.org on 2008/05/06 22:30:29 UTC
svn commit: r653910 - in /webservices/axis2/trunk/java/modules/java2wsdl:
src/org/apache/ws/java2wsdl/ test/org/apache/ test/org/apache/axis2/
test/org/apache/axis2/description/
Author: dims
Date: Tue May 6 13:30:28 2008
New Revision: 653910
URL: http://svn.apache.org/viewvc?rev=653910&view=rev
Log:
add a test case stripped down from a sample originally from Louis A Amodeo
Added:
webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/
webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/axis2/
webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/axis2/description/
webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/axis2/description/CalculatorService.java
webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/axis2/description/DivideByZeroException.java
webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/axis2/description/Java2WSDLTest.java
Modified:
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java
Modified: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java?rev=653910&r1=653909&r2=653910&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java Tue May 6 13:30:28 2008
@@ -80,8 +80,9 @@
// location of the class name to package mapping file
// File is simple file with qualifiedClassName:SchemaQName
private String mappingFileLocation;
+ private HashMap messageReceivers;
- public Java2WSDLBuilder() {
+ public Java2WSDLBuilder() {
try {
ConfigurationContext configCtx = ConfigurationContextFactory
.createDefaultConfigurationContext();
@@ -109,7 +110,13 @@
}
}
- public String getSchemaTargetNamespace() throws Exception {
+ public Java2WSDLBuilder(OutputStream out, String className,
+ ClassLoader classLoader, HashMap messageReceivers) {
+ this(out, className, classLoader);
+ this.messageReceivers = messageReceivers;
+ }
+
+ public String getSchemaTargetNamespace() throws Exception {
if (schemaTargetNamespace == null) {
schemaTargetNamespace = Java2WSDLUtils
.schemaNamespaceFromClassName(className, classLoader,
@@ -223,24 +230,25 @@
schemaGenerator.setUseWSDLTypesNamespace(true);
}
- HashMap messageReciverMap = new HashMap();
- Class inOnlyMessageReceiver = Loader
- .loadClass("org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver");
- MessageReceiver messageReceiver = (MessageReceiver) inOnlyMessageReceiver
- .newInstance();
- messageReciverMap.put(WSDL2Constants.MEP_URI_IN_ONLY, messageReceiver);
- Class inoutMessageReceiver = Loader
- .loadClass("org.apache.axis2.rpc.receivers.RPCMessageReceiver");
- MessageReceiver inOutmessageReceiver = (MessageReceiver) inoutMessageReceiver
- .newInstance();
- messageReciverMap.put(WSDL2Constants.MEP_URI_IN_OUT,
- inOutmessageReceiver);
- AxisService service = new AxisService();
+ if(messageReceivers == null) {
+ Class inOnlyMessageReceiver = Loader
+ .loadClass("org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver");
+ MessageReceiver messageReceiver = (MessageReceiver) inOnlyMessageReceiver
+ .newInstance();
+ messageReceivers.put(WSDL2Constants.MEP_URI_IN_ONLY, messageReceiver);
+ Class inoutMessageReceiver = Loader
+ .loadClass("org.apache.axis2.rpc.receivers.RPCMessageReceiver");
+ MessageReceiver inOutmessageReceiver = (MessageReceiver) inoutMessageReceiver
+ .newInstance();
+ messageReceivers.put(WSDL2Constants.MEP_URI_IN_OUT,
+ inOutmessageReceiver);
+ }
+ AxisService service = new AxisService();
schemaGenerator.setAxisService(service);
AxisService axisService = AxisService.createService(className,
serviceName == null ? Java2WSDLUtils
.getSimpleClassName(className) : serviceName,
- axisConfig, messageReciverMap,
+ axisConfig, messageReceivers,
targetNamespace == null ? Java2WSDLUtils
.namespaceFromClassName(className, classLoader,
resolveNSGen()).toString() : targetNamespace,
Added: webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/axis2/description/CalculatorService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/axis2/description/CalculatorService.java?rev=653910&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/axis2/description/CalculatorService.java (added)
+++ webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/axis2/description/CalculatorService.java Tue May 6 13:30:28 2008
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.description;
+
+public class CalculatorService {
+ public void multiply(int number){
+ runningTotal *= number;
+ }
+
+ public void add(int number){
+ runningTotal += number;
+ }
+
+ public void divide(int number)throws DivideByZeroException{
+ if(number == 0)
+ {
+ throw new DivideByZeroException("CalculatorService tried to divide by zero", runningTotal);
+ } else
+ {
+ runningTotal = runningTotal / number;
+ return;
+ }
+ }
+
+ public void subtract(int number){
+ runningTotal = runningTotal - number;
+ }
+
+ public int getTotal(){
+ return runningTotal;
+ }
+
+ public void clear(){
+ runningTotal = 0;
+ }
+ private int runningTotal;
+}
Added: webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/axis2/description/DivideByZeroException.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/axis2/description/DivideByZeroException.java?rev=653910&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/axis2/description/DivideByZeroException.java (added)
+++ webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/axis2/description/DivideByZeroException.java Tue May 6 13:30:28 2008
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.description;
+
+public class DivideByZeroException extends Exception
+{
+
+ public DivideByZeroException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public DivideByZeroException(String message, int fault)
+ {
+ super(message);
+ this.fault = fault;
+ }
+
+ public DivideByZeroException(String message, int fault, Throwable cause)
+ {
+ super(message, cause);
+ this.fault = fault;
+ }
+
+ public int getFaultInfo()
+ {
+ return fault;
+ }
+
+ private int fault;
+}
Added: webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/axis2/description/Java2WSDLTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/axis2/description/Java2WSDLTest.java?rev=653910&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/axis2/description/Java2WSDLTest.java (added)
+++ webservices/axis2/trunk/java/modules/java2wsdl/test/org/apache/axis2/description/Java2WSDLTest.java Tue May 6 13:30:28 2008
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.description;
+
+import junit.framework.TestCase;
+import org.apache.ws.java2wsdl.Java2WSDLBuilder;
+import org.xml.sax.InputSource;
+
+import javax.wsdl.Definition;
+import javax.wsdl.xml.WSDLReader;
+import javax.wsdl.factory.WSDLFactory;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.HashMap;
+
+public class Java2WSDLTest extends TestCase {
+ public void test1() throws Exception {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ Java2WSDLBuilder builder = new Java2WSDLBuilder(out, CalculatorService.class.getName(), CalculatorService.class.getClassLoader(), new HashMap());
+ builder.generateWSDL();
+ InputSource inputSource = new InputSource(new ByteArrayInputStream(out.toByteArray()));
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ Definition definition = wsdlReader.readWSDL(null, inputSource);
+ assertNotNull(definition);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org