add TCPPingerTest to see it's results on a macOS

This commit is contained in:
Anton Keks 2021-01-19 23:02:22 +02:00
parent 12b21ed955
commit 2430a28a1c

View File

@ -0,0 +1,27 @@
package net.azib.ipscan.core.net;
import net.azib.ipscan.core.ScanningSubject;
import org.junit.Test;
import java.io.IOException;
import java.net.InetAddress;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class TCPPingerTest {
Pinger pinger = new TCPPinger(10);
@Test
public void pingAlive() throws IOException {
PingResult result = pinger.ping(new ScanningSubject(InetAddress.getLocalHost()), 3);
assertTrue(result.isAlive());
assertTrue(result.getAverageTime() <= 10);
}
@Test
public void pingDead() throws IOException {
PingResult result = pinger.ping(new ScanningSubject(InetAddress.getByName("192.168.99.253")), 1);
assertFalse(result.isAlive());
}
}