@Test public void testPing() { final MockPingListener listener = new MockPingListener(); final MockPing mockPing = new MockPing(null, listener, 3); mockPing.setCount(6); mockPing.run(); Assert.assertEquals(mockPing.getCount(), listener.pingCount); Assert.assertEquals(mockPing.timeouts.length, listener.timeoutCount); }
public Ping(final InetAddress dest, final PingListener listener) { mDest = dest; if (listener == null) { throw new NullPointerException(); } mListener = listener; final byte type = dest instanceof Inet6Address ? EchoPacketBuilder.TYPE_ICMP_V6 : EchoPacketBuilder.TYPE_ICMP_V4; setEchoPacketBuilder(new EchoPacketBuilder(type, "abcdefghijklmnopqrstuvwabcdefghi".getBytes())); }
Ping implements Runnable { public Ping(final InetAddress dest, final PingListener listener) { mDest = dest; if (listener == null) { throw new NullPointerException(); } mListener = listener; final byte type = dest instanceof Inet6Address ? EchoPacketBuilder.TYPE_ICMP_V6 : EchoPacketBuilder.TYPE_ICMP_V4; setEchoPacketBuilder(new EchoPacketBuilder(type, "abcdefghijklmnopqrstuvwabcdefghi".getBytes())); } }
Ping implements Runnable { public Ping(final InetAddress dest, final PingListener listener) { mDest = dest; if (listener == null) { throw new NullPointerException(); } mListener = listener; final byte type = dest instanceof Inet6Address ? EchoPacketBuilder.TYPE_ICMP_V6 : EchoPacketBuilder.TYPE_ICMP_V4; setEchoPacketBuilder(new EchoPacketBuilder(type, "abcdefghijklmnopqrstuvwabcdefghi".getBytes())); } Ping(final InetAddress dest, final PingListener listener); }
Ping implements Runnable { public Ping(final InetAddress dest, final PingListener listener) { mDest = dest; if (listener == null) { throw new NullPointerException(); } mListener = listener; final byte type = dest instanceof Inet6Address ? EchoPacketBuilder.TYPE_ICMP_V6 : EchoPacketBuilder.TYPE_ICMP_V4; setEchoPacketBuilder(new EchoPacketBuilder(type, "abcdefghijklmnopqrstuvwabcdefghi".getBytes())); } Ping(final InetAddress dest, final PingListener listener); void setTimeoutMs(final int timeoutMs); int getTimeoutMs(); int getDelayMs(); void setDelayMs(final int delayMs); int getCount(); void setCount(final int count); Network getNetwork(); void setNetwork(final Network network); void setEchoPacketBuilder(final EchoPacketBuilder echoPacketBuilder); @Override void run(); }
Ping implements Runnable { public Ping(final InetAddress dest, final PingListener listener) { mDest = dest; if (listener == null) { throw new NullPointerException(); } mListener = listener; final byte type = dest instanceof Inet6Address ? EchoPacketBuilder.TYPE_ICMP_V6 : EchoPacketBuilder.TYPE_ICMP_V4; setEchoPacketBuilder(new EchoPacketBuilder(type, "abcdefghijklmnopqrstuvwabcdefghi".getBytes())); } Ping(final InetAddress dest, final PingListener listener); void setTimeoutMs(final int timeoutMs); int getTimeoutMs(); int getDelayMs(); void setDelayMs(final int delayMs); int getCount(); void setCount(final int count); Network getNetwork(); void setNetwork(final Network network); void setEchoPacketBuilder(final EchoPacketBuilder echoPacketBuilder); @Override void run(); static final int DEFAULT_COUNT; static final long TIMED_OUT_MS; }