cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsosno...@apache.org
Subject svn commit: r1491320 - in /cxf/trunk/rt/ws/rm/src: main/java/org/apache/cxf/ws/rm/ main/java/org/apache/cxf/ws/rm/policy/ test/java/org/apache/cxf/ws/rm/ test/java/org/apache/cxf/ws/rm/policy/
Date Mon, 10 Jun 2013 01:11:09 GMT
Author: dsosnoski
Date: Mon Jun 10 01:11:08 2013
New Revision: 1491320

URL: http://svn.apache.org/r1491320
Log:
CXF-4139 Clean up initial checkins, fully integrate use of RMConfiguration into policy handling

Modified:
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractRMInterceptor.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMConfiguration.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RM10AssertionBuilder.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RMPolicyUtilities.java
    cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
    cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/policy/PolicyUtilsTest.java

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractRMInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractRMInterceptor.java?rev=1491320&r1=1491319&r2=1491320&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractRMInterceptor.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractRMInterceptor.java Mon Jun
10 01:11:08 2013
@@ -33,7 +33,7 @@ import org.apache.cxf.phase.AbstractPhas
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.ws.policy.AssertionInfo;
 import org.apache.cxf.ws.policy.AssertionInfoMap;
-import org.apache.cxf.ws.rm.policy.RM10PolicyUtils;
+import org.apache.cxf.ws.rm.policy.RMPolicyUtilities;
 
 /**
  * Interceptor responsible for implementing exchange of RM protocol messages,
@@ -113,7 +113,7 @@ public abstract class AbstractRMIntercep
      */
     void assertReliability(Message message) {
         AssertionInfoMap aim = message.get(AssertionInfoMap.class);
-        Collection<AssertionInfo> ais = RM10PolicyUtils.collectRMAssertions(aim);
+        Collection<AssertionInfo> ais = RMPolicyUtilities.collectRMAssertions(aim);
         for (AssertionInfo ai : ais) {
             ai.setAsserted(true);
         }

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMConfiguration.java?rev=1491320&r1=1491319&r2=1491320&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMConfiguration.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMConfiguration.java Mon Jun 10
01:11:08 2013
@@ -39,11 +39,9 @@ public class RMConfiguration {
     private RM10AddressingNamespaceType rm10AddressingNamespace;
     
     /**
-     * Constructor just sets defaults.
+     * Constructor.
      */
     public RMConfiguration() {
-        baseRetransmissionInterval = new Long(RetransmissionQueue.DEFAULT_BASE_RETRANSMISSION_INTERVAL);
-        rmNamespace = RM10Constants.NAMESPACE_URI;
     }
     
     /**

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java?rev=1491320&r1=1491319&r2=1491320&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java Mon Jun 10 01:11:08
2013
@@ -231,19 +231,26 @@ public class RMManager {
      * @return configuration (non-<code>null</code>)
      */
     public RMConfiguration getConfiguration() {
-        return configuration;
+        return forceConfiguration();
     }
 
     /**
      * @param configuration (non-<code>null</code>)
      */
     public void setConfiguration(RMConfiguration configuration) {
+        if (configuration.getBaseRetransmissionInterval() == null) {
+            Long value = new Long(RetransmissionQueue.DEFAULT_BASE_RETRANSMISSION_INTERVAL);
+            configuration.setBaseRetransmissionInterval(value);
+        }
+        if (configuration.getRMNamespace() == null) {
+            configuration.setRMNamespace(RM10Constants.NAMESPACE_URI);
+        }
         this.configuration = configuration;
     }
     
     RMConfiguration forceConfiguration() {
         if (configuration == null) {
-            configuration = new RMConfiguration();
+            setConfiguration(new RMConfiguration());
         }
         return configuration;
     }
@@ -349,7 +356,7 @@ public class RMManager {
                 addrUri = maps.getNamespaceURI();
             }
             if (addrUri == null) {
-                addrUri = configuration.getConfiguredProtocol().getWSANamespace();
+                addrUri = forceConfiguration().getConfiguredProtocol().getWSANamespace();
             }
         }
         return addrUri;
@@ -370,7 +377,7 @@ public class RMManager {
                 rmUri = rmps.getNamespaceURI();
             }
             if (rmUri == null) {
-                rmUri = configuration.getRMNamespace();
+                rmUri = getConfiguration().getRMNamespace();
             }
         }
         return rmUri;
