org.apache.sling.testing.tools.http

## Class RequestExecutor

- java.lang.Object
- - org.apache.sling.testing.tools.http.RequestExecutor

    public class RequestExecutor
    extends Object

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

### Constructor Summary

Constructors
Constructor and Description
`RequestExecutor(org.apache.http.impl.client.DefaultHttpClient client)`

### Method Summary

All Methods Instance Methods Concrete Methods
`RequestExecutor` `assertContentContains(String... expected)` For each supplied string, fail unless content contains it
`RequestExecutor` `assertContentRegexp(String... regexp)` For each supplied regexp, fail unless content contains at least one line that matches.
`RequestExecutor` `assertContentType(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, String... metadata)`
`String` `getContent()`
`org.apache.http.HttpEntity` `getEntity()`
`org.apache.http.client.methods.HttpUriRequest` `getRequest()`
`org.apache.http.HttpResponse` `getResponse()`
`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 String toString()

Overrides:
  `toString` in class `Object`

#### execute

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

Throws:
  `org.apache.http.client.ClientProtocolException`
  `IOException`

#### consumeEntity

    protected void consumeEntity()
                          throws org.apache.http.ParseException,
                                 IOException

Can be overridden to consume in a different way, or not at all

Throws:
  `org.apache.http.ParseException`
  `IOException`

#### clear

    protected void clear()

#### assertStatus

    public RequestExecutor assertStatus(int expected)

Verify that response matches supplied status

#### assertContentType

    public RequestExecutor assertContentType(String expected)

Verify that response matches supplied content type

#### assertContentRegexp

    public RequestExecutor assertContentRegexp(String... regexp)
                                        throws 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:
  `IOException`

#### assertContentContains

    public RequestExecutor assertContentContains(String... expected)
                                          throws org.apache.http.ParseException,
                                                 IOException

For each supplied string, fail unless content contains it

Throws:
  `org.apache.http.ParseException`
  `IOException`

#### generateDocumentation

    public void generateDocumentation(RequestDocumentor documentor,
                                      String... metadata)
                               throws IOException

Throws:
  `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 String getContent()