You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by mm...@apache.org on 2004/09/14 02:05:22 UTC

svn commit: rev 46004 - in incubator/beehive/trunk/wsm: . drt drt/tests/org/apache/beehive/wsm/axis src/runtime/org/apache/beehive/wsm/jsr181/model src/runtime/org/apache/beehive/wsm/jsr181/wsdl

Author: mmerz
Date: Mon Sep 13 17:05:21 2004
New Revision: 46004

Added:
   incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/
   incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/AxisHookTest.java   (contents, props changed)
Modified:
   incubator/beehive/trunk/wsm/build.xml
   incubator/beehive/trunk/wsm/drt/build.xml
   incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceMETHODMetadata.java
   incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceTYPEMetadata.java
   incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/WSDLProcessor.java
Log:
Modified the drt to test some axis dependent components and modified the constructors of the metadata classes to take a few required values in cases where no annotations are available.



Modified: incubator/beehive/trunk/wsm/build.xml
==============================================================================
--- incubator/beehive/trunk/wsm/build.xml	(original)
+++ incubator/beehive/trunk/wsm/build.xml	Mon Sep 13 17:05:21 2004
@@ -334,7 +334,7 @@
   <!-- ==================================================================== -->
   <!-- drt -->
   <!-- ==================================================================== -->
-  <target name="drt" depends="build">
+  <target name="drt" depends="build_all">
     <ant dir="drt" target="drt" inheritAll="false"/>
   </target>
 

Modified: incubator/beehive/trunk/wsm/drt/build.xml
==============================================================================
--- incubator/beehive/trunk/wsm/drt/build.xml	(original)
+++ incubator/beehive/trunk/wsm/drt/build.xml	Mon Sep 13 17:05:21 2004
@@ -21,6 +21,9 @@
        <os family="unix" />
     </condition>
 
+    <property name="lib.dir" value="../lib"/>
+    <property name="ext.lib.dir" value="../external"/>
+
     <!-- =================================================================== -->
     <!-- Usage - print the usage -->
     <!-- ==================================================================== -->
@@ -39,12 +42,27 @@
         <echo message="----------------------------------------------------------------"/>
     </target>
 
+
+    <fileset id="axis.jars" dir="${ext.lib.dir}">
+        <include name="wsdl4j.jar"/>
+        <include name="saaj.jar"/>
+        <include name="jaxrpc.jar"/>
+        <include name="commons-logging.jar"/>
+        <include name="commons-discovery.jar"/>
+        <include name="axis-ant.jar"/>
+        <include name="axis.jar"/>
+    </fileset>
+
     <path id="drt.classpath">
         <pathelement location="${junit.jar}"/>
         <pathelement location="${tools.jar}"/>
-        <pathelement path="${xbean.jar}" />
-        <pathelement path="../lib/xmltypes.jar"/>
-        <pathelement path="../build/jars/wsm.jar"/>
+        <pathelement location="${xbean.jar}" />
+        <pathelement location="${jsr173.jar}" />
+        <pathelement location="${log4j.jar}"/>
+        <pathelement location="${lib.dir}/xmltypes.jar"/>
+        <pathelement location="../build/jars/wsm.jar"/>
+        <pathelement location="../build/jars/wsm-axis.jar"/>
+        <fileset refid="axis.jars"/>
     </path>
 
     <target name="clean">
@@ -79,12 +97,8 @@
         <echo message="** junit logfiles written to ${drt.logs} **" />
         <junit haltonerror="off" printsummary="on" tempdir="${build.dir}" fork="yes">
             <classpath>
-                <pathelement location="${tools.jar}" />
-                <pathelement location="${build.tests}" />
-                <pathelement path="${xbean.jar}" />
-                <pathelement path="${jsr173.jar}" />
-                <pathelement path="../lib/xmltypes.jar"/>
-                <pathelement path="../build/jars/wsm.jar"/>
+                <pathelement location= "${build.tests}"/>
+                <path refid="drt.classpath"/>
             </classpath>
             <formatter type="plain" />
             <batchtest filtertrace="off" todir="${drt.logs}" >

