cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cxf git commit: CXF-6622: Enhance Failover Feature to support Circuit Breakers based implementation. Added more tests.
Date Tue, 24 Nov 2015 02:41:17 GMT
Repository: cxf
Updated Branches:
  refs/heads/master a7362dfaf -> befeb0484


CXF-6622: Enhance Failover Feature to support Circuit Breakers based implementation. Added
more tests.


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

Branch: refs/heads/master
Commit: befeb0484cb195cbcd6163f65c54a94ba26d8335
Parents: a7362df
Author: reta <drreta@gmail.com>
Authored: Mon Nov 23 21:40:41 2015 -0500
Committer: reta <drreta@gmail.com>
Committed: Mon Nov 23 21:40:41 2015 -0500

----------------------------------------------------------------------
 .../failover/CircuitBreakerFailoverTest.java    | 44 +++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/befeb048/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/CircuitBreakerFailoverTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/CircuitBreakerFailoverTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/CircuitBreakerFailoverTest.java
index 81cba78..27e46e1 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/CircuitBreakerFailoverTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/CircuitBreakerFailoverTest.java
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.systest.jaxrs.failover;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -62,9 +63,50 @@ public class CircuitBreakerFailoverTest extends AbstractFailoverTest {
         }
     }
     
+    @Test
+    public void testSequentialStrategyWithElapsingCircuitBreakerTimeout() throws Throwable
{
+        FailoverFeature feature = customizeFeature(
+            new CircuitBreakerFailoverFeature(1, 3000), false, 
+            "http://localhost:" + NON_PORT + "/non-existent", 
+            "http://localhost:" + NON_PORT + "/non-existent2"); 
+        
+        final BookStore bookStore = getBookStore(
+            "http://localhost:" + NON_PORT + "/non-existent", feature);
+        
+        // First iteration is going to open all circuit breakers. The timeout at the end
+        // should reset all circuit breakers and the URLs could be tried again. 
+        for (int i = 0; i < 2; ++i) {
+            try {
+                bookStore.getBook(1);
+                fail("Exception expected");
+            } catch (ProcessingException ex) {
+                if (!(ex.getCause() instanceof IOException)) {
+                    throw ex.getCause();
+                }
+            }
+            
+            // Let's wait a bit more than circuit breaker timeout
+            Thread.sleep(4000);
+        }
+    }
+    
+    @Test
+    public void testSequentialStrategyWithRetry() throws Exception {
+        FailoverFeature feature = getFeature(false, 
+            "http://localhost:" + NON_PORT + "/non-existent", 
+            Server.ADDRESS2); 
+        
+        strategyTest("http://localhost:" + NON_PORT + "/non-existent", feature, 
+            Server.ADDRESS2, null, false, false, false);
+    }
+    
     @Override
     protected FailoverFeature getFeature(boolean random, String ...address) {
-        CircuitBreakerFailoverFeature feature = new CircuitBreakerFailoverFeature();
+        return customizeFeature(new CircuitBreakerFailoverFeature(), random, address);
+    }
+    
+    private FailoverFeature customizeFeature(CircuitBreakerFailoverFeature feature, 
+            boolean random, String ...address) {
         List<String> alternateAddresses = new ArrayList<String>();
         for (String s : address) {
             alternateAddresses.add(s);


Mime
View raw message