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/22 00:43:12 UTC
svn commit: rev 47005 - in incubator/beehive/trunk/wsm: drt/tests/org/apache/beehive/wsm/axis src/runtime/org/apache/beehive/wsm/axis
Author: mmerz
Date: Tue Sep 21 15:43:11 2004
New Revision: 47005
Added:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/DropInDeploymentHandlerTest.java (contents, props changed)
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/FakeWebService.java (contents, props changed)
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/ModeratelyComplexObject.java (contents, props changed)
Modified:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/AxisHookTest.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java
Log:
Added test cases for the DropInDeploymentHandler.
Contributor: Jonathan Colwell
Modified: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/AxisHookTest.java
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/AxisHookTest.java (original)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/AxisHookTest.java Tue Sep 21 15:43:11 2004
@@ -23,7 +23,7 @@
import javax.jws.WebParam;
import javax.jws.soap.SOAPBinding;
-
+import javax.wsdl.OperationType;
import org.apache.axis.description.ServiceDesc;
//import org.apache.axis.description.JavaServiceDesc;
import org.apache.axis.description.ParameterDesc;
@@ -55,30 +55,37 @@
public static final String WM_TWOWAYPARAM = "number";
public static final String WM_ONEWAYPARAM = "text";
- public void setUp() {
-
+
+ ServiceDesc sd;
+
+ public void setUp() throws Exception {
+
+ WebServiceTYPEMetadata wsm = makeFakeMetadata();
+ sd = AxisHook.createServiceDesc(wsm, null);
}
public void tearDown() {
}
- public void testCreateServiceDesc() throws Exception
+ public void testName() throws Exception
{
- WebServiceTYPEMetadata wsm = makeFakeMetadata();
- ServiceDesc sd = AxisHook.createServiceDesc(wsm, null);
-
- examineServiceDesc(sd);
+ assertEquals(WS_NAME, sd.getName());
}
- /**
- * @return true if the ServiceDesc contains the expected values
- */
- protected void examineServiceDesc(ServiceDesc sd)
+
+ public void testNamespace() throws Exception
{
- assertEquals(WS_NAME, sd.getName());
assertEquals(WS_NAMESPACE, sd.getDefaultNamespace());
+ }
+
+
+ public void testUse() throws Exception
+ {
assertEquals(EnumWrapper.LITERAL, sd.getUse());
+ }
+ public void testStyle() throws Exception
+ {
/*
* NOTE jcolwell@bea.com 2004-Sep-13 --
* in AXIS, WRAPPED is considered a Style and overrides DOCUMENT
@@ -86,12 +93,18 @@
*/
//assertTrue(EnumWrapper.DOCUMENT.equals(sd.getStyle()));
assertEquals(EnumWrapper.WRAPPED, sd.getStyle());
+ }
+
+
+ public void testTwoWayOperation() throws Exception
+ {
OperationDesc twoWayOp = sd.getOperationByName(WM_OPERATION);
assertNotNull(twoWayOp);
if (twoWayOp != null) {
assertEquals(WM_ACTION, twoWayOp.getSoapAction());
+ assertEquals(OperationType.REQUEST_RESPONSE, twoWayOp.getMep());
// NOTE jcolwell@bea.com 2004-Sep-13 --
- //check that this is method returns something
+ //check that this method returns something
ParameterDesc param = twoWayOp.getParameter(0);
assertNotNull(param);
if (param != null) {
@@ -100,11 +113,15 @@
assertEquals(ParameterDesc.INOUT, param.getMode());
}
}
+ }
+ public void testOneWayOperation() throws Exception
+ {
OperationDesc oneWayOp = sd.getOperationByName(WM_ONEWAY + WM_OPERATION);
assertNotNull(oneWayOp);
if (oneWayOp != null) {
assertEquals(WM_ONEWAY + WM_ACTION, oneWayOp.getSoapAction());
+ assertEquals(OperationType.ONE_WAY, oneWayOp.getMep());
// NOTE jcolwell@bea.com 2004-Sep-13 --
// make sure this method does not return anything
ParameterDesc param = oneWayOp.getParameter(0);
Added: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/DropInDeploymentHandlerTest.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/DropInDeploymentHandlerTest.java Tue Sep 21 15:43:11 2004
@@ -0,0 +1,158 @@
+/*
+ * DropInDeploymentHandlerTest.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 javax.xml.namespace.QName;
+
+import org.apache.axis.Message;
+import org.apache.axis.MessageContext;
+import org.apache.axis.description.ServiceDesc;
+import org.apache.axis.description.ParameterDesc;
+import org.apache.axis.description.OperationDesc;
+import org.apache.axis.handlers.soap.SOAPService;
+import org.apache.axis.message.RPCElement;
+import org.apache.axis.message.SOAPEnvelope;
+import org.apache.axis.server.AxisServer;
+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;
+import org.apache.beehive.wsm.jsr181.wsdl.WSDLProcessor;
+
+import org.w3c.dom.Node;
+import org.xmlsoap.schemas.wsdl.DefinitionsDocument;
+import org.xmlsoap.schemas.wsdl.TDefinitions;
+import org.xmlsoap.schemas.wsdl.TService;
+import org.xmlsoap.schemas.wsdl.TBinding;
+import org.xmlsoap.schemas.wsdl.TBindingOperation;
+import org.xmlsoap.schemas.wsdl.soap.TOperation;
+import org.xmlsoap.schemas.wsdl.soap.TStyleChoice;
+
+
+/*******************************************************************************
+ * NOTE jcolwell@bea.com 2004-Sep-21 --
+ * The FakeWebService and this class should be expanded to test most of the
+ * JSR-181 annotations.
+ *
+ * @author Jonathan Colwell
+ */
+public class DropInDeploymentHandlerTest extends TestCase {
+
+ SOAPService fakeSOAPService;
+
+ public void setUp() throws Exception {
+
+ DropInDeploymentHandler didh = new DropInDeploymentHandler();
+
+ fakeSOAPService = didh
+ .createSOAPServiceFromAnnotatedClass(FakeWebService.class);
+
+ }
+
+ public void tearDown() {
+ }
+
+
+
+ /*
+ * FIXME jcolwell@bea.com 2004-Sep-21 --
+ * examine the generated WSDL to see that it matches the settings in
+ * FakeWebService. For the moment, just having at least one
+ * operation and the correct name is sufficient.
+ */
+ public void testGenerateWSDL() throws Exception
+ {
+ MessageContext mc = new MessageContext(null);
+ mc.setService(fakeSOAPService);
+ fakeSOAPService.generateWSDL(mc);
+ Node doc = (Node)mc.getProperty("WSDL");
+ assertNotNull(doc);
+ if (doc != null) {
+ DefinitionsDocument defDoc = DefinitionsDocument.Factory.parse(doc);
+ assertNotNull(defDoc);
+ if (defDoc != null) {
+ TDefinitions tDefs = defDoc.getDefinitions();
+ assertNotNull(tDefs);
+ if (tDefs != null) {
+ assertEquals("http://fake.target.namespace/",
+ tDefs.getTargetNamespace());
+ TService tSrv = tDefs.getServiceArray(0);
+ assertNotNull(tSrv);
+ if (tSrv != null) {
+ assertEquals("FakeServiceName", tSrv.getName());
+
+ }
+ TBinding tBind = tDefs.getBindingArray(0);
+ assertNotNull(tBind);
+ if (tBind != null) {
+
+ org.xmlsoap.schemas.wsdl.soap.TBinding[] tSoapBinding =
+ WSDLProcessor.getSOAPBinding(tBind);
+
+ assertEquals(TStyleChoice.RPC, tSoapBinding[0]
+ .getStyle());
+
+ TBindingOperation[] tBops = tBind.getOperationArray();
+ assertTrue(tBind.sizeOfOperationArray() == 2);
+
+ assertEquals("doInvocation", tBops[0].getName());
+ assertNotNull(tBops[0].getOutput());
+ TOperation[] soapOps = WSDLProcessor
+ .getSOAPOperations(tBops[0]);
+ assertTrue(soapOps.length > 0);
+ assertEquals("invocationAction",
+ soapOps[0].getSoapAction());
+
+ assertEquals("processThingy", tBops[1].getName());
+ assertNull(tBops[1].getOutput());
+ }
+ }
+ }
+ }
+ }
+
+
+ public void testInvokeSOAPService() throws Exception
+ {
+ MessageContext mc = new MessageContext(new AxisServer());
+ SOAPEnvelope env = new SOAPEnvelope();
+ env.addBodyElement(new RPCElement("doInvocation"));
+ mc.setRequestMessage(new Message(env));
+ mc.setService(fakeSOAPService);
+ fakeSOAPService.invoke(mc);
+ Message msg = mc.getResponseMessage();
+ msg.saveChanges();
+ assertNotNull(msg);
+ if (msg != null) {
+ Node n = msg.getSOAPBody().getFirstChild();
+ assertEquals("doInvocationResponse", n.getNodeName());
+ n = n.getFirstChild();
+ assertEquals("invocationSucceeded", n.getNodeName());
+ n = n.getFirstChild();
+ assertNotNull(n);
+ assertEquals("true", n.getNodeValue());
+ }
+ }
+}
Added: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/FakeWebService.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/FakeWebService.java Tue Sep 21 15:43:11 2004
@@ -0,0 +1,58 @@
+/*
+ * FakeWebService.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 javax.jws.Oneway;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPMessageHandler;
+import javax.jws.soap.SOAPMessageHandlers;
+
+
+/*******************************************************************************
+ * NOTE jcolwell@bea.com 2004-Sep-21 --
+ * Add more methods and annotations to provide a thorough test of the
+ * AXIS JSR-181 implementation.
+ *
+ * @author Jonathan Colwell
+ */
+@WebService(name = "FakeName",
+ serviceName = "FakeServiceName",
+ targetNamespace = "http://fake.target.namespace/")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+public class FakeWebService {
+
+ @WebMethod(action = "invocationAction")
+ @WebResult(name = "invocationSucceeded")
+ public boolean doInvocation() {
+ return true;
+ }
+
+ @WebMethod(operationName = "processThingy")
+ @Oneway
+ public void processModeratelyComplexObject(@WebParam(name = "thingy")
+ ModeratelyComplexObject mco)
+ {
+
+ }
+}
Added: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/ModeratelyComplexObject.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/ModeratelyComplexObject.java Tue Sep 21 15:43:11 2004
@@ -0,0 +1,53 @@
+/*
+ * ModeratelyComplexObject.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 java.util.Date;
+import java.util.Map;
+
+/*******************************************************************************
+ *
+ *
+ * @author Jonathan Colwell
+ */
+public interface ModeratelyComplexObject {
+
+ public void setDate(Date d);
+
+ public void setMap(Map m);
+
+ public void setString(String s);
+
+ public void setNumber(double n);
+
+ public void setBinary(byte[] b);
+
+ /*
+ public Date getDate();
+
+ public Map getMap();
+
+ public String getString();
+
+ public double getNumber();
+
+ public byte[] getBinary();
+ */
+}
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java Tue Sep 21 15:43:11 2004
@@ -92,7 +92,7 @@
{
try {
SOAPService ss =
- createSOAPServiceUsingAnnotations(compileDroppedInSource(mc));
+ createSOAPServiceFromAnnotatedClass(compileDroppedInSource(mc));
if (ss != null) {
ss.setEngine(mc.getAxisEngine());
ss.init();
@@ -112,7 +112,14 @@
}
- private SOAPService createSOAPServiceUsingAnnotations(Class cls)
+ protected SOAPService createSOAPServiceFromAnnotatedSource(File sourceFile)
+ throws Exception
+ {
+ // FIXME jcolwell@bea.com 2004-Sep-21 -- run APT and set up the metadata
+ return null;
+ }
+
+ protected SOAPService createSOAPServiceFromAnnotatedClass(Class cls)
throws Exception
{
@@ -124,59 +131,73 @@
WebServiceTYPEMetadata wsm = WsmReflectionAnnotationProcessor
.getObjectModel(cls);
- if (wsm != null) {
- HandlerHandler hh = new HandlerHandler();
- hh.init(wsm);
- rpc = new SOAPService(hh, new RPCProvider(), hh);
- rpc.setName(wsm.getWsName());
- rpc.setOption(RPCProvider.OPTION_CLASSNAME, cls.getName() );
-
- // Take the setting for the scope option from the handler
- // parameter named "scope"
- String scope = (String)getOption(RPCProvider.OPTION_SCOPE);
- if (scope == null) {
- scope = "Request";
- }
- rpc.setOption(RPCProvider.OPTION_SCOPE, scope);
-
- ServiceDesc sd = AxisHook
- .createServiceDesc(wsm, cls.getClassLoader());
- rpc.setServiceDescription(sd);
-
- List allowedMethodNames = sd.getAllowedMethods();
- Iterator allowIt = allowedMethodNames.iterator();
- StringBuffer sb = new StringBuffer();
- boolean firstPass = true;
- while (allowIt.hasNext()) {
- if (firstPass) {
- sb.append(' ');
- firstPass = false;
- }
- sb.append(((String)allowIt.next()));
- }
- rpc.setOption(RPCProvider.OPTION_ALLOWEDMETHODS,
- sb.toString());
- rpc.setOption(RPCProvider.OPTION_WSDL_PORTTYPE,
- wsm.getWsName());
- rpc.setOption(RPCProvider.OPTION_WSDL_SERVICEPORT,
- wsm.getWsName());
- rpc.setOption(RPCProvider.OPTION_WSDL_SERVICEELEMENT,
- wsm.getWsServiceName());
- rpc.setOption(RPCProvider.OPTION_WSDL_TARGETNAMESPACE,
- wsm.getWsTargetNamespace());
+ rpc = createSOAPServiceUsingAnnotations(wsm, cls);
+ }
+ return rpc;
+ }
+ else {
+ return null;
+ }
+ }
- rpc.setStyle(sd.getStyle());
- rpc.setUse(sd.getUse());
+ protected SOAPService createSOAPServiceUsingAnnotations
+ (WebServiceTYPEMetadata wsm, Class cls)
+ throws Exception {
+
+
+ if (wsm != null) {
+ HandlerHandler hh = new HandlerHandler();
+ hh.init(wsm);
+ SOAPService rpc = new SOAPService(hh, new RPCProvider(), hh);
+ rpc.setName(wsm.getWsName());
+ rpc.setOption(RPCProvider.OPTION_CLASSNAME, cls.getName() );
+
+ // Take the setting for the scope option from the handler
+ // parameter named "scope"
+ String scope = (String)getOption(RPCProvider.OPTION_SCOPE);
+ if (scope == null) {
+ scope = "Request";
+ }
+ rpc.setOption(RPCProvider.OPTION_SCOPE, scope);
- mSoapServiceMap.put(cls, rpc);
+ ServiceDesc sd = AxisHook
+ .createServiceDesc(wsm, cls.getClassLoader());
+ rpc.setServiceDescription(sd);
+
+ List allowedMethodNames = sd.getAllowedMethods();
+ Iterator allowIt = allowedMethodNames.iterator();
+ StringBuffer sb = new StringBuffer();
+ boolean firstPass = true;
+ while (allowIt.hasNext()) {
+ if (firstPass) {
+ sb.append(' ');
+ firstPass = false;
}
+ sb.append(((String)allowIt.next()));
}
+ rpc.setOption(RPCProvider.OPTION_ALLOWEDMETHODS,
+ sb.toString());
+ rpc.setOption(RPCProvider.OPTION_WSDL_PORTTYPE,
+ wsm.getWsName());
+ rpc.setOption(RPCProvider.OPTION_WSDL_SERVICEPORT,
+ wsm.getWsName());
+ rpc.setOption(RPCProvider.OPTION_WSDL_SERVICEELEMENT,
+ wsm.getWsServiceName());
+ rpc.setOption(RPCProvider.OPTION_WSDL_TARGETNAMESPACE,
+ wsm.getWsTargetNamespace());
+
+ rpc.setStyle(sd.getStyle());
+ rpc.setUse(sd.getUse());
+
+ mSoapServiceMap.put(cls, rpc);
return rpc;
}
- return null;
+ else {
+ return null;
+ }
}
- private Class compileDroppedInSource(MessageContext mc)
+ protected Class compileDroppedInSource(MessageContext mc)
throws Exception
{
if (mc != null) {