Author: mmerz
Date: Wed Sep 15 13:19:37 2004
New Revision: 46132
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/axis/AnnotatedJWSHandler.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/processor/reflection/WsmReflectionAnnotationProcessor.java
Log:
Enhanced tests, fixed initialization bugs.
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
Wed Sep 15 13:19:37 2004
@@ -32,490 +32,509 @@
public class Jsr181ModelTest extends TestCase {
- public void setUp() {
- }
+ public void setUp() {
+ }
- public void tearDown() {
- }
+ public void tearDown() {
+ }
- // test TYPE level annotations
+ // test TYPE level annotations
- 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(
- SOAPBinding.Style.RPC, SOAPBinding.Use.ENCODED,
- SOAPBinding.ParameterStyle.DEFAULT));
- try {
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
- null, "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue(
- "Error, the TYPE annotation should fail without
@WebService",
- false);
- } catch (IllegalArgumentException e) {
- // good case
- }
- }
-
- 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);
- assertTrue("Invalid WebService Name, got: " + type.getWsName(), type
- .getWsName().compareTo("testclass") == 0);
- assertTrue(type.getWsServiceName().compareTo("testclassService") == 0);
- assertTrue(type.getWsWsdlLocation().length() == 0);
- assertTrue("Invalid target name space: " + type.getWsTargetNamespace(),
- type.getWsTargetNamespace().compareTo("http://c.b.a") == 0);
- }
-
- 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");
- 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);
-
- }
-
- 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.DEFAULT, SOAPBinding.Use.DEFAULT,
- SOAPBinding.ParameterStyle.DEFAULT));
- 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);
- }
-
- public void testTYPESOAPBindingAnnotation() 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);
- assertTrue(type.getSoapBinding().getStyle() == SOAPBinding.Style.RPC);
- assertTrue(type.getSoapBinding().getUse() == SOAPBinding.Use.ENCODED);
- assertTrue(type.getSoapBinding().getParameterStyle() ==
SOAPBinding.ParameterStyle.BARE);
- }
-
- // no test for default HandlerChains, all fields are required in the
- // @HandlerChain
-
- public void testTYPEHandlerChainAnnotation() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new
ArrayList<WebServiceMETHODMetadata>();
- Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
- WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "",
"");
- typeAnnotations.add(wsAnnotation);
-
- typeAnnotations.add(new FakeHandlerChainAnnotation("testfile",
- "testname"));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
- wsAnnotation, "a.b.c.testclass", typeAnnotations,
methodMetadata);
- assertTrue(type.getHcFileName() == "testfile");
- assertTrue(type.getHcName() == "testname");
- }
-
- // 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().size() == 0);
-
- }
-
- // test a single default handler in the 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[1];
- defaultHandlers[0] = new FakeSOAPMessageHandlerAnnotation("",
- "soaphandlerclass", new FakeInitParamAnnotation[0],
- new String[0], new FakeQName[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);
- SOAPMessageHandlerInfo handler = type.getSoapHandlers().get(0);
- assertTrue(handler.getName().compareTo("soaphandlerclass") == 0);
- assertTrue(handler.getClassName().compareTo("soaphandlerclass") == 0);
- assertTrue(handler.getParams().size() == 0);
- assertTrue(handler.getRoles().size() == 0);
- assertTrue(handler.getHeaders().size() == 0);
- }
-
- 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 = { "messagehandlerroles" };
- QName[] headers = { new FakeQName("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.getParams().size() == 1);
- assertTrue(handler.getRoles().size() == 1);
- assertTrue(handler.getHeaders().size() == 1);
-
- InitParamInfo p = handler.getParams().iterator().next();
- assert (p.getName().compareTo("paramname") == 0);
- assert (p.getValue().compareTo("paramvalue") == 0);
-
- assert (handler.getRoles().iterator().next().compareTo(
- "messagehandlerroles") == 0);
-
- QNameInfo q = handler.getHeaders().iterator().next();
- assert (q.getNamespaceURI().compareTo("messagehanderheadernamespace")
== 0);
- assert (q.getLocalName().compareTo("messagehanderheaderlocalname") ==
0);
- }
-
- 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);
-
- assertNull(type.getSecurityRoles().getRolesAllowed());
- assertNull(type.getSecurityRoles().getRolesReferenced());
-
- }
-
- 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);
-
- 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);
- }
-
- 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.getSiRunAs());
-
- }
-
- 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"));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
- wsAnnotation, "a.b.c.testclass", typeAnnotations,
methodMetadata);
- assertTrue(type.getSiRunAs().compareTo("runasidentity") == 0);
- }
-
- //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(
- null, "methodname", Void.class, 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, 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, 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, methodAnnotations,null);
- assertTrue(method.getWmOperationName().compareTo("methodname") == 0);
- assertTrue(method.getWmAction().length() == 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, 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, 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, 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, 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, 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);
-
- }
-
-
- 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
+ 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(
+ SOAPBinding.Style.RPC, SOAPBinding.Use.ENCODED,
+ SOAPBinding.ParameterStyle.DEFAULT));
+ try {
+ WebServiceTYPEMetadata type = new
WebServiceTYPEMetadata(null,
+ "a.b.c.testclass", typeAnnotations,
methodMetadata);
+ assertTrue(
+ "Error, the TYPE annotation should fail
without @WebService",
+ false);
+ } catch (IllegalArgumentException e) {
+ // good case
+ }
+ }
+
+ 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);
+ assertTrue("Invalid WebService Name, got: " + type.getWsName(),
type
+ .getWsName().compareTo("testclass") == 0);
+
assertTrue(type.getWsServiceName().compareTo("testclassService") == 0);
+ assertTrue(type.getWsWsdlLocation().length() == 0);
+ assertTrue("Invalid target name space: " +
type.getWsTargetNamespace(),
+
type.getWsTargetNamespace().compareTo("http://c.b.a") == 0);
+ }
+
+ 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");
+ 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);
+
+ }
+
+ 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.DEFAULT,
SOAPBinding.Use.DEFAULT,
+ SOAPBinding.ParameterStyle.DEFAULT));
+ 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);
+ }
+
+ public void testTYPESOAPBindingAnnotation() 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);
+ assertTrue(type.getSoapBinding().getStyle() ==
SOAPBinding.Style.RPC);
+ assertTrue(type.getSoapBinding().getUse() ==
SOAPBinding.Use.ENCODED);
+ assertTrue(type.getSoapBinding().getParameterStyle() ==
SOAPBinding.ParameterStyle.BARE);
+ }
+
+ // no test for default HandlerChains, all fields are required in the
+ // @HandlerChain
+
+ public void testTYPEHandlerChainAnnotation() throws Exception {
+ Collection<WebServiceMETHODMetadata> methodMetadata = new
ArrayList<WebServiceMETHODMetadata>();
+ Collection<Annotation> typeAnnotations = new
ArrayList<Annotation>();
+ WebService wsAnnotation = new FakeWebServiceAnnotation("", "",
"", "",
+ "");
+ typeAnnotations.add(wsAnnotation);
+
+ typeAnnotations.add(new FakeHandlerChainAnnotation("testfile",
+ "testname"));
+ WebServiceTYPEMetadata type = new
WebServiceTYPEMetadata(wsAnnotation,
+ "a.b.c.testclass", typeAnnotations,
methodMetadata);
+ assertTrue(type.getHcFileName() == "testfile");
+ assertTrue(type.getHcName() == "testname");
+ }
+
+ // 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().size() == 0);
+
+ }
+
+ // test a single default handler in the 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[1];
+ defaultHandlers[0] = new FakeSOAPMessageHandlerAnnotation("",
+ "soaphandlerclass", new
FakeInitParamAnnotation[0],
+ new String[0], new FakeQName[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);
+ SOAPMessageHandlerInfo handler = type.getSoapHandlers().get(0);
+ assertTrue(handler.getName().compareTo("soaphandlerclass") ==
0);
+ assertTrue(handler.getClassName().compareTo("soaphandlerclass")
== 0);
+ assertTrue(handler.getParams().size() == 0);
+ assertTrue(handler.getRoles().size() == 0);
+ assertTrue(handler.getHeaders().size() == 0);
+ }
+
+ 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 = { "messagehandlerroles" };
+ QName[] headers = { new
FakeQName("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.getParams().size() == 1);
+ assertTrue(handler.getRoles().size() == 1);
+ assertTrue(handler.getHeaders().size() == 1);
+
+ InitParamInfo p = handler.getParams().iterator().next();
+ assert (p.getName().compareTo("paramname") == 0);
+ assert (p.getValue().compareTo("paramvalue") == 0);
+
+ assert (handler.getRoles().iterator().next().compareTo(
+ "messagehandlerroles") == 0);
+
+ QNameInfo q = handler.getHeaders().iterator().next();
+ assert
(q.getNamespaceURI().compareTo("messagehanderheadernamespace") == 0);
+ assert
(q.getLocalName().compareTo("messagehanderheaderlocalname") == 0);
+ }
+
+ 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);
+
+ assertNull(type.getSecurityRoles().getRolesAllowed());
+ assertNull(type.getSecurityRoles().getRolesReferenced());
+
+ }
+
+ 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);
+
+ 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);
+ }
+
+ 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.getSiRunAs());
+
+ }
+
+ 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"));
+ WebServiceTYPEMetadata type = new
WebServiceTYPEMetadata(wsAnnotation,
+ "a.b.c.testclass", typeAnnotations,
methodMetadata);
+ assertTrue(type.getSiRunAs().compareTo("runasidentity") == 0);
+ }
+
+ //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(
+ null, "methodname", Void.class,
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,
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,
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,
methodAnnotations, null);
+ assertTrue(method.getWmOperationName().compareTo("methodname")
== 0);
+ assertTrue(method.getWmAction().length() == 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,
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,
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,
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,
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,
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);
+
+ }
+
+ 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 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());
+
+ }
+ // TODO: test combination of type, method, annotation
}
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AnnotatedJWSHandler.java
==============================================================================
---
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AnnotatedJWSHandler.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AnnotatedJWSHandler.java
Wed Sep 15 13:19:37 2004
@@ -87,6 +87,8 @@
*/
protected void setupService(MessageContext msgContext) throws Exception {
// FORCE the targetService to be JWS if the URL is right.
+
+ System.out.println("..............JWSAnnotatedHandler: setUpService");
//TODO: use log4j
String realpath = msgContext.getStrProp(Constants.MC_REALPATH);
String extension = (String)getOption(OPTION_JWS_FILE_EXTENSION);
if (extension == null) extension = DEFAULT_JWS_FILE_EXTENSION;
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 Sep 15 13:19:37 2004
@@ -58,14 +58,12 @@
}
this.javaType = javaType;
+ setWpMode(WebParam.Mode.IN); // by default if there were no
anotations.
setWpName(defaultName); // in case there are no annotations
// check required parameters
- if (null == annotations
- || !hasAnnotationType(annotations, javax.jws.WebParam.class)) {
- throw new IllegalArgumentException("@WebParam is required");
- }
+
// initialize from required annotation
if(null != webParamAnnotation) initFromAnnotation(webParamAnnotation);
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
Wed Sep 15 13:19:37 2004
@@ -68,8 +68,8 @@
for (Class paramType : methodParamTypes) {
WebParam webParam = null;
WebServicePARAMETERMetadata paramMetaData = new
WebServicePARAMETERMetadata(
- wpAnnotation, paramType, null, Arrays
- .asList(allAnnotations[offset])); // class
+ wpAnnotation, paramType, "in" +offset, // by
default parameter should be IN
+
Arrays.asList(allAnnotations[offset])); // class
// reflection
// doesn't keep the
// name of