You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/10/18 23:20:37 UTC
[sling-org-apache-sling-hc-it] 27/49: SLING-3501 - add tests for OR
selection option in HealthCheckExecutor
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hc-it.git
commit 785417aa11c99ac6255f127e3df311e506f26a93
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Jan 5 16:41:16 2015 +0000
SLING-3501 - add tests for OR selection option in HealthCheckExecutor
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1649583 13f79535-47bb-0310-9956-ffa450edef68
---
.../it/core/HealthCheckExecutorSelectionTest.java | 42 +++++++++++++++++-----
src/test/java/org/apache/sling/hc/it/core/U.java | 8 ++++-
2 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/src/test/java/org/apache/sling/hc/it/core/HealthCheckExecutorSelectionTest.java b/src/test/java/org/apache/sling/hc/it/core/HealthCheckExecutorSelectionTest.java
index 91054b3..88c9bfe 100644
--- a/src/test/java/org/apache/sling/hc/it/core/HealthCheckExecutorSelectionTest.java
+++ b/src/test/java/org/apache/sling/hc/it/core/HealthCheckExecutorSelectionTest.java
@@ -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 HealthCheckExecutorSelectionTest {
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 HealthCheckExecutorSelectionTest {
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 HealthCheckExecutorSelectionTest {
@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 HealthCheckExecutorSelectionTest {
@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);
}
}
diff --git a/src/test/java/org/apache/sling/hc/it/core/U.java b/src/test/java/org/apache/sling/hc/it/core/U.java
index 91333d7..36a1026 100644
--- a/src/test/java/org/apache/sling/hc/it/core/U.java
+++ b/src/test/java/org/apache/sling/hc/it/core/U.java
@@ -28,6 +28,7 @@ import static org.ops4j.pax.exam.CoreOptions.when;
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;
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.