HttpAsserts
which has no TestNG dependencies
(or HttpTool
for some utility methods).@Deprecated
public class HttpTestUtils
extends java.lang.Object
Constructor and Description |
---|
HttpTestUtils()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static <any> |
assertAsyncHttpStatusCodeContinuallyEquals(ListeningExecutorService executor,
java.lang.String url,
int expectedStatusCode)
Deprecated.
Schedules (with the given executor) a poller that repeatedly accesses the given url, to confirm it always gives
back the expected status code.
|
static void |
assertContentContainsText(java.lang.String url,
java.lang.String phrase,
java.lang.String... additionalPhrases)
Deprecated.
|
static void |
assertContentEventuallyContainsText(java.util.Map<java.lang.String,?> flags,
java.lang.String url,
java.lang.String phrase,
java.lang.String... additionalPhrases)
Deprecated.
|
static void |
assertContentEventuallyContainsText(java.lang.String url,
java.lang.String phrase,
java.lang.String... additionalPhrases)
Deprecated.
|
static void |
assertContentEventuallyMatches(java.util.Map<java.lang.String,?> flags,
java.lang.String url,
java.lang.String regex)
Deprecated.
|
static void |
assertContentEventuallyMatches(java.lang.String url,
java.lang.String regex)
Deprecated.
|
static void |
assertContentMatches(java.lang.String url,
java.lang.String regex)
Deprecated.
|
static void |
assertContentNotContainsText(java.lang.String url,
java.lang.String phrase,
java.lang.String... additionalPhrases)
Deprecated.
|
static void |
assertErrorContentContainsText(java.lang.String url,
java.lang.String phrase,
java.lang.String... additionalPhrases)
Deprecated.
|
static void |
assertErrorContentNotContainsText(java.lang.String url,
java.lang.String phrase,
java.lang.String... additionalPhrases)
Deprecated.
|
static void |
assertHealthyStatusCode(int code)
Deprecated.
|
static void |
assertHttpStatusCodeEquals(java.lang.String url,
int... acceptableReturnCodes)
Deprecated.
|
static void |
assertHttpStatusCodeEventuallyEquals(java.util.Map<java.lang.String,?> flags,
java.lang.String url,
int expectedCode)
Deprecated.
|
static void |
assertHttpStatusCodeEventuallyEquals(java.lang.String url,
int expectedCode)
Deprecated.
|
static void |
assertUrlReachable(java.lang.String url)
Deprecated.
Asserts that gets back any "valid" response - i.e.
|
static void |
assertUrlUnreachable(java.lang.String url)
Deprecated.
|
static void |
assertUrlUnreachableEventually(java.util.Map<java.lang.String,?> flags,
java.lang.String url)
Deprecated.
|
static void |
assertUrlUnreachableEventually(java.lang.String url)
Deprecated.
|
static void |
closeQuietly(java.net.HttpURLConnection connection)
Deprecated.
Closes all streams of the connection, and disconnects it.
|
static java.net.URLConnection |
connectToUrl(java.lang.String u)
Deprecated.
Connects to the given url and returns the connection.
|
static void |
consumeAndCloseQuietly(java.net.HttpURLConnection connection)
Deprecated.
Consumes the input stream entirely and then cleanly closes the connection.
|
static java.lang.String |
getContent(java.lang.String url)
Deprecated.
|
static java.lang.String |
getErrorContent(java.lang.String url)
Deprecated.
|
static int |
getHttpStatusCode(java.lang.String url)
Deprecated.
|
public static java.net.URLConnection connectToUrl(java.lang.String u) throws java.lang.Exception
connection.getInputStream().close()
the result of this
(especially if they are making heavy use of this method).java.lang.Exception
public static void assertHealthyStatusCode(int code)
public static int getHttpStatusCode(java.lang.String url) throws java.lang.Exception
java.lang.Exception
public static void assertUrlReachable(java.lang.String url)
public static void assertUrlUnreachable(java.lang.String url)
public static void assertUrlUnreachableEventually(java.lang.String url)
public static void assertUrlUnreachableEventually(java.util.Map<java.lang.String,?> flags, java.lang.String url)
public static void assertHttpStatusCodeEquals(java.lang.String url, int... acceptableReturnCodes)
public static void assertHttpStatusCodeEventuallyEquals(java.lang.String url, int expectedCode)
public static void assertHttpStatusCodeEventuallyEquals(java.util.Map<java.lang.String,?> flags, java.lang.String url, int expectedCode)
public static void assertContentContainsText(java.lang.String url, java.lang.String phrase, java.lang.String... additionalPhrases)
public static void assertContentNotContainsText(java.lang.String url, java.lang.String phrase, java.lang.String... additionalPhrases)
public static void assertErrorContentContainsText(java.lang.String url, java.lang.String phrase, java.lang.String... additionalPhrases)
public static void assertErrorContentNotContainsText(java.lang.String url, java.lang.String phrase, java.lang.String... additionalPhrases)
public static void assertContentEventuallyContainsText(java.lang.String url, java.lang.String phrase, java.lang.String... additionalPhrases)
public static void assertContentEventuallyContainsText(java.util.Map<java.lang.String,?> flags, java.lang.String url, java.lang.String phrase, java.lang.String... additionalPhrases)
public static void assertContentMatches(java.lang.String url, java.lang.String regex)
public static void assertContentEventuallyMatches(java.lang.String url, java.lang.String regex)
public static void assertContentEventuallyMatches(java.util.Map<java.lang.String,?> flags, java.lang.String url, java.lang.String regex)
public static java.lang.String getErrorContent(java.lang.String url)
public static java.lang.String getContent(java.lang.String url)
public static <any> assertAsyncHttpStatusCodeContinuallyEquals(ListeningExecutorService executor, java.lang.String url, int expectedStatusCode)
Future<?> future = assertAsyncHttpStatusCodeContinuallyEquals(executor, url, 200);
// do other stuff...
if (future.isDone()) future.get(); // get exception if it's failed
For stopping it, you can either do future.cancel(true), or you can just do executor.shutdownNow().
TODO Look at difference between this and WebAppMonitor, to decide if this should be kept.public static void consumeAndCloseQuietly(java.net.HttpURLConnection connection)
public static void closeQuietly(java.net.HttpURLConnection connection)