cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r531330 - in /incubator/cxf/trunk/rt/frontend/jaxws/src: main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java test/java/org/apache/cxf/jaxws/SOAPBindingTest.java
Date Mon, 23 Apr 2007 04:14:59 GMT
Author: gawor
Date: Sun Apr 22 21:14:58 2007
New Revision: 531330

URL: http://svn.apache.org/viewvc?view=rev&rev=531330
Log:
getRoles() must always include next and ultimateReceiver roles

Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SOAPBindingTest.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java?view=diff&rev=531330&r1=531329&r2=531330
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
Sun Apr 22 21:14:58 2007
@@ -19,7 +19,7 @@
 
 package org.apache.cxf.jaxws.binding.soap;
 
-import java.util.Collections;
+import java.util.HashSet;
 import java.util.ResourceBundle;
 import java.util.Set;
 import java.util.logging.Logger;
@@ -48,24 +48,37 @@
     private Set<String> roles;
 
     public SOAPBindingImpl(BindingInfo sb) {
-        soapBinding = sb;    
+        soapBinding = sb;  
+        addRequiredRoles();
     }
     
-    public Set<String> getRoles() {
+    private void addRequiredRoles() {
         if (this.roles == null) {
-            return Collections.emptySet();
-        } else {
-            return this.roles;
+            this.roles = new HashSet<String>();
+        }
+        if (this.soapBinding instanceof SoapBindingInfo) {
+            SoapBindingInfo bindingInfo = (SoapBindingInfo) this.soapBinding;
+            if (bindingInfo.getSoapVersion() instanceof Soap11) {
+                this.roles.add(bindingInfo.getSoapVersion().getNextRole());
+            } else if (bindingInfo.getSoapVersion() instanceof Soap12) {
+                this.roles.add(bindingInfo.getSoapVersion().getNextRole());
+                this.roles.add(bindingInfo.getSoapVersion().getUltimateReceiverRole());
+            }
         }
     }
 
+    public Set<String> getRoles() {
+        return this.roles;
+    }
+
     public void setRoles(Set<String> set) {
         if (set != null 
             && (set.contains(Soap11.getInstance().getNoneRole()) 
-             || set.contains(Soap12.getInstance().getNoneRole()))) {
+                || set.contains(Soap12.getInstance().getNoneRole()))) {
             throw new WebServiceException(BUNDLE.getString("NONE_ROLE_ERR"));
         }
         this.roles = set;
+        addRequiredRoles();
     }
 
     public boolean isMTOMEnabled() {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SOAPBindingTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SOAPBindingTest.java?view=diff&rev=531330&r1=531329&r2=531330
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SOAPBindingTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SOAPBindingTest.java
Sun Apr 22 21:14:58 2007
@@ -27,7 +27,7 @@
 import javax.xml.ws.WebServiceException;
 import javax.xml.ws.soap.SOAPBinding;
 
-import org.apache.cxf.binding.soap.Soap11;
+import org.apache.cxf.binding.soap.Soap12;
 import org.apache.cxf.calculator.CalculatorPortType;
 import org.junit.Test;
 
@@ -54,18 +54,23 @@
         SOAPBinding binding = (SOAPBinding)bindingProvider.getBinding();
         
         assertNotNull(binding.getRoles());
-        assertEquals(0, binding.getRoles().size());
+        assertEquals(2, binding.getRoles().size());
+        assertTrue(binding.getRoles().contains(Soap12.getInstance().getNextRole()));
+        assertTrue(binding.getRoles().contains(Soap12.getInstance().getUltimateReceiverRole()));
         
+        String myrole = "http://myrole";
         Set<String> roles = new HashSet<String>();
-        roles.add(Soap11.getInstance().getNextRole());
+        roles.add(myrole);
         
         binding.setRoles(roles);
         
         assertNotNull(binding.getRoles());
-        assertEquals(1, binding.getRoles().size());
-        assertEquals(Soap11.getInstance().getNextRole(), binding.getRoles().iterator().next());
+        assertEquals(3, binding.getRoles().size());
+        assertTrue(binding.getRoles().contains(myrole));
+        assertTrue(binding.getRoles().contains(Soap12.getInstance().getNextRole()));
+        assertTrue(binding.getRoles().contains(Soap12.getInstance().getUltimateReceiverRole()));
                 
-        roles.add(Soap11.getInstance().getNoneRole());
+        roles.add(Soap12.getInstance().getNoneRole());
         
         try {        
             binding.setRoles(roles);



Mime
View raw message