sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject [sling-org-apache-sling-hc-it] 07/37: SLING-2822 - Rule execution uses an slf4j Logger to store output and detect issues
Date Tue, 07 Nov 2017 09:39:37 GMT
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hc.it-1.0.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hc-it.git

commit 1fb8c3b9656a826a7066205c0be0b5d52cf93b37
Author: Bertrand Delacretaz <bdelacretaz@apache.org>
AuthorDate: Fri Apr 19 14:13:52 2013 +0000

    SLING-2822 - Rule execution uses an slf4j Logger to store output and detect issues
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/healthcheck/it@1469841
13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/org/apache/sling/hc/it/core/AllRulesTest.java    | 15 +++++++++------
 .../sling/hc/it/core/OsgiHealthCheckFacadeTest.java       | 15 ++++++++-------
 .../java/org/apache/sling/hc/it/core/OsgiRulesTest.java   |  6 +++---
 src/test/java/org/apache/sling/hc/it/core/U.java          |  4 ++--
 4 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/src/test/java/org/apache/sling/hc/it/core/AllRulesTest.java b/src/test/java/org/apache/sling/hc/it/core/AllRulesTest.java
index 147052a..730c04f 100644
--- a/src/test/java/org/apache/sling/hc/it/core/AllRulesTest.java
+++ b/src/test/java/org/apache/sling/hc/it/core/AllRulesTest.java
@@ -50,16 +50,19 @@ public class AllRulesTest {
         // There should be at least one rule builder, but not a lot
         final String [] rules = { 
             "osgi:bundle.state:org.apache.sling.hc.core:active",
-            "osgi:bundle.state:some.nonexistenbundle:BUNDLE_NOT_FOUND",
+            "osgi:bundle.state:some.nonexistenbundle:active",
             "jmxbeans:java.lang#type=ClassLoading:LoadedClassCount:> 100",
-            "healthcheck:RuleBuilderCount:between 2 and 10"
+            "healthcheck:RuleBuilderCount:between 2 and 10",
+            "healthcheck:RuleBuilderCount:between 2000 and 10000"
         };
         final List<EvaluationResult> r = U.evaluateRules(facade, rules);
         
-        assertEquals(4, r.size());
+        assertEquals(5, r.size());
         int i=0;
-        U.assertResult(r.get(i++), EvaluationResult.Status.OK, "Rule: bundle.state:org.apache.sling.hc.core
active");
-        U.assertResult(r.get(i++), EvaluationResult.Status.OK, "Rule: bundle.state:some.nonexistenbundle
BUNDLE_NOT_FOUND");
-        U.assertResult(r.get(i++), EvaluationResult.Status.OK, "Rule: java.lang:type=ClassLoading:LoadedClassCount
> 100");
+        U.assertResult(r.get(i++), true, "Rule: bundle.state:org.apache.sling.hc.core active");
+        U.assertResult(r.get(i++), false, "Rule: bundle.state:some.nonexistenbundle active");
+        U.assertResult(r.get(i++), true, "Rule: java.lang:type=ClassLoading:LoadedClassCount
> 100");
+        U.assertResult(r.get(i++), true, "Rule: RuleBuilderCount between 2 and 10");
+        U.assertResult(r.get(i++), false, "Rule: RuleBuilderCount between 2000 and 10000");
     }
 }
diff --git a/src/test/java/org/apache/sling/hc/it/core/OsgiHealthCheckFacadeTest.java b/src/test/java/org/apache/sling/hc/it/core/OsgiHealthCheckFacadeTest.java
index bffa77b..1ac26c3 100644
--- a/src/test/java/org/apache/sling/hc/it/core/OsgiHealthCheckFacadeTest.java
+++ b/src/test/java/org/apache/sling/hc/it/core/OsgiHealthCheckFacadeTest.java
@@ -37,6 +37,7 @@ import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
 
 @RunWith(PaxExam.class)
 public class OsgiHealthCheckFacadeTest {
@@ -68,8 +69,8 @@ public class OsgiHealthCheckFacadeTest {
         
         assertEquals(2, r.size());
         int i=0;
-        U.assertResult(r.get(i++), EvaluationResult.Status.OK, "Rule: RuleBuilderCount >
0");
-        U.assertResult(r.get(i++), EvaluationResult.Status.ERROR, "Rule: RuleBuilderCount
> 42");
+        U.assertResult(r.get(i++), true, "Rule: RuleBuilderCount > 0");
+        U.assertResult(r.get(i++), false, "Rule: RuleBuilderCount > 42");
     }
     
     @Test
@@ -87,7 +88,7 @@ public class OsgiHealthCheckFacadeTest {
                 return "five";
             }
             @Override
-            public Object getValue() {
+            public Object getValue(Logger logger) {
                 return 5;
             }
         };
@@ -109,10 +110,10 @@ public class OsgiHealthCheckFacadeTest {
             final List<EvaluationResult> r = U.evaluateRules(facade, rules);
             assertEquals(4, r.size());
             int i=0;
-            U.assertResult(r.get(i++), EvaluationResult.Status.OK, "Rule: RuleBuilderCount
> 0");
-            U.assertResult(r.get(i++), EvaluationResult.Status.ERROR, "Rule: RuleBuilderCount
> 42");
-            U.assertResult(r.get(i++), EvaluationResult.Status.OK, "Rule: five 5");
-            U.assertResult(r.get(i++), EvaluationResult.Status.ERROR, "Rule: five 12");
+            U.assertResult(r.get(i++), true, "Rule: RuleBuilderCount > 0");
+            U.assertResult(r.get(i++), false, "Rule: RuleBuilderCount > 42");
+            U.assertResult(r.get(i++), true, "Rule: five 5");
+            U.assertResult(r.get(i++), false, "Rule: five 12");
         } finally {
             reg.unregister();
         }
diff --git a/src/test/java/org/apache/sling/hc/it/core/OsgiRulesTest.java b/src/test/java/org/apache/sling/hc/it/core/OsgiRulesTest.java
index 2cb3498..887e7e8 100644
--- a/src/test/java/org/apache/sling/hc/it/core/OsgiRulesTest.java
+++ b/src/test/java/org/apache/sling/hc/it/core/OsgiRulesTest.java
@@ -49,13 +49,13 @@ public class OsgiRulesTest {
         // There should be at least one rule builder, but not a lot
         final String [] rules = { 
             "osgi:bundle.state:org.apache.sling.hc.core:active",
-            "osgi:bundle.state:some.nonexistenbundle:BUNDLE_NOT_FOUND",
+            "osgi:bundle.state:some.nonexistenbundle:active"
         };
         final List<EvaluationResult> r = U.evaluateRules(facade, rules);
         
         assertEquals(2, r.size());
         int i=0;
-        U.assertResult(r.get(i++), EvaluationResult.Status.OK, "Rule: bundle.state:org.apache.sling.hc.core
active");
-        U.assertResult(r.get(i++), EvaluationResult.Status.OK, "Rule: bundle.state:some.nonexistenbundle
BUNDLE_NOT_FOUND");
+        U.assertResult(r.get(i++), true, "Rule: bundle.state:org.apache.sling.hc.core active");
+        U.assertResult(r.get(i++), false, "Rule: bundle.state:some.nonexistenbundle active");
     }
 }
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 1fd3a49..2e90b52 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
@@ -66,8 +66,8 @@ public class U {
         return e.evaluateRules();
     }
     
-    static void assertResult(EvaluationResult rr, EvaluationResult.Status status, String
ruleString) {
-        assertEquals("Expecting " + rr.getRule() + " result to match", status, rr.getStatus());
+    static void assertResult(EvaluationResult rr, boolean expectOk, String ruleString) {
+        assertEquals("Expecting " + rr.getRule() + " result to match", expectOk, !rr.anythingToReport());
         assertEquals("Expecting " + rr.getRule() + " string to match", ruleString, rr.getRule().toString());
     }
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <commits@sling.apache.org>.

Mime
View raw message