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/11 00:26:37 UTC

svn commit: rev 43692 - in incubator/beehive/trunk/wsm: drt/tests/org/apache/beehive/wsm/jsr181/model src/runtime/org/apache/beehive/wsm/jsr181/model src/runtime/org/apache/beehive/wsm/jsr181/processor/apt src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection

Author: mmerz
Date: Fri Sep 10 15:26:36 2004
New Revision: 43692

Removed:
   incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/MetaDataTest.java
Modified:
   incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java
   incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPBindingInfo.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
   incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java
   incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java
Log:
Added method and parameter level unit tests, modified the model classes to implement the correct defaults.

The model classes now have:

 	** empty constructor  -- primarily for the case of building model from WSDL -- this still needs some work 

	** constructor with (RequiredAnnotation,  required defaults, List<Annotations> optional annotations, more arguments).  The first argument is the required annotation for the model object (e.g. @webmethod for method, but for case of WebParam, it may NOT be null), followed by other required arguments for the class, followed the list of optional annotations,

	**  InitFromAnnotation(annotation) for all anotations that the model expects, it should enforce the JSR 181 defaults for a given anotation.



Here is how the new model classes work:

 

	a)       Model attributes are not initialized by default.  – this would make sure the  constructors are initializing the class properly.

	b)       the model class attributes are initialized in the empty constructor as required in the WSDL case

	c)       In the constructor with the (required annotation, other required defaults. List<Annotoation>.) we do the following:


		1:        first check to make sure the required annotation are not null,

		2:      initialize the model attributes based on the required annotations as if  there are no optional annotations

		3:       For each annotation in the list of optional annotation call initFromAnnotation

		4:       The container model class (e.g. Method for Parameters, or Type for Method and Parameters) are responsible for setting the missing defaults that could not have been set when the model class was created.  



Contributor:  Daryoush Mehrtash



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	Fri Sep 10 15:26:36 2004
@@ -7,6 +7,9 @@
 
 import javax.jws.InitParam;
 import javax.jws.QName;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
 import javax.jws.soap.SOAPBinding;
 import javax.jws.soap.SOAPMessageHandler;
 
@@ -21,6 +24,8 @@
 import org.apache.beehive.wsm.jsr181.model.fakeAnnotations.FakeSecurityIdentityAnnotation;
 import org.apache.beehive.wsm.jsr181.model.fakeAnnotations.FakeSecurityRoleAnnotation;
 import org.apache.beehive.wsm.jsr181.model.fakeAnnotations.FakeWebMethodAnnotation;
+import org.apache.beehive.wsm.jsr181.model.fakeAnnotations.FakeWebParamAnnotation;
+import org.apache.beehive.wsm.jsr181.model.fakeAnnotations.FakeWebResultAnnotation;
 import org.apache.beehive.wsm.jsr181.model.fakeAnnotations.FakeWebServiceAnnotation;
 
 import junit.framework.TestCase;
@@ -38,6 +43,16 @@
     public void testTYPERequiredAnnotations() throws Exception {
         // test to make sure the Type throws an exception if there are no
         // WebMethod annotation defined.
+         try {
+            WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
+                   null,  "a.b.c.testclass", null,null);
+            assertTrue(
+                    "Error, the TYPE annotation should fail without @WebService",
+                    false);
+        } catch (IllegalArgumentException e) {
+            // good case
+        }        
+        
         Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
         Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
         typeAnnotations.add(new FakeSOAPBindingAnnotation(
@@ -45,7 +60,7 @@
                 SOAPBinding.ParameterStyle.DEFAULT));
         try {
             WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
-                    typeAnnotations, "a.b.c.testclass", methodMetadata);
+                    null,  "a.b.c.testclass", typeAnnotations, methodMetadata);
             assertTrue(
                     "Error, the TYPE annotation should fail without @WebService",
                     false);
@@ -57,9 +72,10 @@
     public void testTYPEWebServiceDefaults() throws Exception {
         Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
         Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
-        typeAnnotations.add(new FakeWebServiceAnnotation("", "", "", "", ""));
+        WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+        typeAnnotations.add(wsAnnotation);
         WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
-                typeAnnotations, "a.b.c.testclass", methodMetadata);
+                wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
         assertTrue("Invalid WebService Name, got: " + type.getWsName(), type
                 .getWsName().compareTo("testclass") == 0);
         assertTrue(type.getWsServiceName().compareTo("testclassService") == 0);
