You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/10/18 23:20:29 UTC
[sling-org-apache-sling-hc-it] 19/49: SLING-3624 - test the
annotated health check sample
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hc-it.git
commit 65dc05a14b8a4cc42325cfd1f12fa7c5c82e5cb1
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Jul 30 20:40:33 2014 +0000
SLING-3624 - test the annotated health check sample
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1614760 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 5 +-
.../sling/hc/it/core/SampleHealthChecksTest.java | 59 ++++++++++++++++++++++
src/test/java/org/apache/sling/hc/it/core/U.java | 2 +
3 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 2c950bc..54b9344 100644
--- a/pom.xml
+++ b/pom.xml
@@ -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>
diff --git a/src/test/java/org/apache/sling/hc/it/core/SampleHealthChecksTest.java b/src/test/java/org/apache/sling/hc/it/core/SampleHealthChecksTest.java
new file mode 100644
index 0000000..be0f901
--- /dev/null
+++ b/src/test/java/org/apache/sling/hc/it/core/SampleHealthChecksTest.java
@@ -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));
+ }
+}
diff --git a/src/test/java/org/apache/sling/hc/it/core/U.java b/src/test/java/org/apache/sling/hc/it/core/U.java
index 8a993d3..cb9f445 100644
--- a/src/test/java/org/apache/sling/hc/it/core/U.java
+++ b/src/test/java/org/apache/sling/hc/it/core/U.java
@@ -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"),
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.