@@ -0,0 +1,2726 @@
+package com.yahoo.jdisc.core;%0A%0Aimport com.yahoo.jdisc.Metric;%0Aimport com.yahoo.jdisc.ResourceReference;%0Aimport com.yahoo.jdisc.test.TestDriver;%0Aimport org.junit.Test;%0A%0Aimport java.util.Map;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0A/**%0A * @author bjorncs%0A */%0Apublic class ActiveContainerStatisticsTest %7B%0A%0A    @Test%0A    public void counts_deactivated_activecontainers() %7B%0A        TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();%0A        ActiveContainerStatistics stats = new ActiveContainerStatistics();%0A        MockMetric metric = new MockMetric();%0A%0A        ActiveContainer containerWithoutRetainedResources = new ActiveContainer(driver.newContainerBuilder());%0A%0A        stats.onActivated(containerWithoutRetainedResources);%0A        stats.emitMetrics(metric);%0A        assertEquals(0, metric.totalCount);%0A        assertEquals(0, metric.withRetainedReferencesCount);%0A%0A        stats.onDeactivated(containerWithoutRetainedResources);%0A        containerWithoutRetainedResources.release();%0A        stats.emitMetrics(metric);%0A        assertEquals(1, metric.totalCount);%0A        assertEquals(0, metric.withRetainedReferencesCount);%0A%0A        ActiveContainer containerWithRetainedResources = new ActiveContainer(driver.newContainerBuilder());%0A%0A        try (ResourceReference ignoredRef = containerWithRetainedResources.refer()) %7B%0A             stats.onActivated(containerWithRetainedResources);%0A             stats.onDeactivated(containerWithRetainedResources);%0A             containerWithRetainedResources.release();%0A             stats.emitMetrics(metric);%0A             assertEquals(2, metric.totalCount);%0A             assertEquals(1, metric.withRetainedReferencesCount);%0A        %7D%0A%0A    %7D%0A%0A    private static class MockMetric implements Metric %7B%0A        public int totalCount;%0A        public int withRetainedReferencesCount;%0A%0A        @Override%0A        public void set(String key, Number val, Context ctx) %7B%0A            switch (key) %7B%0A                case ActiveContainerStatistics.Metrics.TOTAL_DEACTIVATED_CONTAINERS:%0A                    totalCount = val.intValue();%0A                    break;%0A                case ActiveContainerStatistics.Metrics.DEACTIVATED_CONTAINERS_WITH_RETAINED_REFERENCES:%0A                    withRetainedReferencesCount = val.intValue();%0A                    break;%0A                default:%0A                    throw new UnsupportedOperationException();%0A            %7D%0A        %7D%0A%0A        @Override%0A        public void add(String key, Number val, Context ctx) %7B%0A            throw new UnsupportedOperationException();%0A        %7D%0A%0A        @Override%0A        public Context createContext(Map%3CString, ?%3E properties) %7B%0A            throw new UnsupportedOperationException();%0A        %7D%0A    %7D%0A%0A%7D%0A

Add unit test for ActiveContainerStatistics