@@ -71,11 +87,12 @@
     public void testTYPEWebServiceAnnotation() throws Exception {
         Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
         Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
-        typeAnnotations.add(new FakeWebServiceAnnotation("testname",
+        WebService wsAnnotation = new FakeWebServiceAnnotation("testname",
                 "testserviceName", "testwsdllocation", "testtargetnamespace",
-                "testendpointinterface"));
+                "testendpointinterface");
+        typeAnnotations.add(wsAnnotation);
         WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
-                typeAnnotations, "a.b.c.testclass", methodMetadata);
+                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);
@@ -86,14 +103,15 @@
     public void testTYPESOAPBindingAnnotationDefaults() throws Exception {
         Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
         Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
-        typeAnnotations.add(new FakeWebServiceAnnotation("testname",
+        WebService wsAnnotation = new FakeWebServiceAnnotation("testname",
                 "testserviceName", "testwsdllocation", "testtargetnamespace",
-                "testendpointinterface"));
+                "testendpointinterface");
+        typeAnnotations.add(wsAnnotation);
         typeAnnotations.add(new FakeSOAPBindingAnnotation(
                 SOAPBinding.Style.DEFAULT, SOAPBinding.Use.DEFAULT,
                 SOAPBinding.ParameterStyle.DEFAULT));
         WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
-                typeAnnotations, "a.b.c.testclass", methodMetadata);
+                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);
@@ -102,14 +120,14 @@
     public void testTYPESOAPBindingAnnotation() throws Exception {
         Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
         Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
-        typeAnnotations.add(new FakeWebServiceAnnotation("", "", "", "", ""));
-
+        WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+        typeAnnotations.add(wsAnnotation);
         typeAnnotations.add(new FakeSOAPBindingAnnotation(
                 SOAPBinding.Style.RPC, SOAPBinding.Use.ENCODED,
                 SOAPBinding.ParameterStyle.BARE));
         WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
-                typeAnnotations, "a.b.c.testclass", methodMetadata);
-        assertTrue(type.getSoapBinding().getStyle() == SOAPBinding.Style.RPC);
+                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);
     }
@@ -120,12 +138,13 @@
     public void testTYPEHandlerChainAnnotation() throws Exception {
         Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
         Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
-        typeAnnotations.add(new FakeWebServiceAnnotation("", "", "", "", ""));
+        WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+        typeAnnotations.add(wsAnnotation);
 
         typeAnnotations.add(new FakeHandlerChainAnnotation("testfile",
                 "testname"));
         WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
-                typeAnnotations, "a.b.c.testclass", methodMetadata);
+                wsAnnotation, "a.b.c.testclass", typeAnnotations,  methodMetadata);
         assertTrue(type.getHcFileName() == "testfile");
         assertTrue(type.getHcName() == "testname");
     }
@@ -134,14 +153,15 @@
     public void testTYPESoapMessageHandlersDefaults1() throws Exception {
         Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
         Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
-        typeAnnotations.add(new FakeWebServiceAnnotation("", "", "", "", ""));
+        WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+        typeAnnotations.add(wsAnnotation);
 
         FakeSOAPMessageHandlerAnnotation[] emptyHandlers = new FakeSOAPMessageHandlerAnnotation[0];
         typeAnnotations
                 .add(new FakeSOAPMessageHandlersAnnotation(emptyHandlers));
         WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
-                typeAnnotations, "a.b.c.testclass", methodMetadata);
-        assertTrue(type.getSoapHandlers().size() == 0);
+                wsAnnotation, "a.b.c.testclass", typeAnnotations,  methodMetadata);
+         assertTrue(type.getSoapHandlers().size() == 0);
 
     }
 
