cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [3/3] cxf git commit: [CXF-6185] Updates to ClientPolicyCalculator to handle optional chunking/autoredirect Patch from Xu ShiChang Desmond applied
Date Fri, 31 Mar 2017 19:29:55 GMT
[CXF-6185] Updates to ClientPolicyCalculator to handle optional chunking/autoredirect
Patch from Xu ShiChang Desmond applied


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/f03e6313
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/f03e6313
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/f03e6313

Branch: refs/heads/master
Commit: f03e6313365a853c6c4eea9d5f63532fb92364fb
Parents: 7228709
Author: Daniel Kulp <dkulp@apache.org>
Authored: Fri Mar 31 14:43:46 2017 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri Mar 31 14:56:36 2017 -0400

----------------------------------------------------------------------
 .../policy/impl/ClientPolicyCalculator.java     | 20 ++++++++++++--------
 .../http/policy/ClientPolicyCalculatorTest.java |  1 +
 .../transport/http/policy/PolicyUtilsTest.java  |  2 +-
 3 files changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/f03e6313/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/impl/ClientPolicyCalculator.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/impl/ClientPolicyCalculator.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/impl/ClientPolicyCalculator.java
index 1746b66..629bcac 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/impl/ClientPolicyCalculator.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/impl/ClientPolicyCalculator.java
@@ -32,7 +32,7 @@ public class ClientPolicyCalculator implements PolicyCalculator<HTTPClientPolicy
     /**
      * Determines if two HTTPClientPolicy objects are equal. REVISIT: Check if
      * this can be replaced by a generated equals method.
-     *
+     * 
      * @param p1 one client policy
      * @param p2 another client policy
      * @return true iff the two policies are equal
@@ -76,7 +76,7 @@ public class ClientPolicyCalculator implements PolicyCalculator<HTTPClientPolicy
     /**
      * Returns a new HTTPClientPolicy that is compatible with the two specified
      * policies or null if no compatible policy can be determined.
-     *
+     * 
      * @param p1 one policy
      * @param p2 another policy
      * @return the compatible policy
@@ -152,7 +152,7 @@ public class ClientPolicyCalculator implements PolicyCalculator<HTTPClientPolicy
 
     /**
      * Checks if two HTTPClientPolicy objects are compatible.
-     *
+     * 
      * @param p1 one client policy
      * @param p2 another client policy
      * @return true iff policies are compatible
@@ -229,16 +229,20 @@ public class ClientPolicyCalculator implements PolicyCalculator<HTTPClientPolicy
         }
 
         if (compatible) {
-            compatible &= p1.isAllowChunking() == p2.isAllowChunking();
+            compatible &= !p1.isSetAllowChunking() 
+                || !p2.isSetAllowChunking() 
+                || p1.isAllowChunking() == p2.isAllowChunking();
         }
 
         if (compatible) {
-            compatible &= p1.isAutoRedirect() == p2.isAutoRedirect();
+            compatible &= !p1.isSetAutoRedirect() 
+                || !p2.isSetAutoRedirect() 
+                || p1.isAutoRedirect() == p2.isAutoRedirect();
         }
 
         return compatible;
     }
-
+    
     public boolean isAsserted(Message message, HTTPClientPolicy policy, HTTPClientPolicy
refPolicy) {
         boolean outbound = MessageUtils.isOutbound(message);
         boolean compatible = compatible(policy, refPolicy);
@@ -252,7 +256,7 @@ public class ClientPolicyCalculator implements PolicyCalculator<HTTPClientPolicy
     public QName getDataClassName() {
         return new ObjectFactory().createClient(null).getName();
     }
-
+    
     public static String toString(HTTPClientPolicy p) {
         StringBuilder buf = new StringBuilder();
         buf.append(p);
@@ -263,4 +267,4 @@ public class ClientPolicyCalculator implements PolicyCalculator<HTTPClientPolicy
         buf.append("])");
         return buf.toString();
     }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf/blob/f03e6313/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/ClientPolicyCalculatorTest.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/ClientPolicyCalculatorTest.java
b/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/ClientPolicyCalculatorTest.java
index 8b04511..053d18c 100644
--- a/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/ClientPolicyCalculatorTest.java
+++ b/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/ClientPolicyCalculatorTest.java
@@ -37,6 +37,7 @@ public class ClientPolicyCalculatorTest extends Assert {
         p1.setConnectionTimeout(10000);
         assertTrue("Policies are not compatible.", calc.compatible(p1, p2));
         p1.setAllowChunking(false);
+        p2.setAllowChunking(true);
         assertTrue("Policies are compatible.", !calc.compatible(p1, p2));
         p2.setAllowChunking(false);
         assertTrue("Policies are compatible.", calc.compatible(p1, p2));

http://git-wip-us.apache.org/repos/asf/cxf/blob/f03e6313/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java
b/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java
index 563d6f5..ba5696d 100644
--- a/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java
+++ b/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java
@@ -138,7 +138,7 @@ public class PolicyUtilsTest extends Assert {
         pde.assertMessage(message, ep, new ClientPolicyCalculator());
         assertTrue(eai.isAsserted());
         assertTrue(cmai.isAsserted());
-        assertTrue(outbound ? !icmai.isAsserted() : icmai.isAsserted());
+        assertTrue(icmai.isAsserted());
         control.verify();
     }
 


Mime
View raw message