org.jboss.resteasy.test
Class TestPortProvider

java.lang.Object
  extended by org.jboss.resteasy.test.TestPortProvider

public class TestPortProvider
extends java.lang.Object

Utility class that provides a port number for the Resteasy embedded container.

Version:
$Revision: 673 $
Author:
Justin Edelson

Constructor Summary
TestPortProvider()
           
 
Method Summary
static ClientRequest createClientRequest(ClientRequestFactory factory, java.lang.String path)
           
static ClientRequest createClientRequest(java.lang.String path)
          Create a Resteasy ClientRequest object using the configured port.
static org.apache.commons.httpclient.methods.DeleteMethod createDeleteMethod(java.lang.String path)
          Create a commons-httpclient DeleteMethod object.
static org.apache.commons.httpclient.methods.GetMethod createGetMethod(java.lang.String path)
          Create a commons-httpclient GetMethod object.
static org.apache.commons.httpclient.methods.OptionsMethod createOptionsMethod(java.lang.String path)
          Create a commons-httpclient OptionsMethod object.
static org.apache.commons.httpclient.methods.PostMethod createPostMethod(java.lang.String path)
          Create a commons-httpclient PostMethod object.
static
<T> T
createProxy(java.lang.Class<T> clazz)
          Create a Resteasy client proxy with an empty base request path.
static
<T> T
createProxy(java.lang.Class<T> clazz, java.lang.String path)
          Create a Resteasy client proxy.
static org.apache.commons.httpclient.methods.PutMethod createPutMethod(java.lang.String path)
          Create a commons-httpclient PutMethod object.
static java.net.URI createURI(java.lang.String path)
          Create a URI for the provided path, using the configured port
static java.net.URL createURL(java.lang.String path)
          Create a URL for the provided path, using the configured port
static java.lang.String generateBaseUrl()
          Generate a base URL incorporating the configured port.
static java.lang.String generateURL(java.lang.String path)
          Generate a URL incorporating the configured port.
static int getPort()
          Look up the configured port number, first checking an environment variable (RESTEASY_PORT), then a system property (org.jboss.resteasy.port), and finally the default port (8081).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestPortProvider

public TestPortProvider()
Method Detail

createClientRequest

public static ClientRequest createClientRequest(java.lang.String path)
Create a Resteasy ClientRequest object using the configured port.

Parameters:
path - the request path
Returns:
the ClientRequest object

createClientRequest

public static ClientRequest createClientRequest(ClientRequestFactory factory,
                                                java.lang.String path)

createDeleteMethod

public static org.apache.commons.httpclient.methods.DeleteMethod createDeleteMethod(java.lang.String path)
Create a commons-httpclient DeleteMethod object.

Parameters:
path - the request path
Returns:
a DeleteMethod object

createGetMethod

public static org.apache.commons.httpclient.methods.GetMethod createGetMethod(java.lang.String path)
Create a commons-httpclient GetMethod object.

Parameters:
path - the request path
Returns:
a GetMethod object

createOptionsMethod

public static org.apache.commons.httpclient.methods.OptionsMethod createOptionsMethod(java.lang.String path)
Create a commons-httpclient OptionsMethod object.

Parameters:
path - the request path
Returns:
an OptionsMethod object

createPostMethod

public static org.apache.commons.httpclient.methods.PostMethod createPostMethod(java.lang.String path)
Create a commons-httpclient PostMethod object.

Parameters:
path - the request path
Returns:
a PostMethod object

createProxy

public static <T> T createProxy(java.lang.Class<T> clazz)
Create a Resteasy client proxy with an empty base request path.

Parameters:
clazz - the client interface class
Returns:
the proxy object

createProxy

public static <T> T createProxy(java.lang.Class<T> clazz,
                                java.lang.String path)
Create a Resteasy client proxy.

Parameters:
clazz - the client interface class
Returns:
the proxy object

createPutMethod

public static org.apache.commons.httpclient.methods.PutMethod createPutMethod(java.lang.String path)
Create a commons-httpclient PutMethod object.

Parameters:
path - the request path
Returns:
a PutMethod object

createURI

public static java.net.URI createURI(java.lang.String path)
Create a URI for the provided path, using the configured port

Parameters:
path - the request path
Returns:
a full URI

createURL

public static java.net.URL createURL(java.lang.String path)
                              throws java.net.MalformedURLException
Create a URL for the provided path, using the configured port

Parameters:
path - the request path
Returns:
a full URL
Throws:
java.net.MalformedURLException

generateBaseUrl

public static java.lang.String generateBaseUrl()
Generate a base URL incorporating the configured port.

Returns:
a full URL

generateURL

public static java.lang.String generateURL(java.lang.String path)
Generate a URL incorporating the configured port.

Parameters:
path - the path
Returns:
a full URL

getPort

public static int getPort()
Look up the configured port number, first checking an environment variable (RESTEASY_PORT), then a system property (org.jboss.resteasy.port), and finally the default port (8081).

Returns:
the port number specified in either the environment or system properties


Copyright © 2009. All Rights Reserved.