@@ -149,7 +169,8 @@
     public void testTYPESoapMessageHandlersDefaults2() throws Exception {
         Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
         Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
-        typeAnnotations.add(new FakeWebServiceAnnotation("", "", "", "", ""));
+        WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+        typeAnnotations.add(wsAnnotation);
 
         SOAPMessageHandler[] defaultHandlers = new FakeSOAPMessageHandlerAnnotation[1];
         defaultHandlers[0] = new FakeSOAPMessageHandlerAnnotation("",
@@ -158,8 +179,8 @@
         typeAnnotations.add(new FakeSOAPMessageHandlersAnnotation(
                 defaultHandlers));
         WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
-                typeAnnotations, "a.b.c.testclass", methodMetadata);
-        assertTrue("number of handlers returned: "
+                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);
@@ -173,7 +194,8 @@
     public void testTYPESoapMessageHandlers() throws Exception {
         Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
         Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
-        typeAnnotations.add(new FakeWebServiceAnnotation("", "", "", "", ""));
+        WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+        typeAnnotations.add(wsAnnotation);
 
         InitParam[] params = { new FakeInitParamAnnotation("paramname",
                 "paramvalue") };
@@ -185,8 +207,8 @@
         typeAnnotations.add(new FakeSOAPMessageHandlersAnnotation(
                 defaultHandlers));
         WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
-                typeAnnotations, "a.b.c.testclass", methodMetadata);
-        assertTrue("number of handlers returned: "
+                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);
@@ -211,11 +233,12 @@
     public void testTYPESecurityRolesDefaults() throws Exception {
         Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
         Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
-        typeAnnotations.add(new FakeWebServiceAnnotation("", "", "", "", ""));
+        WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+        typeAnnotations.add(wsAnnotation);
         typeAnnotations.add(new FakeSecurityRoleAnnotation(null, null));
         WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
-                typeAnnotations, "a.b.c.testclass", methodMetadata);
-
+                wsAnnotation, "a.b.c.testclass", typeAnnotations,  methodMetadata);
+ 
         assertNull(type.getSecurityRoles().getRolesAllowed());
         assertNull(type.getSecurityRoles().getRolesReferenced());
 
@@ -224,14 +247,15 @@
     public void testTYPESecurityRoles() throws Exception {
         Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
         Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
-        typeAnnotations.add(new FakeWebServiceAnnotation("", "", "", "", ""));
+        WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+        typeAnnotations.add(wsAnnotation);
         String[] rolesAllowed = { "rolesallowed" };
         String[] rolesReferenced = { "rolesreferenced" };
         typeAnnotations.add(new FakeSecurityRoleAnnotation(rolesAllowed,
                 rolesReferenced));
         WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
-                typeAnnotations, "a.b.c.testclass", methodMetadata);
-
+                wsAnnotation, "a.b.c.testclass", typeAnnotations,  methodMetadata);
+ 
         assertTrue(type.getSecurityRoles().getRolesAllowed().size() == 1);
         assertTrue(type.getSecurityRoles().getRolesAllowed().iterator().next()
                 .compareTo("rolesallowed") == 0);
@@ -243,11 +267,12 @@
     public void testTYPESecurityIdentityDefaults() throws Exception {
         Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
         Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
-        typeAnnotations.add(new FakeWebServiceAnnotation("", "", "", "", ""));
+        WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+        typeAnnotations.add(wsAnnotation);
         typeAnnotations.add(new FakeSecurityIdentityAnnotation(null));
         WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
-                typeAnnotations, "a.b.c.testclass", methodMetadata);
-
+                wsAnnotation, "a.b.c.testclass", typeAnnotations,  methodMetadata);
+ 
         assertNull(type.getSiRunAs());
 
     }
@@ -255,21 +280,30 @@
     public void testTYPESecurityIdentity() throws Exception {
         Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
         Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
-        typeAnnotations.add(new FakeWebServiceAnnotation("", "", "", "", ""));
+        WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+        typeAnnotations.add(wsAnnotation);
         typeAnnotations
                 .add(new FakeSecurityIdentityAnnotation("runasidentity"));
         WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
-                typeAnnotations, "a.b.c.testclass", methodMetadata);
-
-        assertTrue(type.getSiRunAs().compareTo("runasidentity") == 0);
+                wsAnnotation, "a.b.c.testclass", typeAnnotations,  methodMetadata);
+         assertTrue(type.getSiRunAs().compareTo("runasidentity") == 0);
     }
 
-    //TODO: test METHOD level
+    //test METHOD level
     public void testMETHODRequiredAnnotations() throws Exception {
+        try {
+            WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+                    null, "methodname", Void.class, 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(
-                    methodAnnotations, "methodname", Void.class, null);
+                    null, "methodname", Void.class, methodAnnotations, null);
             assertTrue(
                     "Error, the METHOD annotation should fail without @WebMethod",
                     false);
@@ -277,10 +311,11 @@
             // good case
         }
 
