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 216a61315d5107805445ad0d4b721074c69a4c84
Author: Bertrand Delacretaz <[email protected]>
AuthorDate: Thu Jul 31 09:31:34 2014 +0000

    SLING-3624 - test DynamicMBean registration from annotation
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1614840 
13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/hc/it/core/SampleHealthChecksTest.java     | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

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
index be0f901..e8ed466 100644
--- a/src/test/java/org/apache/sling/hc/it/core/SampleHealthChecksTest.java
+++ b/src/test/java/org/apache/sling/hc/it/core/SampleHealthChecksTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue;
 import java.util.List;
 
 import javax.inject.Inject;
+import javax.management.DynamicMBean;
 
 import org.apache.sling.hc.api.execution.HealthCheckExecutionResult;
 import org.apache.sling.hc.api.execution.HealthCheckExecutor;
@@ -32,6 +33,9 @@ import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
 
 @RunWith(PaxExam.class)
 public class SampleHealthChecksTest {
@@ -39,13 +43,16 @@ public class SampleHealthChecksTest {
     @Inject
     private HealthCheckExecutor executor;
     
+    @Inject
+    private BundleContext bundleContext;
+    
     @Configuration
     public Option[] config() {
         return U.config();
     }
-
+    
     @Test
-    public void testAnnotatedHealthCheck() {
+    public void testAnnotatedHC() {
         final List<HealthCheckExecutionResult> results = 
executor.execute("annotation","sample");
         assertNotNull("Expecting non-null results");
         assertEquals("Expecting a single result", 1, results.size());
@@ -56,4 +63,13 @@ public class SampleHealthChecksTest {
                 "Expecting first log message to contain " + expected,
                 
r.getHealthCheckResult().iterator().next().getMessage().contains(expected));
     }
+
+    @Test
+    public void testAnnotatedHCMBean() throws InvalidSyntaxException {
+        // Verify that we have a DynamicMBean service with the right name, the 
JMX whiteboard will do the rest
+        final String filter = 
"(jmx.objectname=org.apache.sling.healthcheck:type=HealthCheck,name=annotatedHC)";
+        final ServiceReference<?> [] refs = 
bundleContext.getServiceReferences(DynamicMBean.class.getName(), filter);
+        assertNotNull("Expecting non-null ServiceReferences for " + filter, 
refs);
+        assertEquals("Expecting a single ServiceReference for " + filter, 1, 
refs.length);
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to