You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by da...@apache.org on 2007/05/21 21:15:13 UTC
svn commit: r540246 - in /webservices/axis2/scratch/java/davidillsley/src:
main/java/org/apache/axis2/addressing/policy/AddressingAssertionHelper.java
test/java/org/apache/axis2/addressing/policy/WSDLTest.java
Author: davidillsley
Date: Mon May 21 12:15:13 2007
New Revision: 540246
URL: http://svn.apache.org/viewvc?view=rev&rev=540246
Log:
Some more work on wsa:Addressing support
Added:
webservices/axis2/scratch/java/davidillsley/src/main/java/org/apache/axis2/addressing/policy/AddressingAssertionHelper.java
webservices/axis2/scratch/java/davidillsley/src/test/java/org/apache/axis2/addressing/policy/WSDLTest.java
Added: webservices/axis2/scratch/java/davidillsley/src/main/java/org/apache/axis2/addressing/policy/AddressingAssertionHelper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/scratch/java/davidillsley/src/main/java/org/apache/axis2/addressing/policy/AddressingAssertionHelper.java?view=auto&rev=540246
==============================================================================
--- webservices/axis2/scratch/java/davidillsley/src/main/java/org/apache/axis2/addressing/policy/AddressingAssertionHelper.java (added)
+++ webservices/axis2/scratch/java/davidillsley/src/main/java/org/apache/axis2/addressing/policy/AddressingAssertionHelper.java Mon May 21 12:15:13 2007
@@ -0,0 +1,47 @@
+package org.apache.axis2.addressing.policy;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.axis2.description.AxisBinding;
+import org.apache.axis2.description.AxisDescription;
+import org.apache.axis2.description.AxisEndpoint;
+import org.apache.axis2.description.AxisService;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+
+public class AddressingAssertionHelper {
+ public static AddressingAssertion getEffectiveAddressingAssertion(AxisService as){
+ AddressingAssertion aa = getDirectAddressingAssertion(as);
+ if(aa != null){
+ return aa;
+ }
+ aa = getDirectAddressingAssertion(getAxisBinding(as));
+ return aa;
+ }
+
+ static AddressingAssertion getDirectAddressingAssertion(AxisDescription ad){
+ AddressingAssertion result = null;
+ if(ad.getPolicyInclude() != null && ad.getPolicyInclude().getEffectivePolicy() != null){
+ Iterator<Policy> alternatives = ad.getPolicyInclude().getEffectivePolicy().getAlternatives();
+ while(alternatives.hasNext() && (result == null)){
+ List<Assertion> assertions = (List<Assertion>)alternatives.next();
+ for(Assertion a: assertions){
+ if(a instanceof AddressingAssertion){
+ result = ((AddressingAssertion)a);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ static AxisBinding getAxisBinding(AxisService as){
+ Map<String, AxisEndpoint> endpoints = as.getEndpoints();
+ if(!endpoints.isEmpty()){
+ return endpoints.entrySet().iterator().next().getValue().getBinding();
+ }
+ return null;
+ }
+}
Added: webservices/axis2/scratch/java/davidillsley/src/test/java/org/apache/axis2/addressing/policy/WSDLTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/scratch/java/davidillsley/src/test/java/org/apache/axis2/addressing/policy/WSDLTest.java?view=auto&rev=540246
==============================================================================
--- webservices/axis2/scratch/java/davidillsley/src/test/java/org/apache/axis2/addressing/policy/WSDLTest.java (added)
+++ webservices/axis2/scratch/java/davidillsley/src/test/java/org/apache/axis2/addressing/policy/WSDLTest.java Mon May 21 12:15:13 2007
@@ -0,0 +1,67 @@
+package org.apache.axis2.addressing.policy;
+import java.io.FileInputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.addressing.policy.AddressingAssertion;
+import org.apache.axis2.addressing.policy.AddressingAssertion.ResponsesEPRs;
+import org.apache.axis2.addressing.policy.AddressingAssertionHelper;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
+
+public class WSDLTest extends TestCase {
+
+ AddressingAssertion getAddressingAssertion(String wsdlFileName) throws Exception{
+ WSDL11ToAxisServiceBuilder builder = new WSDL11ToAxisServiceBuilder(new FileInputStream("src/test/resources/"+wsdlFileName));
+ AxisService as = builder.populateService();
+ return AddressingAssertionHelper.getEffectiveAddressingAssertion(as);
+ }
+
+ public void testBindingAnon()throws Exception{
+ AddressingAssertion aa = getAddressingAssertion("binding-anon.wsdl");
+ assertNotNull(aa);
+ assertEquals(ResponsesEPRs.ANONYMOUS, aa.getAllowedResponseType());
+ }
+ public void testBindingNonAnon()throws Exception{
+ AddressingAssertion aa = getAddressingAssertion("binding-nonanon.wsdl");
+ assertNotNull(aa);
+ assertEquals(ResponsesEPRs.NON_ANONYMOUS, aa.getAllowedResponseType());
+ }
+ public void testBindingBoth()throws Exception{
+ AddressingAssertion aa = getAddressingAssertion("binding-both.wsdl");
+ assertNotNull(aa);
+ assertEquals(ResponsesEPRs.BOTH, aa.getAllowedResponseType());
+ }
+ public void testBindingEither()throws Exception{
+ AddressingAssertion aa = getAddressingAssertion("binding-either.wsdl");
+ assertNotNull(aa);
+ assertEquals(ResponsesEPRs.EITHER, aa.getAllowedResponseType());
+ }
+
+ public void testPortAnon()throws Exception{
+ AddressingAssertion aa = getAddressingAssertion("port-anon.wsdl");
+ assertNotNull(aa);
+ assertEquals(ResponsesEPRs.ANONYMOUS, aa.getAllowedResponseType());
+ }
+ public void testPortNonAnon()throws Exception{
+ AddressingAssertion aa = getAddressingAssertion("port-nonanon.wsdl");
+ assertNotNull(aa);
+ assertEquals(ResponsesEPRs.NON_ANONYMOUS, aa.getAllowedResponseType());
+ }
+ public void testPortBoth()throws Exception{
+ AddressingAssertion aa = getAddressingAssertion("port-both.wsdl");
+ assertNotNull(aa);
+ assertEquals(ResponsesEPRs.BOTH, aa.getAllowedResponseType());
+ }
+ public void testPortEither()throws Exception{
+ AddressingAssertion aa = getAddressingAssertion("port-either.wsdl");
+ assertNotNull(aa);
+ assertEquals(ResponsesEPRs.EITHER, aa.getAllowedResponseType());
+ }
+
+ public void testPortNonAnonBindingAnon()throws Exception{
+ AddressingAssertion aa = getAddressingAssertion("port-nonanon-binding-anon.wsdl");
+ assertNotNull(aa);
+ assertEquals(ResponsesEPRs.NON_ANONYMOUS, aa.getAllowedResponseType());
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org