-        methodAnnotations.add(new FakeWebMethodAnnotation("", ""));
+        WebMethod mAnnotation = new FakeWebMethodAnnotation("", "");
+        methodAnnotations.add(mAnnotation);
         try {
             WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
-                    methodAnnotations, null, Void.class, null);
+                    mAnnotation,  null, Void.class, methodAnnotations,null);
             assertTrue(
                     "Error, the METHOD annotation should fail without method name",
                     false);
@@ -289,7 +324,7 @@
         }
         try {
             WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
-                    methodAnnotations, "methodName", null, null);
+                   mAnnotation, "methodName", null,  methodAnnotations,null);
             assertTrue(
                     "Error, the METHOD annotation should fail without return type class",
                     false);
@@ -300,9 +335,10 @@
 
     public void testMETHODWebMethodDefaults() throws Exception {
         Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
-        methodAnnotations.add(new FakeWebMethodAnnotation("", ""));
+        WebMethod mAnnotation = new FakeWebMethodAnnotation("", "");
+        methodAnnotations.add(mAnnotation);
         WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
-                methodAnnotations, "methodname", Void.class, null);
+               mAnnotation,  "methodname", Void.class, methodAnnotations,null);
         assertTrue(method.getWmOperationName().compareTo("methodname") == 0);
         assertTrue(method.getWmAction().length() == 0);
         
@@ -310,9 +346,10 @@
 
     public void testMETHODWebMethod() throws Exception {
         Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
-        methodAnnotations.add(new FakeWebMethodAnnotation("operationname", "action"));
+        WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
+        methodAnnotations.add(mAnnotation);
         WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
-                methodAnnotations, "methodname", Void.class, null);
+              mAnnotation,  "methodname", Void.class, methodAnnotations, null);
         assertTrue(method.getWmOperationName().compareTo("operationname") == 0);
         assertTrue(method.getWmAction().compareTo("action") == 0);
         
@@ -320,30 +357,165 @@
     
     public void testMETHODOneWayDefaults() throws Exception {
         Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
-        methodAnnotations.add(new FakeWebMethodAnnotation("operationname", "action"));
-        WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
-                methodAnnotations, "methodname", String.class, null);
+        WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
+        methodAnnotations.add(mAnnotation);
+       WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+                mAnnotation,  "methodname", Void.class, methodAnnotations, null);
         assertFalse(method.isOneWay());
     }
     
     public void testMETHODOneWay() throws Exception {
         Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
-        methodAnnotations.add(new FakeWebMethodAnnotation("operationname", "action"));
+        WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
+        methodAnnotations.add(mAnnotation);
         methodAnnotations.add(new FakeOneWayAnnotation());
         WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
-                methodAnnotations, "methodname", String.class, null);
+                mAnnotation,  "methodname", Void.class, methodAnnotations, null);
         assertTrue(method.isOneWay());       
     }
     
-    public void testMETHODWebResultsDefaults() throws Exception {
-        
+    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, methodAnnotations, null);
+        assertTrue(method.getWrName().compareTo("result") == 0);
     }
     
-    public void testMETHODWebResults() throws Exception {
-        
+    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, methodAnnotations, null);
+       assertTrue(method.getWrName().compareTo("resultname") == 0);
+         
+    }
+    
+    public void testMETHODSoapBindingDefaults() throws Exception {
+        Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+        WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
+        methodAnnotations.add(mAnnotation);
+        methodAnnotations.add(new FakeSOAPBindingAnnotation(
+                SOAPBinding.Style.DEFAULT, SOAPBinding.Use.DEFAULT,
+                SOAPBinding.ParameterStyle.DEFAULT));
+        WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+                mAnnotation,  "methodname", Void.class, methodAnnotations, null);
+       assertTrue(method.getSoapBinding().getStyle() == SOAPBinding.Style.DOCUMENT);
+        assertTrue(method.getSoapBinding().getUse() == SOAPBinding.Use.LITERAL);
+        assertTrue(method.getSoapBinding().getParameterStyle() == SOAPBinding.ParameterStyle.WRAPPED);
+    }
+    
+    public void testMETHODSoapBinding() throws Exception {
+        Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+        WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
+        methodAnnotations.add(mAnnotation);
+        methodAnnotations.add(new FakeSOAPBindingAnnotation(
+                SOAPBinding.Style.RPC, SOAPBinding.Use.ENCODED,
+                SOAPBinding.ParameterStyle.BARE));
+        WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+                mAnnotation,  "methodname", Void.class, methodAnnotations, null);
+       assertTrue(method.getSoapBinding().getStyle() == SOAPBinding.Style.RPC);
+        assertTrue(method.getSoapBinding().getUse() == SOAPBinding.Use.ENCODED);
+        assertTrue(method.getSoapBinding().getParameterStyle() == SOAPBinding.ParameterStyle.BARE);
+         
     }
