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 f64d35ba89217a212a57502b5a2b5a768776c36b Author: Bertrand Delacretaz <[email protected]> AuthorDate: Mon Feb 29 13:10:27 2016 +0000 SLING-5569 - move Health Checks core integration tests to the core module git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1732889 13f79535-47bb-0310-9956-ffa450edef68 --- .../sling/hc/it/core/AsyncHealthCheckTest.java | 110 ---------- .../it/core/HealthCheckExecutorSelectionTest.java | 147 -------------- .../sling/hc/it/core/HealthCheckFilterTest.java | 221 --------------------- .../sling/hc/it/core/HealthCheckServletTest.java | 121 ----------- .../it/core/JmxAdjustableStatusForTestingTest.java | 155 --------------- .../apache/sling/hc/it/core/MockHttpService.java | 55 ----- 6 files changed, 809 deletions(-) diff --git a/src/test/java/org/apache/sling/hc/it/core/AsyncHealthCheckTest.java b/src/test/java/org/apache/sling/hc/it/core/AsyncHealthCheckTest.java deleted file mode 100644 index acbd8c9..0000000 --- a/src/test/java/org/apache/sling/hc/it/core/AsyncHealthCheckTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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.assertTrue; - -import java.util.Dictionary; -import java.util.Hashtable; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicInteger; - -import javax.inject.Inject; - -import org.apache.sling.hc.api.HealthCheck; -import org.apache.sling.hc.api.Result; -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; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; - -@RunWith(PaxExam.class) -public class AsyncHealthCheckTest { - - @Inject - private HealthCheckExecutor executor; - - @Inject - private BundleContext bundleContext; - - @Configuration - public Option[] config() { - return U.config(); - } - - @Test - public void testAsyncHealthCheck() throws InterruptedException { - final String id = UUID.randomUUID().toString(); - final AtomicInteger counter = new AtomicInteger(Integer.MIN_VALUE); - final HealthCheck hc = new HealthCheck() { - @Override - public Result execute() { - final int v = counter.incrementAndGet(); - return new Result(Result.Status.OK, "counter is now " + v); - } - - }; - - final Dictionary<String, Object> props = new Hashtable<String, Object>(); - props.put(HealthCheck.NAME, "name_" + id); - props.put(HealthCheck.TAGS, id); - props.put(HealthCheck.ASYNC_CRON_EXPRESSION, "*/1 * * * * ?"); - - @SuppressWarnings("rawtypes") - final ServiceRegistration reg = bundleContext.registerService(HealthCheck.class, hc, props); - - try { - // Wait for HC to be registered - U.expectHealthChecks(1, executor, id); - - // Now reset the counter and check that HC increments it even if we don't - // use the executor - { - counter.set(0); - final long timeout = System.currentTimeMillis() + 5000L; - while(System.currentTimeMillis() < timeout) { - if(counter.get() > 0) { - break; - } - Thread.sleep(100L); - } - assertTrue("Expecting counter to be incremented", counter.get() > 0); - } - - // Verify that we get the right log - final String msg = executor.execute(id).get(0).getHealthCheckResult().iterator().next().getMessage(); - assertTrue("Expecting the right message: " + msg, msg.contains("counter is now")); - - // And verify that calling executor lots of times doesn't increment as much - final int previous = counter.get(); - final int n = 100; - for(int i=0; i < n; i++) { - executor.execute(id); - } - assertTrue("Expecting counter to increment asynchronously", counter.get() < previous + n); - } finally { - reg.unregister(); - } - - } - -} diff --git a/src/test/java/org/apache/sling/hc/it/core/HealthCheckExecutorSelectionTest.java b/src/test/java/org/apache/sling/hc/it/core/HealthCheckExecutorSelectionTest.java deleted file mode 100644 index 88c9bfe..0000000 --- a/src/test/java/org/apache/sling/hc/it/core/HealthCheckExecutorSelectionTest.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * 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 java.util.ArrayList; -import java.util.Dictionary; -import java.util.Hashtable; -import java.util.List; -import java.util.UUID; - -import javax.inject.Inject; - -import org.apache.sling.hc.api.HealthCheck; -import org.apache.sling.hc.api.Result; -import org.apache.sling.hc.api.execution.HealthCheckExecutionOptions; -import org.apache.sling.hc.api.execution.HealthCheckExecutor; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -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; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; - -/** Test the HealthCheckExecutor selection mechanism */ -@RunWith(PaxExam.class) -public class HealthCheckExecutorSelectionTest { - - @Inject - private HealthCheckExecutor executor; - - @Inject - private BundleContext bundleContext; - - private static String idA; - private static String idB; - private HealthCheckExecutionOptions options; - - @SuppressWarnings("rawtypes") - private List<ServiceRegistration> regs = new ArrayList<ServiceRegistration>(); - - @Configuration - public Option[] config() { - return U.config(); - } - - private void registerHC(final String ... tags) { - final HealthCheck hc = new HealthCheck() { - @Override - public Result execute() { - return new Result(Result.Status.OK, "All good for " + tags[0]); - } - - }; - - final Dictionary<String, Object> props = new Hashtable<String, Object>(); - props.put(HealthCheck.NAME, "name_" + tags[0]); - props.put(HealthCheck.TAGS, tags); - - regs.add(bundleContext.registerService(HealthCheck.class, hc, props)); - } - - @BeforeClass - public static void setId() { - idA = UUID.randomUUID().toString(); - idB = UUID.randomUUID().toString(); - } - - @Before - public void setup() { - options = new HealthCheckExecutionOptions(); - - U.expectHealthChecks(0, executor, idA); - U.expectHealthChecks(0, executor, idB); - - registerHC(idA); - registerHC(idB); - registerHC(idB); - registerHC(idA, idB); - } - - @After - @SuppressWarnings("rawtypes") - public void cleanup() { - for(ServiceRegistration r : regs) { - r.unregister(); - } - regs.clear(); - - U.expectHealthChecks(0, executor, idA); - U.expectHealthChecks(0, executor, idB); - } - - @Test - public void testDefaultSelectionA(){ - U.expectHealthChecks(2, executor, idA); - U.expectHealthChecks(2, executor, options, idA); - } - - @Test - public void testDefaultSelectionB(){ - U.expectHealthChecks(3, executor, idB); - U.expectHealthChecks(3, executor, options, idB); - } - - @Test - public void testDefaultSelectionAB(){ - U.expectHealthChecks(1, executor, idA, idB); - U.expectHealthChecks(1, executor, options, idA, idB); - } - - @Test - public void testOrSelectionA(){ - options.setCombineTagsWithOr(true); - U.expectHealthChecks(1, executor, options, idA); - } - - @Test - public void testOrSelectionB(){ - options.setCombineTagsWithOr(true); - U.expectHealthChecks(3, executor, options, idB); - } - - @Test - public void testOrSelectionAB(){ - options.setCombineTagsWithOr(true); - U.expectHealthChecks(4, executor, options, idA, idB); - } -} diff --git a/src/test/java/org/apache/sling/hc/it/core/HealthCheckFilterTest.java b/src/test/java/org/apache/sling/hc/it/core/HealthCheckFilterTest.java deleted file mode 100644 index 4a154f7..0000000 --- a/src/test/java/org/apache/sling/hc/it/core/HealthCheckFilterTest.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * 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.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Dictionary; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; - -import javax.inject.Inject; - -import org.apache.sling.hc.api.HealthCheck; -import org.apache.sling.hc.api.Result; -import org.apache.sling.hc.util.HealthCheckFilter; -import org.junit.After; -import org.junit.Before; -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; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@RunWith(PaxExam.class) -public class HealthCheckFilterTest { - - private final Logger log = LoggerFactory.getLogger(getClass()); - - private HealthCheckFilter filter; - - @Inject - private BundleContext bundleContext; - - private List<TestHealthCheck> testServices = new ArrayList<TestHealthCheck>(); - private static int instanceCounter = 0; - - class TestHealthCheck implements HealthCheck { - - private final int id; - private final ServiceRegistration<?> reg; - final String[] tags; - - TestHealthCheck(String... tags) { - id = instanceCounter++; - this.tags = tags; - final Dictionary<String, Object> props = new Hashtable<String, Object>(); - if (tags != null) { - props.put(HealthCheck.TAGS, tags); - } - props.put(HealthCheck.TAGS, tags); - reg = bundleContext.registerService(HealthCheck.class.getName(), - this, props); - log.info("Registered {} with {}={}", new Object[] { this, - HealthCheck.TAGS, props.get(HealthCheck.TAGS) }); - } - - @Override - public String toString() { - return Arrays.asList(tags).toString(); - } - - @Override - public boolean equals(Object other) { - return other instanceof TestHealthCheck - && ((TestHealthCheck) other).id == id; - } - - @Override - public int hashCode() { - return id; - } - - @Override - public Result execute() { - return null; - } - - void unregister() { - reg.unregister(); - } - } - - @Configuration - public Option[] config() { - return U.config(); - } - - @Before - public void setup() { - testServices.add(new TestHealthCheck("foo")); - testServices.add(new TestHealthCheck("bar")); - testServices.add(new TestHealthCheck("foo", "bar")); - testServices.add(new TestHealthCheck("other", "thing")); - testServices.add(new TestHealthCheck()); - filter = new HealthCheckFilter(bundleContext); - } - - @After - public void cleanup() { - for (TestHealthCheck tc : testServices) { - tc.unregister(); - } - } - - /** - * @param included - * true or false, in the same order as testServices - */ - private void assertServices(List<HealthCheck> s, boolean... included) { - final Iterator<TestHealthCheck> it = testServices.iterator(); - for (boolean inc : included) { - final TestHealthCheck thc = it.next(); - if (inc) { - assertTrue("Expecting list of services to include " + thc, - s.contains(thc)); - } else { - assertFalse("Not expecting list of services to include " + thc, - s.contains(thc)); - } - } - } - - @Test - public void testSelectorService() { - assertNotNull("Expecting HealthCheckSelector service to be provided", - filter); - } - - @Test - public void testAllServices() { - final List<HealthCheck> s = filter.getTaggedHealthChecks(); - assertServices(s, true, true, true, true, true); - } - - @Test - public void testEmptyTags() { - final List<HealthCheck> s = filter.getTaggedHealthChecks("", "", ""); - assertServices(s, true, true, true, true, true); - } - - @Test - public void testFooTag() { - final List<HealthCheck> s = filter.getTaggedHealthChecks("foo"); - assertServices(s, true, false, true, false, false); - } - - @Test - public void testBarTag() { - final List<HealthCheck> s = filter.getTaggedHealthChecks("bar"); - assertServices(s, false, true, true, false, false); - } - - @Test - public void testFooAndBar() { - final List<HealthCheck> s = filter.getTaggedHealthChecks("foo", "bar"); - assertServices(s, false, false, true, false, false); - } - - @Test - public void testFooMinusBar() { - final List<HealthCheck> s = filter - .getTaggedHealthChecks("foo", "-bar"); - assertServices(s, true, false, false, false, false); - } - - @Test - public void testWhitespace() { - final List<HealthCheck> s = filter.getTaggedHealthChecks( - "\t \n\r foo \t", "", " \t-bar\n", ""); - assertServices(s, true, false, false, false, false); - } - - @Test - public void testOther() { - final List<HealthCheck> s = filter.getTaggedHealthChecks("other"); - assertServices(s, false, false, false, true, false); - } - - @Test - public void testMinusOther() { - final List<HealthCheck> s = filter.getTaggedHealthChecks("-other"); - assertServices(s, true, true, true, false, true); - } - - @Test - public void testMinusOtherFoo() { - final List<HealthCheck> s = filter.getTaggedHealthChecks("-other", - "-foo"); - assertServices(s, false, true, false, false, true); - } - - @Test - public void testNoResults() { - final List<HealthCheck> s = filter.getTaggedHealthChecks("NOT A TAG"); - assertTrue("Expecting no services", s.isEmpty()); - } -} diff --git a/src/test/java/org/apache/sling/hc/it/core/HealthCheckServletTest.java b/src/test/java/org/apache/sling/hc/it/core/HealthCheckServletTest.java deleted file mode 100644 index b62ca67..0000000 --- a/src/test/java/org/apache/sling/hc/it/core/HealthCheckServletTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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 java.io.IOException; -import java.util.Dictionary; -import java.util.Hashtable; -import java.util.List; -import java.util.UUID; - -import javax.inject.Inject; - -import org.junit.After; -import org.junit.Before; -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; -import org.osgi.framework.BundleContext; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.cm.ConfigurationAdmin; -import org.osgi.service.http.HttpService; - -/** Verify that the HealthCheckExecutorServlet becomes available - * after creating the corresponding config - */ -@RunWith(PaxExam.class) -public class HealthCheckServletTest { - - @Inject - private ConfigurationAdmin configAdmin; - - @Inject - private BundleContext bundleContext; - - private MockHttpService httpService; - private ServiceRegistration reg; - - @Configuration - public Option[] config() { - return U.config(); - } - - private int countServletServices(String packageNamePrefix) throws InvalidSyntaxException { - final ServiceReference<?> [] refs = bundleContext.getServiceReferences("javax.servlet.Servlet", null); - int count = 0; - if(refs != null) { - for(ServiceReference ref : refs) { - final Object o = bundleContext.getService(ref); - if(o.getClass().getName().startsWith(packageNamePrefix)) { - count++; - } - bundleContext.ungetService(ref); - } - } - return count; - } - - @Before - public void setup() { - httpService = new MockHttpService(); - reg = bundleContext.registerService(HttpService.class, httpService, null); - } - - @After - public void cleanup() { - reg.unregister(); - reg = null; - httpService = null; - } - - @Test - public void testServletBecomesActive() throws InvalidSyntaxException, IOException, InterruptedException { - final String property = "servletPath"; - final String path = "/test/" + UUID.randomUUID(); - final String packagePrefix = "org.apache.sling.hc"; - assertEquals("Initially expecting no servlet from " + packagePrefix, 0, countServletServices(packagePrefix)); - final int pathsBefore = httpService.getPaths().size(); - - // Activate servlet and wait for it to show up - final String pid = "org.apache.sling.hc.core.impl.servlet.HealthCheckExecutorServlet"; - final org.osgi.service.cm.Configuration cfg = configAdmin.getConfiguration(pid, null); - final Dictionary<String, Object> props = new Hashtable<String, Object>(); - props.put(property, path); - cfg.update(props); - - final long timeoutMsec = 5000L; - final long endTime = System.currentTimeMillis() + timeoutMsec; - while(System.currentTimeMillis() < endTime) { - if(countServletServices(packagePrefix) > 0) { - break; - } - Thread.sleep(50L); - } - - assertEquals("After adding configuration, expecting one servlet from " + packagePrefix, 1, countServletServices(packagePrefix)); - final List<String> paths = httpService.getPaths(); - assertEquals("Expecting one new servlet registration", pathsBefore + 1, paths.size()); - assertEquals("Expecting the HC servlet to be registered at " + path, path, paths.get(paths.size() - 1)); - } -} diff --git a/src/test/java/org/apache/sling/hc/it/core/JmxAdjustableStatusForTestingTest.java b/src/test/java/org/apache/sling/hc/it/core/JmxAdjustableStatusForTestingTest.java deleted file mode 100644 index 15a5425..0000000 --- a/src/test/java/org/apache/sling/hc/it/core/JmxAdjustableStatusForTestingTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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 java.util.ArrayList; -import java.util.Dictionary; -import java.util.Hashtable; -import java.util.List; - -import javax.inject.Inject; -import javax.management.DynamicMBean; - -import org.apache.sling.hc.api.HealthCheck; -import org.apache.sling.hc.api.Result; -import org.apache.sling.hc.api.ResultLog; -import org.apache.sling.hc.api.ResultLog.Entry; -import org.apache.sling.hc.api.execution.HealthCheckExecutionResult; -import org.apache.sling.hc.api.execution.HealthCheckExecutor; -import org.apache.sling.hc.util.FormattingResultLog; -import org.junit.After; -import org.junit.Before; -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; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; - -/** Test jmx-adjustable status for testing HC. */ -@RunWith(PaxExam.class) -public class JmxAdjustableStatusForTestingTest { - - @Inject - private HealthCheckExecutor executor; - - @Inject - private BundleContext bundleContext; - - private static String testTag = "testTagName"; - - @SuppressWarnings("rawtypes") - private List<ServiceRegistration> regs = new ArrayList<ServiceRegistration>(); - - @Configuration - public Option[] config() { - return U.config(); - } - - private void assertResult(String tag, Result.Status expected) { - final Result result = getOverallResult(executor.execute(tag)); - assertEquals("Expected status " + expected + " for tag " + tag, expected, result.getStatus()); - } - - @Before - public void setup() { - U.expectHealthChecks(0, executor, testTag); - registerHC(testTag); - U.expectHealthChecks(1, executor, testTag); - assertResult(testTag, Result.Status.OK); - } - - @After - @SuppressWarnings("rawtypes") - public void cleanup() throws Exception { - invokeMBean("reset", new Object[] {}, new String[] {}); - - U.expectHealthChecks(1, executor, testTag); - assertResult(testTag, Result.Status.OK); - - for (ServiceRegistration r : regs) { - r.unregister(); - } - regs.clear(); - U.expectHealthChecks(0, executor, testTag); - } - - @Test - public void testWarnStatus() throws Exception { - invokeMBean("addWarnResultForTags", new Object[] { testTag }, new String[] { String.class.getName() }); - U.expectHealthChecks(2, executor, testTag); - assertResult(testTag, Result.Status.WARN); - } - - @Test - public void testCriticalStatus() throws Exception { - invokeMBean("addCriticalResultForTags", new Object[] { "anotherTag," + testTag }, - new String[] { String.class.getName() }); - - final String [] tags = { "anotherTag", testTag }; - for(String tag : tags) { - U.expectHealthChecks(2, executor, testTag); - assertResult(tag, Result.Status.CRITICAL); - } - } - - @Test - public void testAnotherTag() throws Exception { - // Selecting an unused tag returns WARN - not sure why but - // if that changes we should detect it. - assertResult("some_unused_tag", Result.Status.WARN); - } - - private void registerHC(final String... tags) { - final HealthCheck hc = new HealthCheck() { - @Override - public Result execute() { - return new Result(Result.Status.OK, "All good for " + tags[0]); - } - }; - - final Dictionary<String, Object> props = new Hashtable<String, Object>(); - props.put(HealthCheck.NAME, "name_" + tags[0]); - props.put(HealthCheck.TAGS, tags); - - regs.add(bundleContext.registerService(HealthCheck.class, hc, props)); - } - - private void invokeMBean(String operation, Object[] args, String[] signature) throws Exception { - - ServiceReference<?>[] serviceReference = bundleContext.getServiceReferences(DynamicMBean.class.getName(), - "(jmx.objectname=org.apache.sling.healthcheck:type=AdjustableHealthCheckForTesting)"); - DynamicMBean mBean = (DynamicMBean) bundleContext.getService(serviceReference[0]); - mBean.invoke(operation, args, signature); - - } - - private Result getOverallResult(List<HealthCheckExecutionResult> results) { - FormattingResultLog resultLog = new FormattingResultLog(); - for (HealthCheckExecutionResult executionResult : results) { - for (Entry entry : executionResult.getHealthCheckResult()) { - resultLog.add(new ResultLog.Entry(entry.getStatus(), entry.getMessage(), entry.getException())); - } - } - return new Result(resultLog); - } -} diff --git a/src/test/java/org/apache/sling/hc/it/core/MockHttpService.java b/src/test/java/org/apache/sling/hc/it/core/MockHttpService.java deleted file mode 100644 index 13d6548..0000000 --- a/src/test/java/org/apache/sling/hc/it/core/MockHttpService.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 java.util.ArrayList; -import java.util.Collections; -import java.util.Dictionary; -import java.util.List; - -import javax.servlet.Servlet; - -import org.osgi.service.http.HttpContext; -import org.osgi.service.http.HttpService; - -class MockHttpService implements HttpService { - - private List<String> paths = new ArrayList<String>(); - - @Override - public void registerResources(String alias, String name, HttpContext context) { - } - - @Override - public void registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context) { - paths.add(alias); - } - - public void unregister(String alias) { - paths.remove(alias); - } - - @Override - public HttpContext createDefaultHttpContext() { - return null; - } - - List<String> getPaths() { - return Collections.unmodifiableList(paths); - } -} -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
