@@ -0,0 +1,2149 @@
+package com.etsy.statsd.profiler.worker;%0A%0Aimport com.etsy.statsd.profiler.Profiler;%0Aimport org.junit.Test;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Collection;%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0Aimport java.util.concurrent.TimeUnit;%0A%0Aimport static org.junit.Assert.*;%0A%0Apublic class ProfilerShutdownHookWorkerTest %7B%0A    @Test%0A    public void testRunnable() throws InterruptedException %7B%0A        Set%3CString%3E output = new HashSet%3C%3E();%0A        Profiler mockProfiler1 = new MockProfiler1(output);%0A        Profiler mockProfiler2 = new MockProfiler2(output);%0A        Collection%3CProfiler%3E profilers = Arrays.asList(mockProfiler1, mockProfiler2);%0A%0A        Thread t = new Thread(new ProfilerShutdownHookWorker(profilers));%0A        t.run();%0A        t.join();%0A%0A        Set%3CString%3E expectedOutput = new HashSet%3C%3E();%0A        expectedOutput.add(MockProfiler1.class.getSimpleName());%0A        expectedOutput.add(MockProfiler2.class.getSimpleName());%0A        assertEquals(expectedOutput, output);%0A    %7D%0A%0A    private static class MockProfiler2 extends Profiler %7B%0A        private Set%3CString%3E output;%0A%0A        public MockProfiler2(Set%3CString%3E output) %7B%0A            super(null);%0A            this.output = output;%0A        %7D%0A%0A        @Override%0A        public void profile() %7B %7D%0A%0A        @Override%0A        public void flushData() %7B%0A            output.add(this.getClass().getSimpleName());%0A        %7D%0A%0A        @Override%0A        public long getPeriod() %7B%0A            return 0;%0A        %7D%0A%0A        @Override%0A        public TimeUnit getTimeUnit() %7B%0A            return null;%0A        %7D%0A    %7D%0A%0A    private static class MockProfiler1 extends Profiler %7B%0A        private Set%3CString%3E output;%0A%0A        public MockProfiler1(Set%3CString%3E output) %7B%0A            super(null);%0A            this.output = output;%0A        %7D%0A%0A        @Override%0A        public void profile() %7B %7D%0A%0A        @Override%0A        public void flushData() %7B%0A            output.add(this.getClass().getSimpleName());%0A        %7D%0A%0A        @Override%0A        public long getPeriod() %7B%0A            return 0;%0A        %7D%0A%0A        @Override%0A        public TimeUnit getTimeUnit() %7B%0A            return null;%0A        %7D%0A    %7D%0A%7D

Test for ProfilerShutdownHookWorker