Author: bdelacretaz
Date: Wed Jul 30 20:40:33 2014
New Revision: 1614760

URL: http://svn.apache.org/r1614760
Log:
SLING-3624 - test the annotated health check sample

Added:
    
sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/SampleHealthChecksTest.java
Modified:
    sling/trunk/bundles/extensions/healthcheck/it/pom.xml
    
sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/U.java

Modified: sling/trunk/bundles/extensions/healthcheck/it/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/it/pom.xml?rev=1614760&r1=1614759&r2=1614760&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/healthcheck/it/pom.xml (original)
+++ sling/trunk/bundles/extensions/healthcheck/it/pom.xml Wed Jul 30 20:40:33 
2014
@@ -24,6 +24,8 @@
         
<org.ops4j.pax.logging.DefaultServiceLog.level>INFO</org.ops4j.pax.logging.DefaultServiceLog.level>
         <felix.shell>false</felix.shell>
         <sling.java.version>6</sling.java.version>
+        <sling.hc.samples.version>1.0.5-SNAPSHOT</sling.hc.samples.version>
+        <sling.hc.core.version>${project.version}</sling.hc.core.version>
     </properties>
 
     <scm>
@@ -40,7 +42,8 @@
                 <configuration>
                     <systemProperties>
                         
<org.ops4j.pax.logging.DefaultServiceLog.level>${org.ops4j.pax.logging.DefaultServiceLog.level}</org.ops4j.pax.logging.DefaultServiceLog.level>
-                        
<sling.hc.core.version>${project.version}</sling.hc.core.version>
+                        
<sling.hc.core.version>${sling.hc.core.version}</sling.hc.core.version>
+                        
<sling.hc.samples.version>${sling.hc.samples.version}</sling.hc.samples.version>
                         <felix.shell>${felix.shell}</felix.shell>
                     </systemProperties>
                 </configuration>

Added: 
sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/SampleHealthChecksTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/SampleHealthChecksTest.java?rev=1614760&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/SampleHealthChecksTest.java
 (added)
+++ 
sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/SampleHealthChecksTest.java
 Wed Jul 30 20:40:33 2014
@@ -0,0 +1,59 @@
+/*
+ * 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.it.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.sling.hc.api.execution.HealthCheckExecutionResult;
+import org.apache.sling.hc.api.execution.HealthCheckExecutor;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+
+@RunWith(PaxExam.class)
+public class SampleHealthChecksTest {
+
+    @Inject
+    private HealthCheckExecutor executor;
+    
+    @Configuration
+    public Option[] config() {
+        return U.config();
+    }
+
+    @Test
+    public void testAnnotatedHealthCheck() {
+        final List<HealthCheckExecutionResult> results = 
executor.execute("annotation","sample");
+        assertNotNull("Expecting non-null results");
+        assertEquals("Expecting a single result", 1, results.size());
+        final HealthCheckExecutionResult r = results.get(0);
+        assertTrue("Expecting non-empty HC log", 
r.getHealthCheckResult().iterator().hasNext());
+        final String expected = "All good";
+        assertTrue(
+                "Expecting first log message to contain " + expected,
+                
r.getHealthCheckResult().iterator().next().getMessage().contains(expected));
+    }
+}

Modified: 
sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/U.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/U.java?rev=1614760&r1=1614759&r2=1614760&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/U.java
 (original)
+++ 
sling/trunk/bundles/extensions/healthcheck/it/src/test/java/org/apache/sling/hc/it/core/U.java
 Wed Jul 30 20:40:33 2014
@@ -31,6 +31,7 @@ public class U {
     
     static Option[] config() {
         final String coreVersion = System.getProperty("sling.hc.core.version");
+        final String samplesVersion = 
System.getProperty("sling.hc.samples.version");
         final String localRepo = System.getProperty("maven.repo.local", "");
         final boolean felixShell = 
"true".equals(System.getProperty("felix.shell", "false"));
 
@@ -49,6 +50,7 @@ public class U {
             provision(
                     mavenBundle("org.apache.felix", "org.apache.felix.scr", 
"1.6.2"),
                     mavenBundle("org.apache.sling", 
"org.apache.sling.hc.core", coreVersion),
+                    mavenBundle("org.apache.sling", 
"org.apache.sling.hc.samples", samplesVersion),
                     mavenBundle("org.apache.sling", 
"org.apache.sling.commons.osgi", "2.2.0"),
                     mavenBundle("org.apache.sling", 
"org.apache.sling.jcr.jcr-wrapper", "2.0.0"),
                     mavenBundle("org.apache.sling", "org.apache.sling.api", 
"2.4.2"),


Reply via email to