// Path: fluency-core/src/main/java/org/komamitsu/fluency/util/Tuple3.java
// public class Tuple3<F, S, T>
// {
//     private final F first;
//     private final S second;
//     private final T third;
// 
//     public Tuple3(F first, S second, T third)
//     {
//         this.first = first;
//         this.second = second;
//         this.third = third;
//     }
// 
//     public F getFirst()
//     {
//         return first;
//     }
// 
//     public S getSecond()
//     {
//         return second;
//     }
// 
//     public T getThird()
//     {
//         return third;
//     }
// }


import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.komamitsu.fluency.util.Tuple3;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
/*
 * Copyright 2018 Mitsunori Komatsu (komamitsu)
 *
 * Licensed 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.komamitsu.fluency.fluentd.ingester.sender.heartbeat;




public class HeartbeaterTest
{
    private TestableHeartbeater.Config config;

    @BeforeEach
    public void setup()
    {
        config = new TestableHeartbeater.Config();
        config.setHost("dummy-hostname");
        config.setPort(123456);
        config.setIntervalMillis(300);
    }

    @Test
    public void testHeartbeater()
            throws InterruptedException
    {
        try (TestableHeartbeater heartbeater = new TestableHeartbeater(config)) {
            heartbeater.start();
            TimeUnit.SECONDS.sleep(1);
            heartbeater.close();
            TimeUnit.MILLISECONDS.sleep(500);
            assertTrue(1 < heartbeater.pongedRecords.size() && heartbeater.pongedRecords.size() < 4);
// Path: fluency-core/src/main/java/org/komamitsu/fluency/util/Tuple3.java
// public class Tuple3<F, S, T>
// {
//     private final F first;
//     private final S second;
//     private final T third;
// 
//     public Tuple3(F first, S second, T third)
//     {
//         this.first = first;
//         this.second = second;
//         this.third = third;
//     }
// 
//     public F getFirst()
//     {
//         return first;
//     }
// 
//     public S getSecond()
//     {
//         return second;
//     }
// 
//     public T getThird()
//     {
//         return third;
//     }
// }


// Path: fluency-fluentd/src/test/java/org/komamitsu/fluency/fluentd/ingester/sender/heartbeat/HeartbeaterTest.java
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.komamitsu.fluency.util.Tuple3;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

/*
 * Copyright 2018 Mitsunori Komatsu (komamitsu)
 *
 * Licensed 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.komamitsu.fluency.fluentd.ingester.sender.heartbeat;




public class HeartbeaterTest
{
    private TestableHeartbeater.Config config;

    @BeforeEach
    public void setup()
    {
        config = new TestableHeartbeater.Config();
        config.setHost("dummy-hostname");
        config.setPort(123456);
        config.setIntervalMillis(300);
    }

    @Test
    public void testHeartbeater()
            throws InterruptedException
    {
        try (TestableHeartbeater heartbeater = new TestableHeartbeater(config)) {
            heartbeater.start();
            TimeUnit.SECONDS.sleep(1);
            heartbeater.close();
            TimeUnit.MILLISECONDS.sleep(500);
            assertTrue(1 < heartbeater.pongedRecords.size() && heartbeater.pongedRecords.size() < 4);
            Tuple3<Long, String, Integer> firstPong = heartbeater.pongedRecords.get(0);