Added: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/AxisHookTest.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/AxisHookTest.java	Mon Sep 13 17:05:21 2004
@@ -0,0 +1,193 @@
+/*
+ * AxisHookTest.java
+ * 
+ * Copyright 2001-2004 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.beehive.wsm.axis;
+
+import junit.framework.TestCase;
+
+import javax.jws.WebParam;
+import javax.jws.soap.SOAPBinding;
+
+import org.apache.axis.description.ServiceDesc;
+//import org.apache.axis.description.JavaServiceDesc;
+import org.apache.axis.description.ParameterDesc;
+import org.apache.axis.description.OperationDesc;
+import org.apache.beehive.wsm.axis.badtiger.EnumWrapper;
+import org.apache.beehive.wsm.jsr181.model.WebServiceTYPEMetadata;
+import org.apache.beehive.wsm.jsr181.model.WebServiceMETHODMetadata;
+import org.apache.beehive.wsm.jsr181.model.WebServicePARAMETERMetadata;
+import org.apache.beehive.wsm.jsr181.model.SOAPBindingInfo;
+
+/*******************************************************************************
+ * 
+ *
+ * @author Jonathan Colwell
+ */
+public class AxisHookTest extends TestCase {
+
+
+    public static final Class WS_CLASS = FakeWebService.class;
+    public static final String WM_JAVAMETHODNAME = "fakeWebMethod";
+    public static final String WM_JAVAONEWAYMETHODNAME = "fakeOneWayWebMethod";
+    public static final String WS_NAME = "WebServiceName";
+    //public static final String WS_SERVICENAME = WS_NAME + "Service";
+    public static final String WS_NAMESPACE = "http://web.service/namespace";
+    public static final String WM_OPERATION = "OperationName";
+    public static final String WM_ACTION = "Lights_Camera_Action!";
+    public static final String WM_RESULT = "ResultName";
+    public static final String WM_ONEWAY = "Oneway";
+    public static final String WM_TWOWAYPARAM = "number";
+    public static final String WM_ONEWAYPARAM = "text";
+
+    public void setUp() {
+    
+    }
+    
+    public void tearDown() {
+    }
+
+    public void testCreateServiceDesc() throws Exception
+    {
+        WebServiceTYPEMetadata wsm = makeFakeMetadata();
+        ServiceDesc sd = AxisHook.createServiceDesc(wsm, null);
+
+        examineServiceDesc(sd);
+    }
+
+    /**
+     * @return true if the ServiceDesc contains the expected values
+     */
+    protected void examineServiceDesc(ServiceDesc sd)
+    {
+        assertEquals(WS_NAME, sd.getName());
+        assertEquals(WS_NAMESPACE, sd.getDefaultNamespace());
+        assertEquals(EnumWrapper.LITERAL, sd.getUse());
+
+        /*
+         * NOTE jcolwell@bea.com 2004-Sep-13 -- 
+         * in AXIS, WRAPPED is considered a Style and overrides DOCUMENT
+         * rather than living next to it as ParameterStyle does in jsr-181
+         */
+        //assertTrue(EnumWrapper.DOCUMENT.equals(sd.getStyle()));
+        assertEquals(EnumWrapper.WRAPPED, sd.getStyle());
+        OperationDesc twoWayOp = sd.getOperationByName(WM_JAVAMETHODNAME);
+        assertNotNull(twoWayOp);
+        if (twoWayOp != null) {
+            assertEquals(WM_ACTION, twoWayOp.getSoapAction());
+            // NOTE jcolwell@bea.com 2004-Sep-13 -- 
+            //check that this is method returns something
+            ParameterDesc param = twoWayOp.getParameter(0);
+            assertNotNull(param);
+            if (param != null) {
+                assertEquals(WM_TWOWAYPARAM, param.getName());
+                assertEquals(Integer.TYPE, param.getJavaType());
+                assertEquals(ParameterDesc.INOUT, param.getMode());
+            }
+        }
+            
+        OperationDesc oneWayOp = sd.getOperationByName(WM_JAVAONEWAYMETHODNAME);
+        assertNotNull(oneWayOp);
+        if (oneWayOp != null) {
+            assertEquals(WM_ONEWAY + WM_ACTION, oneWayOp.getSoapAction());
+            // NOTE jcolwell@bea.com 2004-Sep-13 -- 
+            // make sure this method does not return anything
+            ParameterDesc param = oneWayOp.getParameter(0);
+            assertNotNull(param);
+            if (param != null) {
+                assertEquals(WM_ONEWAYPARAM, param.getName());
+                assertEquals(String.class, param.getJavaType());
+                assertEquals(ParameterDesc.IN, param.getMode());
+            }
+        }
+    }
+     
+    protected WebServiceTYPEMetadata makeFakeMetadata()
+    {
+        WebServiceTYPEMetadata wstm =
+            new WebServiceTYPEMetadata(WS_CLASS.getName());
+        wstm.setWsName(WS_NAME);
+        /*
+         * NOTE jcolwell@bea.com 2004-Sep-13 -- 
+         * service name not used in the ServiceDesc
+         */
+        //wstm.setWsServiceName(WS_SERVICENAME);
+        wstm.setWsTargetNamespace(WS_NAMESPACE);
+        wstm.setSoapBinding(makeFakeSoapBinding());
+        wstm.addMethod(makeFakeMethod());
+        wstm.addMethod(makeFakeOnewayMethod());
+
+        return wstm;
+    }
+
+    protected WebServiceMETHODMetadata makeFakeOnewayMethod()
+    {
+        WebServiceMETHODMetadata wsmm = 
+            new WebServiceMETHODMetadata(WM_JAVAONEWAYMETHODNAME, Void.TYPE);
+        wsmm.setWmOperationName(WM_ONEWAY + WM_OPERATION);
+        wsmm.setWmAction(WM_ONEWAY + WM_ACTION);
+        wsmm.setOneWay(true);
+
+        WebServicePARAMETERMetadata wspm = new WebServicePARAMETERMetadata();
+        wspm.setJavaType(String.class);
+        wspm.setWpName(WM_ONEWAYPARAM);
+        wspm.setWpMode(WebParam.Mode.IN);
+        wsmm.addParam(wspm);
+
+        return wsmm;
+    }
+
+
+    protected WebServiceMETHODMetadata makeFakeMethod()
+    {
+        WebServiceMETHODMetadata wsmm =
+            new WebServiceMETHODMetadata(WM_JAVAMETHODNAME, String.class);
+        wsmm.setWmOperationName(WM_OPERATION);
+        wsmm.setWmAction(WM_ACTION);
+        wsmm.setWrName(WM_RESULT);
+        wsmm.setOneWay(false);
+        
+        WebServicePARAMETERMetadata wspm = new WebServicePARAMETERMetadata();
+        wspm.setJavaType(Integer.TYPE);
+        wspm.setWpName(WM_TWOWAYPARAM);
+        wspm.setWpMode(WebParam.Mode.INOUT);
+        wsmm.addParam(wspm);
+
+        return wsmm;
+    }
+
+    protected SOAPBindingInfo makeFakeSoapBinding()
+    {
+        SOAPBindingInfo sbi = new SOAPBindingInfo();
+        sbi.setStyle(SOAPBinding.Style.DOCUMENT);
+        sbi.setUse(SOAPBinding.Use.LITERAL);
+        sbi.setParameterStyle(SOAPBinding.ParameterStyle.WRAPPED);
+        return sbi;
+    }
+
+    public static class FakeWebService {
+
+        public String fakeWebMethod(int num) {
+            return "You're number " + Integer.toString(num) + '!';
+        }
+
+        public void fakeOneWayWebMethod(String text) {
+            //do nothing
+        }
+    }
+}

Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceMETHODMetadata.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceMETHODMetadata.java	(original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceMETHODMetadata.java	Mon Sep 13 17:05:21 2004
@@ -63,13 +63,17 @@
     /**
      *  
      */
-    public WebServiceMETHODMetadata() {
+    public WebServiceMETHODMetadata(String methodName,
+                                    Class returnType) {
         super();
+        javaMethodName = methodName;
+        javaReturnType = returnType;
     }
 
     public WebServiceMETHODMetadata(javax.jws.WebMethod methodAnnotation, 
             String javaMethodName, Class javaReturnType,
             Collection<Annotation> annotations, List< ? extends WebServicePARAMETERMetadata> webParams) {
+        super();
         // check parameters
         if ((null == javaMethodName) || (null == javaReturnType)) {
             throw new IllegalArgumentException(
@@ -349,4 +353,4 @@
         return javaReturnType;
     }
 
-}
\ No newline at end of file
+}

Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceTYPEMetadata.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceTYPEMetadata.java	(original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceTYPEMetadata.java	Mon Sep 13 17:05:21 2004
@@ -63,8 +63,10 @@
     /**
      *  
      */
-    public WebServiceTYPEMetadata() {
+    public WebServiceTYPEMetadata(String fqClassName) {
         super();
+
+        javaFQClassName = fqClassName;
     }
 
 //    TODO:  not used anymore, remove it.
@@ -432,4 +434,4 @@
     public String getJavaFQClassName() {
         return javaFQClassName;
     }
-}
\ No newline at end of file
+}

Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/WSDLProcessor.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/WSDLProcessor.java	(original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/WSDLProcessor.java	Mon Sep 13 17:05:21 2004
@@ -83,7 +83,7 @@
         throws IllegalAccessException, NoSuchFieldException
     {
         
-        WebServiceTYPEMetadata wsm = new WebServiceTYPEMetadata();
+        WebServiceTYPEMetadata wsm = new WebServiceTYPEMetadata(null);
         Map<String, WebServiceMETHODMetadata> methodMap = 
             new HashMap<String, WebServiceMETHODMetadata>();
         TDefinitions defs = defDoc.getDefinitions();
@@ -169,12 +169,9 @@
                                           WebServiceMETHODMetadata> methodMap,
                                           Map<String, TPart[]> messageMap)
     {
-        WebServiceMETHODMetadata wmm = new WebServiceMETHODMetadata();
         String opName = op.getName();
-        //wmm.setJavaMethodName(opName);
-        wmm.setWmOperationName(opName);
-        methodMap.put(opName, wmm);
         TParam outputParam = op.getOutput();
+        Class returnType = Void.TYPE;
         if (outputParam != null) {
             TPart[] returnTypes = messageMap
                 .get(outputParam.getMessage().getLocalPart());
@@ -183,20 +180,20 @@
 
                 String returnName = returnTypes[0].getName();
                 QName qReturnType = returnTypes[0].getType();
+                
                 /*
-                  wmm.setJavaReturnType(qReturnType
-                  .getNamespaceURI()
-                  + '.' + qReturnType
-                  .getLocalPart());
-                */
-            }
-            else {
-                //wmm.setJavaReturnType("void");
+                 * FIXME jcolwell@bea.com 2004-Sep-13 -- 
+                 * properly convert the QName to a java class
+                 */
+                returnType = null;
             }
         }
-        else {
-            //wmm.setJavaReturnType("void");
-        }
+        WebServiceMETHODMetadata wmm = 
+            new WebServiceMETHODMetadata(opName, returnType);
+        //wmm.setJavaMethodName(opName);
+        wmm.setWmOperationName(opName);
+        methodMap.put(opName, wmm);
+      
 
         List paramOrder = op.getParameterOrder();
         if (paramOrder != null) {