incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1469841 - in /sling/trunk/contrib/extensions/healthcheck: hc-core/src/main/java/org/apache/sling/hc/api/ hc-core/src/main/java/org/apache/sling/hc/impl/ hc-core/src/main/java/org/apache/sling/hc/util/ hc-core/src/test/java/org/apache/sling...
Date Fri, 19 Apr 2013 14:13:53 GMT
Author: bdelacretaz
Date: Fri Apr 19 14:13:52 2013
New Revision: 1469841

URL: http://svn.apache.org/r1469841
Log:
SLING-2822 - Rule execution uses an slf4j Logger to store output and detect issues

Added:
    sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/RuleLogger.java
    sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/impl/RuleLoggerImpl.java
Modified:
    sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/EvaluationResult.java
    sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/Evaluator.java
    sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/Rule.java
    sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/SystemAttribute.java
    sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/impl/DefaultRuleBuilder.java
    sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/impl/RulesEngineImpl.java
    sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/util/DefaultEvaluator.java
    sling/trunk/contrib/extensions/healthcheck/hc-core/src/test/java/org/apache/sling/hc/impl/DefaultEvaluatorTest.java
    sling/trunk/contrib/extensions/healthcheck/hc-core/src/test/java/org/apache/sling/hc/impl/RuleTest.java
    sling/trunk/contrib/extensions/healthcheck/hc-core/src/test/java/org/apache/sling/hc/impl/RulesEngineTest.java
    sling/trunk/contrib/extensions/healthcheck/hc-rules/src/main/java/org/apache/sling/hc/rules/jmx/JmxBeansRuleBuilder.java
    sling/trunk/contrib/extensions/healthcheck/hc-rules/src/main/java/org/apache/sling/hc/rules/osgi/BundlesRuleBuilder.java
    sling/trunk/contrib/extensions/healthcheck/hc-rules/src/test/java/org/apache/sling/hc/rules/impl/JmxBeansRuleBuilderTest.java
    sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/JsonResultRendererImpl.java
    sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/ScriptSystemAttribute.java
    sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/rules/JUnitTestRuleBuilder.java
    sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/rules/LoginRuleBuilder.java
    sling/trunk/contrib/extensions/healthcheck/hc-sling/src/test/java/org/apache/sling/hc/sling/LoginRuleBuilderTest.java
    sling/trunk/contrib/extensions/healthcheck/hc-sling/src/test/java/org/apache/sling/hc/sling/RulesResourceParserTest.java
    sling/trunk/contrib/extensions/healthcheck/hc-sling/src/test/java/org/apache/sling/hc/sling/impl/ScriptSystemAttributeTest.java
    sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/AllRulesTest.java
    sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/OsgiHealthCheckFacadeTest.java
    sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/OsgiRulesTest.java
    sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/U.java
    sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/java/org/apache/sling/hc/demo/tests/ResourcesExistTest.java
    sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/RepositoryPresentTest.json
    sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/ResourcesExistTest-checkAppsExist.json
    sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/ResourcesExistTest.json
    sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/admin-foo.json
    sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/admin-login.json
    sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/junit-sling-all.json

Modified: sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/EvaluationResult.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/EvaluationResult.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/EvaluationResult.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/EvaluationResult.java Fri Apr 19 14:13:52 2013
@@ -17,28 +17,65 @@
  */
 package org.apache.sling.hc.api;
 
