Package patterntesting.runtime.junit
Class NetworkTester
- java.lang.Object
-
- patterntesting.runtime.junit.NetworkTester
-
public final class NetworkTester extends java.lang.Object
With the NetworkTester you can assert if a host is online or offline.- Since:
- 1.8 (26.07.2017)
- Version:
- $Revision: 1.11 $
- Author:
- oboehm
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
assertExists(java.net.URI uri)
Asserts, that the given URI exists and is reachable.static void
assertExists(java.net.URL url)
Asserts, that the given URL exists and is reachable.static void
assertOffline(java.lang.String host)
Asserts, that the given host is offline.static void
assertOffline(java.lang.String host, int port)
Asserts, that the port of the given host is offline.static void
assertOffline(java.lang.String host, int time, java.util.concurrent.TimeUnit unit)
Asserts, that the given host is offline.static void
assertOffline(java.net.InetAddress host)
Asserts, that the given host is offline.static void
assertOffline(java.net.InetAddress host, int port)
Asserts, that the port of the given host is offline.static void
assertOffline(java.net.InetAddress host, int time, java.util.concurrent.TimeUnit unit)
Asserts, that the given host is offline.static void
assertOffline(java.net.InetSocketAddress host)
Asserts, that the socket address is offline.static void
assertOnline(java.lang.String host)
Asserts, that the given host is online.static void
assertOnline(java.lang.String host, int port)
Asserts, that the given host is online at the given port.static void
assertOnline(java.lang.String host, int time, java.util.concurrent.TimeUnit unit)
Asserts, that the given host is online.static void
assertOnline(java.net.InetAddress host)
Asserts, that the given host is online.static void
assertOnline(java.net.InetAddress host, int port)
Asserts, that the given host is online at the given port.static void
assertOnline(java.net.InetAddress host, int time, java.util.concurrent.TimeUnit unit)
Asserts, that the given host is online.static void
assertOnline(java.net.InetSocketAddress host)
Asserts, that the socket address is online.static boolean
exists(java.net.URI uri)
Checks, if the given URI exists and is reachable.static boolean
exists(java.net.URL url)
Checks, if the given URL exists and is reachable.static boolean
isOnline(java.lang.String host)
Checks if the given host is online.static boolean
isOnline(java.lang.String host, int port)
Checks if the given host is online.static boolean
isOnline(java.lang.String host, int time, java.util.concurrent.TimeUnit unit)
Checks if the given host is online.
-
-
-
Method Detail
-
assertOnline
public static void assertOnline(java.lang.String host)
Asserts, that the given host is online.- Parameters:
host
- the hostname or IP address
-
isOnline
public static boolean isOnline(java.lang.String host)
Checks if the given host is online.- Parameters:
host
- the hostname or IP address- Returns:
- true if host is online
- Since:
- 2.0
-
assertOnline
public static void assertOnline(java.lang.String host, int time, java.util.concurrent.TimeUnit unit)
Asserts, that the given host is online. The given time is the maximal time we try to connect to the given host.- Parameters:
host
- hostname or ip addresstime
- how long should we try to connect to host?unit
- the time unit
-
isOnline
public static boolean isOnline(java.lang.String host, int time, java.util.concurrent.TimeUnit unit)
Checks if the given host is online. The given time is the maximal time we try to connect to the given host.- Parameters:
host
- hostname or ip addresstime
- how long should we try to connect to host?unit
- the time unit- Returns:
- true if host is online
- Since:
- 2.0
-
assertOnline
public static void assertOnline(java.lang.String host, int port)
Asserts, that the given host is online at the given port.- Parameters:
host
- the hostname or IP addressport
- the port between 0 and 0xFFFF
-
assertOnline
public static void assertOnline(java.net.InetSocketAddress host)
Asserts, that the socket address is online.- Parameters:
host
- the hostname or IP address
-
assertOnline
public static void assertOnline(java.net.InetAddress host)
Asserts, that the given host is online.- Parameters:
host
- the IP address
-
assertOnline
public static void assertOnline(java.net.InetAddress host, int time, java.util.concurrent.TimeUnit unit)
Asserts, that the given host is online. The given time is the maximal time we try to connect to the given host.- Parameters:
host
- hostname or ip addresstime
- how long should we try to connect to host?unit
- the time unit
-
assertOnline
public static void assertOnline(java.net.InetAddress host, int port)
Asserts, that the given host is online at the given port.- Parameters:
host
- the IP addressport
- the port between 0 and 0xFFFF
-
isOnline
public static boolean isOnline(java.lang.String host, int port)
Checks if the given host is online.- Parameters:
host
- the hostname or IP addressport
- the port between 0 and 0xFFFF- Returns:
- true if host is online
- Since:
- 2.0.2
-
assertOffline
public static void assertOffline(java.lang.String host)
Asserts, that the given host is offline. This is the opposite ofassertOnline(String)
.- Parameters:
host
- the hostname or IP address
-
assertOffline
public static void assertOffline(java.lang.String host, int time, java.util.concurrent.TimeUnit unit)
Asserts, that the given host is offline. The given time is the maximal time we try to connect to the given host. Normally it takes about at least 8 minutes to realize that a host is offline. So if you want to wait a shorter time use this method.- Parameters:
host
- hostname or ip addresstime
- how long should we try to connect to host?unit
- the time unit
-
assertOffline
public static void assertOffline(java.lang.String host, int port)
Asserts, that the port of the given host is offline.- Parameters:
host
- the hostname or IP addressport
- the port between 0 and 0xFFFF
-
assertOffline
public static void assertOffline(java.net.InetSocketAddress host)
Asserts, that the socket address is offline.- Parameters:
host
- the hostname or IP address
-
assertOffline
public static void assertOffline(java.net.InetAddress host)
Asserts, that the given host is offline. This is the opposite ofassertOnline(InetAddress)
.- Parameters:
host
- the hostname or IP address
-
assertOffline
public static void assertOffline(java.net.InetAddress host, int time, java.util.concurrent.TimeUnit unit)
Asserts, that the given host is offline. The given time is the maximal time we try to connect to the given host. Normally it takes about at least 8 minutes to realize that a host is offline. So if you want to wait a shorter time use this method.- Parameters:
host
- hostname or ip addresstime
- how long should we try to connect to host?unit
- the time unit
-
assertOffline
public static void assertOffline(java.net.InetAddress host, int port)
Asserts, that the port of the given host is offline.- Parameters:
host
- the hostname or IP addressport
- the port between 0 and 0xFFFF
-
assertExists
public static void assertExists(java.net.URI uri)
Asserts, that the given URI exists and is reachable.- Parameters:
uri
- a valid URI
-
assertExists
public static void assertExists(java.net.URL url)
Asserts, that the given URL exists and is reachable.- Parameters:
url
- a valid URL
-
exists
public static boolean exists(java.net.URI uri)
Checks, if the given URI exists and is reachable.- Parameters:
uri
- a valid URI- Returns:
- true if uri exists
- Since:
- 2.0.2
-
exists
public static boolean exists(java.net.URL url)
Checks, if the given URL exists and is reachable.- Parameters:
url
- a valid URL- Returns:
- true if url exists
- Since:
- 2.0.2
-
-