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/10/07 04:31:21 UTC
svn commit: rev 53932 - in incubator/beehive/trunk/wsm: drt/tests/org/apache/beehive/wsm/jsr181/model drt/tests/org/apache/beehive/wsm/jsr181/model/fakeAnnotations src/runtime/org/apache/beehive/wsm/jsr181/model
Author: mmerz
Date: Wed Oct 6 19:31:20 2004
New Revision: 53932
Modified:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/fakeAnnotations/FakeSOAPBindingAnnotation.java
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/fakeAnnotations/FakeWebServiceAnnotation.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPMessageHandlerInfo.java
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/WebServicePARAMETERMetadata.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceTYPEMetadata.java
Log:
Adapted the unit tests, particularly Jsr181ModelTest to the new JSR-181 version that was checked in earlier.
This includes a few new tests.
Also added the targetNamespace attribute to the @WebParam and @WebResult implementation along with their default values being derived from @WebService.
Modified: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java (original)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java Wed Oct 6 19:31:20 2004
@@ -25,10 +25,10 @@
import java.util.List;
import java.util.Map;
-import javax.jws.soap.InitParam;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
+import javax.jws.soap.InitParam;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPMessageHandler;
@@ -47,8 +47,9 @@
import junit.framework.TestCase;
- // TODO: test combination of type, method, annotation
-
+//
+// TODO: test combination of type, method, annotation
+//
public class Jsr181ModelTest extends TestCase
{
@Override
@@ -63,40 +64,132 @@
// empty
}
+ /////////////////////////
//
- // test TYPE level annotations
+ // TYPE constructor
//
- public void testTYPERequiredAnnotations() throws Exception
+ /////////////////////////
+ //
+ // todo test constructor properly
+ //
+ public void testTYPEConstructor() throws Exception
{
- // test to make sure the Type throws an exception if there are no
- // WebMethod annotation defined.
+ FakeWebServiceAnnotation fakeWebServiceAnnotation =
+ new FakeWebServiceAnnotation("name", "svcName", null, null, null);
+ FakeSOAPBindingAnnotation fakeSOAPBindingAnnotation =
+ new FakeSOAPBindingAnnotation(
+ SOAPBinding.Style.RPC,
+ SOAPBinding.Use.ENCODED,
+ SOAPBinding.ParameterStyle.WRAPPED
+ );
+
+ String fqClassname = "a.b.c.testclass";
+ Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
+ typeAnnotations.add(fakeSOAPBindingAnnotation);
+ Collection<WebServiceMETHODMetadata> webMethods =
+ new ArrayList<WebServiceMETHODMetadata>();
+
+ // does missing @WebService throw an error?
try {
WebServiceTYPEMetadata type =
- new WebServiceTYPEMetadata(null, "a.b.c.testclass", null,null);
- assertTrue(
- "Error, the TYPE annotation should fail without @WebService",
- false
- );
+ new WebServiceTYPEMetadata(null, fqClassname, typeAnnotations, webMethods);
+ fail("Failed to generate error for TYPE without @WebService annotation");
}
catch (IllegalArgumentException e)
{
// good case
}
+
+ // does missing fqClassname throw an error?
+ try {
+ WebServiceTYPEMetadata type =
+ new WebServiceTYPEMetadata(fakeWebServiceAnnotation, null, typeAnnotations, webMethods);
+ fail("Failed to generate error for TYPE without TYPE name");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // good case
+ }
+
+ // does missing annotations throw an error?
+ try {
+ WebServiceTYPEMetadata type =
+ new WebServiceTYPEMetadata(fakeWebServiceAnnotation, fqClassname, null, webMethods);
+ fail("Failed to generate error for TYPE without TYPE annotations");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // good case
+ }
+ }
+
+ /////////////////////////
+ //
+ // METHOD constructor
+ //
+ /////////////////////////
+ //
+ // todo test constructor properly
+ //
+ public void testMETHODConstructor() throws Exception
+ {
+ try {
+ WebServiceMETHODMetadata method =
+ new WebServiceMETHODMetadata(null, "methodname", void.class, false, null, null);
+ fail("Error, the METHOD annotation should fail without @WebMethod");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // good case
+ }
- Collection<WebServiceMETHODMetadata> methodMetadata =
- new ArrayList<WebServiceMETHODMetadata>();
- Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
- typeAnnotations.add(new FakeSOAPBindingAnnotation(
- SOAPBinding.Style.RPC, SOAPBinding.Use.ENCODED,
- SOAPBinding.ParameterStyle.WRAPPED)
- );
+ Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
try {
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
- null, "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue(
- "Error, the TYPE annotation should fail without @WebService",
- false
- );
+ WebServiceMETHODMetadata method =
+ new WebServiceMETHODMetadata(null, "methodname", void.class, false, methodAnnotations, null);
+ fail("Error, the METHOD annotation should fail without @WebMethod");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // good case
+ }
+
+ WebMethod mAnnotation = new FakeWebMethodAnnotation("", "");
+ methodAnnotations.add(mAnnotation);
+ try {
+ WebServiceMETHODMetadata method =
+ new WebServiceMETHODMetadata(mAnnotation, null, void.class, false, methodAnnotations, null);
+ fail("Error, the METHOD annotation should fail without method name");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // good case
+ }
+ try {
+ WebServiceMETHODMetadata method =
+ new WebServiceMETHODMetadata(mAnnotation, "methodName", null, false, methodAnnotations,null);
+ fail("Error, the METHOD annotation should fail without return type class");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // good case
+ }
+ }
+
+ /////////////////////////
+ //
+ // PARAMETER constructor
+ //
+ /////////////////////////
+ //
+ // todo test constructor properly
+ //
+ public void testPARAMETERConstructor() throws Exception
+ {
+ try {
+ WebServicePARAMETERMetadata param =
+ new WebServicePARAMETERMetadata(null, null, "paramname", null);
+ fail("Java type is required in for constructor");
}
catch (IllegalArgumentException e)
{
@@ -104,232 +197,485 @@
}
}
- public void testTYPEWebServiceDefaults() throws Exception {
+ /////////////////////////
+ //
+ // @WebService
+ //
+ /////////////////////////
+
+ public void testTYPEWebServiceDefaults() throws Exception
+ {
Collection<WebServiceMETHODMetadata> methodMetadata =
new ArrayList<WebServiceMETHODMetadata>();
Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
WebService wsAnnotation =
new FakeWebServiceAnnotation("", "", "", "", "");
typeAnnotations.add(wsAnnotation);
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
- wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertEquals("Invalid WebService name", "testclass", type.getWsName());
- assertEquals("Invalid WebService service name", "testclassService",
- type.getWsServiceName());
- assertTrue("Invalid WSDL location", type.getWsWsdlLocation().length() == 0);
- assertEquals("Invalid target name space", "http://c.b.a",
- type.getWsTargetNamespace());
+
+ WebServiceTYPEMetadata type =
+ new WebServiceTYPEMetadata(wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+
+ assertEquals("testclass", type.getWsName());
+ assertEquals("http://c.b.a", type.getWsTargetNamespace());
+ assertEquals("testclassService", type.getWsServiceName());
+ assertEquals("", type.getWsWsdlLocation());
+ assertEquals("", type.getWsEndpointInterface());
}
- public void testTYPEWebServiceAnnotation() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
- Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
- WebService wsAnnotation = new FakeWebServiceAnnotation("testname",
- "testserviceName", "testwsdllocation", "testtargetnamespace",
- "testendpointinterface");
+ public void testTYPEWebService() throws Exception
+ {
+ Collection<WebServiceMETHODMetadata> methodMetadata =
+ new ArrayList<WebServiceMETHODMetadata>();
+ Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
+ WebService wsAnnotation =
+ new FakeWebServiceAnnotation("testname", "testserviceName", "testwsdllocation", "testtargetnamespace", "testendpointinterface");
typeAnnotations.add(wsAnnotation);
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
- wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue(type.getWsName().compareTo("testname") == 0);
- assertTrue(type.getWsServiceName().compareTo("testserviceName") == 0);
- assertTrue(type.getWsWsdlLocation().compareTo("testwsdllocation") == 0);
- assertTrue(type.getWsTargetNamespace().compareTo("testtargetnamespace") == 0);
- assertTrue(type.getWsEndpointInterface().compareTo("testendpointinterface") == 0);
- }
-
- public void testTYPESOAPBindingAnnotationDefaults() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
- Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
- WebService wsAnnotation = new FakeWebServiceAnnotation("testname",
- "testserviceName", "testwsdllocation", "testtargetnamespace",
- "testendpointinterface");
- typeAnnotations.add(wsAnnotation);
- typeAnnotations.add(new FakeSOAPBindingAnnotation(
- SOAPBinding.Style.DOCUMENT, SOAPBinding.Use.LITERAL,
- SOAPBinding.ParameterStyle.WRAPPED));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
- wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue(type.getSoapBinding().getStyle() == SOAPBinding.Style.DOCUMENT);
- assertTrue(type.getSoapBinding().getUse() == SOAPBinding.Use.LITERAL);
- assertTrue(type.getSoapBinding().getParameterStyle() == SOAPBinding.ParameterStyle.WRAPPED);
+
+ WebServiceTYPEMetadata type =
+ new WebServiceTYPEMetadata(wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+
+ assertEquals("testname", type.getWsName());
+ assertEquals("testtargetnamespace", type.getWsTargetNamespace());
+ assertEquals("testserviceName", type.getWsServiceName());
+ assertEquals("testwsdllocation", type.getWsWsdlLocation());
+ assertEquals("testendpointinterface", type.getWsEndpointInterface());
}
- public void testTYPESOAPBindingAnnotation() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ /////////////////////////
+ //
+ // @WebMethod
+ //
+ /////////////////////////
+
+ public void testMETHODWebMethodDefaults() throws Exception
+ {
+ Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+ WebMethod mAnnotation = new FakeWebMethodAnnotation("", "");
+ methodAnnotations.add(mAnnotation);
+
+ WebServiceMETHODMetadata method =
+ new WebServiceMETHODMetadata(mAnnotation, "methodname", void.class, false, methodAnnotations, null);
+
+ assertEquals("methodname", method.getWmOperationName());
+ assertEquals("", method.getWmAction());
+ }
+
+ public void testMETHODWebMethod() throws Exception
+ {
+ Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+ WebMethod mAnnotation =
+ new FakeWebMethodAnnotation("operationname", "action");
+ methodAnnotations.add(mAnnotation);
+
+ WebServiceMETHODMetadata method =
+ new WebServiceMETHODMetadata(mAnnotation, "methodname", void.class, false, methodAnnotations, null);
+
+ assertEquals("operationname", method.getWmOperationName());
+ assertEquals("action", method.getWmAction());
+ }
+
+ /////////////////////////
+ //
+ // @Oneway
+ //
+ /////////////////////////
+
+ public void testMETHODOneWayDefaults() throws Exception
+ {
+ Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+ WebMethod mAnnotation =
+ new FakeWebMethodAnnotation("", "");
+ methodAnnotations.add(mAnnotation);
+
+ WebServiceMETHODMetadata method =
+ new WebServiceMETHODMetadata(mAnnotation, "methodname", void.class, false, methodAnnotations, null);
+
+ assertFalse(method.isOneWay());
+ }
+
+ public void testMETHODOneWay() throws Exception
+ {
+ Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+ WebMethod mAnnotation = new FakeWebMethodAnnotation("", "");
+ methodAnnotations.add(mAnnotation);
+ methodAnnotations.add(new FakeOneWayAnnotation());
+
+ WebServiceMETHODMetadata method =
+ new WebServiceMETHODMetadata(mAnnotation, "methodname", void.class, false, methodAnnotations, null);
+
+ assertTrue(method.isOneWay());
+ }
+
+ /////////////////////////
+ //
+ // @WebParam
+ //
+ /////////////////////////
+
+ public void testPARAMETERWebParamDefaults() throws Exception
+ {
+ Collection<Annotation> paramAnnotations = new ArrayList<Annotation>();
+ WebParam wpAnnotation = new FakeWebParamAnnotation("", "", WebParam.Mode.IN, false);
+ paramAnnotations.add(wpAnnotation);
+
+ WebServicePARAMETERMetadata param =
+ new WebServicePARAMETERMetadata (wpAnnotation, String.class, "paramname", paramAnnotations);
+
+/*** *** ***/
+
+ // create param list
+ List<WebServicePARAMETERMetadata> params =
+ new ArrayList<WebServicePARAMETERMetadata>();
+
+ // create methods
+ Collection<WebServiceMETHODMetadata> methods =
+ new ArrayList<WebServiceMETHODMetadata>();
+
+ params.add(param);
+
+ Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+ WebMethod methodAnnotation =
+ new FakeWebMethodAnnotation("operationname", "action");
+ methodAnnotations.add(methodAnnotation);
+
+ WebServiceMETHODMetadata method =
+ new WebServiceMETHODMetadata(methodAnnotation, "methodname", void.class, false, methodAnnotations, params);
+
+ methods.add(method);
+
+ // create annotations
Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
typeAnnotations.add(wsAnnotation);
- typeAnnotations.add(new FakeSOAPBindingAnnotation(
- SOAPBinding.Style.RPC, SOAPBinding.Use.ENCODED,
- SOAPBinding.ParameterStyle.BARE));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
- wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue(type.getSoapBinding().getStyle() == SOAPBinding.Style.RPC);
- assertTrue(type.getSoapBinding().getUse() == SOAPBinding.Use.ENCODED);
- assertTrue(type.getSoapBinding().getParameterStyle() == SOAPBinding.ParameterStyle.BARE);
+
+ // create type
+ WebServiceTYPEMetadata type =
+ new WebServiceTYPEMetadata(wsAnnotation, "a.b.c.testclass", typeAnnotations, methods);
+
+/*** *** ***/
+
+ assertEquals("paramname", param.getWpName());
+ assertEquals(type.getWsTargetNamespace(), param.getWpTargetNamespace());
+ assertEquals(WebParam.Mode.IN, param.getWpMode());
+ assertFalse(param.isWpHeader());
}
+
+ public void testPARAMETERWebParam() throws Exception
+ {
+ Collection<Annotation> paramAnnotations = new ArrayList<Annotation>();
+ WebParam wpAnnotation =
+ new FakeWebParamAnnotation("paramname", "targetNamespace", WebParam.Mode.INOUT, true);
+ paramAnnotations.add(wpAnnotation);
- // no test for default HandlerChains, all fields are required in the
- // @HandlerChain
+ WebServicePARAMETERMetadata param =
+ new WebServicePARAMETERMetadata(wpAnnotation, String.class, "paramname", paramAnnotations);
+
+ assertEquals("paramname", param.getWpName());
+ assertEquals("targetNamespace", param.getWpTargetNamespace());
+ assertEquals(WebParam.Mode.INOUT, param.getWpMode());
+ assertTrue(param.isWpHeader());
+ }
- public void testTYPEHandlerChainAnnotation() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ /////////////////////////
+ //
+ // @WebResult
+ //
+ /////////////////////////
+
+ public void testMETHODWebResultDefaults() throws Exception
+ {
+ Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+ WebMethod mAnnotation =
+ new FakeWebMethodAnnotation("operationname", "action");
+ methodAnnotations.add(mAnnotation);
+ methodAnnotations.add(new FakeWebResultAnnotation("result", ""));
+
+ WebServiceMETHODMetadata method =
+ new WebServiceMETHODMetadata(mAnnotation, "methodname", void.class, false, methodAnnotations, null);
+
+/*** *** ***/
+
+ // create methods
+ Collection<WebServiceMETHODMetadata> methods =
+ new ArrayList<WebServiceMETHODMetadata>();
+
+ methods.add(method);
+
+ // create annotations
Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
typeAnnotations.add(wsAnnotation);
- typeAnnotations.add(new FakeHandlerChainAnnotation
- ("org/apache/beehive/wsm/jsr181/model/fakeAnnotations/handlerChainConfig.xml",
- "testname"));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
- wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue(type.getHcFileName() == "org/apache/beehive/wsm/jsr181/model/fakeAnnotations/handlerChainConfig.xml");
- assertTrue(type.getHcName() == "testname");
- assertFalse(type.getSoapHandlers().isEmpty());
+ // create type
+ WebServiceTYPEMetadata type =
+ new WebServiceTYPEMetadata(wsAnnotation, "a.b.c.testclass", typeAnnotations, methods);
+
+/*** *** ***/
+
+ assertEquals("result", method.getWrName());
+ assertEquals(type.getWsTargetNamespace(), method.getWrTargetNamespace());
}
+
+ public void testMETHODWebResult() throws Exception
+ {
+ Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+ WebMethod mAnnotation =
+ new FakeWebMethodAnnotation("operationname", "action");
+ methodAnnotations.add(mAnnotation);
+ methodAnnotations.add(new FakeWebResultAnnotation("result", "targetNamespace"));
- // test empty handler list
- public void testTYPESoapMessageHandlersDefaults1() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ WebServiceMETHODMetadata method =
+ new WebServiceMETHODMetadata(mAnnotation, "methodname", void.class, false, methodAnnotations, null);
+
+ assertEquals("result", method.getWrName());
+ assertEquals("targetNamespace", method.getWrTargetNamespace());
+ }
+
+ /////////////////////////
+ //
+ // @HandlerChain
+ //
+ /////////////////////////
+
+ // no default values to check
+
+ public void testTYPEHandlerChain() throws Exception
+ {
+ String hcFileName = "org/apache/beehive/wsm/jsr181/model/fakeAnnotations/handlerChainConfig.xml";
+ String hcName = "testname";
+
+ Collection<WebServiceMETHODMetadata> methodMetadata =
+ new ArrayList<WebServiceMETHODMetadata>();
Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
typeAnnotations.add(wsAnnotation);
+ typeAnnotations.add(new FakeHandlerChainAnnotation(hcFileName, hcName));
+
+ WebServiceTYPEMetadata type =
+ new WebServiceTYPEMetadata(wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
- FakeSOAPMessageHandlerAnnotation[] emptyHandlers = new FakeSOAPMessageHandlerAnnotation[0];
- typeAnnotations
- .add(new FakeSOAPMessageHandlersAnnotation(emptyHandlers));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
- wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue(type.getSoapHandlers().size() == 0);
+ assertEquals(hcFileName, type.getHcFileName());
+ assertEquals(hcName, type.getHcName());
+ }
+ /////////////////////////
+ //
+ // @SOAPBinding
+ //
+ /////////////////////////
+
+ // no default values to check
+
+ public void testTYPESOAPBinding() throws Exception
+ {
+ Collection<WebServiceMETHODMetadata> methodMetadata =
+ new ArrayList<WebServiceMETHODMetadata>();
+ Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
+ WebService wsAnnotation =
+ new FakeWebServiceAnnotation("", "", "", "", "");
+ typeAnnotations.add(wsAnnotation);
+ typeAnnotations.add(
+ new FakeSOAPBindingAnnotation(
+ SOAPBinding.Style.RPC,
+ SOAPBinding.Use.ENCODED,
+ SOAPBinding.ParameterStyle.BARE));
+
+ WebServiceTYPEMetadata type =
+ new WebServiceTYPEMetadata(wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+
+ assertEquals(SOAPBinding.Style.RPC, type.getSoapBinding().getStyle());
+ assertEquals(SOAPBinding.Use.ENCODED, type.getSoapBinding().getUse());
+ assertEquals(SOAPBinding.ParameterStyle.BARE, type.getSoapBinding().getParameterStyle());
}
- // test a single default handler in the handlers list
- public void testTYPESoapMessageHandlersDefaults2() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ /////////////////////////
+ //
+ // @SOAPMessageHandlers
+ //
+ /////////////////////////
+
+ // test empty handler list
+ public void testTYPESoapMessageHandlersDefaults1() throws Exception
+ {
+ Collection<WebServiceMETHODMetadata> methodMetadata =
+ new ArrayList<WebServiceMETHODMetadata>();
Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
typeAnnotations.add(wsAnnotation);
+ FakeSOAPMessageHandlerAnnotation[] emptyHandlers =
+ new FakeSOAPMessageHandlerAnnotation[0];
+ typeAnnotations.add(new FakeSOAPMessageHandlersAnnotation(emptyHandlers));
+
+ WebServiceTYPEMetadata type =
+ new WebServiceTYPEMetadata(wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+
+ assertTrue(type.getSoapHandlers().isEmpty());
+ }
- SOAPMessageHandler[] defaultHandlers = new FakeSOAPMessageHandlerAnnotation[1];
- defaultHandlers[0] = new FakeSOAPMessageHandlerAnnotation("",
- "soaphandlerclass", new FakeInitParamAnnotation[0],
- new String[0], new String[0]);
- typeAnnotations.add(new FakeSOAPMessageHandlersAnnotation(
- defaultHandlers));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
- wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue("number of handlers returned: "
- + type.getSoapHandlers().size(),
- type.getSoapHandlers().size() == 1);
+ // test single default handler in handlers list
+ public void testTYPESoapMessageHandlersDefaults2() throws Exception
+ {
+ Collection<WebServiceMETHODMetadata> methodMetadata =
+ new ArrayList<WebServiceMETHODMetadata>();
+ Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
+ WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+ typeAnnotations.add(wsAnnotation);
+ SOAPMessageHandler[] defaultHandlers = {
+ new FakeSOAPMessageHandlerAnnotation("", "soaphandlerclass", new FakeInitParamAnnotation[0], new String[0], new String[0])
+ };
+ typeAnnotations.add(
+ new FakeSOAPMessageHandlersAnnotation(defaultHandlers)
+ );
+
+ WebServiceTYPEMetadata type =
+ new WebServiceTYPEMetadata(wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+
+ assertEquals(
+ "number of handlers returned: " + type.getSoapHandlers().size(),
+ 1, type.getSoapHandlers().size()
+ );
SOAPMessageHandlerInfo handler = type.getSoapHandlers().get(0);
- assertTrue(handler.getName().compareTo("soaphandlerclass") == 0);
- assertTrue(handler.getClassName().compareTo("soaphandlerclass") == 0);
- assertTrue(handler.getParameterMap().size() == 0);
- assertTrue(handler.getRoles().size() == 0);
- assertTrue(handler.getHeaders().size() == 0);
+ assertEquals("soaphandlerclass", handler.getName());
+ assertEquals("soaphandlerclass", handler.getClassName());
+ assertEquals(0, handler.getParameterMap().size());
+ assertEquals(0, handler.getRoles().size());
+ assertEquals(0, handler.getHeaders().size());
}
- public void testTYPESoapMessageHandlers() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ public void testTYPESoapMessageHandlers() throws Exception
+ {
+ Collection<WebServiceMETHODMetadata> methodMetadata =
+ new ArrayList<WebServiceMETHODMetadata>();
Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
typeAnnotations.add(wsAnnotation);
+ InitParam[] params = {
+ new FakeInitParamAnnotation("paramname", "paramvalue")
+ };
+ String[] roles = { "roles" };
+ String[] headers = { "namespace.localname" };
+ SOAPMessageHandler[] defaultHandlers = {
+ new FakeSOAPMessageHandlerAnnotation("", "soaphandlerclass", params, roles, headers)
+ };
+ typeAnnotations.add(new FakeSOAPMessageHandlersAnnotation(defaultHandlers));
- InitParam[] params = { new FakeInitParamAnnotation("paramname",
- "paramvalue") };
- String[] roles = { "messagehandlerroles" };
- String[] headers = { "messagehanderheadernamespace.messagehanderheaderlocalname" };
- SOAPMessageHandler[] defaultHandlers = { new FakeSOAPMessageHandlerAnnotation(
- "", "soaphandlerclass", params, roles, headers) };
- typeAnnotations.add(new FakeSOAPMessageHandlersAnnotation(
- defaultHandlers));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
- wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue("number of handlers returned: "
- + type.getSoapHandlers().size(),
- type.getSoapHandlers().size() == 1);
- SOAPMessageHandlerInfo handler = type.getSoapHandlers().get(0);
- assertTrue(handler.getName().compareTo("soaphandlerclass") == 0);
- assertTrue(handler.getClassName().compareTo("soaphandlerclass") == 0);
- assertTrue(handler.getParameterMap().size() == 1);
- assertTrue(handler.getRoles().size() == 1);
- assertTrue(handler.getHeaders().size() == 1);
+ WebServiceTYPEMetadata type =
+ new WebServiceTYPEMetadata(wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+
+ // handlers
+ List<SOAPMessageHandlerInfo> soapHandlers = type.getSoapHandlers();
+ assertEquals(
+ "number of handlers returned: " + soapHandlers.size(),
+ 1, soapHandlers.size());
+ SOAPMessageHandlerInfo handler = soapHandlers.get(0);
+ assertEquals("soaphandlerclass", handler.getName());
+ assertEquals("soaphandlerclass", handler.getClassName());
+ assertEquals(1, handler.getParameterMap().size());
+ assertEquals(1, handler.getRoles().size());
+ assertEquals(1, handler.getHeaders().size());
+ // params
Map.Entry<String,String> me =
handler.getParameterMap().entrySet().iterator().next();
- assert (me.getKey().compareTo("paramname") == 0);
- assert (me.getValue().compareTo("paramvalue") == 0);
-
- assert (handler.getRoles().iterator().next().compareTo(
- "messagehandlerroles") == 0);
+ assertEquals("paramname", me.getKey());
+ assertEquals("paramvalue", me.getValue());
+ // roles
+ assertEquals("roles", handler.getRoles().iterator().next());
+
+ // headers
String s = handler.getHeaders().iterator().next();
- assertEquals(s, "messagehanderheadernamespace.messagehanderheaderlocalname");
+ assertEquals(s, "namespace.localname");
}
- public void testTYPESecurityRolesDefaults() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ /////////////////////////
+ //
+ // @SecurityRoles
+ //
+ /////////////////////////
+
+ public void testTYPESecurityRolesDefaults() throws Exception
+ {
+ Collection<WebServiceMETHODMetadata> methodMetadata =
+ new ArrayList<WebServiceMETHODMetadata>();
Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
typeAnnotations.add(wsAnnotation);
typeAnnotations.add(new FakeSecurityRoleAnnotation(null, null));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
- wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+
+ WebServiceTYPEMetadata type =
+ new WebServiceTYPEMetadata(wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
assertNull(type.getSecurityRoles().getRolesAllowed());
assertNull(type.getSecurityRoles().getRolesReferenced());
-
}
- public void testTYPESecurityRoles() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ public void testTYPESecurityRoles() throws Exception
+ {
+ Collection<WebServiceMETHODMetadata> methodMetadata =
+ new ArrayList<WebServiceMETHODMetadata>();
Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
typeAnnotations.add(wsAnnotation);
String[] rolesAllowed = { "rolesallowed" };
String[] rolesReferenced = { "rolesreferenced" };
- typeAnnotations.add(new FakeSecurityRoleAnnotation(rolesAllowed,
- rolesReferenced));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
- wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+ typeAnnotations.add(new FakeSecurityRoleAnnotation(rolesAllowed, rolesReferenced));
+
+ WebServiceTYPEMetadata type =
+ new WebServiceTYPEMetadata(wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue(type.getSecurityRoles().getRolesAllowed().size() == 1);
- assertTrue(type.getSecurityRoles().getRolesAllowed().iterator().next()
- .compareTo("rolesallowed") == 0);
- assertTrue(type.getSecurityRoles().getRolesReferenced().size() == 1);
- assertTrue(type.getSecurityRoles().getRolesReferenced().iterator()
- .next().compareTo("rolesreferenced") == 0);
+ assertEquals(1, type.getSecurityRoles().getRolesAllowed().size());
+ assertEquals("rolesallowed", (String) type.getSecurityRoles().getRolesAllowed().iterator().next());
+ assertEquals(1, type.getSecurityRoles().getRolesReferenced().size());
+ assertEquals("rolesreferenced", type.getSecurityRoles().getRolesReferenced().iterator().next());
}
- public void testTYPESecurityIdentityDefaults() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ /////////////////////////
+ //
+ // @SecurityIdentity
+ //
+ /////////////////////////
+
+ public void testTYPESecurityIdentityDefaults() throws Exception
+ {
+ Collection<WebServiceMETHODMetadata> methodMetadata =
+ new ArrayList<WebServiceMETHODMetadata>();
Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
typeAnnotations.add(wsAnnotation);
typeAnnotations.add(new FakeSecurityIdentityAnnotation(null));
+
WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
assertNull(type.getSiValue());
-
}
- public void testTYPESecurityIdentity() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ public void testTYPESecurityIdentity() throws Exception
+ {
+ Collection<WebServiceMETHODMetadata> methodMetadata =
+ new ArrayList<WebServiceMETHODMetadata>();
Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
typeAnnotations.add(wsAnnotation);
- typeAnnotations
- .add(new FakeSecurityIdentityAnnotation("runasidentity"));
+ typeAnnotations.add(new FakeSecurityIdentityAnnotation("value"));
+
WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertEquals(type.getSiValue(), "runasidentity");
+
+ assertEquals(type.getSiValue(), "value");
}
+ /////////////////////////
+ //
+ // JSR-181 Rules
+ //
+ /////////////////////////
+
public void testTYPESOAPHandlerWithHandlerChain() throws Exception
{
boolean hasPassed = false;
+
try {
Collection<Annotation> typeAnnotations =
new ArrayList<Annotation>();
@@ -345,12 +691,7 @@
typeAnnotations.add(new FakeSOAPMessageHandlersAnnotation(new SOAPMessageHandler[0]));
typeAnnotations.add(new FakeHandlerChainAnnotation("fileName", "chainName"));
WebServiceTYPEMetadata type =
- new WebServiceTYPEMetadata(
- wsAnnotation,
- "a.b.c.testclass",
- typeAnnotations,
- new ArrayList<WebServiceMETHODMetadata>()
- );
+ new WebServiceTYPEMetadata(wsAnnotation, "a.b.c.testclass", typeAnnotations, new ArrayList<WebServiceMETHODMetadata>());
}
catch (Exception e)
{
@@ -360,148 +701,41 @@
{
fail("Error not caught: @SOAPMessageHandlers cannot be combined with @HandlerChain");
}
-
- }
-
- //
- // test METHOD level annotations
- //
- public void testMETHODRequiredAnnotations() throws Exception {
- try {
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- null, "methodname", void.class, false, null, null);
- assertTrue(
- "Error, the METHOD annotation should fail without @WebMethod",
- false);
- } catch (IllegalArgumentException e) {
- // good case
- }
- Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- try {
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- null, "methodname", void.class, false, methodAnnotations, null);
- assertTrue(
- "Error, the METHOD annotation should fail without @WebMethod",
- false);
- } catch (IllegalArgumentException e) {
- // good case
- }
-
- WebMethod mAnnotation = new FakeWebMethodAnnotation("", "");
- methodAnnotations.add(mAnnotation);
- try {
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, null, void.class, false, methodAnnotations,null);
- assertTrue(
- "Error, the METHOD annotation should fail without method name",
- false);
- } catch (IllegalArgumentException e) {
- // good case
- }
- try {
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodName", null, false, methodAnnotations,null);
- assertTrue(
- "Error, the METHOD annotation should fail without return type class",
- false);
- } catch (IllegalArgumentException e) {
- // good case
- }
- }
-
- public void testMETHODWebMethodDefaults() throws Exception {
- Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- WebMethod mAnnotation = new FakeWebMethodAnnotation("", "");
- methodAnnotations.add(mAnnotation);
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", void.class, false, methodAnnotations,null);
- assertTrue(method.getWmOperationName().compareTo("methodname") == 0);
- assertTrue(method.getWmAction().length() == 0);
- assertTrue(method.getWrName().compareTo("result") == 0);
-
- }
-
- public void testMETHODWebMethod() throws Exception {
- Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
- methodAnnotations.add(mAnnotation);
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", void.class, false, methodAnnotations, null);
- assertTrue(method.getWmOperationName().compareTo("operationname") == 0);
- assertTrue(method.getWmAction().compareTo("action") == 0);
-
- }
-
- public void testMETHODOneWayDefaults() throws Exception {
- Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
- methodAnnotations.add(mAnnotation);
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", void.class, false, methodAnnotations, null);
- assertFalse(method.isOneWay());
- }
-
- public void testMETHODOneWay() throws Exception {
- Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
- methodAnnotations.add(mAnnotation);
- methodAnnotations.add(new FakeOneWayAnnotation());
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", void.class, false, methodAnnotations, null);
- assertTrue(method.isOneWay());
- }
-
- public void testMETHODWebResultDefaults() throws Exception {
- Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
- methodAnnotations.add(mAnnotation);
- methodAnnotations.add(new FakeWebResultAnnotation("result", ""));
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", void.class, false, methodAnnotations, null);
- assertTrue(method.getWrName().compareTo("result") == 0);
- }
-
- public void testMETHODWebResult() throws Exception {
- Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
- methodAnnotations.add(mAnnotation);
- methodAnnotations.add(new FakeWebResultAnnotation("resultname", ""));
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", void.class, false, methodAnnotations, null);
- assertTrue(method.getWrName().compareTo("resultname") == 0);
-
}
- public void testMETHODSecurityRoleDefaults() throws Exception {
+ public void testMETHODSecurityRoleDefaults() throws Exception
+ {
Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
+ WebMethod mAnnotation =
+ new FakeWebMethodAnnotation("operationname", "action");
methodAnnotations.add(mAnnotation);
methodAnnotations.add(new FakeSecurityRoleAnnotation(null, null));
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", void.class, false, methodAnnotations, null);
- assertNull(method.getSecurityRoles().getRolesAllowed());
- assertNull(method.getSecurityRoles().getRolesReferenced());
+ WebServiceMETHODMetadata method =
+ new WebServiceMETHODMetadata(mAnnotation, "methodname", void.class, false, methodAnnotations, null);
+
+ assertNull(method.getSecurityRoles().getRolesAllowed());
+ assertNull(method.getSecurityRoles().getRolesReferenced());
}
- public void testMETHODSecurityRole() throws Exception {
+ public void testMETHODSecurityRole() throws Exception
+ {
Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
+ WebMethod mAnnotation =
+ new FakeWebMethodAnnotation("operationname", "action");
methodAnnotations.add(mAnnotation);
String[] rolesAllowed = { "rolesallowed" };
String[] rolesReferenced = { "rolesreferenced" };
methodAnnotations.add(new FakeSecurityRoleAnnotation(rolesAllowed,
rolesReferenced));
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", void.class, false, methodAnnotations, null);
- assertTrue(method.getSecurityRoles().getRolesAllowed().size() == 1);
- assertTrue(method.getSecurityRoles().getRolesAllowed().iterator().next()
- .compareTo("rolesallowed") == 0);
- assertTrue(method.getSecurityRoles().getRolesReferenced().size() == 1);
- assertTrue(method.getSecurityRoles().getRolesReferenced().iterator()
- .next().compareTo("rolesreferenced") == 0);
-
+ WebServiceMETHODMetadata method =
+ new WebServiceMETHODMetadata(mAnnotation, "methodname", void.class, false, methodAnnotations, null);
+
+ assertEquals(1, method.getSecurityRoles().getRolesAllowed().size());
+ assertEquals("rolesallowed", method.getSecurityRoles().getRolesAllowed().iterator().next());
+ assertEquals(1, method.getSecurityRoles().getRolesReferenced().size());
+ assertEquals("rolesreferenced", method.getSecurityRoles().getRolesReferenced().iterator().next());
}
public void testMETHODOnewayWithWebResult() throws Exception
@@ -635,65 +869,5 @@
{
fail("Error not caught: @Oneway method has OUT or INOUT parameters");
}
- }
-
- //
- // test PARAMETER level annotations
- //
- public void testPARAMETERRequiredAnnotations() throws Exception {
-
- try {
- WebServicePARAMETERMetadata param = new WebServicePARAMETERMetadata (
- null, null, "paramname", null );
- assertTrue(
- "Java type should be a required field in Parameter",
- false);
- } catch (IllegalArgumentException e) {
- // good case
- }
-
- }
-
- public void testPARAMETERWebParamDefault1() {
- WebServicePARAMETERMetadata param = new WebServicePARAMETERMetadata(
- null, String.class, "paramname", null);
-
- assertTrue(param.getWpMode() == WebParam.Mode.IN);
- assertTrue(param.getWpName().compareTo("paramname") == 0);
- assertFalse(param.isWpHeader());
- }
- public void testPARAMETERWebParamDefault2() {
-
- Collection<Annotation> paramAnnotations = new ArrayList<Annotation>();
- WebServicePARAMETERMetadata param = new WebServicePARAMETERMetadata(
- null, String.class, "paramname", paramAnnotations);
- assertTrue(param.getWpMode() == WebParam.Mode.IN);
- assertTrue(param.getWpName().compareTo("paramname") == 0);
- assertFalse(param.isWpHeader());
- }
-
- public void testPARAMETERWebParamDefault3() {
- Collection<Annotation> paramAnnotations = new ArrayList<Annotation>();
- WebParam wpAnnotation = new FakeWebParamAnnotation("", "", WebParam.Mode.IN, false);
- paramAnnotations.add(wpAnnotation);
- WebServicePARAMETERMetadata param = new WebServicePARAMETERMetadata (
- wpAnnotation, String.class, "paramname", paramAnnotations);
-
- assertTrue(param.getWpMode() == WebParam.Mode.IN);
- assertTrue(param.getWpName().compareTo("paramname") == 0);
- assertFalse(param.isWpHeader());
- }
-
- public void testPARAMETERWebParam() {
- Collection<Annotation> paramAnnotations = new ArrayList<Annotation>();
- WebParam wpAnnotation = new FakeWebParamAnnotation("paramannotationname", "", WebParam.Mode.INOUT, true);
- paramAnnotations.add(wpAnnotation);
- WebServicePARAMETERMetadata param = new WebServicePARAMETERMetadata (
- wpAnnotation, String.class, "paramname", paramAnnotations);
-
- assertTrue(param.getWpMode() == WebParam.Mode.INOUT);
- assertTrue(param.getWpName().compareTo("paramannotationname") == 0);
- assertTrue(param.isWpHeader());
-
}
}
Modified: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/fakeAnnotations/FakeSOAPBindingAnnotation.java
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/fakeAnnotations/FakeSOAPBindingAnnotation.java (original)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/fakeAnnotations/FakeSOAPBindingAnnotation.java Wed Oct 6 19:31:20 2004
@@ -1,9 +1,5 @@
package org.apache.beehive.wsm.jsr181.model.fakeAnnotations;
-import java.lang.annotation.Annotation;
-
-import javax.jws.soap.SOAPBinding;
-
/*
* Copyright 2004 The Apache Software Foundation
*
@@ -22,37 +18,44 @@
* $Header:$
*/
-//org.apache.beehive.wsm.model.TestSOAPBindingAnnotation.java
-public class FakeSOAPBindingAnnotation implements SOAPBinding, Annotation{
+import java.lang.annotation.Annotation;
- SOAPBinding.Style style;
- SOAPBinding.Use use;
- SOAPBinding.ParameterStyle parameterStyle;
+import javax.jws.soap.SOAPBinding;
+
+public class FakeSOAPBindingAnnotation implements SOAPBinding, Annotation
+{
+ private SOAPBinding.Style style;
+ private SOAPBinding.Use use;
+ private SOAPBinding.ParameterStyle parameterStyle;
- /**
- *
- */
- public FakeSOAPBindingAnnotation(SOAPBinding.Style style, SOAPBinding.Use use, SOAPBinding.ParameterStyle parameterStyle) {
+ public FakeSOAPBindingAnnotation(
+ SOAPBinding.Style style,
+ SOAPBinding.Use use,
+ SOAPBinding.ParameterStyle parameterStyle
+ )
+ {
this.style=style;
this.use=use;
this.parameterStyle=parameterStyle;
}
-
- public Style style() {
+ public Style style()
+ {
return style;
}
-
- public Use use() {
+ public Use use()
+ {
return use;
}
- public ParameterStyle parameterStyle() {
+ public ParameterStyle parameterStyle()
+ {
return parameterStyle;
}
- public Class annotationType() {
+
+ public Class annotationType()
+ {
return SOAPBinding.class;
}
-
-}
+}
\ No newline at end of file
Modified: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/fakeAnnotations/FakeWebServiceAnnotation.java
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/fakeAnnotations/FakeWebServiceAnnotation.java (original)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/fakeAnnotations/FakeWebServiceAnnotation.java Wed Oct 6 19:31:20 2004
@@ -1,9 +1,5 @@
package org.apache.beehive.wsm.jsr181.model.fakeAnnotations;
-import java.lang.annotation.Annotation;
-
-import javax.jws.WebService;
-
/*
* Copyright 2004 The Apache Software Foundation
*
@@ -22,22 +18,26 @@
* $Header:$
*/
-//org.apache.beehive.wsm.model.testWebServiceAnnotation.java
-public class FakeWebServiceAnnotation implements WebService, Annotation {
+import java.lang.annotation.Annotation;
- private String name;
+import javax.jws.WebService;
+public class FakeWebServiceAnnotation implements WebService, Annotation
+{
+ private String name;
private String endpointInterface;
-
private String serviceName;
-
private String wsdlLocation;
-
private String targetNamespace;
- public FakeWebServiceAnnotation(String name, String serviceName,
- String wsdlLocation, String targetNamespace,
- String endpointInterface) {
+ public FakeWebServiceAnnotation(
+ String name,
+ String serviceName,
+ String wsdlLocation,
+ String targetNamespace,
+ String endpointInterface
+ )
+ {
this.name = name;
this.serviceName = serviceName;
this.wsdlLocation = wsdlLocation;
@@ -50,7 +50,8 @@
*
* @see javax.jws.WebService#name()
*/
- public String name() {
+ public String name()
+ {
return name;
}
@@ -59,7 +60,8 @@
*
* @see javax.jws.WebService#serviceName()
*/
- public String serviceName() {
+ public String serviceName()
+ {
return serviceName;
}
@@ -68,7 +70,8 @@
*
* @see javax.jws.WebService#wsdlLocation()
*/
- public String wsdlLocation() {
+ public String wsdlLocation()
+ {
return wsdlLocation;
}
@@ -77,7 +80,8 @@
*
* @see javax.jws.WebService#targetNamespace()
*/
- public String targetNamespace() {
+ public String targetNamespace()
+ {
return targetNamespace;
}
@@ -86,7 +90,8 @@
*
* @see javax.jws.WebService#endpointInterface()
*/
- public String endpointInterface() {
+ public String endpointInterface()
+ {
return endpointInterface;
}
@@ -95,9 +100,8 @@
*
* @see java.lang.annotation.Annotation#annotationType()
*/
- public Class annotationType() {
+ public Class annotationType()
+ {
return WebService.class;
}
-
-}
-
+}
\ No newline at end of file
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPMessageHandlerInfo.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPMessageHandlerInfo.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPMessageHandlerInfo.java Wed Oct 6 19:31:20 2004
@@ -1,17 +1,5 @@
package org.apache.beehive.wsm.jsr181.model;
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jws.soap.InitParam;
-import javax.jws.soap.SOAPMessageHandler;
-
-
/*
* Copyright 2004 The Apache Software Foundation
*
@@ -30,7 +18,19 @@
* $Header:$
*/
-public class SOAPMessageHandlerInfo {
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jws.soap.InitParam;
+import javax.jws.soap.SOAPMessageHandler;
+
+public class SOAPMessageHandlerInfo
+{
String name;
String className;
HashMap<String, String> parameterMap = new HashMap<String, String>();
@@ -126,7 +126,7 @@
}
public void addInitParam(String key, String value) {
- parameterMap.put(name, value);
+ parameterMap.put(key, value);
}
public void addInitParams(Map<String,String> params) {
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 Wed Oct 6 19:31:20 2004
@@ -26,10 +26,10 @@
import java.util.List;
import javax.jws.Oneway;
-import javax.jws.security.SecurityRoles;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
+import javax.jws.security.SecurityRoles;
public class WebServiceMETHODMetadata extends AnnotationModel
{
@@ -38,10 +38,9 @@
private boolean oneway = false;
private List<WebServicePARAMETERMetadata> params =
new ArrayList<WebServicePARAMETERMetadata>();
- private String wrName; // webresults
+ private String wrName;
+ private String wrTargetNamespace;
private SOAPBindingInfo soapBinding;
-// private QNameInfo dwRequestElement;
-// private QNameInfo dwResponseElement;
private SecurityRolesInfo securityRoles;
private String javaMethodName;
private Class javaReturnType;
@@ -162,6 +161,7 @@
if (null != annotation)
{
setWrName(annotation.name());
+ setWrTargetNamespace(annotation.targetNamespace());
}
}
@@ -186,27 +186,7 @@
setWmAction("");
}
}
-/*
- public QNameInfo getDwRequestElement()
- {
- return dwRequestElement;
- }
-
- public void setDwRequestElement(QNameInfo dwRequestElement)
- {
- this.dwRequestElement = dwRequestElement;
- }
-
- public QNameInfo getDwResponseElement()
- {
- return dwResponseElement;
- }
- public void setDwResponseElement(QNameInfo dwResponseElement)
- {
- this.dwResponseElement = dwResponseElement;
- }
-*/
public boolean isOneWay()
{
return oneway;
@@ -255,6 +235,16 @@
public void setWrName(String wrName)
{
this.wrName = wrName;
+ }
+
+ public String getWrTargetNamespace()
+ {
+ return wrTargetNamespace;
+ }
+
+ public void setWrTargetNamespace(String wrTargetNamespace)
+ {
+ this.wrTargetNamespace = wrTargetNamespace;
}
public List<WebServicePARAMETERMetadata> getParams()
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServicePARAMETERMetadata.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServicePARAMETERMetadata.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServicePARAMETERMetadata.java Wed Oct 6 19:31:20 2004
@@ -27,6 +27,7 @@
public class WebServicePARAMETERMetadata extends AnnotationModel
{
private String wpName;
+ private String wpTargetNamespace;
private WebParam.Mode wpMode;
private boolean wpHeader;
private Class javaType;
@@ -53,7 +54,7 @@
this.javaType = javaType;
setWpMode(WebParam.Mode.IN); // by default if there were no anotations
- setWpName(defaultName); // in case there are no annotations
+ setWpName(defaultName); // in case there are no annotations
// check required parameters
@@ -100,6 +101,16 @@
this.wpName = wpName;
}
+ public String getWpTargetNamespace()
+ {
+ return wpTargetNamespace;
+ }
+
+ public void setWpTargetNamespace(String wpTargetNamespace)
+ {
+ this.wpTargetNamespace = wpTargetNamespace;
+ }
+
public Class getJavaType()
{
return javaType;
@@ -118,6 +129,7 @@
{
setWpName(annotation.name());
}
+ setWpTargetNamespace(annotation.targetNamespace());
setWpMode(annotation.mode());
setWpHeader(annotation.header());
}
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 Wed Oct 6 19:31:20 2004
@@ -32,14 +32,14 @@
import java.util.Map;
import javax.jws.HandlerChain;
+import javax.jws.WebService;
import javax.jws.security.SecurityIdentity;
import javax.jws.security.SecurityRoles;
-import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPMessageHandler;
import javax.jws.soap.SOAPMessageHandlers;
-import javax.xml.namespace.QName;
+//import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -80,55 +80,66 @@
WebService webServiceAnnotation,
String fqClassName,
Collection<Annotation> annotations,
- Collection< ? extends WebServiceMETHODMetadata> webMethods
+ Collection<? extends WebServiceMETHODMetadata> webMethods
) throws Exception
{
super();
- // check required parameters
+ // check required parameter: webServiceAnnotation
+ if (null == webServiceAnnotation)
+ {
+ throw new IllegalArgumentException("@WebService is required");
+ }
+
+ // check required parameter: fqClassName
if ((null == fqClassName) || (0 == fqClassName.length()))
{
throw new IllegalArgumentException("className not set");
}
javaFQClassName = fqClassName;
- // check required parameters
- if (null == webServiceAnnotation )
+ // check required parameters: annotations, webMethods
+ if ((null == annotations) || (null == webMethods))
{
- throw new IllegalArgumentException("@WebService is required");
+ throw new IllegalArgumentException("annotations or webMethods is null");
}
// enforce JSR-181 rules
if (AnnotationModel.hasAnnotationType(annotations, SOAPMessageHandlers.class) &&
AnnotationModel.hasAnnotationType(annotations, HandlerChain.class))
{
- // todo needs to be proper Exception subclass
+ // todo needs to be proper Exception subclass (e.g. ObjectModelException)
throw new Exception(
- "Illegal combination of @SOAPMessageHandlers and @HandlerChain");
+ "Illegal combination of @SOAPMessageHandlers and @HandlerChain"
+ );
}
-
- // initialize from required annotation
+
initFromAnnotation(webServiceAnnotation);
// set optional annotations
- for (Annotation a : annotations) {
+ for (Annotation a : annotations)
+ {
// @HandlerChain
- if (a.annotationType() == javax.jws.HandlerChain.class) {
+ if (a.annotationType() == javax.jws.HandlerChain.class)
+ {
initFromAnnotation((javax.jws.HandlerChain) a);
}
// @SecurityIdentity
- else if (a.annotationType() == javax.jws.security.SecurityIdentity.class) {
+ else if (a.annotationType() == javax.jws.security.SecurityIdentity.class)
+ {
initFromAnnotation((javax.jws.security.SecurityIdentity) a);
}
// @SecurityRoles
- else if (a.annotationType() == javax.jws.security.SecurityRoles.class) {
+ else if (a.annotationType() == javax.jws.security.SecurityRoles.class)
+ {
initFromAnnotation((javax.jws.security.SecurityRoles) a);
}
- // @SOAPBinding (TYPE-level)
- else if (a.annotationType() == javax.jws.soap.SOAPBinding.class) {
+ // @SOAPBinding
+ else if (a.annotationType() == javax.jws.soap.SOAPBinding.class)
+ {
initFromAnnotation((javax.jws.soap.SOAPBinding) a);
}
@@ -139,14 +150,33 @@
}
else
{
- //TODO: What to do with annotations that are not specified in
- // 181, for now ignore them.
+ // TODO: What to do with annotations that are not specified in
+ // 181? For now ignore them. Later: delegation model?
}
}
- // set WebServiceMETHODMetadata
+ // set WebServiceMETHODMetadata and back fill JSR-181 default values
for (WebServiceMETHODMetadata wsmm : webMethods)
{
+ // JSR-181 defaults: fill in default for tergetNamespace from @WebService
+ String wrTargetNamespace = wsmm.getWrTargetNamespace();
+ if ((null != wrTargetNamespace) && (0 == wrTargetNamespace.length()))
+ {
+ wsmm.setWrTargetNamespace(getWsTargetNamespace());
+ }
+
+ // JSR-181 defaults: fill in default for tergetNamespace from @WebService
+ for (WebServicePARAMETERMetadata wspm : wsmm.getParams())
+ {
+ String wpTargetNamespace = wspm.getWpTargetNamespace();
+ if ((null != wpTargetNamespace) && (0 == wpTargetNamespace.length()))
+ {
+ wspm.setWpTargetNamespace(getWsTargetNamespace());
+System.out.println("***" + wspm.getWpTargetNamespace());
+ }
+ }
+
+ // add WebMethod to TYPE metadata
addMethod(wsmm);
}
}
@@ -187,34 +217,21 @@
}
}
- private void initFromAnnotation(SOAPBinding annotation) {
- if (null != annotation) {
+ private void initFromAnnotation(SOAPBinding annotation)
+ {
+ if (null != annotation)
+ {
setSoapBinding(new SOAPBindingInfo(annotation));
}
SOAPBindingInfo sbi = getSoapBinding();
- if (null == sbi) {
+ if (null == sbi)
+ {
throw new IllegalArgumentException(
- "illegal SOAPBinding annotation on WebService class:\n\t"
- + sbi);
- }
-/* not defaults to set anymore...
- // style
- if (javax.jws.soap.SOAPBinding.Style.DEFAULT == sbi.getStyle()) {
- sbi.setStyle(javax.jws.soap.SOAPBinding.Style.DOCUMENT);
+ "illegal SOAPBinding annotation on WebService class:\n\t" + sbi
+ );
}
- // use
- if (javax.jws.soap.SOAPBinding.Use.DEFAULT == sbi.getUse()) {
- sbi.setUse(javax.jws.soap.SOAPBinding.Use.LITERAL);
- }
-
- // default
- if (javax.jws.soap.SOAPBinding.ParameterStyle.DEFAULT == sbi
- .getParameterStyle()) {
- sbi
- .setParameterStyle(javax.jws.soap.SOAPBinding.ParameterStyle.WRAPPED);
- }
-*/
+ // no defaults to handle
}
private void initFromAnnotation(HandlerChain annotation) {
@@ -242,47 +259,57 @@
}
}
- private void initFromAnnotation(SOAPMessageHandlers annotation) {
-
- if (null != annotation) {
- if (getHcFileName() == null) {
+ private void initFromAnnotation(SOAPMessageHandlers annotation)
+ {
+ if (null != annotation)
+ {
+ if (null == getHcFileName())
+ {
SOAPMessageHandler[] soapMsgHandlerArray = annotation.value();
-
- for (int i = 0; i < soapMsgHandlerArray.length; i++) {
- addSOAPHandler(new SOAPMessageHandlerInfo
- (soapMsgHandlerArray[i]));
+ for (int i = 0; i < soapMsgHandlerArray.length; i++)
+ {
+ addSOAPHandler(
+ new SOAPMessageHandlerInfo(soapMsgHandlerArray[i])
+ );
}
}
- else {
- throw new IllegalArgumentException
- ("SOAPMessageHandlers and HandlerChain annotations" +
- " are mutually exclusive, and a HandlerChain " +
- "annotation is already present.");
+ else
+ {
+ throw new IllegalArgumentException(
+ "SOAPMessageHandlers and HandlerChain annotations " +
+ "are mutually exclusive, and a HandlerChain " +
+ "annotation is already present."
+ );
}
}
}
- private void initFromAnnotation(SecurityRoles annotation) {
- if (null != annotation) {
+ private void initFromAnnotation(SecurityRoles annotation)
+ {
+ if (null != annotation)
+ {
setSecurityRoles(new SecurityRolesInfo(annotation));
}
- // no defaults to handle
+ // no defaults to handle
}
- private void initFromAnnotation(SecurityIdentity annotation) {
- if (null != annotation) {
+ private void initFromAnnotation(SecurityIdentity annotation)
+ {
+ if (null != annotation)
+ {
setSiValue(annotation.value());
}
- // no defaults to handle
+ // no defaults to handle
}
- private void configureHandlerChain(String handlerChainConfigPath,
- String handlerChainName)
+ private void configureHandlerChain(
+ String handlerChainConfigPath,
+ String handlerChainName
+ )
throws Exception
{
-
URL handlerChainConfigURL;
// check if we have a likely absolute URL
@@ -314,7 +341,6 @@
handlerChainConfigURL = getClass().getClassLoader()
.getResource(fullPath.toString().replace('.', '/') +
handlerChainConfigPath);
-
}
}
initHandlersFromChainConfig(handlerChainConfigURL, handlerChainName);