-    //TODO: test PARAMETER level annotation
+    
+    
+    public void testMETHODSecurityRoleDefaults() throws Exception {
+        Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+        WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
+        methodAnnotations.add(mAnnotation);
+        methodAnnotations.add(new FakeSecurityRoleAnnotation(null, null));
 
+        WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+                mAnnotation,  "methodname", Void.class, methodAnnotations, null);
+         assertNull(method.getSecurityRoles().getRolesAllowed());
+         assertNull(method.getSecurityRoles().getRolesReferenced());
+    }
+    
+    public void testMETHODSecurityRole() throws Exception {
+        Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+        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, 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);
+         
+    }
+    
+       
+    //test PARAMETER level annotation
+    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 testPARAMETERWebParamDefault() {
+        try {
+            WebServicePARAMETERMetadata param = new WebServicePARAMETERMetadata(
+                    null, String.class, "paramname", null);
+            assertTrue(
+                    "Error, the PARAMTER annotation should fail without @WebParam",
+                    false);
+        } catch (IllegalArgumentException e) {
+            // good case
+        }
+        Collection<Annotation> paramAnnotations = new ArrayList<Annotation>();
+        try {
+            WebServicePARAMETERMetadata param= new WebServicePARAMETERMetadata (
+                   null, String.class, "paramname", paramAnnotations);
+            assertTrue(
+                    "Error, the PARAMTER annotation should fail without @WebParam",
+                                       false);
+        } catch (IllegalArgumentException e) {
+            // good case
+        }
+ 
+        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());
+        
+    }
     // TODO: test combination of type, method, annotation
 }
 

Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPBindingInfo.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPBindingInfo.java	(original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPBindingInfo.java	Fri Sep 10 15:26:36 2004
@@ -79,5 +79,10 @@
         setStyle(annotation.style());
         setUse(annotation.use());
         setParameterStyle(annotation.parameterStyle());
+        
+        // set the defaults
+        if(getStyle() == SOAPBinding.Style.DEFAULT) setStyle(SOAPBinding.Style.DOCUMENT);
+        if(getUse() == SOAPBinding.Use.DEFAULT) setUse(SOAPBinding.Use.LITERAL);
+        if(getParameterStyle() == SOAPBinding.ParameterStyle.DEFAULT) setParameterStyle(SOAPBinding.ParameterStyle.WRAPPED);
      }
 }

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	Fri Sep 10 15:26:36 2004
@@ -67,9 +67,9 @@
         super();
     }
 
