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-support.git
commit 5d198fd708cc8584e31a3a33247059442556bf2e Author: Georg Henzler <ghenz...@apache.org> AuthorDate: Thu May 25 05:01:52 2017 +0000 SLING-6698 Using map in activate() git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1796129 13f79535-47bb-0310-9956-ffa450edef68 --- .../sling/hc/support/impl/ThreadUsageHealthCheck.java | 4 +--- .../sling/hc/support/impl/ThreadUsageHealthCheckTest.java | 15 ++++----------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/apache/sling/hc/support/impl/ThreadUsageHealthCheck.java b/src/main/java/org/apache/sling/hc/support/impl/ThreadUsageHealthCheck.java index fbea827..e08bb92 100644 --- a/src/main/java/org/apache/sling/hc/support/impl/ThreadUsageHealthCheck.java +++ b/src/main/java/org/apache/sling/hc/support/impl/ThreadUsageHealthCheck.java @@ -35,7 +35,6 @@ import org.apache.sling.hc.annotations.SlingHealthCheck; import org.apache.sling.hc.api.HealthCheck; import org.apache.sling.hc.api.Result; import org.apache.sling.hc.util.FormattingResultLog; -import org.osgi.service.component.ComponentContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,8 +63,7 @@ public class ThreadUsageHealthCheck implements HealthCheck { private boolean cpuTimeThresholdWarnIsConfigured; @Activate - protected final void activate(final ComponentContext componentContext) { - final Dictionary<String, Object> properties = componentContext.getProperties(); + protected final void activate(final Map<String, Object> properties) { this.samplePeriodInMs = PropertiesUtil.toLong(properties.get(PROP_SAMPLE_PERIOD_IN_MS), DEFAULT_SAMPLE_PERIOD_IN_MS); this.availableProcessors = Runtime.getRuntime().availableProcessors(); diff --git a/src/test/java/org/apache/sling/hc/support/impl/ThreadUsageHealthCheckTest.java b/src/test/java/org/apache/sling/hc/support/impl/ThreadUsageHealthCheckTest.java index 75816ed..257f72b 100644 --- a/src/test/java/org/apache/sling/hc/support/impl/ThreadUsageHealthCheckTest.java +++ b/src/test/java/org/apache/sling/hc/support/impl/ThreadUsageHealthCheckTest.java @@ -26,37 +26,30 @@ import static org.mockito.MockitoAnnotations.initMocks; import java.lang.management.ThreadMXBean; import java.util.ArrayList; import java.util.Date; -import java.util.Dictionary; import java.util.List; +import java.util.Map; import org.apache.sling.hc.api.Result; +import org.apache.sling.hc.support.impl.ThreadUsageHealthCheck.ThreadTimeInfo; import org.apache.sling.hc.util.FormattingResultLog; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.Spy; -import org.osgi.service.component.ComponentContext; - -import org.apache.sling.hc.support.impl.ThreadUsageHealthCheck.ThreadTimeInfo; public class ThreadUsageHealthCheckTest { @Spy ThreadUsageHealthCheck threadsHealthCheck; - @Mock - ComponentContext componentContext; @Mock - Dictionary<String, Object> componentConfig; + Map<String, Object> componentConfig; @Before public void setup() { initMocks(this); - - doReturn(componentConfig).when(componentContext).getProperties(); doNothing().when(threadsHealthCheck).checkForDeadlock(any(FormattingResultLog.class), any(ThreadMXBean.class)); - } @Test @@ -104,7 +97,7 @@ public class ThreadUsageHealthCheckTest { private void setupExpectations(long samplePeriod, int processorsAvailable, List<ThreadTimeInfo> resultListOk) { doReturn(processorsAvailable * 90).when(componentConfig).get(ThreadUsageHealthCheck.PROP_CPU_TIME_THRESHOLD_WARN); doReturn(samplePeriod).when(componentConfig).get(ThreadUsageHealthCheck.PROP_SAMPLE_PERIOD_IN_MS); - threadsHealthCheck.activate(componentContext); + threadsHealthCheck.activate(componentConfig); doReturn(resultListOk).when(threadsHealthCheck).collectThreadTimeInfos(any(FormattingResultLog.class), any(ThreadMXBean.class)); } -- To stop receiving notification emails like this one, please contact "commits@sling.apache.org" <commits@sling.apache.org>.