+import java.util.List;
+
 /** The result of evaluating a {@link Rule} */
 public class EvaluationResult {
     
-    public enum Status {
-        OK,
+    private final Rule rule;
+    private final RuleLogger ruleLogger;
+    
+    /** Log messages at or above this level cause {@link #anythingToReport} to return true */
+    public static final LogLevel MIN_LEVEL_TO_REPORT = LogLevel.INFO;
+    
+    public enum LogLevel {
+        TRACE,
+        DEBUG,
+        INFO,
+        WARN,
         ERROR
     }
     
-    private final Status status;
-    private final Rule rule;
+    public static class LogMessage {
+        private final LogLevel level;
+        private final String message;
+        
+        public LogMessage(LogLevel level, String message) {
+            this.level = level;
+            this.message = message;
+        }
+        
+        public String toString() {
+            return level + ": " + message;
+        }
+        
+        public LogLevel getLevel() {
+            return level;
+        }
+        
+        public String getMessage() {
+            return message;
+        }
+    }
     
-    public EvaluationResult(Rule r) {
+    EvaluationResult(Rule r, RuleLogger logger) {
         rule = r;
-        status = r.evaluate();
+        ruleLogger = logger;
     }
     
     public Rule getRule() {
         return rule;
     }
     
-    public Status getStatus() {
-        return status;
+    /** True if there's anything to report, i.e. if rule execution
+     *  logged any messages at the INFO level or above 
+     */
+    public boolean anythingToReport() {
+        return ruleLogger.getMaxLevel().ordinal() >= MIN_LEVEL_TO_REPORT.ordinal();
+    }
+
+    /** Return all log messages */
+    public List<LogMessage> getLogMessages() {
+        return ruleLogger.getMessages();
     }
-   
 }

Modified: sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/Evaluator.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/Evaluator.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/Evaluator.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/Evaluator.java Fri Apr 19 14:13:52 2013
@@ -17,7 +17,9 @@
  */
 package org.apache.sling.hc.api;
 
+import org.slf4j.Logger;
+
 /** Evaluates a String expression on the current value of a {@link SystemAttribute} */ 
 public interface Evaluator {
-    EvaluationResult.Status evaluate(SystemAttribute a, String expression);
+    void evaluate(SystemAttribute a, String expression, Logger logger);
 }

Modified: sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/Rule.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/Rule.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/Rule.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/Rule.java Fri Apr 19 14:13:52 2013
@@ -17,7 +17,10 @@
  */
 package org.apache.sling.hc.api;
 
+import org.apache.sling.hc.impl.RuleLoggerImpl;
 import org.apache.sling.hc.util.DefaultEvaluator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /** Groups a {@link SystemAttribute}, {@link Evaluator} and
  *  String expression to be able to check that the attribute's
@@ -27,6 +30,7 @@ public class Rule {
     private final SystemAttribute attribute;
     private final Evaluator evaluator;
     private final String expression;
+    private final Logger logger = LoggerFactory.getLogger(getClass());
     
     public Rule(SystemAttribute attr, String expression) {
         this(attr, expression, new DefaultEvaluator());
@@ -38,12 +42,17 @@ public class Rule {
         this.evaluator = e;
     }
     
-    public EvaluationResult.Status evaluate() {
-        return evaluator.evaluate(attribute, expression);
+    /** Evaluate the rule and return the results */
+    public EvaluationResult evaluate() {
+        final RuleLoggerImpl ruleLogger = new RuleLoggerImpl(logger);
+        evaluator.evaluate(attribute, expression, ruleLogger);
+        return new EvaluationResult(this, ruleLogger);
     }
     
     @Override
     public String toString() {
-        return getClass().getSimpleName() + ": " + attribute + " " + expression;
+        return getClass().getSimpleName() + ": " 
+            + attribute 
+            + (expression == null ? "" : " " + expression);
     }
 }

Added: sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/RuleLogger.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/RuleLogger.java?rev=1469841&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/RuleLogger.java (added)
+++ sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/RuleLogger.java Fri Apr 19 14:13:52 2013
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The SF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.sling.hc.api;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+
+/** slf4j Logger that captures log output and provides
+ *  the level of the highest message that was logged.
+ *  Used when evaluating {@link Rule} objects, to find
+ *  out whether anything was logged that needs to be reported.
+ *  
+ *  The convention is that messages above the DEBUG level are
+ *  always reported when evaluating rules, all messages can
+ *  optionally be made available in the rule evaluation results.   
+ */
+public interface RuleLogger extends Logger {
+
+    /** Return the list of messages logged during rule execution */
+    List<EvaluationResult.LogMessage> getMessages();
+    
+    /** Return the highest log level used during execution */
+    EvaluationResult.LogLevel getMaxLevel();
+}

Modified: sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/SystemAttribute.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/SystemAttribute.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/SystemAttribute.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/api/SystemAttribute.java Fri Apr 19 14:13:52 2013
@@ -17,7 +17,12 @@
  */
 package org.apache.sling.hc.api;
 
+import org.slf4j.Logger;
+
 /** An attribute of the system that's being checked */
 public interface SystemAttribute {
-    Object getValue();
+    /** Return the value of out attribute, logging any relevant
+     *  info to the supplied logger.
+     */
+    Object getValue(Logger logger);
 }

Modified: sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/impl/DefaultRuleBuilder.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/impl/DefaultRuleBuilder.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/impl/DefaultRuleBuilder.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/impl/DefaultRuleBuilder.java Fri Apr 19 14:13:52 2013
@@ -22,6 +22,7 @@ import org.apache.sling.hc.api.Rule;
 import org.apache.sling.hc.api.RuleBuilder;
 import org.apache.sling.hc.api.SystemAttribute;
 import org.apache.sling.hc.util.DefaultEvaluator;
+import org.slf4j.Logger;
 
 /** {@link RuleBuilder} that provides a few default Rules. */
 public class DefaultRuleBuilder implements RuleBuilder {
@@ -36,8 +37,10 @@ public class DefaultRuleBuilder implemen
             return RULE_BUILDER_COUNT;
         }
         @Override
-        public Object getValue() {
-            return new Integer(facade.getRuleBuilders().size());
+        public Object getValue(Logger logger) {
+            final int value = facade.getRuleBuilders().size();
+            logger.debug("Our facade has {} builders", value);
+            return value;
         }
     };
     

Added: sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/impl/RuleLoggerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/impl/RuleLoggerImpl.java?rev=1469841&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/impl/RuleLoggerImpl.java (added)
+++ sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/impl/RuleLoggerImpl.java Fri Apr 19 14:13:52 2013
@@ -0,0 +1,417 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The SF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.sling.hc.impl;
+
+import static org.apache.sling.hc.api.EvaluationResult.LogLevel.DEBUG;
+import static org.apache.sling.hc.api.EvaluationResult.LogLevel.ERROR;
+import static org.apache.sling.hc.api.EvaluationResult.LogLevel.INFO;
+import static org.apache.sling.hc.api.EvaluationResult.LogLevel.TRACE;
+import static org.apache.sling.hc.api.EvaluationResult.LogLevel.WARN;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.sling.hc.api.EvaluationResult;
+import org.apache.sling.hc.api.RuleLogger;
+import org.slf4j.Logger;
+import org.slf4j.Marker;
+import org.slf4j.helpers.MessageFormatter;
+
+/** {@link RuleLogger} used to evaluate our rules - wraps 
+ *  and slf4j Logger to capture log output and keep
+ *  track of the highest log level used.
+ */
+public class RuleLoggerImpl implements RuleLogger {
+
+    private final Logger wrappedLogger;
+    private final List<EvaluationResult.LogMessage> messages = new LinkedList<EvaluationResult.LogMessage>();
+    private EvaluationResult.LogLevel maxLevel = EvaluationResult.LogLevel.DEBUG;
+    
+    public RuleLoggerImpl(Logger wrapped) {
+        this.wrappedLogger = wrapped;
+    }
+    
+    private void storeMessage(EvaluationResult.LogLevel level, String message) {
+        maxLevel = level.ordinal() > maxLevel.ordinal() ? level : maxLevel;
+        messages.add(new EvaluationResult.LogMessage(level, message));
+    }
+    
+    public List<EvaluationResult.LogMessage> getMessages() {
+        return Collections.unmodifiableList(messages);
+    }
+    
+    public EvaluationResult.LogLevel getMaxLevel() {
+        return maxLevel;
+    }
+    
+    @Override
+    public String getName() {
+        return getClass().getName();
+    }
+    
+    @Override
+    public void debug(Marker arg0, String arg1, Object arg2, Object arg3) {
+        storeMessage(DEBUG, MessageFormatter.format(arg1, arg2, arg3).getMessage());
+        wrappedLogger.debug(arg0, arg1, arg2, arg3);
+    }
+
+    @Override
+    public void debug(Marker arg0, String arg1, Object arg2) {
+        storeMessage(DEBUG, MessageFormatter.format(arg1, arg2).getMessage());
+        wrappedLogger.debug(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void debug(Marker arg0, String arg1, Object[] arg2) {
+        storeMessage(DEBUG, MessageFormatter.arrayFormat(arg1, arg2).getMessage());
+        wrappedLogger.debug(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void debug(Marker arg0, String arg1, Throwable arg2) {
+        storeMessage(DEBUG, MessageFormatter.format(arg1, arg2).getMessage());
+        wrappedLogger.debug(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void debug(Marker arg0, String arg1) {
+        storeMessage(DEBUG, arg1);
+        wrappedLogger.debug(arg0, arg1);
+    }
+
+    @Override
+    public void debug(String arg0, Object arg1, Object arg2) {
+        storeMessage(DEBUG, MessageFormatter.format(arg0, arg1, arg2).getMessage());
+        wrappedLogger.debug(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void debug(String arg0, Object arg1) {
+        storeMessage(DEBUG, MessageFormatter.format(arg0, arg1).getMessage());
+        wrappedLogger.debug(arg0, arg1);
+    }
+
+    @Override
+    public void debug(String arg0, Object[] arg1) {
+        storeMessage(DEBUG, MessageFormatter.arrayFormat(arg0, arg1).getMessage());
+        wrappedLogger.debug(arg0, arg1);
+    }
+
+    @Override
+    public void debug(String arg0, Throwable arg1) {
+        storeMessage(DEBUG, MessageFormatter.format(arg0, arg1).getMessage());
+        wrappedLogger.debug(arg0, arg1);
+    }
+
+    @Override
+    public void debug(String arg0) {
+        storeMessage(DEBUG, arg0);
+        wrappedLogger.debug(arg0);
+    }
+
+    @Override
+    public boolean isDebugEnabled() {
+        return true;
+    }
+
+    @Override
+    public boolean isDebugEnabled(Marker arg0) {
+        return true;
+    }
+    
+    @Override
+    public void info(Marker arg0, String arg1, Object arg2, Object arg3) {
+        storeMessage(INFO, MessageFormatter.format(arg1, arg2, arg3).getMessage());
+        wrappedLogger.info(arg0, arg1, arg2, arg3);
+    }
+
+    @Override
+    public void info(Marker arg0, String arg1, Object arg2) {
+        storeMessage(INFO, MessageFormatter.format(arg1, arg2).getMessage());
+        wrappedLogger.info(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void info(Marker arg0, String arg1, Object[] arg2) {
+        storeMessage(INFO, MessageFormatter.arrayFormat(arg1, arg2).getMessage());
+        wrappedLogger.info(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void info(Marker arg0, String arg1, Throwable arg2) {
+        storeMessage(INFO, MessageFormatter.format(arg1, arg2).getMessage());
+        wrappedLogger.info(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void info(Marker arg0, String arg1) {
+        storeMessage(INFO, arg1);
+        wrappedLogger.info(arg0, arg1);
+    }
+
+    @Override
+    public void info(String arg0, Object arg1, Object arg2) {
+        storeMessage(INFO, MessageFormatter.format(arg0, arg1, arg2).getMessage());
+        wrappedLogger.info(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void info(String arg0, Object arg1) {
+        storeMessage(INFO, MessageFormatter.format(arg0, arg1).getMessage());
+        wrappedLogger.info(arg0, arg1);
+    }
+
+    @Override
+    public void info(String arg0, Object[] arg1) {
+        storeMessage(INFO, MessageFormatter.arrayFormat(arg0, arg1).getMessage());
+        wrappedLogger.info(arg0, arg1);
+    }
+
+    @Override
+    public void info(String arg0, Throwable arg1) {
+        storeMessage(INFO, MessageFormatter.format(arg0, arg1).getMessage());
+        wrappedLogger.info(arg0, arg1);
+    }
+
+    @Override
+    public void info(String arg0) {
+        storeMessage(INFO, arg0);
+        wrappedLogger.info(arg0);
+    }
+
+    @Override
+    public boolean isInfoEnabled() {
+        return true;
+    }
+
+    @Override
+    public boolean isInfoEnabled(Marker arg0) {
+        return true;
+    }
+    
+    @Override
+    public void warn(Marker arg0, String arg1, Object arg2, Object arg3) {
+        storeMessage(WARN, MessageFormatter.format(arg1, arg2, arg3).getMessage());
+        wrappedLogger.warn(arg0, arg1, arg2, arg3);
+    }
+
+    @Override
+    public void warn(Marker arg0, String arg1, Object arg2) {
+        storeMessage(WARN, MessageFormatter.format(arg1, arg2).getMessage());
+        wrappedLogger.warn(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void warn(Marker arg0, String arg1, Object[] arg2) {
+        storeMessage(WARN, MessageFormatter.arrayFormat(arg1, arg2).getMessage());
+        wrappedLogger.warn(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void warn(Marker arg0, String arg1, Throwable arg2) {
+        storeMessage(WARN, MessageFormatter.format(arg1, arg2).getMessage());
+        wrappedLogger.warn(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void warn(Marker arg0, String arg1) {
+        storeMessage(WARN, arg1);
+        wrappedLogger.warn(arg0, arg1);
+    }
+
+    @Override
+    public void warn(String arg0, Object arg1, Object arg2) {
+        storeMessage(WARN, MessageFormatter.format(arg0, arg1, arg2).getMessage());
+        wrappedLogger.warn(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void warn(String arg0, Object arg1) {
+        storeMessage(WARN, MessageFormatter.format(arg0, arg1).getMessage());
+        wrappedLogger.warn(arg0, arg1);
+    }
+
+    @Override
+    public void warn(String arg0, Object[] arg1) {
+        storeMessage(WARN, MessageFormatter.arrayFormat(arg0, arg1).getMessage());
+        wrappedLogger.warn(arg0, arg1);
+    }
+
+    @Override
+    public void warn(String arg0, Throwable arg1) {
+        storeMessage(WARN, MessageFormatter.format(arg0, arg1).getMessage());
+        wrappedLogger.warn(arg0, arg1);
+    }
+
+    @Override
+    public void warn(String arg0) {
+        storeMessage(WARN, arg0);
+        wrappedLogger.warn(arg0);
+    }
+
+    @Override
+    public boolean isWarnEnabled() {
+        return true;
+    }
+
+    @Override
+    public boolean isWarnEnabled(Marker arg0) {
+        return true;
+    }
+    
+    @Override
+    public void error(Marker arg0, String arg1, Object arg2, Object arg3) {
+        storeMessage(ERROR, MessageFormatter.format(arg1, arg2, arg3).getMessage());
+        wrappedLogger.error(arg0, arg1, arg2, arg3);
+    }
+
+    @Override
+    public void error(Marker arg0, String arg1, Object arg2) {
+        storeMessage(ERROR, MessageFormatter.format(arg1, arg2).getMessage());
+        wrappedLogger.error(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void error(Marker arg0, String arg1, Object[] arg2) {
+        storeMessage(ERROR, MessageFormatter.arrayFormat(arg1, arg2).getMessage());
+        wrappedLogger.error(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void error(Marker arg0, String arg1, Throwable arg2) {
+        storeMessage(ERROR, MessageFormatter.format(arg1, arg2).getMessage());
+        wrappedLogger.error(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void error(Marker arg0, String arg1) {
+        storeMessage(ERROR, arg1);
+        wrappedLogger.error(arg0, arg1);
+    }
+
+    @Override
+    public void error(String arg0, Object arg1, Object arg2) {
+        storeMessage(ERROR, MessageFormatter.format(arg0, arg1, arg2).getMessage());
+        wrappedLogger.error(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void error(String arg0, Object arg1) {
+        storeMessage(ERROR, MessageFormatter.format(arg0, arg1).getMessage());
+        wrappedLogger.error(arg0, arg1);
+    }
+
+    @Override
+    public void error(String arg0, Object[] arg1) {
+        storeMessage(ERROR, MessageFormatter.arrayFormat(arg0, arg1).getMessage());
+        wrappedLogger.error(arg0, arg1);
+    }
+
+    @Override
+    public void error(String arg0, Throwable arg1) {
+        storeMessage(ERROR, MessageFormatter.format(arg0, arg1).getMessage());
+        wrappedLogger.error(arg0, arg1);
+    }
+
+    @Override
+    public void error(String arg0) {
+        storeMessage(ERROR, arg0);
+        wrappedLogger.error(arg0);
+    }
+
+    @Override
+    public boolean isErrorEnabled() {
+        return true;
+    }
+
+    @Override
+    public boolean isErrorEnabled(Marker arg0) {
+        return true;
+    }
+    
+    @Override
+    public void trace(Marker arg0, String arg1, Object arg2, Object arg3) {
+        storeMessage(TRACE, MessageFormatter.format(arg1, arg2, arg3).getMessage());
+        wrappedLogger.trace(arg0, arg1, arg2, arg3);
+    }
+
+    @Override
+    public void trace(Marker arg0, String arg1, Object arg2) {
+        storeMessage(TRACE, MessageFormatter.format(arg1, arg2).getMessage());
+        wrappedLogger.trace(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void trace(Marker arg0, String arg1, Object[] arg2) {
+        storeMessage(TRACE, MessageFormatter.arrayFormat(arg1, arg2).getMessage());
+        wrappedLogger.trace(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void trace(Marker arg0, String arg1, Throwable arg2) {
+        storeMessage(TRACE, MessageFormatter.format(arg1, arg2).getMessage());
+        wrappedLogger.trace(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void trace(Marker arg0, String arg1) {
+        storeMessage(TRACE, arg1);
+        wrappedLogger.trace(arg0, arg1);
+    }
+
+    @Override
+    public void trace(String arg0, Object arg1, Object arg2) {
+        storeMessage(TRACE, MessageFormatter.format(arg0, arg1, arg2).getMessage());
+        wrappedLogger.trace(arg0, arg1, arg2);
+    }
+
+    @Override
+    public void trace(String arg0, Object arg1) {
+        storeMessage(TRACE, MessageFormatter.format(arg0, arg1).getMessage());
+        wrappedLogger.trace(arg0, arg1);
+    }
+
+    @Override
+    public void trace(String arg0, Object[] arg1) {
+        storeMessage(TRACE, MessageFormatter.arrayFormat(arg0, arg1).getMessage());
+        wrappedLogger.trace(arg0, arg1);
+    }
+
+    @Override
+    public void trace(String arg0, Throwable arg1) {
+        storeMessage(TRACE, MessageFormatter.format(arg0, arg1).getMessage());
+        wrappedLogger.trace(arg0, arg1);
+    }
+
+    @Override
+    public void trace(String arg0) {
+        storeMessage(TRACE, arg0);
+        wrappedLogger.trace(arg0);
+    }
+
+    @Override
+    public boolean isTraceEnabled() {
+        return true;
+    }
+
+    @Override
+    public boolean isTraceEnabled(Marker arg0) {
+        return true;
+    }
+}

Modified: sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/impl/RulesEngineImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/impl/RulesEngineImpl.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/impl/RulesEngineImpl.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/impl/RulesEngineImpl.java Fri Apr 19 14:13:52 2013
@@ -20,8 +20,8 @@ package org.apache.sling.hc.impl;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.sling.hc.api.Rule;
 import org.apache.sling.hc.api.EvaluationResult;
+import org.apache.sling.hc.api.Rule;
 import org.apache.sling.hc.api.RulesEngine;
 
 public class RulesEngineImpl implements RulesEngine {
@@ -42,7 +42,7 @@ public class RulesEngineImpl implements 
     public List<EvaluationResult> evaluateRules() {
         final List<EvaluationResult> result = new ArrayList<EvaluationResult>();
         for(Rule r : rules) {
-            result.add(new EvaluationResult(r));
+            result.add(r.evaluate());
         }
         return result;
     }

Modified: sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/util/DefaultEvaluator.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/util/DefaultEvaluator.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/util/DefaultEvaluator.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-core/src/main/java/org/apache/sling/hc/util/DefaultEvaluator.java Fri Apr 19 14:13:52 2013
@@ -18,32 +18,48 @@
 package org.apache.sling.hc.util;
 
 import org.apache.sling.hc.api.Evaluator;
-import org.apache.sling.hc.api.EvaluationResult;
 import org.apache.sling.hc.api.SystemAttribute;
-import org.apache.sling.hc.api.EvaluationResult.Status;
+import org.slf4j.Logger;
 
 public class DefaultEvaluator implements Evaluator {
     @Override
-    public Status evaluate(SystemAttribute a, String expression) {
-        final String [] parts = expression.split(" ");
+    public void evaluate(SystemAttribute a, String expression, Logger logger) {
+        
         boolean matches = false;
+        final Object oValue = a.getValue(logger);
+        final String stringValue = oValue == null ? "" : oValue.toString();
         
-        if(expression.startsWith(">") && parts.length == 2) {
-            matches = Integer.valueOf(a.getValue().toString()).intValue() > Integer.valueOf(parts[1]);
-            
-        } else if(expression.startsWith("<") && parts.length == 2) {
-            matches = Integer.valueOf(a.getValue().toString()).intValue() < Integer.valueOf(parts[1]);
-            
-        } else if(parts.length == 4 && "between".equalsIgnoreCase(parts[0]) && "and".equalsIgnoreCase(parts[2]) ) {
-            final int aValue = Integer.valueOf(a.getValue().toString()).intValue();
-            final int lowerBound = Integer.valueOf(parts[1]);
-            final int upperBound = Integer.valueOf(parts[3]);
-            matches = aValue > lowerBound && aValue < upperBound;
-            
-        } else {
-            matches = expression.equals(a.getValue().toString()); 
+        if(expression == null || expression.trim().length() == 0) {
+            // No expression, result will be based on a.getValue() logging only
+            return;
         }
         
-        return matches ? EvaluationResult.Status.OK : EvaluationResult.Status.ERROR;
+        final String [] parts = expression.split(" ");
+        
+        try {
+            if(expression.startsWith(">") && parts.length == 2) {
+                final int value = Integer.valueOf(stringValue).intValue();
+                matches = value > Integer.valueOf(parts[1]);
+                
+            } else if(expression.startsWith("<") && parts.length == 2) {
+                final int value = Integer.valueOf(stringValue).intValue();
+                matches = value < Integer.valueOf(parts[1]);
+                
+            } else if(parts.length == 4 && "between".equalsIgnoreCase(parts[0]) && "and".equalsIgnoreCase(parts[2]) ) {
+                final int value = Integer.valueOf(stringValue).intValue();
+                final int lowerBound = Integer.valueOf(parts[1]);
+                final int upperBound = Integer.valueOf(parts[3]);
+                matches = value > lowerBound && value < upperBound;
+                
+            } else {
+                matches = expression.equals(stringValue); 
+            }
+        } catch(NumberFormatException nfe) {
+            logger.warn("Invalid numeric value [{}] while evaluating {}", oValue, expression);
+        }
+        
+        if(!matches) {
+            logger.warn("Value [{}] does not match expression [{}]", stringValue, expression);
+        }
     }
 }

Modified: sling/trunk/contrib/extensions/healthcheck/hc-core/src/test/java/org/apache/sling/hc/impl/DefaultEvaluatorTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-core/src/test/java/org/apache/sling/hc/impl/DefaultEvaluatorTest.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-core/src/test/java/org/apache/sling/hc/impl/DefaultEvaluatorTest.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-core/src/test/java/org/apache/sling/hc/impl/DefaultEvaluatorTest.java Fri Apr 19 14:13:52 2013
@@ -17,50 +17,168 @@
  */
 package org.apache.sling.hc.impl;
 
+import static org.junit.Assert.assertTrue;
+
+import org.apache.sling.hc.api.EvaluationResult;
 import org.apache.sling.hc.api.Evaluator;
 import org.apache.sling.hc.api.SystemAttribute;
 import org.apache.sling.hc.util.DefaultEvaluator;
+import org.junit.Before;
 import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.apache.sling.hc.api.EvaluationResult.Status.OK;
-import static org.apache.sling.hc.api.EvaluationResult.Status.ERROR;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DefaultEvaluatorTest {
+    private final Logger logger = LoggerFactory.getLogger(getClass());
+    private RuleLoggerImpl wrapper; 
+
     private final Evaluator evaluator = new DefaultEvaluator();
     
-    private final SystemAttribute five = new SystemAttribute() {
+    static class ConstantAttribute implements SystemAttribute {
+        
+        private final Object value;
+        
+        ConstantAttribute(Object value) {
+            this.value = value;
+        }
+        
         @Override
-        public Object getValue() {
-            return "5";
+        public Object getValue(Logger logger) {
+            return value;
         }
     };
     
+    private final SystemAttribute five = new ConstantAttribute("5");
+    private final SystemAttribute active = new ConstantAttribute("active");
+    private final SystemAttribute intTwelve = new ConstantAttribute(12);
+    private final SystemAttribute nullAttr = new ConstantAttribute(null);
+    
+    private void assertWrapperResult(RuleLoggerImpl wrapper, boolean expectOk) {
+        if(!expectOk) {
+            assertTrue("Expecting max log level >= INFO, got " + wrapper.getMaxLevel(), 
+                    wrapper.getMaxLevel().ordinal() >= EvaluationResult.LogLevel.INFO.ordinal());
+        } else {
+            assertTrue("Expecting max log level < INFO, got " + wrapper.getMaxLevel(), 
+                    wrapper.getMaxLevel().ordinal() < EvaluationResult.LogLevel.INFO.ordinal());
+        }
+    }
+    
+    @Before
+    public void setup() {
+        wrapper = new RuleLoggerImpl(logger);
+    }
+    
+    @Test
+    public void testActiveEquals() {
+        evaluator.evaluate(active, "active", wrapper);
+        assertWrapperResult(wrapper, true);
+    }
+    
+    @Test
+    public void testActiveNotEquals() {
+        evaluator.evaluate(active, "foo", wrapper);
+        assertWrapperResult(wrapper, false);
+    }
+    
+    @Test
+    public void testFiveEquals() {
+        evaluator.evaluate(five, "5", wrapper);
+        assertWrapperResult(wrapper, true);
+    }
+    
+    @Test
+    public void testIntTwelveEquals() {
+        evaluator.evaluate(intTwelve, "12", wrapper);
+        assertWrapperResult(wrapper, true);
+    }
+    
+    @Test
+    public void testIntTwelveGreaterThan() {
+        evaluator.evaluate(intTwelve, "> 11", wrapper);
+        assertWrapperResult(wrapper, true);
+    }
+    
+    @Test
+    public void testFiveNotEquals() {
+        evaluator.evaluate(five, "foo", wrapper);
+        assertWrapperResult(wrapper, false);
+    }
+    
+    @Test
+    public void testNullNotEquals() {
+        evaluator.evaluate(nullAttr, "foo", wrapper);
+        assertWrapperResult(wrapper, false);
+    }
+    
+    @Test
+    public void testNullNotGreater() {
+        evaluator.evaluate(nullAttr, "> 2", wrapper);
+        assertWrapperResult(wrapper, false);
+    }
+    
+    @Test
+    public void testGreaterThanTrue() {
+        evaluator.evaluate(five, "> 2", wrapper);
+        assertWrapperResult(wrapper, true);
+    }
+    
+    @Test
+    public void testGreaterThanFalse() {
+        evaluator.evaluate(five, "> 12", wrapper);
+        assertWrapperResult(wrapper, false);
+    }
+    
+    @Test
+    public void testLessThanTrue() {
+        evaluator.evaluate(five, "< 12", wrapper);
+        assertWrapperResult(wrapper, true);
+    }
+    
+    @Test
+    public void testLessThanFalse() {
+        evaluator.evaluate(five, "< 2", wrapper);
+        assertWrapperResult(wrapper, false);
+    }
+    
+    @Test
+    public void testBetweenA() {
+        evaluator.evaluate(five, "between 2 and 6", wrapper);
+        assertWrapperResult(wrapper, true);
+    }
+    
+    @Test
+    public void testBetweenB() {
+        evaluator.evaluate(five, "between 2 and 5", wrapper);
+        assertWrapperResult(wrapper, false);
+    }
+    
+    @Test
+    public void testBetweenC() {
+        evaluator.evaluate(five, "between 5 and 7", wrapper);
+        assertWrapperResult(wrapper, false);
+    }
+    
     @Test
-    public void testEquals() {
-        assertEquals(OK, evaluator.evaluate(five, "5"));
-        assertEquals(ERROR, evaluator.evaluate(five, "foo"));
+    public void testBetweenD() {
+        evaluator.evaluate(five, "between 4 and 7", wrapper);
+        assertWrapperResult(wrapper, true);
     }
     
     @Test
-    public void testGreaterThan() {
-        assertEquals(OK, evaluator.evaluate(five, "> 2"));
-        assertEquals(ERROR, evaluator.evaluate(five, "> 12"));
+    public void testBetweenE() {
+        evaluator.evaluate(five, "BETWEEN 2 AND 6", wrapper);
+        assertWrapperResult(wrapper, true);
     }
     
     @Test
-    public void testLessThan() {
-        assertEquals(OK, evaluator.evaluate(five, "< 12"));
-        assertEquals(ERROR, evaluator.evaluate(five, "< 2"));
+    public void testBetweenF() {
+        evaluator.evaluate(five, "between 12 and 61", wrapper);
+        assertWrapperResult(wrapper, false);
     }
     
     @Test
-    public void testBetween() {
-        assertEquals(OK, evaluator.evaluate(five, "between 2 and 6"));
-        assertEquals(ERROR, evaluator.evaluate(five, "between 2 and 5"));
-        assertEquals(ERROR, evaluator.evaluate(five, "between 5 and 7"));
-        assertEquals(OK, evaluator.evaluate(five, "between 4 and 7"));
-        assertEquals(OK, evaluator.evaluate(five, "BETWEEN 2 AND 6"));
-        assertEquals(ERROR, evaluator.evaluate(five, "between 12 and 61"));
-        assertEquals(ERROR, evaluator.evaluate(five, "BETWEEN 12 AND 61"));
+    public void testBetweenG() {
+        evaluator.evaluate(five, "BETWEEN 12 AND 61", wrapper);
+        assertWrapperResult(wrapper, false);
     }
 }

Modified: sling/trunk/contrib/extensions/healthcheck/hc-core/src/test/java/org/apache/sling/hc/impl/RuleTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-core/src/test/java/org/apache/sling/hc/impl/RuleTest.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-core/src/test/java/org/apache/sling/hc/impl/RuleTest.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-core/src/test/java/org/apache/sling/hc/impl/RuleTest.java Fri Apr 19 14:13:52 2013
@@ -17,26 +17,86 @@
  */
 package org.apache.sling.hc.impl;
 
-import static org.apache.sling.hc.api.EvaluationResult.Status.ERROR;
-import static org.apache.sling.hc.api.EvaluationResult.Status.OK;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.sling.hc.api.Rule;
 import org.apache.sling.hc.api.SystemAttribute;
 import org.junit.Test;
+import org.slf4j.Logger;
 
 public class RuleTest {
+    
     final SystemAttribute five = new SystemAttribute() {
         @Override
-        public Object getValue() {
+        public String toString() {
+            return "5";
+        }
+        
+        @Override
+        public Object getValue(Logger logger) {
             return 5;
         }
     };
     
+    final SystemAttribute logErrorAndNull = new SystemAttribute() {
+        @Override
+        public Object getValue(Logger logger) {
+            logger.warn("Something went wrong");
+            return null;
+        }
+    };
+    
+    final SystemAttribute nullAttr = new SystemAttribute() {
+        @Override
+        public Object getValue(Logger logger) {
+            return null;
+        }
+    };
+    
+    @Test
+    public void testToStringWithExpr() {
+        assertEquals("Rule: 5 hello", new Rule(five, "hello").toString());
+    }
+    
+    @Test
+    public void testToStringNoExpr() {
+        assertEquals("Rule: 5", new Rule(five, null).toString());
+    }
+    
+    @Test
+    public void testEqualsFive() {
+        assertFalse(new Rule(five,"5").evaluate().anythingToReport());
+    }
+    
+    @Test
+    public void testGreaterThanTwo() {
+        assertFalse(new Rule(five,"> 2").evaluate().anythingToReport());
+    }
+    
+    @Test
+    public void testGreaterThanTwelve() {
+        assertTrue(new Rule(five,"> 12").evaluate().anythingToReport());
+    }
+    
+    @Test
+    public void testLogAndNullNoExpr() {
+        assertTrue(new Rule(logErrorAndNull,null).evaluate().anythingToReport());
+    }
+    
+    @Test
+    public void testLogAndNullEmptyExpr() {
+        assertTrue(new Rule(logErrorAndNull,"\t\n").evaluate().anythingToReport());
+    }
+    
+    @Test
+    public void testNullNoLog() {
+        assertFalse(new Rule(nullAttr,null).evaluate().anythingToReport());
+    }
+    
     @Test
-    public void testWithDefaultEvaluator() {
-        assertEquals("== 5", OK, new Rule(five,"5").evaluate());
-        assertEquals("> 2", OK, new Rule(five,"> 2").evaluate());
-        assertEquals("> 12 is false", ERROR, new Rule(five,"> 12").evaluate());
+    public void testNullEmptyExpr() {
+        assertFalse(new Rule(nullAttr,"").evaluate().anythingToReport());
     }
 }

Modified: sling/trunk/contrib/extensions/healthcheck/hc-core/src/test/java/org/apache/sling/hc/impl/RulesEngineTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-core/src/test/java/org/apache/sling/hc/impl/RulesEngineTest.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-core/src/test/java/org/apache/sling/hc/impl/RulesEngineTest.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-core/src/test/java/org/apache/sling/hc/impl/RulesEngineTest.java Fri Apr 19 14:13:52 2013
@@ -23,12 +23,13 @@ import java.io.IOException;
 import java.io.StringReader;
 import java.util.List;
 
+import org.apache.sling.hc.api.EvaluationResult;
 import org.apache.sling.hc.api.Rule;
 import org.apache.sling.hc.api.RuleBuilder;
-import org.apache.sling.hc.api.EvaluationResult;
 import org.apache.sling.hc.api.SystemAttribute;
 import org.apache.sling.hc.util.DefaultEvaluator;
 import org.junit.Test;
+import org.slf4j.Logger;
 
 public class RulesEngineTest {
     
@@ -41,7 +42,7 @@ public class RulesEngineTest {
             
             SystemAttribute attr = new SystemAttribute() {
                 @Override
-                public Object getValue() {
+                public Object getValue(Logger logger) {
                     if("constant".equals(ruleName)) {
                         return Integer.valueOf(qualifier);
                     } else if("invert".equals(ruleName)) {
@@ -62,8 +63,8 @@ public class RulesEngineTest {
         }
     }
     
-    private void assertResult(EvaluationResult rr, EvaluationResult.Status status, String ruleString) {
-        assertEquals("Rule " + rr.getRule() + " result matches", rr.getStatus(), status);
+    private void assertResult(EvaluationResult rr, boolean expectOk, String ruleString) {
+        assertEquals("Rule " + rr.getRule() + " result matches", expectOk, !rr.anythingToReport());
         assertEquals("Rule " + rr.getRule() + " string matches", rr.getRule().toString(), ruleString);
     }
     
@@ -90,13 +91,13 @@ public class RulesEngineTest {
         assertEquals(8, result.size());
         
         int i=0;
-        assertResult(result.get(i++), EvaluationResult.Status.OK, "test_constant_5_5");
-        assertResult(result.get(i++), EvaluationResult.Status.OK, "test_constant_5_> 2");
-        assertResult(result.get(i++), EvaluationResult.Status.OK, "test_constant_5_< 12");
-        assertResult(result.get(i++), EvaluationResult.Status.OK, "test_constant_5_between 4 and 6");
-        assertResult(result.get(i++), EvaluationResult.Status.ERROR, "test_constant_5_between 12 and 21");
-        assertResult(result.get(i++), EvaluationResult.Status.ERROR, "test_constant_5_42");
-        assertResult(result.get(i++), EvaluationResult.Status.ERROR, "test_invert_12_-1");
-        assertResult(result.get(i++), EvaluationResult.Status.OK, "test_invert_12_-12");
+        assertResult(result.get(i++), true, "test_constant_5_5");
+        assertResult(result.get(i++), true, "test_constant_5_> 2");
+        assertResult(result.get(i++), true, "test_constant_5_< 12");
+        assertResult(result.get(i++), true, "test_constant_5_between 4 and 6");
+        assertResult(result.get(i++), false, "test_constant_5_between 12 and 21");
+        assertResult(result.get(i++), false, "test_constant_5_42");
+        assertResult(result.get(i++), false, "test_invert_12_-1");
+        assertResult(result.get(i++), true, "test_invert_12_-12");
     }
 }

Modified: sling/trunk/contrib/extensions/healthcheck/hc-rules/src/main/java/org/apache/sling/hc/rules/jmx/JmxBeansRuleBuilder.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-rules/src/main/java/org/apache/sling/hc/rules/jmx/JmxBeansRuleBuilder.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-rules/src/main/java/org/apache/sling/hc/rules/jmx/JmxBeansRuleBuilder.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-rules/src/main/java/org/apache/sling/hc/rules/jmx/JmxBeansRuleBuilder.java Fri Apr 19 14:13:52 2013
@@ -25,6 +25,7 @@ import javax.management.ObjectName;
 import org.apache.sling.hc.api.Rule;
 import org.apache.sling.hc.api.RuleBuilder;
 import org.apache.sling.hc.api.SystemAttribute;
+import org.slf4j.Logger;
 
 /** Rules that give access to JMX beans */
 public class JmxBeansRuleBuilder implements RuleBuilder {
@@ -51,16 +52,17 @@ public class JmxBeansRuleBuilder impleme
         }
         
         @Override
-        public Object getValue() {
+        public Object getValue(Logger logger) {
             try {
                 final ObjectName objectName = new ObjectName(beanName);
                 if(jmxServer.queryNames(objectName, null).size() == 0) {
-                    return "MBean not found: " + objectName;
+                    logger.error("MBean not found: {}", objectName);
                 }
                 return jmxServer.getAttribute(objectName, attributeName);
             } catch(Exception e) {
-                return "MBean exception: " + e.toString();
+                logger.error("MBean exception", e);
             }
+            return null;
         }
     }
     

Modified: sling/trunk/contrib/extensions/healthcheck/hc-rules/src/main/java/org/apache/sling/hc/rules/osgi/BundlesRuleBuilder.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-rules/src/main/java/org/apache/sling/hc/rules/osgi/BundlesRuleBuilder.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-rules/src/main/java/org/apache/sling/hc/rules/osgi/BundlesRuleBuilder.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-rules/src/main/java/org/apache/sling/hc/rules/osgi/BundlesRuleBuilder.java Fri Apr 19 14:13:52 2013
@@ -22,13 +22,13 @@ import org.apache.sling.hc.api.RuleBuild
 import org.apache.sling.hc.api.SystemAttribute;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
 
 /** RuleBuilder about OSGi bundles */
 public class BundlesRuleBuilder implements RuleBuilder {
 
     public static final String NAMESPACE = "osgi";
     public static final String BUNDLE_STATE_RULE = "bundle.state";
-    public static final String BUNDLE_NOT_FOUND = "BUNDLE_NOT_FOUND";
     private final BundleContext bundleContext;
     
     static class BundleAttribute implements SystemAttribute {
@@ -46,8 +46,8 @@ public class BundlesRuleBuilder implemen
         }
         
         @Override
-        public Object getValue() {
-            return attr.getValue();
+        public Object getValue(Logger logger) {
+            return attr.getValue(logger);
         }
     }
     
@@ -93,13 +93,17 @@ public class BundlesRuleBuilder implemen
             // Get the state of a bundle
             attr = new BundleAttribute(ruleName + ":" + qualifier, new SystemAttribute() {
                 @Override
-                public Object getValue() {
+                public Object getValue(Logger logger) {
+                    String result = null;
                     Bundle b = findBundle(qualifier);
                     if(b == null) {
-                        return BUNDLE_NOT_FOUND;
+                        logger.error("Bundle not found: {}", qualifier);
                     } else {
-                        return bundleStateToString(b.getState());
+                        result = bundleStateToString(b.getState());
+                        logger.debug("Bundle {} found, state={} ({})", 
+                                new Object[] { b.getSymbolicName(), result, b.getState()});
                     }
+                    return result;
                 }
             });
         }
@@ -110,4 +114,4 @@ public class BundlesRuleBuilder implemen
         
         return null;
     }
-}
+}
\ No newline at end of file

Modified: sling/trunk/contrib/extensions/healthcheck/hc-rules/src/test/java/org/apache/sling/hc/rules/impl/JmxBeansRuleBuilderTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-rules/src/test/java/org/apache/sling/hc/rules/impl/JmxBeansRuleBuilderTest.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-rules/src/test/java/org/apache/sling/hc/rules/impl/JmxBeansRuleBuilderTest.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-rules/src/test/java/org/apache/sling/hc/rules/impl/JmxBeansRuleBuilderTest.java Fri Apr 19 14:13:52 2013
@@ -17,13 +17,14 @@
  */
 package org.apache.sling.hc.rules.impl;
 
-import org.apache.sling.hc.api.EvaluationResult;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
 import org.apache.sling.hc.api.Rule;
 import org.apache.sling.hc.api.RuleBuilder;
 import org.apache.sling.hc.rules.jmx.JmxBeansRuleBuilder;
 import org.junit.Test;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
 
 public class JmxBeansRuleBuilderTest {
     private final RuleBuilder jmxRuleBuilder = new JmxBeansRuleBuilder();
@@ -33,20 +34,20 @@ public class JmxBeansRuleBuilderTest {
         // Assuming this attribute is present in all JVMs that we use to run tests...
         final Rule r = jmxRuleBuilder.buildRule("jmxbeans", "java.lang:type=ClassLoading", "LoadedClassCount", "> 100");
         assertNotNull("Expecting to get a jmxbean Rule", r);
-        assertEquals(EvaluationResult.Status.OK, r.evaluate());
+        assertFalse(r.evaluate().anythingToReport());
     }
     
     @Test
     public void testHashSeparatorInBeanName() {
         final Rule r = jmxRuleBuilder.buildRule("jmxbeans", "java.lang#type=ClassLoading", "LoadedClassCount", "> 100");
         assertNotNull("Expecting to get a jmxbean Rule", r);
-        assertEquals(EvaluationResult.Status.OK, r.evaluate());
+        assertFalse(r.evaluate().anythingToReport());
     }
     
     @Test
     public void testNonExistentBean() {
         final Rule r = jmxRuleBuilder.buildRule("jmxbeans", "java.lang:type=DoesNotExist", "LoadedClassCount", "5");
         assertNotNull("Expecting to get a jmxbean Rule", r);
-        assertEquals(EvaluationResult.Status.ERROR, r.evaluate());
+        assertTrue(r.evaluate().anythingToReport());
     }
 }

Modified: sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/JsonResultRendererImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/JsonResultRendererImpl.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/JsonResultRendererImpl.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/JsonResultRendererImpl.java Fri Apr 19 14:13:52 2013
@@ -36,12 +36,25 @@ public class JsonResultRendererImpl impl
     @Override
     public void render(List<EvaluationResult> results, Writer output) throws IOException {
         // TODO: trouble with animalsniffer and JSON dependency
-        output.write("TODO: this should be JSON - not implemented yet\n");
+        output.write("TODO: this should be JSON - not implemented yet\n\n");
         for(EvaluationResult r : results) {
-            output.write(r.getStatus().toString());
-            output.write(" ");
             output.write(r.getRule().toString());
             output.write("\n");
+            
+            if(!r.anythingToReport()) {
+                output.write("Rule execution successful, nothing to report\n");
+            } else {
+                output.write("*** WARNING *** Rule has info, warnings or errors, see log for report\n");
+            }
+            
+            for(EvaluationResult.LogMessage msg : r.getLogMessages()) {
+                output.write("\t");
+                output.write(msg.getLevel().toString());
+                output.write("\t");
+                output.write(msg.getMessage());
+                output.write("\n");
+            }
+            output.write("\n");
         }
         /*
         final JSONWriter w = new JSONWriter(output);

Modified: sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/ScriptSystemAttribute.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/ScriptSystemAttribute.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/ScriptSystemAttribute.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/ScriptSystemAttribute.java Fri Apr 19 14:13:52 2013
@@ -27,6 +27,7 @@ import org.apache.sling.api.scripting.Sl
 import org.apache.sling.engine.SlingRequestProcessor;
 import org.apache.sling.hc.api.Rule;
 import org.apache.sling.hc.api.SystemAttribute;
+import org.slf4j.Logger;
 
 /** Creates {@link Rule} that executes a Sling script and
  *  returns its output, filtered to omit comments and blank lines 
@@ -53,20 +54,33 @@ class ScriptSystemAttribute implements S
     }
     
     @Override
-    public Object getValue() {
+    public Object getValue(Logger logger) {
         try {
             final HttpRequest req = new HttpRequest(script.getScriptResource().getPath());
             final HttpResponse resp = new HttpResponse();
             requestProcessor.processRequest(req, resp, script.getScriptResource().getResourceResolver());
             if(resp.getStatus() != HttpServletResponse.SC_OK) {
-                return "Unexpected requests status: " + resp.getStatus();
+                final String msg = "Unexpected request status: " + resp.getStatus();
+                logger.error(msg);
+                return msg;
             }
-            return filterContent(resp.getContent());
+            final String result = filterContent(resp.getContent());
+            logger.debug("Script {} outputs [{}]", script.getScriptResource().getPath(), shorten(result));
+            return result;
         } catch(Exception e) {
+            logger.error("Exception during script execution", e);
             return e.toString();
         }
     }
     
+    static String shorten(String str) {
+        final int limit = 120;
+        if(str.length() > limit) {
+            return str.substring(limit) + "...";
+        }
+        return str;
+    }
+    
     static String filterContent(String content) throws IOException {
         final BufferedReader br = new BufferedReader(new StringReader(content));
         String line = null;

Modified: sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/rules/JUnitTestRuleBuilder.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/rules/JUnitTestRuleBuilder.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/rules/JUnitTestRuleBuilder.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/rules/JUnitTestRuleBuilder.java Fri Apr 19 14:13:52 2013
@@ -28,15 +28,16 @@ import javax.servlet.http.HttpServletRes
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.Service;
-import org.apache.sling.junit.Renderer;
-import org.apache.sling.junit.TestSelector;
-import org.apache.sling.junit.TestsManager;
 import org.apache.sling.hc.api.Rule;
 import org.apache.sling.hc.api.RuleBuilder;
 import org.apache.sling.hc.api.SystemAttribute;
+import org.apache.sling.junit.Renderer;
+import org.apache.sling.junit.TestSelector;
+import org.apache.sling.junit.TestsManager;
 import org.junit.runner.Description;
 import org.junit.runner.notification.Failure;
 import org.junit.runner.notification.RunListener;
+import org.slf4j.Logger;
 
 /** Creates {@link Rule} to execute JUnit tests using the 
  *  org.apache.sling.junit.core services. 
@@ -56,7 +57,12 @@ public class JUnitTestRuleBuilder implem
     private static class CustomRunListener extends RunListener {
         
         final List<Failure> failures = new ArrayList<Failure>();
-        int nTests; 
+        int nTests;
+        private final Logger logger;
+        
+        CustomRunListener(Logger logger) {
+            this.logger = logger;
+        }
         
         @Override
         public void testFailure(Failure failure) throws Exception {
@@ -67,6 +73,7 @@ public class JUnitTestRuleBuilder implem
         @Override
         public void testFinished(Description description) throws Exception {
             super.testFinished(description);
+            logger.debug("Test executed: {}", description.getDisplayName());
             nTests++;
         }
     }
@@ -139,28 +146,28 @@ public class JUnitTestRuleBuilder implem
         }
         
         @Override
-        public Object getValue() {
-            String errorMsg = null;
-            final CustomRunListener listener = new CustomRunListener();
+        public Object getValue(Logger logger) {
+            final CustomRunListener listener = new CustomRunListener(logger);
             final Renderer r = new CustomRenderer(listener, extension);
             final Collection<String> testNames = testsManager.getTestNames(selector);
             if(testNames.isEmpty()) {
-                errorMsg = "No tests found for selector " + selector;
+                logger.error("No tests found for selector {}", selector);
             } else {
                 try {
                     testsManager.executeTests(testNames, r, selector);
                     if(!listener.failures.isEmpty()) {
-                        // TODO need better formatting of this;
-                        errorMsg = "Some tests failed: " + listener.failures;
+                        for(Failure f : listener.failures) {
+                            logger.warn("Test failed: {}, {}", f.getTestHeader(), f);
+                        }
                     } else if(listener.nTests == 0) {
-                        errorMsg = "No tests executed with selector " + selector;
+                        logger.warn("No tests executed with selector {}", selector);
                     }
                 } catch(Exception e) {
-                    errorMsg = "Exception while executing tests: " + e.toString();
+                    logger.error("Exception while executing tests: {}", e.toString());
                 }
             }
             
-            return errorMsg != null ? errorMsg : ALL_PASSED;
+            return null;
         }
     }
     

Modified: sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/rules/LoginRuleBuilder.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/rules/LoginRuleBuilder.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/rules/LoginRuleBuilder.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-sling/src/main/java/org/apache/sling/hc/sling/impl/rules/LoginRuleBuilder.java Fri Apr 19 14:13:52 2013
@@ -25,24 +25,25 @@ import javax.jcr.SimpleCredentials;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.Service;
-import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.hc.api.Rule;
 import org.apache.sling.hc.api.RuleBuilder;
 import org.apache.sling.hc.api.SystemAttribute;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.slf4j.Logger;
 
-/** Creates {@link Rule} to check if specific credentials allow for
+/** Creates {@link Rule} to check that specific credentials do not allow for
  *  logging in to a {@link SlingRepository}. Can be used to verify 
  *  that default passwords have been disabled on production systems.
- *  Checking for failed logins is the only realistic use case, as
- *  by the credentials will be exposed in plain text in the repository,
- *  which is only ok for default demo passwords of course.   
+ *  Do NOT use any secret credentials when configuring this rule, it is
+ *  only meant to check that well-known demo credentials are disabled on
+ *  production systems.   
  */
 @Component
 @Service(value=RuleBuilder.class)
 public class LoginRuleBuilder implements RuleBuilder {
 
     public static final String NAMESPACE = "sling";
-    public static final String RULE_NAME = "login";
+    public static final String RULE_NAME = "loginfails";
     
     @Reference
     private SlingRepository repository;
@@ -58,26 +59,25 @@ public class LoginRuleBuilder implements
         }
         
         @Override
-        public Object getValue() {
-            String result = "???";
+        public Object getValue(Logger logger) {
             final Credentials creds = new SimpleCredentials(username, password.toCharArray());
             Session s = null;
             try {
                 s = repository.login(creds);
-                result = "LOGIN_OK";
+                logger.warn("Login as user [{}] successful, should have failed", username);
             } catch(RepositoryException rex) {
-                result = "LOGIN_FAILED";
+                logger.debug("Login as user [{}] failed as expected", username);
             } finally {
                 if(s != null) {
                     s.logout();
                 }
             }
-            return result;
+            return null;
         }
         
         @Override
         public String toString() {
-            return "Attempt to login as user " + username;
+            return "Expect login as user [" + username + "] to fail";
         }
     }
     

Modified: sling/trunk/contrib/extensions/healthcheck/hc-sling/src/test/java/org/apache/sling/hc/sling/LoginRuleBuilderTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-sling/src/test/java/org/apache/sling/hc/sling/LoginRuleBuilderTest.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-sling/src/test/java/org/apache/sling/hc/sling/LoginRuleBuilderTest.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-sling/src/test/java/org/apache/sling/hc/sling/LoginRuleBuilderTest.java Fri Apr 19 14:13:52 2013
@@ -17,15 +17,14 @@
  */
 package org.apache.sling.hc.sling;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.lang.reflect.Field;
 
 import org.apache.sling.commons.testing.jcr.RepositoryProvider;
-import org.apache.sling.jcr.api.SlingRepository;
-import org.apache.sling.hc.api.EvaluationResult;
 import org.apache.sling.hc.api.Rule;
 import org.apache.sling.hc.sling.impl.rules.LoginRuleBuilder;
+import org.apache.sling.jcr.api.SlingRepository;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -43,19 +42,19 @@ public class LoginRuleBuilderTest {
 
     @Test
     public void testAdminLoginSucceeds() {
-        final Rule r = builder.buildRule("sling", "login", "admin#admin", "LOGIN_OK");
-        assertEquals("Expecting admin login to succeed", EvaluationResult.Status.OK, r.evaluate());
+        final Rule r = builder.buildRule("sling", "loginfails", "admin#admin", "LOGIN_OK");
+        assertTrue("Expecting loginfails rule to fail for admin:admin login", r.evaluate().anythingToReport());
     }
     
     @Test
     public void testAdminBadPasswordFails() {
-        final Rule r = builder.buildRule("sling", "login", "admin#bad", "OK");
-        assertEquals("Expecting admin login to succeed", EvaluationResult.Status.ERROR, r.evaluate());
+        final Rule r = builder.buildRule("sling", "loginfails", "admin#bad", "OK");
+        assertTrue("Expecting admin/bad login to fail", r.evaluate().anythingToReport());
     }
     
     @Test
     public void testFooLoginFails() {
-        final Rule r = builder.buildRule("sling", "login", "foo#bar", "OK");
-        assertEquals("Expecting admin login to succeed", EvaluationResult.Status.ERROR, r.evaluate());
+        final Rule r = builder.buildRule("sling", "loginfails", "foo#bar", "OK");
+        assertTrue("Expecting foo/bar login to fail", r.evaluate().anythingToReport());
     }
 }

Modified: sling/trunk/contrib/extensions/healthcheck/hc-sling/src/test/java/org/apache/sling/hc/sling/RulesResourceParserTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-sling/src/test/java/org/apache/sling/hc/sling/RulesResourceParserTest.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-sling/src/test/java/org/apache/sling/hc/sling/RulesResourceParserTest.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-sling/src/test/java/org/apache/sling/hc/sling/RulesResourceParserTest.java Fri Apr 19 14:13:52 2013
@@ -35,6 +35,7 @@ import org.apache.sling.hc.api.SystemAtt
 import org.apache.sling.hc.sling.impl.RulesResourceParserImpl;
 import org.junit.Before;
 import org.junit.Test;
+import org.slf4j.Logger;
 
 public class RulesResourceParserTest {
     private final RulesResourceParserImpl parser = new RulesResourceParserImpl();
@@ -61,7 +62,7 @@ public class RulesResourceParserTest {
                             return namespace + ":" + ruleName + ":" + qualifier;
                         }
                         @Override
-                        public Object getValue() {
+                        public Object getValue(Logger logger) {
                             return toString();
                         }
                     };

Modified: sling/trunk/contrib/extensions/healthcheck/hc-sling/src/test/java/org/apache/sling/hc/sling/impl/ScriptSystemAttributeTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/hc-sling/src/test/java/org/apache/sling/hc/sling/impl/ScriptSystemAttributeTest.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/hc-sling/src/test/java/org/apache/sling/hc/sling/impl/ScriptSystemAttributeTest.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/hc-sling/src/test/java/org/apache/sling/hc/sling/impl/ScriptSystemAttributeTest.java Fri Apr 19 14:13:52 2013
@@ -17,8 +17,6 @@
  */
 package org.apache.sling.hc.sling.impl;
 
-import static org.apache.sling.hc.api.EvaluationResult.Status.ERROR;
-import static org.apache.sling.hc.api.EvaluationResult.Status.OK;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
@@ -44,7 +42,7 @@ public class ScriptSystemAttributeTest {
         MockitoAnnotations.initMocks(this);
     }
     
-    private void assertResult(String info, final String scriptOutput, EvaluationResult.Status status) {
+    private void assertResult(String info, final String scriptOutput, boolean expectOk) {
         final Answer<?> answer = new Answer<Object>() {
             @Override
             public Object answer(InvocationOnMock invocation) throws Throwable {
@@ -72,27 +70,28 @@ public class ScriptSystemAttributeTest {
         final ScriptSystemAttribute a = new ScriptSystemAttribute(processor, script);
 
         final Rule r = new Rule(a, ScriptSystemAttribute.SUCCESS_STRING);
-        assertEquals("Expecting " + status + " for " + info, status,r.evaluate());
+        final EvaluationResult result = r.evaluate();
+        assertEquals("Expecting anythingToReport=" + !expectOk + " for " + info, !expectOk, result.anythingToReport());
     }
     
     @Test
     public void testEmptyScripts() {
-        assertResult("Empty script -> error", "", ERROR);
+        assertResult("Empty script -> error", "", false);
     }
     
     @Test
     public void testOkScript() {
-        assertResult("TEST_PASSED script -> ok", "TEST_PASSED", OK);
+        assertResult("TEST_PASSED script -> ok", "TEST_PASSED", true);
     }
     
     @Test
     public void testComments() {
-        assertResult("TEST_PASSED script and blank line -> ok", "\n\nTEST_PASSED\n\n", OK);
-        assertResult("TEST_PASSED script and comments -> ok", "\n\n#comment\n\t  # comment 2\nTEST_PASSED\n\n", OK);
+        assertResult("TEST_PASSED script and blank line -> ok", "\n\nTEST_PASSED\n\n", true);
+        assertResult("TEST_PASSED script and comments -> ok", "\n\n#comment\n\t  # comment 2\nTEST_PASSED\n\n", true);
     }
     
     @Test
     public void testDoublePassed() {
-        assertResult("Double TEST_PASSED script -> error", "TEST_PASSED\nTEST_PASSED", ERROR);
+        assertResult("Double TEST_PASSED script -> error", "TEST_PASSED\nTEST_PASSED", false);
     }
 }

Modified: sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/AllRulesTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/AllRulesTest.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/AllRulesTest.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/AllRulesTest.java Fri Apr 19 14:13:52 2013
@@ -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");
     }
 }

Modified: sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/OsgiHealthCheckFacadeTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/OsgiHealthCheckFacadeTest.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/OsgiHealthCheckFacadeTest.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/OsgiHealthCheckFacadeTest.java Fri Apr 19 14:13:52 2013
@@ -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();
         }

Modified: sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/OsgiRulesTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/OsgiRulesTest.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/OsgiRulesTest.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/OsgiRulesTest.java Fri Apr 19 14:13:52 2013
@@ -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");
     }
 }

Modified: sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/U.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/U.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/U.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/U.java Fri Apr 19 14:13:52 2013
@@ -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());
     }
 }

Modified: sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/java/org/apache/sling/hc/demo/tests/ResourcesExistTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/java/org/apache/sling/hc/demo/tests/ResourcesExistTest.java?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/java/org/apache/sling/hc/demo/tests/ResourcesExistTest.java (original)
+++ sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/java/org/apache/sling/hc/demo/tests/ResourcesExistTest.java Fri Apr 19 14:13:52 2013
@@ -58,4 +58,9 @@ public class ResourcesExistTest {
     public void checkNonExistentPath() throws Exception {
         assertResource("/NON_EXISTENT/" + System.currentTimeMillis());
     }
+    
+    @Test
+    public void checkAnotherNonExistentPath() throws Exception {
+        assertResource("/ALSO_NON_EXISTENT/" + System.currentTimeMillis());
+    }
 }

Modified: sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/RepositoryPresentTest.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/RepositoryPresentTest.json?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/RepositoryPresentTest.json (original)
+++ sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/RepositoryPresentTest.json Fri Apr 19 14:13:52 2013
@@ -1,6 +1,5 @@
 {
   "sling:resourceType" : "sling/healthcheck/rules",
-  "expression": "ALL_TESTS_PASSED",
   "ruleName": "junit",
   "namespace": "sling",
   "jcr:primaryType": "nt:unstructured",

Modified: sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/ResourcesExistTest-checkAppsExist.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/ResourcesExistTest-checkAppsExist.json?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/ResourcesExistTest-checkAppsExist.json (original)
+++ sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/ResourcesExistTest-checkAppsExist.json Fri Apr 19 14:13:52 2013
@@ -1,6 +1,5 @@
 {
   "sling:resourceType" : "sling/healthcheck/rules",
-  "expression": "ALL_TESTS_PASSED",
   "ruleName": "junit",
   "namespace": "sling",
   "jcr:primaryType": "nt:unstructured",

Modified: sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/ResourcesExistTest.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/ResourcesExistTest.json?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/ResourcesExistTest.json (original)
+++ sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/ResourcesExistTest.json Fri Apr 19 14:13:52 2013
@@ -1,6 +1,5 @@
 {
   "sling:resourceType" : "sling/healthcheck/rules",
-  "expression": "ALL_TESTS_PASSED",
   "ruleName": "junit",
   "namespace": "sling",
   "jcr:primaryType": "nt:unstructured",

Modified: sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/admin-foo.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/admin-foo.json?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/admin-foo.json (original)
+++ sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/admin-foo.json Fri Apr 19 14:13:52 2013
@@ -1,7 +1,6 @@
 {
   "sling:resourceType" : "sling/healthcheck/rules",
-  "expression": "LOGIN_FAILED",
-  "ruleName": "login",
+  "ruleName": "loginfails",
   "namespace": "sling",
   "jcr:primaryType": "nt:unstructured",
   "qualifier": "admin#foo"

Modified: sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/admin-login.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/admin-login.json?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/admin-login.json (original)
+++ sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/admin-login.json Fri Apr 19 14:13:52 2013
@@ -1,7 +1,6 @@
 {
   "sling:resourceType" : "sling/healthcheck/rules",
-  "expression": "LOGIN_OK",
-  "ruleName": "login",
+  "ruleName": "loginfails",
   "namespace": "sling",
   "jcr:primaryType": "nt:unstructured",
   "qualifier": "admin#admin"

Modified: sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/junit-sling-all.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/junit-sling-all.json?rev=1469841&r1=1469840&r2=1469841&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/junit-sling-all.json (original)
+++ sling/trunk/contrib/extensions/healthcheck/sling-demo/src/main/resources/SLING-CONTENT/apps/hc/demo/junit-sling-all.json Fri Apr 19 14:13:52 2013
@@ -1,6 +1,5 @@
 {
   "sling:resourceType" : "sling/healthcheck/rules",
-  "expression": "ALL_TESTS_PASSED",
   "ruleName": "junit",
   "namespace": "sling",
   "jcr:primaryType": "nt:unstructured",



Mime
View raw message