com.eclipsesource.restfuse
Class Destination

java.lang.Object
  extended by com.eclipsesource.restfuse.Destination
All Implemented Interfaces:
org.junit.rules.TestRule

public class Destination
extends java.lang.Object
implements org.junit.rules.TestRule

A Destination marks a requirement for http tests. Before you can use the HttpTest annotation you need to instantiate a Destination in your TestCase. This rule does manage the HttpTest and the Callback annotations of your test methods.

A Destination needs an url during instantiation. This url will be used within a TestCase to send requests to. If the url is not valid an IllegalArgumentException will be thrown.

A simple test looks like this:

 @RunWith( HttpJUnitRunner.class )
 public class Example {
 
   @Rule
   public Destination destination = new Destination( "http://localhost" );
    
   @Context
   private Response response;
 
   @HttpTest( method = Method.GET, path = "/test" ) 
   public void testMethod() {
     com.eclipsesource.restfuse.Assert.assertAccepted( response );
   }
 }
 

See Also:
HttpTest, Callback

Constructor Summary
Destination(java.lang.Object testObject, java.lang.String baseUrl)
          Constructs a new Destination object.
Destination(java.lang.Object testObject, java.lang.String baseUrl, java.lang.String proxyHost, int proxyPort)
          Constructs a new Destination object and sets some proxy properties which will be used when sending the HTTP request.
 
Method Summary
 org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
           
 RequestContext getRequestContext()
          Access to context to define additional request properties at runtime
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Destination

public Destination(java.lang.Object testObject,
                   java.lang.String baseUrl)

Constructs a new Destination object. An url is needed as parameter which will be used in the whole test to send requests to.

Parameters:
baseUrl - The url to send requests to.
Throws:
java.lang.IllegalArgumentException - Will be thrown when the baseUrl is null or not a valid url.

Destination

public Destination(java.lang.Object testObject,
                   java.lang.String baseUrl,
                   java.lang.String proxyHost,
                   int proxyPort)

Constructs a new Destination object and sets some proxy properties which will be used when sending the HTTP request. An url is needed as parameter which will be used in the whole test to send requests to. The passed proxy properties has to conform with the proxy properties described here http://docs.oracle.com/javase/1.5.0/docs/guide/net/properties.html

Parameters:
baseUrl - The url to send requests to.
proxyHost - The value of the http.proxyHost property.
proxyPort - The value of the http.proxyPort property.
Throws:
java.lang.IllegalArgumentException - Will be thrown when the baseUrl is null or not a valid url.
Method Detail

apply

public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base,
                                               org.junit.runner.Description description)
Specified by:
apply in interface org.junit.rules.TestRule

getRequestContext

public RequestContext getRequestContext()
Access to context to define additional request properties at runtime

Returns:
context to be manipulated