public abstract class TestRouteResult
extends java.lang.Object
To support the testkit API, a third-party testing library needs to implement this class and provide implementations for the abstract assertion methods.
Constructor and Description |
---|
TestRouteResult(scala.concurrent.Future<RouteResult> _result,
scala.concurrent.duration.FiniteDuration awaitAtMost,
scala.concurrent.ExecutionContext ec,
org.apache.pekko.stream.Materializer materializer) |
Modifier and Type | Method and Description |
---|---|
TestRouteResult |
assertContentType(ContentType expected)
Assert on the content type of the response.
|
TestRouteResult |
assertContentType(java.lang.String expected)
Assert on the content type of the response.
|
TestRouteResult |
assertEntity(java.lang.String expected)
Assert on the response entity to be a UTF8 representation of the given string.
|
<T> TestRouteResult |
assertEntityAs(Unmarshaller<HttpEntity,T> unmarshaller,
T expected)
Assert on the response entity to equal the given object after applying an
pekko.http.javadsl.unmarshalling.Unmarshaller . |
TestRouteResult |
assertEntityBytes(org.apache.pekko.util.ByteString expected)
Assert on the response entity to equal the given bytes.
|
protected abstract void |
assertEquals(int expected,
int actual,
java.lang.String message) |
protected abstract void |
assertEquals(java.lang.Object expected,
java.lang.Object actual,
java.lang.String message) |
protected TestRouteResult |
assertEqualsKind(int expected,
int actual,
java.lang.String kind) |
protected TestRouteResult |
assertEqualsKind(java.lang.Object expected,
java.lang.Object actual,
java.lang.String kind) |
TestRouteResult |
assertHeaderExists(HttpHeader expected)
Assert that a given header instance exists in the response.
|
TestRouteResult |
assertHeaderExists(java.lang.String name,
java.lang.String value)
Assert that a header of the given name and value exists.
|
TestRouteResult |
assertHeaderKindExists(java.lang.String name)
Assert that a header of the given type exists.
|
TestRouteResult |
assertHeaderKindNotExists(java.lang.String name)
Assert that a header of the given type does not exist.
|
TestRouteResult |
assertMediaType(MediaType expected)
Assert on the media type of the response.
|
TestRouteResult |
assertMediaType(java.lang.String expected)
Assert on the media type of the response.
|
TestRouteResult |
assertRejections(Rejection... expectedRejections)
Assert that a given header instance exists in the response.
|
TestRouteResult |
assertRejections(scala.collection.immutable.Seq<Rejection> expectedRejections) |
TestRouteResult |
assertStatusCode(int expected)
Assert on the numeric status code.
|
TestRouteResult |
assertStatusCode(StatusCode expected)
Assert on the status code.
|
protected abstract void |
assertTrue(boolean predicate,
java.lang.String message) |
ContentType |
contentType()
Returns the response's content-type
|
java.lang.String |
contentTypeString()
Returns a string representation of the response's content-type
|
HttpEntity.Strict |
entity() |
<T> T |
entity(Unmarshaller<HttpEntity,T> unmarshaller)
Returns the entity of the response unmarshalled with the given
Unmarshaller . |
org.apache.pekko.util.ByteString |
entityBytes()
Returns the bytes of the response entity
|
java.lang.String |
entityString()
Returns the entity of the response interpreted as an UTF-8 encoded string.
|
protected abstract void |
fail(java.lang.String message) |
<T extends HttpHeader> |
header(java.lang.Class<T> clazz)
Returns the first header of the response which is of the given class.
|
MediaType |
mediaType()
Returns the media-type of the response's content-type
|
java.lang.String |
mediaTypeString()
Returns a string representation of the media-type of the response's content-type
|
Rejection |
rejection()
Expects the route to have been rejected with a single rejection.
|
java.util.List<Rejection> |
rejections()
Expects the route to have been rejected, returning the list of rejections, or empty list if the route
was rejected with an empty rejection list.
|
HttpResponse |
response() |
StatusCode |
status()
Returns the
pekko.http.javadsl.model.StatusCode of the response. |
int |
statusCode()
Returns the numeric status code of the response.
|
public TestRouteResult(scala.concurrent.Future<RouteResult> _result, scala.concurrent.duration.FiniteDuration awaitAtMost, scala.concurrent.ExecutionContext ec, org.apache.pekko.stream.Materializer materializer)
public TestRouteResult assertContentType(java.lang.String expected)
expected
- (undocumented)public TestRouteResult assertContentType(ContentType expected)
expected
- (undocumented)public TestRouteResult assertEntity(java.lang.String expected)
expected
- (undocumented)public <T> TestRouteResult assertEntityAs(Unmarshaller<HttpEntity,T> unmarshaller, T expected)
pekko.http.javadsl.unmarshalling.Unmarshaller
.unmarshaller
- (undocumented)expected
- (undocumented)public TestRouteResult assertEntityBytes(org.apache.pekko.util.ByteString expected)
expected
- (undocumented)protected abstract void assertEquals(java.lang.Object expected, java.lang.Object actual, java.lang.String message)
protected abstract void assertEquals(int expected, int actual, java.lang.String message)
protected TestRouteResult assertEqualsKind(java.lang.Object expected, java.lang.Object actual, java.lang.String kind)
protected TestRouteResult assertEqualsKind(int expected, int actual, java.lang.String kind)
public TestRouteResult assertHeaderExists(java.lang.String name, java.lang.String value)
name
- (undocumented)value
- (undocumented)public TestRouteResult assertHeaderExists(HttpHeader expected)
expected
- (undocumented)public TestRouteResult assertHeaderKindExists(java.lang.String name)
name
- (undocumented)public TestRouteResult assertHeaderKindNotExists(java.lang.String name)
name
- (undocumented)public TestRouteResult assertMediaType(java.lang.String expected)
expected
- (undocumented)public TestRouteResult assertMediaType(MediaType expected)
expected
- (undocumented)public TestRouteResult assertRejections(Rejection... expectedRejections)
expectedRejections
- (undocumented)public TestRouteResult assertRejections(scala.collection.immutable.Seq<Rejection> expectedRejections)
public TestRouteResult assertStatusCode(int expected)
expected
- (undocumented)public TestRouteResult assertStatusCode(StatusCode expected)
expected
- (undocumented)protected abstract void assertTrue(boolean predicate, java.lang.String message)
public ContentType contentType()
public java.lang.String contentTypeString()
public HttpEntity.Strict entity()
public <T> T entity(Unmarshaller<HttpEntity,T> unmarshaller)
Unmarshaller
.unmarshaller
- (undocumented)public org.apache.pekko.util.ByteString entityBytes()
public java.lang.String entityString()
protected abstract void fail(java.lang.String message)
public <T extends HttpHeader> T header(java.lang.Class<T> clazz)
clazz
- (undocumented)public MediaType mediaType()
public java.lang.String mediaTypeString()
public Rejection rejection()
public java.util.List<Rejection> rejections()
public HttpResponse response()
public StatusCode status()
pekko.http.javadsl.model.StatusCode
of the response.public int statusCode()