org.jmx4odp.junitDiagnosticWorkers
Class HttpClientTest

java.lang.Object
  extended by TestCase
      extended by org.jmx4odp.junitDiagnosticWorkers.HttpClientTest
Direct Known Subclasses:
BasicHttpUrlTest, HttpClientTestExample

public class HttpClientTest
extends TestCase

Extend or implement this test class for tests of HTTP services

Author:
Lucas McGregor

Constructor Summary
HttpClientTest()
          Creates a new instance of HttpClient
 
Method Summary
static void assertHttpAccepted(java.net.HttpURLConnection con)
          assertTrue for isHttpStatus(con, java.net.HttpURLConnection.HTTP_ACCEPTED)
static void assertHttpForbidden(java.net.HttpURLConnection con)
          assertTrue for isHttpStatus(con, java.net.HttpURLConnection.HTTP_FORBIDDEN)
static void assertHttpMovedPerm(java.net.HttpURLConnection con)
          assertTrue for isHttpStatus(con, java.net.HttpURLConnection.HTTP_MOVED_PERM)
static void assertHttpMovedTemp(java.net.HttpURLConnection con)
          assertTrue for isHttpStatus(con, java.net.HttpURLConnection.HTTP_MOVED_TEMP)
static void assertHttpNoString(java.net.HttpURLConnection con, java.lang.String pattern)
          asserts true if the content returned from the HttpURLConnection does not contain the string anywhere in it.
static void assertHttpNotFound(java.net.HttpURLConnection con)
          assertTrue for isHttpStatus(con, java.net.HttpURLConnection.HTTP_NOT_FOUND)
static void assertHttpOk(java.net.HttpURLConnection con)
          assertTrue for isHttpStatus(con, java.net.HttpURLConnection.HTTP_OK)
static void assertHttpString(java.net.HttpURLConnection con, java.lang.String pattern)
          asserts true if the content returned from the HttpURLConnection contains the string anywhere in it.
 java.net.HttpURLConnection getUrlConnection(java.lang.String s)
          Get a HttpConnection object based on the URL from the string.
 java.net.HttpURLConnection getUrlConnection(java.net.URL url)
          Get a HttpConnection object based on the URL.
static boolean isHttpStatus(java.net.HttpURLConnection con, int status)
          returns a true if the HttpUrlConnection status is the same as the status passed in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpClientTest

public HttpClientTest()
Creates a new instance of HttpClient

Method Detail

getUrlConnection

public java.net.HttpURLConnection getUrlConnection(java.lang.String s)
                                            throws java.lang.Exception
Get a HttpConnection object based on the URL from the string. It needs to be an HTTP URL.

Throws:
java.lang.Exception

getUrlConnection

public java.net.HttpURLConnection getUrlConnection(java.net.URL url)
                                            throws java.lang.Exception
Get a HttpConnection object based on the URL. I tneeds to be an HTTP URL.

Throws:
java.lang.Exception

isHttpStatus

public static boolean isHttpStatus(java.net.HttpURLConnection con,
                                   int status)
returns a true if the HttpUrlConnection status is the same as the status passed in.


assertHttpOk

public static void assertHttpOk(java.net.HttpURLConnection con)
assertTrue for isHttpStatus(con, java.net.HttpURLConnection.HTTP_OK)


assertHttpAccepted

public static void assertHttpAccepted(java.net.HttpURLConnection con)
assertTrue for isHttpStatus(con, java.net.HttpURLConnection.HTTP_ACCEPTED)


assertHttpForbidden

public static void assertHttpForbidden(java.net.HttpURLConnection con)
assertTrue for isHttpStatus(con, java.net.HttpURLConnection.HTTP_FORBIDDEN)


assertHttpMovedPerm

public static void assertHttpMovedPerm(java.net.HttpURLConnection con)
assertTrue for isHttpStatus(con, java.net.HttpURLConnection.HTTP_MOVED_PERM)


assertHttpMovedTemp

public static void assertHttpMovedTemp(java.net.HttpURLConnection con)
assertTrue for isHttpStatus(con, java.net.HttpURLConnection.HTTP_MOVED_TEMP)


assertHttpNotFound

public static void assertHttpNotFound(java.net.HttpURLConnection con)
assertTrue for isHttpStatus(con, java.net.HttpURLConnection.HTTP_NOT_FOUND)


assertHttpString

public static void assertHttpString(java.net.HttpURLConnection con,
                                    java.lang.String pattern)
asserts true if the content returned from the HttpURLConnection contains the string anywhere in it.


assertHttpNoString

public static void assertHttpNoString(java.net.HttpURLConnection con,
                                      java.lang.String pattern)
asserts true if the content returned from the HttpURLConnection does not contain the string anywhere in it.