@@ -406,7 +413,7 @@ public class RMManager {
             RelatesToType relatesTo = null;
             if (isServer) {
                 AddressingProperties inMaps = RMContextUtils.retrieveMAPs(message, false,
false);
-                inMaps.exposeAs(configuration.getConfiguredProtocol().getWSANamespace());
+                inMaps.exposeAs(getConfiguration().getConfiguredProtocol().getWSANamespace());
                 acksTo = RMUtils.createReference(inMaps.getTo().getValue());
                 to = inMaps.getReplyTo();
                 source.getReliableEndpoint().getServant().setUnattachedIdentifier(inSeqId);
@@ -607,8 +614,7 @@ public class RMManager {
     @PostConstruct
     void initialise() {
         if (configuration == null) {
-            configuration = new RMConfiguration();
-            configuration.setExponentialBackoff(true);
+            forceConfiguration().setExponentialBackoff(true);
         }
         DeliveryAssuranceType deliveryAssurance = configuration.getDeliveryAssurance();
         if (deliveryAssurance == null) {

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java?rev=1491320&r1=1491319&r2=1491320&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java Mon Jun 10 01:11:08
2013
@@ -187,4 +187,34 @@ public final class RMUtils {
         // Added the instance id to make the ObjectName unique
         buffer.append(ManagementConstants.INSTANCE_ID_PROP).append('=').append(ep.hashCode());
     }
+
+    /**
+     * Utility method to compare two (possibly-null) String values.
+     * 
+     * @param aval
+     * @param bval
+     * @return <code>true</code> if equal, <code>false</code> if
not
+     */
+    public static boolean equalStrings(String aval, String bval) {
+        if (null != aval) {
+            return aval.equals(bval);
+        } else {
+            return null == bval;
+        }
+    }
+
+    /**
+     * Utility method to compare two (possibly-null) Long values.
+     * 
+     * @param aval
+     * @param bval
+     * @return <code>true</code> if equal, <code>false</code> if
not
+     */
+    public static boolean equalLongs(Long aval, Long bval) {
+        if (null != aval) {
+            return aval.equals(bval);
+        } else {
+            return null == bval;
+        }
+    }
 }

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RM10AssertionBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RM10AssertionBuilder.java?rev=1491320&r1=1491319&r2=1491320&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RM10AssertionBuilder.java
(original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RM10AssertionBuilder.java
Mon Jun 10 01:11:08 2013
@@ -69,7 +69,7 @@ public class RM10AssertionBuilder extend
             }
             JaxbAssertion<RMAssertion> other = 
                     JaxbAssertion.cast((Assertion)policyComponent);            
-            return RM10PolicyUtils.equals(this.getData(), other.getData());  
+            return RMPolicyUtilities.equals(this.getData(), other.getData());  
         }
         
         @Override

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RMPolicyUtilities.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RMPolicyUtilities.java?rev=1491320&r1=1491319&r2=1491320&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RMPolicyUtilities.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RMPolicyUtilities.java Mon
Jun 10 01:11:08 2013
@@ -25,16 +25,17 @@ import java.util.Collection;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.ws.policy.AssertionInfo;
 import org.apache.cxf.ws.policy.AssertionInfoMap;
+import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion;
 import org.apache.cxf.ws.rm.RM10Constants;
 import org.apache.cxf.ws.rm.RM11Constants;
 import org.apache.cxf.ws.rm.RMConfiguration;
+import org.apache.cxf.ws.rm.RMUtils;
 import org.apache.cxf.ws.rm.manager.DeliveryAssuranceType;
 import org.apache.cxf.ws.rm.policy.RM12Assertion.Order;
 import org.apache.cxf.ws.rmp.v200502.RMAssertion;
 
 /**
- * Policy assertion builder for WS-RMP 1.0 (submission). Since this version of WS-RMP nests
everything as
- * direct child elements of the RMAssertion JAXB can be used directly to convert to/from
XML.
+ * Utilities for working with policies and configurations.
  */
 public final class RMPolicyUtilities {
     
@@ -42,8 +43,8 @@ public final class RMPolicyUtilities {
     }
     
     /**
-     * Returns an RMAssertion that is compatible with the default value
-     * and all RMAssertions pertaining to the message (can never be null).
+     * Returns an RMAssertion that is compatible with the default value and all RMAssertions
pertaining to the
+     * message (can never be null).
      * 
      * @param rma the default value (non-<code>null</code>)
      * @param message the message
@@ -53,8 +54,8 @@ public final class RMPolicyUtilities {
         RMConfiguration compatible = defaultValue;
         Collection<AssertionInfo> ais = collectRMAssertions(message.get(AssertionInfoMap.class));
         for (AssertionInfo ai : ais) {
-            if (ai.getAssertion() instanceof RM10AssertionBuilder.RMPolicyAssertion) {
-                RMAssertion rma = ((RM10AssertionBuilder.RMPolicyAssertion)ai.getAssertion()).getData();
+            if (ai.getAssertion() instanceof JaxbAssertion<?>) {
+                RMAssertion rma = (RMAssertion)((JaxbAssertion<?>)ai.getAssertion()).getData();
                 compatible = intersect(rma, compatible);
             } else if (ai.getAssertion() instanceof RM12Assertion) {
                 RM12Assertion rma = (RM12Assertion) ai.getAssertion();
@@ -85,14 +86,6 @@ public final class RMPolicyUtilities {
         return mergedAsserts;
     }
 
-    static boolean equalLongs(Long aval, Long bval) {
-        if (null != aval) {
-            return aval.equals(bval);
-        } else {
-            return false;
-        }
-    }
-    
     public static boolean equals(RMAssertion a, RMAssertion b) {
         if (a == b) {
             return true;
@@ -106,7 +99,7 @@ public final class RMPolicyUtilities {
         if (null != b.getInactivityTimeout()) {
             bval = b.getInactivityTimeout().getMilliseconds();            
         }
-        if (!equalLongs(aval, bval)) {
+        if (!RMUtils.equalLongs(aval, bval)) {
             return false;
         }
             
@@ -118,7 +111,7 @@ public final class RMPolicyUtilities {
         if (null != b.getBaseRetransmissionInterval()) {
             bval = b.getBaseRetransmissionInterval().getMilliseconds();            
         }
-        if (!equalLongs(aval, bval)) {
+        if (!RMUtils.equalLongs(aval, bval)) {
             return false;
         }
         
@@ -130,7 +123,7 @@ public final class RMPolicyUtilities {
         if (null != b.getAcknowledgementInterval()) {
             bval = b.getAcknowledgementInterval().getMilliseconds(); 
         }
-        if (!equalLongs(aval, bval)) {
+        if (!RMUtils.equalLongs(aval, bval)) {
             return false;
         }
         
@@ -139,6 +132,48 @@ public final class RMPolicyUtilities {
             : null != b.getExponentialBackoff();         
     }
     
+    public static boolean equals(RMConfiguration a, RMConfiguration b) {
+        if (a == b) {
+            return true;
+        }
+        if (a == null) {
+            return b == null;
+        } else if (b == null) {
+            return false;
+        }
+        if (a.getDeliveryAssurance() == null) {
+            if (b.getDeliveryAssurance() != null) {
+                return false;
+            }
+        } else if (b.getDeliveryAssurance() == null) {
+            return false;
+        } else if (a.getDeliveryAssurance().isSetAtLeastOnce() != b.getDeliveryAssurance().isSetAtLeastOnce()
+                || a.getDeliveryAssurance().isSetAtMostOnce() != b.getDeliveryAssurance().isSetAtMostOnce()
+                || a.getDeliveryAssurance().isSetInOrder() != b.getDeliveryAssurance().isSetInOrder())
{
+            return false;
+        }
+        if (a.getRM10AddressingNamespace() == null) {
+            if (b.getRM10AddressingNamespace() != null) {
+                return false;
+            }
+        } else if (b.getRM10AddressingNamespace() == null) {
+            return false;
+        } else if (!RMUtils.equalStrings(a.getRM10AddressingNamespace().getUri(),
+                                         b.getRM10AddressingNamespace().getUri())) {
+            return false;
+        }
+        if (!RMUtils.equalStrings(a.getRMNamespace(), b.getRMNamespace())) {
+            return false;
+        }
+        return a.isExactlyOnce() == b.isExactlyOnce()
+               && a.isExponentialBackoff() == b.isExponentialBackoff()
+               && a.isSequenceSTRRequired() == b.isSequenceSTRRequired()
+               && a.isSequenceTransportSecurityRequired() == b.isSequenceTransportSecurityRequired()
+               && RMUtils.equalLongs(a.getAcknowledgementInterval(), b.getAcknowledgementInterval())
+               && RMUtils.equalLongs(a.getBaseRetransmissionInterval(), b.getBaseRetransmissionInterval())
+               && RMUtils.equalLongs(a.getInactivityTimeout(), b.getInactivityTimeout());
+    }
+    
     /**
      * Intersect a policy with a supplied configuration.
      * 
@@ -220,7 +255,7 @@ public final class RMPolicyUtilities {
         if (null != asser.getInactivityTimeout()) {
             aval = asser.getInactivityTimeout().getMilliseconds();            
         }
-        if (!equalLongs(cfg.getInactivityTimeout(), aval)) {
+        if (!RMUtils.equalLongs(cfg.getInactivityTimeout(), aval)) {
             return false;
         }
             
@@ -228,7 +263,7 @@ public final class RMPolicyUtilities {
         if (null != asser.getBaseRetransmissionInterval()) {
             aval = asser.getBaseRetransmissionInterval().getMilliseconds();            
         }
-        if (!equalLongs(cfg.getBaseRetransmissionInterval(), aval)) {
+        if (!RMUtils.equalLongs(cfg.getBaseRetransmissionInterval(), aval)) {
             return false;
         }
         
@@ -236,7 +271,7 @@ public final class RMPolicyUtilities {
         if (null != asser.getAcknowledgementInterval()) {
             aval = asser.getAcknowledgementInterval().getMilliseconds(); 
         }
-        if (!equalLongs(cfg.getAcknowledgementInterval(), aval)) {
+        if (!RMUtils.equalLongs(cfg.getAcknowledgementInterval(), aval)) {
             return false;
         }
         

Modified: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java?rev=1491320&r1=1491319&r2=1491320&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java (original)
+++ cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java Mon Jun 10 01:11:08
2013
@@ -103,14 +103,13 @@ public class RMManagerTest extends Asser
     @Test
     public void testInitialisation() {
         manager = new RMManager();
-        assertNull("RMConfiguration is set.", manager.getConfiguration());
         assertNull("sourcePolicy is set.", manager.getSourcePolicy());
         assertNull("destinationPolicy is set.", manager.getDestinationPolicy());
         
         manager.initialise();
         
         RMConfiguration cfg = manager.getConfiguration();
-        assertNotNull("RMAssertion is not set.", cfg);
+        assertNotNull("RMConfiguration is not set.", cfg);
         assertNotNull("sourcePolicy is not set.", manager.getSourcePolicy());
         assertNotNull("destinationPolicy is not set.", manager.getDestinationPolicy());
         assertNotNull("deliveryAssirance is not set.", cfg.getDeliveryAssurance());

Modified: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/policy/PolicyUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/policy/PolicyUtilsTest.java?rev=1491320&r1=1491319&r2=1491320&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/policy/PolicyUtilsTest.java (original)
+++ cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/policy/PolicyUtilsTest.java Mon
Jun 10 01:11:08 2013
@@ -27,6 +27,7 @@ import org.apache.cxf.ws.policy.Assertio
 import org.apache.cxf.ws.policy.AssertionInfoMap;
 import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion;
 import org.apache.cxf.ws.rm.RM10Constants;
+import org.apache.cxf.ws.rm.RMConfiguration;
 import org.apache.cxf.ws.rmp.v200502.RMAssertion;
 import org.apache.cxf.ws.rmp.v200502.RMAssertion.AcknowledgementInterval;
 import org.apache.cxf.ws.rmp.v200502.RMAssertion.BaseRetransmissionInterval;
@@ -54,87 +55,81 @@ public class PolicyUtilsTest extends Ass
     @Test
     public void testRMAssertionEquals() {
         RMAssertion a = new RMAssertion();
-        assertTrue(RM10PolicyUtils.equals(a, a));
+        assertTrue(RMPolicyUtilities.equals(a, a));
         
         RMAssertion b = new RMAssertion();
-        assertTrue(RM10PolicyUtils.equals(a, b));
+        assertTrue(RMPolicyUtilities.equals(a, b));
         
         InactivityTimeout iat = new RMAssertion.InactivityTimeout();
         iat.setMilliseconds(new Long(10));
         a.setInactivityTimeout(iat);
-        assertTrue(!RM10PolicyUtils.equals(a, b));
+        assertTrue(!RMPolicyUtilities.equals(a, b));
         b.setInactivityTimeout(iat);
-        assertTrue(RM10PolicyUtils.equals(a, b));
+        assertTrue(RMPolicyUtilities.equals(a, b));
         
         ExponentialBackoff eb = new RMAssertion.ExponentialBackoff();
         a.setExponentialBackoff(eb);
-        assertTrue(!RM10PolicyUtils.equals(a, b));
+        assertTrue(!RMPolicyUtilities.equals(a, b));
         b.setExponentialBackoff(eb);
-        assertTrue(RM10PolicyUtils.equals(a, b));    
+        assertTrue(RMPolicyUtilities.equals(a, b));    
     }
     
     @Test
     public void testIntersect() {
-        RMAssertion a = new RMAssertion();
-        RMAssertion b = new RMAssertion();
-        assertSame(a, RM10PolicyUtils.intersect(a, b));
+        RMAssertion rma = new RMAssertion();
+        RMConfiguration cfg0 = new RMConfiguration();
+        assertTrue(RMPolicyUtilities.equals(cfg0, RMPolicyUtilities.intersect(rma, cfg0)));
         
         InactivityTimeout aiat = new RMAssertion.InactivityTimeout();
-        aiat.setMilliseconds(new Long(3600000));
-        a.setInactivityTimeout(aiat);
-        InactivityTimeout biat = new RMAssertion.InactivityTimeout();
-        biat.setMilliseconds(new Long(7200000));
-        b.setInactivityTimeout(biat);
-        
-        RMAssertion c = RM10PolicyUtils.intersect(a, b);
-        assertEquals(7200000L, c.getInactivityTimeout().getMilliseconds().longValue());
-        assertNull(c.getBaseRetransmissionInterval());
-        assertNull(c.getAcknowledgementInterval());
-        assertNull(c.getExponentialBackoff());
+        aiat.setMilliseconds(new Long(7200000));
+        rma.setInactivityTimeout(aiat);
+        cfg0.setInactivityTimeout(new Long(3600000));
+        
+        RMConfiguration cfg1 = RMPolicyUtilities.intersect(rma, cfg0);
+        assertEquals(7200000L, cfg1.getInactivityTimeout().longValue());
+        assertNull(cfg1.getBaseRetransmissionInterval());
+        assertNull(cfg1.getAcknowledgementInterval());
+        assertFalse(cfg1.isExponentialBackoff());
         
         BaseRetransmissionInterval abri = new RMAssertion.BaseRetransmissionInterval();
-        abri.setMilliseconds(new Long(10000));
-        a.setBaseRetransmissionInterval(abri);
-        BaseRetransmissionInterval bbri = new RMAssertion.BaseRetransmissionInterval();
-        bbri.setMilliseconds(new Long(20000));
-        b.setBaseRetransmissionInterval(bbri);
-        
-        c = RM10PolicyUtils.intersect(a, b);
-        assertEquals(7200000L, c.getInactivityTimeout().getMilliseconds().longValue());
-        assertEquals(20000L, c.getBaseRetransmissionInterval().getMilliseconds().longValue());
-        assertNull(c.getAcknowledgementInterval());
-        assertNull(c.getExponentialBackoff());
+        abri.setMilliseconds(new Long(20000));
+        rma.setBaseRetransmissionInterval(abri);
+        cfg0.setBaseRetransmissionInterval(new Long(10000));
+        
+        cfg1 = RMPolicyUtilities.intersect(rma, cfg0);
+        assertEquals(7200000L, cfg1.getInactivityTimeout().longValue());
+        assertEquals(20000L, cfg1.getBaseRetransmissionInterval().longValue());
+        assertNull(cfg1.getAcknowledgementInterval());
+        assertFalse(cfg1.isExponentialBackoff());
        
         AcknowledgementInterval aai = new RMAssertion.AcknowledgementInterval();
         aai.setMilliseconds(new Long(2000));
-        a.setAcknowledgementInterval(aai);
+        rma.setAcknowledgementInterval(aai);
         
-        c = RM10PolicyUtils.intersect(a, b);
-        assertEquals(7200000L, c.getInactivityTimeout().getMilliseconds().longValue());
-        assertEquals(20000L, c.getBaseRetransmissionInterval().getMilliseconds().longValue());
-        assertEquals(2000L, c.getAcknowledgementInterval().getMilliseconds().longValue());
-        assertNull(c.getExponentialBackoff());
-        
-        b.setExponentialBackoff(new RMAssertion.ExponentialBackoff());
-        c = RM10PolicyUtils.intersect(a, b);
-        assertEquals(7200000L, c.getInactivityTimeout().getMilliseconds().longValue());
-        assertEquals(20000L, c.getBaseRetransmissionInterval().getMilliseconds().longValue());
-        assertEquals(2000L, c.getAcknowledgementInterval().getMilliseconds().longValue());
-        assertNotNull(c.getExponentialBackoff());    
+        cfg1 = RMPolicyUtilities.intersect(rma, cfg0);
+        assertEquals(7200000L, cfg1.getInactivityTimeout().longValue());
+        assertEquals(20000L, cfg1.getBaseRetransmissionInterval().longValue());
+        assertEquals(2000L, cfg1.getAcknowledgementInterval().longValue());
+        assertFalse(cfg1.isExponentialBackoff());
+        
+        cfg0.setExponentialBackoff(true);
+        cfg1 = RMPolicyUtilities.intersect(rma, cfg0);
+        assertEquals(7200000L, cfg1.getInactivityTimeout().longValue());
+        assertEquals(20000L, cfg1.getBaseRetransmissionInterval().longValue());
+        assertEquals(2000L, cfg1.getAcknowledgementInterval().longValue());
+        assertTrue(cfg1.isExponentialBackoff());    
     }
     
     @Test
-    public void testGetRMAssertion() {
-        RMAssertion a = new RMAssertion();
-        BaseRetransmissionInterval abri = new RMAssertion.BaseRetransmissionInterval();
-        abri.setMilliseconds(new Long(3000));
-        a.setBaseRetransmissionInterval(abri);
-        a.setExponentialBackoff(new RMAssertion.ExponentialBackoff());
+    public void testGetRMConfiguration() {
+        RMConfiguration cfg = new RMConfiguration();
+        cfg.setBaseRetransmissionInterval(new Long(3000));
+        cfg.setExponentialBackoff(true);
         
         Message message = control.createMock(Message.class);
         EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(null);
         control.replay();
-        assertSame(a, RM10PolicyUtils.getRMAssertion(a, message));
+        assertSame(cfg, RMPolicyUtilities.getRMConfiguration(cfg, message));
         control.verify();
         
         control.reset();
@@ -143,7 +138,7 @@ public class PolicyUtilsTest extends Ass
         Collection<AssertionInfo> ais = new ArrayList<AssertionInfo>();
         EasyMock.expect(aim.get(RM10Constants.RMASSERTION_QNAME)).andReturn(ais);
         control.replay();
-        assertSame(a, RM10PolicyUtils.getRMAssertion(a, message));
+        assertSame(cfg, RMPolicyUtilities.getRMConfiguration(cfg, message));
         control.verify();
         
         control.reset();
@@ -159,11 +154,11 @@ public class PolicyUtilsTest extends Ass
         EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim);
         EasyMock.expect(aim.get(RM10Constants.RMASSERTION_QNAME)).andReturn(ais);
         control.replay();
-        RMAssertion c = RM10PolicyUtils.getRMAssertion(a, message);
-        assertNull(c.getAcknowledgementInterval());
-        assertNull(c.getInactivityTimeout());
-        assertEquals(2000L, c.getBaseRetransmissionInterval().getMilliseconds().longValue());
-        assertNotNull(c.getExponentialBackoff());   
+        RMConfiguration cfg1 = RMPolicyUtilities.getRMConfiguration(cfg, message);
+        assertNull(cfg1.getAcknowledgementInterval());
+        assertNull(cfg1.getInactivityTimeout());
+        assertEquals(2000L, cfg1.getBaseRetransmissionInterval().longValue());
+        assertTrue(cfg1.isExponentialBackoff());   
         control.verify();
     }
     



Mime
View raw message