@@ -0,0 +1,2759 @@
+package org.komamitsu.fluency.sender.failuredetect;%0A%0Aimport org.junit.Test;%0Aimport org.komamitsu.failuredetector.PhiAccuralFailureDetector;%0Aimport org.komamitsu.fluency.sender.heartbeat.TCPHeartbeater;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java.io.IOException;%0Aimport java.nio.channels.ServerSocketChannel;%0Aimport java.nio.channels.SocketChannel;%0Aimport java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0Aimport java.util.concurrent.TimeUnit;%0A%0Aimport static org.junit.Assert.*;%0A%0Apublic class FailureDetectorTest%0A%7B%0A    private static final Logger LOG = LoggerFactory.getLogger(FailureDetectorTest.class);%0A%0A    @Test%0A    public void testIsAvailable()%0A            throws IOException, InterruptedException%0A    %7B%0A        final ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();%0A        serverSocketChannel.socket().bind(null);%0A        int localPort = serverSocketChannel.socket().getLocalPort();%0A%0A        final ExecutorService executorService = Executors.newSingleThreadExecutor();%0A        Runnable serverTask = new Runnable()%0A        %7B%0A            @Override%0A            public void run()%0A            %7B%0A                while (!executorService.isShutdown()) %7B%0A                    SocketChannel accept = null;%0A                    try %7B%0A                        accept = serverSocketChannel.accept();%0A                        LOG.debug(%22Accepted: %7B%7D%22, accept);%0A                    %7D%0A                    catch (IOException e) %7B%0A                        LOG.warn(%22Stab TCP server got an error%22, e);%0A                    %7D%0A                    finally %7B%0A                        if (accept != null) %7B%0A                            try %7B%0A                                accept.close();%0A                            %7D%0A                            catch (IOException e) %7B%0A                            %7D%0A                        %7D%0A                    %7D%0A                %7D%0A            %7D%0A        %7D;%0A%0A        executorService.execute(serverTask);%0A%0A        TCPHeartbeater.Config heartbeaterConfig = new TCPHeartbeater.Config();%0A        heartbeaterConfig.setPort(localPort);%0A%0A        PhiAccrualFailureDetectStrategy.Config failureDetectorConfig = new PhiAccrualFailureDetectStrategy.Config();%0A        FailureDetector failureDetector = null;%0A        try %7B%0A            failureDetector = new FailureDetector(failureDetectorConfig, heartbeaterConfig);%0A%0A            assertTrue(failureDetector.isAvailable());%0A            TimeUnit.SECONDS.sleep(2L);%0A            assertTrue(failureDetector.isAvailable());%0A%0A            executorService.shutdownNow();%0A            TimeUnit.SECONDS.sleep(2L);%0A            assertFalse(failureDetector.isAvailable());%0A        %7D%0A        finally %7B%0A            failureDetector.close();%0A        %7D%0A    %7D%0A%7D

Add FailureDetectorTest