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:50 UTC
[sling-org-apache-sling-hc-it] 40/49: SLING-4941 - restructure
tests and add testAnotherTag()
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 1615e4b7ed7e9f5f4d67d16ecd9c53e031ee1f17
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Feb 29 09:50:27 2016 +0000
SLING-4941 - restructure tests and add testAnotherTag()
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1732840 13f79535-47bb-0310-9956-ffa450edef68
---
.../it/core/JmxAdjustableStatusForTestingTest.java | 66 +++++++++++-----------
1 file changed, 34 insertions(+), 32 deletions(-)
diff --git a/src/test/java/org/apache/sling/hc/it/core/JmxAdjustableStatusForTestingTest.java b/src/test/java/org/apache/sling/hc/it/core/JmxAdjustableStatusForTestingTest.java
index 96ed2fa..15a5425 100644
--- a/src/test/java/org/apache/sling/hc/it/core/JmxAdjustableStatusForTestingTest.java
+++ b/src/test/java/org/apache/sling/hc/it/core/JmxAdjustableStatusForTestingTest.java
@@ -64,16 +64,28 @@ public class JmxAdjustableStatusForTestingTest {
public Option[] config() {
return U.config();
}
+
+ private void assertResult(String tag, Result.Status expected) {
+ final Result result = getOverallResult(executor.execute(tag));
+ assertEquals("Expected status " + expected + " for tag " + tag, expected, result.getStatus());
+ }
@Before
public void setup() {
U.expectHealthChecks(0, executor, testTag);
registerHC(testTag);
+ U.expectHealthChecks(1, executor, testTag);
+ assertResult(testTag, Result.Status.OK);
}
@After
@SuppressWarnings("rawtypes")
- public void cleanup() {
+ public void cleanup() throws Exception {
+ invokeMBean("reset", new Object[] {}, new String[] {});
+
+ U.expectHealthChecks(1, executor, testTag);
+ assertResult(testTag, Result.Status.OK);
+
for (ServiceRegistration r : regs) {
r.unregister();
}
@@ -82,40 +94,31 @@ public class JmxAdjustableStatusForTestingTest {
}
@Test
- public void testJmxAdjustableStatusForTesting() throws Exception {
-
- U.expectHealthChecks(1, executor, testTag);
-
- Result result = getOverallResult(executor.execute(testTag));
- assertEquals(Result.Status.OK, result.getStatus());
-
+ public void testWarnStatus() throws Exception {
invokeMBean("addWarnResultForTags", new Object[] { testTag }, new String[] { String.class.getName() });
-
- U.expectHealthChecks(2, executor, testTag);
- result = getOverallResult(executor.execute(testTag));
- assertEquals(Result.Status.WARN, result.getStatus());
-
- invokeMBean("reset", new Object[] {}, new String[] {});
-
- U.expectHealthChecks(1, executor, testTag);
- result = getOverallResult(executor.execute(testTag));
- assertEquals(Result.Status.OK, result.getStatus());
-
- invokeMBean("addCriticalResultForTags", new Object[] { "anotherTag," + testTag },
- new String[] { String.class.getName() });
-
U.expectHealthChecks(2, executor, testTag);
- result = getOverallResult(executor.execute(testTag));
- assertEquals(Result.Status.CRITICAL, result.getStatus());
-
- invokeMBean("reset", new Object[] {}, new String[] {});
-
- U.expectHealthChecks(1, executor, testTag);
- result = getOverallResult(executor.execute(testTag));
- assertEquals(Result.Status.OK, result.getStatus());
-
+ assertResult(testTag, Result.Status.WARN);
}
+ @Test
+ public void testCriticalStatus() throws Exception {
+ invokeMBean("addCriticalResultForTags", new Object[] { "anotherTag," + testTag },
+ new String[] { String.class.getName() });
+
+ final String [] tags = { "anotherTag", testTag };
+ for(String tag : tags) {
+ U.expectHealthChecks(2, executor, testTag);
+ assertResult(tag, Result.Status.CRITICAL);
+ }
+ }
+
+ @Test
+ public void testAnotherTag() throws Exception {
+ // Selecting an unused tag returns WARN - not sure why but
+ // if that changes we should detect it.
+ assertResult("some_unused_tag", Result.Status.WARN);
+ }
+
private void registerHC(final String... tags) {
final HealthCheck hc = new HealthCheck() {
@Override
@@ -149,5 +152,4 @@ public class JmxAdjustableStatusForTestingTest {
}
return new Result(resultLog);
}
-
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.