mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
add more pinger tests
This commit is contained in:
parent
fb6419daf5
commit
a6cf076a1f
31
test/net/azib/ipscan/core/net/AbstractPingerTest.java
Normal file
31
test/net/azib/ipscan/core/net/AbstractPingerTest.java
Normal file
@ -0,0 +1,31 @@
|
||||
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;
|
||||
|
||||
abstract class AbstractPingerTest {
|
||||
Pinger pinger;
|
||||
|
||||
AbstractPingerTest(Pinger pinger) {
|
||||
this.pinger = pinger;
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package net.azib.ipscan.core.net;
|
||||
|
||||
public class CombinedUnprivilegedPingerTest extends AbstractPingerTest {
|
||||
public CombinedUnprivilegedPingerTest() {
|
||||
super(new CombinedUnprivilegedPinger(10));
|
||||
}
|
||||
}
|
||||
@ -1,27 +1,7 @@
|
||||
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 JavaPingerTest {
|
||||
JavaPinger pinger = new JavaPinger(10);
|
||||
|
||||
@Test
|
||||
public void pingAlive() throws IOException {
|
||||
PingResult result = pinger.ping(new ScanningSubject(InetAddress.getLocalHost()), 3);
|
||||
assertTrue(result.isAlive());
|
||||
assertTrue(result.getAverageTime() <= 10);
|
||||
public class JavaPingerTest extends AbstractPingerTest {
|
||||
public JavaPingerTest() {
|
||||
super(new JavaPinger(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pingDead() throws IOException {
|
||||
PingResult result = pinger.ping(new ScanningSubject(InetAddress.getByName("192.168.99.253")), 1);
|
||||
assertFalse(result.isAlive());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,27 +1,7 @@
|
||||
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);
|
||||
public class TCPPingerTest extends AbstractPingerTest {
|
||||
public TCPPingerTest() {
|
||||
super(new TCPPinger(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pingDead() throws IOException {
|
||||
PingResult result = pinger.ping(new ScanningSubject(InetAddress.getByName("192.168.99.253")), 1);
|
||||
assertFalse(result.isAlive());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
7
test/net/azib/ipscan/core/net/UDPPingerTest.java
Normal file
7
test/net/azib/ipscan/core/net/UDPPingerTest.java
Normal file
@ -0,0 +1,7 @@
|
||||
package net.azib.ipscan.core.net;
|
||||
|
||||
public class UDPPingerTest extends AbstractPingerTest {
|
||||
public UDPPingerTest() {
|
||||
super(new UDPPinger(10));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user