-    public WebServiceMETHODMetadata(Collection<Annotation> annotations,
+    public WebServiceMETHODMetadata(javax.jws.WebMethod methodAnnotation, 
             String javaMethodName, Class javaReturnType,
-            List< ? extends WebServicePARAMETERMetadata> webParams) {
+            Collection<Annotation> annotations, List< ? extends WebServicePARAMETERMetadata> webParams) {
         // check parameters
         if ((null == javaMethodName) || (null == javaReturnType)) {
             throw new IllegalArgumentException(
@@ -79,11 +79,14 @@
         this.javaReturnType = javaReturnType;
 
         // check required parameters
-        if (!hasAnnotationType(annotations, javax.jws.WebMethod.class)) {
+        if (null == methodAnnotation) {
             throw new IllegalArgumentException("@WebMethod is required");
         }
+        
+        // initialize from required annotation
+       initFromAnnotation(methodAnnotation);
 
-        // extract information from annotations
+       // set optional annotations
         for (Annotation a : annotations) {
 
             // add defaults
@@ -93,10 +96,7 @@
             } else if (a.annotationType() == javax.jws.SecurityRoles.class) {
                 initFromAnnotation((javax.jws.SecurityRoles) a);
 
-            } else if (a.annotationType() == javax.jws.WebMethod.class) {
-                initFromAnnotation((javax.jws.WebMethod) a);
-
-            } else if (a.annotationType() == javax.jws.WebResult.class) {
+             } else if (a.annotationType() == javax.jws.WebResult.class) {
                 initFromAnnotation((javax.jws.WebResult) a);
 
             } else if (a.annotationType() == javax.jws.soap.DocumentWrapper.class) {
@@ -111,22 +111,26 @@
         }
 
         // set WebServicePARAMETERMetadata
-        if (null != webParams) {
-            int i = 0;
-            for (WebServicePARAMETERMetadata wspm : webParams) {
-                i++;
-                // todo check defaults for wspm
-                if (0 == wspm.getWpName().length()) {
-                    if (wspm.getSourceName() == null
-                            || wspm.getSourceName().length() == 0)
-                        wspm.setWpName("param_" + i);
-                    else
-                        wspm.setWpName(wspm.getSourceName());
-                }
-
-                addParam(wspm);
-            }
-        }
+        addParams(webParams);
+        
+//        TODO:  Remove the default checking here, this should have been done in the WebServiceParameter
+//        if (null != webParams) {
+//            
+//            int i = 0;
+//            for (WebServicePARAMETERMetadata wspm : webParams) {
+//                i++;
+//                // todo check defaults for wspm
+//                if (0 == wspm.getWpName().length()) {
+//                    if (wspm.getDefaultName() == null
+//                            || wspm.getDefaultName().length() == 0)
+//                        wspm.setWpName("param_" + i);
+//                    else
+//                        wspm.setWpName(wspm.getDefaultName());
+//                }
+//
+//                addParam(wspm);
+//            }
+//        }
     }
 
     /**
@@ -329,10 +333,14 @@
         return Collections.unmodifiableList(params);
     }
 
-    public void addParam(WebServicePARAMETERMetadata param) {
-        params.add(param);
+    public void addParams(Collection<? extends WebServicePARAMETERMetadata> parameters) {
+        if(null != parameters)    this.params.addAll(parameters);
     }
 
+    public void addParam(WebServicePARAMETERMetadata parameter) {
+        if(null != parameter)    this.params.add(parameter);
+    }
+    
     public String getJavaMethodName() {
         return javaMethodName;
     }

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	Fri Sep 10 15:26:36 2004
@@ -34,47 +34,46 @@
 
     private Class javaType;
 
-    private String sourceName;
+    private String defaultName;
 
-    
-    
-    
     /**
-     * 
+     *  
      */
     public WebServicePARAMETERMetadata() {
         super();
     }
-    
+
     private void setDefaults(javax.jws.WebParam wp) {
         // deferred --> requires METHOD information: position
     }
 
-    // sourceName is argument name in the source file. It can be null if the
+    // defaultName is argument name in the source file. It can be null if the
     // name is not known.
-    public WebServicePARAMETERMetadata(Collection<Annotation> annotations,
-            Class javaType, String sourceName) {
+    public WebServicePARAMETERMetadata(javax.jws.WebParam webParamAnnotation,
+            Class javaType, String defaultName,
+            Collection<Annotation> annotations) {
         // check parameters
         if (null == javaType) {
             throw new IllegalArgumentException("javaType not set");
         }
 
         this.javaType = javaType;
-        this.sourceName = sourceName;
+
+        setWpName(defaultName); // in case there are no annotations
 
         // check required parameters
-        if (!hasAnnotationType(annotations, javax.jws.WebParam.class)) {
+        if (null == annotations
+                || !hasAnnotationType(annotations, javax.jws.WebParam.class)) {
             throw new IllegalArgumentException("@WebParam is required");
         }
-        // extract information from annotations
-        for (Annotation a : annotations) {
-
-            // add defaults
-            if (a.annotationType() == javax.jws.WebParam.class) {
-                initFromAnnotation((javax.jws.WebParam) a);
- 
-            }
-        }
+        
+        // initialize from required annotation
+       if(null != webParamAnnotation) initFromAnnotation(webParamAnnotation);
+        
+       // set optional annotations  .. None in the case of parameters
+//        for (Annotation a : annotations) {   
+//
+//        }
 
     }
 
@@ -123,7 +122,6 @@
         this.wpName = wpName;
     }
 
-
     /**
      * @return Returns the javaType.
      */
@@ -134,33 +132,38 @@
     public void setJavaType(Class javaType) {
         this.javaType = javaType;
     }
-     /**
+
+    /**
      * @param webParam
      */
     private void initFromAnnotation(WebParam annotation) {
         if (null != annotation) {
-            setWpName(annotation.name());
+            if(annotation.name().length()!=0) setWpName(annotation.name());
             setWpMode(annotation.mode());
             setWpHeader(annotation.header());
         }
-        // deferred --> requires METHOD information: position
 
     }
 
- 
-
-    /**
-     * @return Returns the sourceName.
-     */
-    public String getSourceName() {
-        return sourceName;
-    }
-
-    /**
-     * @param sourceName
-     *            The sourceName to set.
-     */
-    public void setSourceName(String sourceName) {
-        this.sourceName = sourceName;
-    }
+    //    /**
+    //     *
+    //     */
+    //    private void setDefaults() {
+    //        if(getWpName().length() == 0) setWpName(getDefaultName());
+    //    }
+    //
+    //    /**
+    //     * @return Returns the defaultName.
+    //     */
+    //    public String getDefaultName() {
+    //        return defaultName;
+    //    }
+    //
+    //    /**
+    //     * @param defaultName
+    //     * The defaultName to set.
+    //     */
+    //    public void setDefaultName(String sourceName) {
+    //        this.defaultName = sourceName;
+    //    }
 }

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	Fri Sep 10 15:26:36 2004
@@ -67,41 +67,42 @@
         super();
     }
 
-    static public WebServiceTYPEMetadata buildWSMetadata(String filename)
-            throws InvalidFileType {
-        if (filename.endsWith(".java") || filename.endsWith(".jws")) {
-            //TODO: get the object model from 2 phase processor
-            return null;
-        } else {
-            throw new InvalidFileType(
-                    "File: "
-                            + filename
-                            + " is not supported.  Only .java, .jws, and .class files are supported");
-        }
-    }
+//    TODO:  not used anymore, remove it.
+//    static public WebServiceTYPEMetadata buildWSMetadata(String filename)
+//            throws InvalidFileType {
+//        if (filename.endsWith(".java") || filename.endsWith(".jws")) {
+//            //TODO: get the object model from 2 phase processor
+//            return null;
+//        } else {
+//            throw new InvalidFileType(
+//                    "File: "
+//                            + filename
+//                            + " is not supported.  Only .java, .jws, and .class files are supported");
+//        }
+//    }
 
-    public WebServiceTYPEMetadata(Collection<Annotation> annotations,
-            String fqClassName,
-            Collection< ? extends WebServiceMETHODMetadata> webMethods) {
+    public WebServiceTYPEMetadata(WebService webServiceAnnotation, String fqClassName, Collection<Annotation> annotations,
+                 Collection< ? extends WebServiceMETHODMetadata> webMethods) {
         super();
-        // check parameters
+        // check required parameters
         if ((null == fqClassName) || (0 == fqClassName.length())) {
             throw new IllegalArgumentException("className not set");
         }
         this.javaFQClassName = fqClassName;
 
         // check required parameters
-        if (!hasAnnotationType(annotations, javax.jws.WebService.class)) {
+        if (null == webServiceAnnotation ) {
             throw new IllegalArgumentException("@WebService is required");
         }
-
-        // extract information from annotations
+        
+        // initialize from required annotation
+        initFromAnnotation(webServiceAnnotation);
+        
+        
+        // set optional annotations
         for (Annotation a : annotations) {
-            if (a.annotationType() == javax.jws.WebService.class) {
-                initFromAnnotation((javax.jws.WebService) a);
-            }
             // @HandlerChain
-            else if (a.annotationType() == javax.jws.HandlerChain.class) {
+            if (a.annotationType() == javax.jws.HandlerChain.class) {
                 initFromAnnotation((javax.jws.HandlerChain) a);
             }
 

Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java	(original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java	Fri Sep 10 15:26:36 2004
@@ -114,9 +114,11 @@
         // create & return webService
         WebServiceTYPEMetadata wstm = null;
         try {
+            Collection<Annotation> annotations = getAnnotations(decl);
             wstm = new WebServiceTYPEMetadata(
-                getAnnotations(decl),
-                decl.getQualifiedName(),
+                (javax.jws.WebService)getAnnotationOfType(annotations, javax.jws.WebService.class),
+                 decl.getQualifiedName(),
+                annotations,
                 webMethods
             );
         }
@@ -144,10 +146,12 @@
         // create & return webMethod
         WebServiceMETHODMetadata wsmm = null;
         try {
-            wsmm = new WebServiceMETHODMetadata(
-                getAnnotations(decl),
+            Collection<Annotation> annotations = getAnnotations(decl);
+             wsmm = new WebServiceMETHODMetadata(
+                (javax.jws.WebMethod)getAnnotationOfType(annotations, javax.jws.WebMethod.class),
                 decl.getSimpleName(),
                 classForName(decl.getReturnType().toString()),
+                annotations,
                 webParams
             );
         }
@@ -164,10 +168,12 @@
         // create & return webParam
         WebServicePARAMETERMetadata wspm = null;
         try {
+            Collection<Annotation> annotations = getAnnotations(decl);
             wspm = new WebServicePARAMETERMetadata(
-                getAnnotations(decl),
+               (javax.jws.WebParam)getAnnotationOfType(annotations, javax.jws.WebParam.class),
                 classForName(decl.getType().toString()),
-                decl.getSimpleName()
+                decl.getSimpleName(),
+                annotations
             );
         }
         catch (Throwable t)
@@ -177,6 +183,23 @@
         return wspm;
     }
 
+    //TODO: can this method be enhanced?
+    protected Annotation getAnnotationOfType(Collection<Annotation> annotations, Class<? extends Annotation> annotationType)
+    {
+        if ((null != annotations) && (null != annotationType) && (0 < annotations.size()))
+        {
+            for ( Annotation a : annotations )
+            {
+                if (a.annotationType() == annotationType)
+                {
+                    return a;
+                }
+            }
+        }
+        return null;
+    }
+
+    
     private Collection<Annotation> getAnnotations(Declaration decl)
     {
         Collection<Annotation> annotations = new ArrayList<Annotation>();

Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java	(original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java	Fri Sep 10 15:26:36 2004
@@ -45,9 +45,11 @@
     }
 
     public static WebServiceTYPEMetadata getObjectModel(Class clazz) {
-        if(null == clazz.getAnnotation(WebService.class))  // no @WebService
+        WebService wsAnnotation;
+        if (null == (wsAnnotation = (WebService) clazz
+                .getAnnotation(WebService.class))) // no @WebService
             return null;
-        
+
         Method[] methods = clazz.getMethods();
         Collection<WebServiceMETHODMetadata> webMethods = new ArrayList<WebServiceMETHODMetadata>();
         for (Method method : methods) {
@@ -61,28 +63,31 @@
                 Class< ? >[] methodParamTypes = method.getParameterTypes();
                 Annotation[][] allAnnotations = method
                         .getParameterAnnotations();
-
+                WebParam wpAnnotation = (WebParam) method
+                        .getAnnotation(WebParam.class);
                 for (Class paramType : methodParamTypes) {
                     WebParam webParam = null;
                     WebServicePARAMETERMetadata paramMetaData = new WebServicePARAMETERMetadata(
-                            Arrays.asList(allAnnotations[offset]),
-                            paramType, null); // class reflection
-                                                             // doesn't keep the
-                                                             // name of
+                            wpAnnotation, paramType, null, Arrays
+                                    .asList(allAnnotations[offset])); // class
+                    // reflection
+                    // doesn't keep the
+                    // name of
                     // the parameter
                     params.add(paramMetaData);
                     offset++;
-               }
+                }
                 WebServiceMETHODMetadata methodMetaData = new WebServiceMETHODMetadata(
-                        Arrays.asList(method.getAnnotations()), method
-                                .getName(), method.getReturnType(), params);
-               	webMethods.add(methodMetaData);
+                        webMethodAnnotation, method.getName(), method
+                                .getReturnType(), Arrays.asList(method
+                                .getAnnotations()), params);
+                webMethods.add(methodMetaData);
             }
 
         }
-       return new WebServiceTYPEMetadata( Arrays.asList(clazz.getAnnotations()), clazz.getName(), webMethods);
+        return new WebServiceTYPEMetadata(wsAnnotation, clazz.getName(), Arrays
+                .asList(clazz.getAnnotations()), webMethods);
+
+    }
 
-    } 
-    
- 
 }