org.apache.sling.testing.tools.http
Class RequestExecutor

java.lang.Object
  extended by org.apache.sling.testing.tools.http.RequestExecutor

public class RequestExecutor
extends java.lang.Object

Executes a Request and provides convenience methods to validate the results.


Constructor Summary
RequestExecutor(org.apache.http.impl.client.DefaultHttpClient client)
           
 
Method Summary
 RequestExecutor assertContentContains(java.lang.String... expected)
          For each supplied string, fail unless content contains it
 RequestExecutor assertContentRegexp(java.lang.String... regexp)
          For each supplied regexp, fail unless content contains at least one line that matches.
 RequestExecutor assertContentType(java.lang.String expected)
          Verify that response matches supplied content type
 RequestExecutor assertStatus(int expected)
          Verify that response matches supplied status
protected  void clear()
           
protected  void consumeEntity()
          Can be overridden to consume in a different way, or not at all
 RequestExecutor execute(Request r)
           
 void generateDocumentation(RequestDocumentor documentor, java.lang.String... metadata)
           
 java.lang.String getContent()
           
 org.apache.http.HttpEntity getEntity()
           
 org.apache.http.client.methods.HttpUriRequest getRequest()
           
 org.apache.http.HttpResponse getResponse()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RequestExecutor

public RequestExecutor(org.apache.http.impl.client.DefaultHttpClient client)
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

execute

public RequestExecutor execute(Request r)
                        throws org.apache.http.client.ClientProtocolException,
                               java.io.IOException
Throws:
org.apache.http.client.ClientProtocolException
java.io.IOException

consumeEntity

protected void consumeEntity()
                      throws org.apache.http.ParseException,
                             java.io.IOException
Can be overridden to consume in a different way, or not at all

Throws:
org.apache.http.ParseException
java.io.IOException

clear

protected void clear()

assertStatus

public RequestExecutor assertStatus(int expected)
Verify that response matches supplied status


assertContentType

public RequestExecutor assertContentType(java.lang.String expected)
Verify that response matches supplied content type


assertContentRegexp

public RequestExecutor assertContentRegexp(java.lang.String... regexp)
                                    throws java.io.IOException
For each supplied regexp, fail unless content contains at least one line that matches. Regexps are automatically prefixed/suffixed with .* so as to have match partial lines.

Throws:
java.io.IOException

assertContentContains

public RequestExecutor assertContentContains(java.lang.String... expected)
                                      throws org.apache.http.ParseException,
                                             java.io.IOException
For each supplied string, fail unless content contains it

Throws:
org.apache.http.ParseException
java.io.IOException

generateDocumentation

public void generateDocumentation(RequestDocumentor documentor,
                                  java.lang.String... metadata)
                           throws java.io.IOException
Throws:
java.io.IOException

getRequest

public org.apache.http.client.methods.HttpUriRequest getRequest()

getResponse

public org.apache.http.HttpResponse getResponse()

getEntity

public org.apache.http.HttpEntity getEntity()

getContent

public java.lang.String getContent()


Copyright © 2007-2011 The Apache Software Foundation. All Rights Reserved.