sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1649583 - in /sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core: HealthCheckExecutorSelectionTest.java U.java
Date Mon, 05 Jan 2015 16:41:16 GMT
Author: bdelacretaz
Date: Mon Jan  5 16:41:16 2015
New Revision: 1649583

URL: http://svn.apache.org/r1649583
Log:
SLING-3501 - add tests for OR selection option in HealthCheckExecutor

Modified:
    sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/HealthCheckExecutorSelectionTest.java
    sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/U.java

Modified: sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/HealthCheckExecutorSelectionTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/HealthCheckExecutorSelectionTest.java?rev=1649583&r1=1649582&r2=1649583&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/HealthCheckExecutorSelectionTest.java
(original)
+++ sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/HealthCheckExecutorSelectionTest.java
Mon Jan  5 16:41:16 2015
@@ -27,6 +27,7 @@ import javax.inject.Inject;
 
 import org.apache.sling.hc.api.HealthCheck;
 import org.apache.sling.hc.api.Result;
+import org.apache.sling.hc.api.execution.HealthCheckExecutionOptions;
 import org.apache.sling.hc.api.execution.HealthCheckExecutor;
 import org.junit.After;
 import org.junit.Before;
@@ -51,6 +52,7 @@ public class HealthCheckExecutorSelectio
     
     private static String idA;
     private static String idB;
+    private HealthCheckExecutionOptions options;
     
     @SuppressWarnings("rawtypes")
     private List<ServiceRegistration> regs = new ArrayList<ServiceRegistration>();
@@ -60,18 +62,18 @@ public class HealthCheckExecutorSelectio
         return U.config();
     }
     
-    private void registerHC(final String id) {
+    private void registerHC(final String ... tags) {
         final HealthCheck hc = new HealthCheck() {
             @Override
             public Result execute() {
-                return new Result(Result.Status.OK, "All good for " + id);
+                return new Result(Result.Status.OK, "All good for " + tags[0]);
             }
             
         };
         
         final Dictionary<String, Object> props = new Hashtable<String, Object>();
-        props.put(HealthCheck.NAME, "name_" + id);
-        props.put(HealthCheck.TAGS, id);
+        props.put(HealthCheck.NAME, "name_" + tags[0]);
+        props.put(HealthCheck.TAGS, tags);
         
         regs.add(bundleContext.registerService(HealthCheck.class, hc, props));
     }
@@ -84,13 +86,15 @@ public class HealthCheckExecutorSelectio
     
     @Before
     public void setup() {
+        options = new HealthCheckExecutionOptions();
+        
         U.expectHealthChecks(0, executor, idA);
         U.expectHealthChecks(0, executor, idB);
         
         registerHC(idA);
         registerHC(idB);
         registerHC(idB);
-        registerHC(idB);
+        registerHC(idA, idB);
     }
     
     @After
@@ -107,15 +111,37 @@ public class HealthCheckExecutorSelectio
 
     @Test
     public void testDefaultSelectionA(){
-        U.expectHealthChecks(1, executor, idA);
+        U.expectHealthChecks(2, executor, idA);
+        U.expectHealthChecks(2, executor, options, idA);
     }
     
     @Test
     public void testDefaultSelectionB(){
         U.expectHealthChecks(3, executor, idB);
+        U.expectHealthChecks(3, executor, options, idB);
+    }
+    
+    @Test
+    public void testDefaultSelectionAB(){
+        U.expectHealthChecks(1, executor, idA, idB);
+        U.expectHealthChecks(1, executor, options, idA, idB);
+    }
+    
+    @Test
+    public void testOrSelectionA(){
+        options.setCombineTagsWithOr(true);
+        U.expectHealthChecks(1, executor, options, idA);
+    }
+    
+    @Test
+    public void testOrSelectionB(){
+        options.setCombineTagsWithOr(true);
+        U.expectHealthChecks(3, executor, options, idB);
     }
+    
     @Test
-    public void testDefaultSelectionAandB(){
-        U.expectHealthChecks(0, executor, idA, idB);
+    public void testOrSelectionAB(){
+        options.setCombineTagsWithOr(true);
+        U.expectHealthChecks(4, executor, options, idA, idB);
     }
 }

Modified: sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/U.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/U.java?rev=1649583&r1=1649582&r2=1649583&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/U.java
(original)
+++ sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/U.java
Mon Jan  5 16:41:16 2015
@@ -28,6 +28,7 @@ import static org.ops4j.pax.exam.CoreOpt
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.sling.hc.api.execution.HealthCheckExecutionOptions;
 import org.apache.sling.hc.api.execution.HealthCheckExecutionResult;
 import org.apache.sling.hc.api.execution.HealthCheckExecutor;
 import org.ops4j.pax.exam.Option;
@@ -37,10 +38,15 @@ public class U {
 
     /** Wait until the specified number of health checks are seen by supplied executor */
     static void expectHealthChecks(int howMany, HealthCheckExecutor executor, String ...
tags) {
+        expectHealthChecks(howMany, executor, new HealthCheckExecutionOptions(), tags);
+    }
+    
+    /** Wait until the specified number of health checks are seen by supplied executor */
+    static void expectHealthChecks(int howMany, HealthCheckExecutor executor, HealthCheckExecutionOptions
options, String ... tags) {
         final long timeout = System.currentTimeMillis() + 10000L;
         int count = 0;
         while(System.currentTimeMillis() < timeout) {
-            final List<HealthCheckExecutionResult> results = executor.execute(tags);
+            final List<HealthCheckExecutionResult> results = executor.execute(options,
tags);
             count = results.size();
             if(count== howMany) {
                 return;



Mime
View raw message