Package akka.http.javadsl.testkit
Class TestRouteResult
- java.lang.Object
-
- akka.http.javadsl.testkit.TestRouteResult
-
public abstract class TestRouteResult extends java.lang.Object
A wrapper for route results.To support the testkit API, a third-party testing library needs to implement this class and provide implementations for the abstract assertion methods.
-
-
Constructor Summary
Constructors Constructor Description TestRouteResult(scala.concurrent.Future<RouteResult> _result, scala.concurrent.duration.FiniteDuration awaitAtMost, scala.concurrent.ExecutionContext ec, akka.stream.Materializer materializer)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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 anUnmarshaller
.TestRouteResult
assertEntityBytes(akka.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-typejava.lang.String
contentTypeString()
Returns a string representation of the response's content-typeHttpEntity.Strict
entity()
<T> T
entity(Unmarshaller<HttpEntity,T> unmarshaller)
Returns the entity of the response unmarshalled with the givenUnmarshaller
.
akka.util.ByteString
entityBytes()
Returns the bytes of the response entityjava.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>
Theader(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 the response's content-typejava.lang.String
mediaTypeString()
Returns a string representation of the media-type of the response's content-typeRejection
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 theStatusCode
of the response.int
statusCode()
Returns the numeric status code of the response.
-
-
-
Constructor Detail
-
TestRouteResult
public TestRouteResult(scala.concurrent.Future<RouteResult> _result, scala.concurrent.duration.FiniteDuration awaitAtMost, scala.concurrent.ExecutionContext ec, akka.stream.Materializer materializer)
-
-
Method Detail
-
assertContentType
public TestRouteResult assertContentType(java.lang.String expected)
Assert on the content type of the response.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertContentType
public TestRouteResult assertContentType(ContentType expected)
Assert on the content type of the response.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertEntity
public TestRouteResult assertEntity(java.lang.String expected)
Assert on the response entity to be a UTF8 representation of the given string.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertEntityAs
public <T> TestRouteResult assertEntityAs(Unmarshaller<HttpEntity,T> unmarshaller, T expected)
Assert on the response entity to equal the given object after applying anUnmarshaller
.- Parameters:
unmarshaller
- (undocumented)expected
- (undocumented)- Returns:
- (undocumented)
-
assertEntityBytes
public TestRouteResult assertEntityBytes(akka.util.ByteString expected)
Assert on the response entity to equal the given bytes.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertEquals
protected abstract void assertEquals(java.lang.Object expected, java.lang.Object actual, java.lang.String message)
-
assertEquals
protected abstract void assertEquals(int expected, int actual, java.lang.String message)
-
assertEqualsKind
protected TestRouteResult assertEqualsKind(java.lang.Object expected, java.lang.Object actual, java.lang.String kind)
-
assertEqualsKind
protected TestRouteResult assertEqualsKind(int expected, int actual, java.lang.String kind)
-
assertHeaderExists
public TestRouteResult assertHeaderExists(java.lang.String name, java.lang.String value)
Assert that a header of the given name and value exists.- Parameters:
name
- (undocumented)value
- (undocumented)- Returns:
- (undocumented)
-
assertHeaderExists
public TestRouteResult assertHeaderExists(HttpHeader expected)
Assert that a given header instance exists in the response.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertHeaderKindExists
public TestRouteResult assertHeaderKindExists(java.lang.String name)
Assert that a header of the given type exists.- Parameters:
name
- (undocumented)- Returns:
- (undocumented)
-
assertHeaderKindNotExists
public TestRouteResult assertHeaderKindNotExists(java.lang.String name)
Assert that a header of the given type does not exist.- Parameters:
name
- (undocumented)- Returns:
- (undocumented)
-
assertMediaType
public TestRouteResult assertMediaType(java.lang.String expected)
Assert on the media type of the response.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertMediaType
public TestRouteResult assertMediaType(MediaType expected)
Assert on the media type of the response.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertRejections
public TestRouteResult assertRejections(Rejection... expectedRejections)
Assert that a given header instance exists in the response.- Parameters:
expectedRejections
- (undocumented)- Returns:
- (undocumented)
-
assertRejections
public TestRouteResult assertRejections(scala.collection.immutable.Seq<Rejection> expectedRejections)
-
assertStatusCode
public TestRouteResult assertStatusCode(int expected)
Assert on the numeric status code.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertStatusCode
public TestRouteResult assertStatusCode(StatusCode expected)
Assert on the status code.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertTrue
protected abstract void assertTrue(boolean predicate, java.lang.String message)
-
contentType
public ContentType contentType()
Returns the response's content-type- Returns:
- (undocumented)
-
contentTypeString
public java.lang.String contentTypeString()
Returns a string representation of the response's content-type- Returns:
- (undocumented)
-
entity
public HttpEntity.Strict entity()
-
entity
public <T> T entity(Unmarshaller<HttpEntity,T> unmarshaller)
Returns the entity of the response unmarshalled with the givenUnmarshaller
.
- Parameters:
unmarshaller
- (undocumented)- Returns:
- (undocumented)
-
entityBytes
public akka.util.ByteString entityBytes()
Returns the bytes of the response entity- Returns:
- (undocumented)
-
entityString
public java.lang.String entityString()
Returns the entity of the response interpreted as an UTF-8 encoded string.- Returns:
- (undocumented)
-
fail
protected abstract void fail(java.lang.String message)
-
header
public <T extends HttpHeader> T header(java.lang.Class<T> clazz)
Returns the first header of the response which is of the given class.- Parameters:
clazz
- (undocumented)- Returns:
- (undocumented)
-
mediaType
public MediaType mediaType()
Returns the media-type of the the response's content-type- Returns:
- (undocumented)
-
mediaTypeString
public java.lang.String mediaTypeString()
Returns a string representation of the media-type of the response's content-type- Returns:
- (undocumented)
-
rejection
public Rejection rejection()
Expects the route to have been rejected with a single rejection. Fails the test if the route completes with a response, or is rejected with 0 or >1 rejections.- Returns:
- (undocumented)
-
rejections
public 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. Fails the test if the route completes with a response rather than having been rejected.- Returns:
- (undocumented)
-
response
public HttpResponse response()
-
status
public StatusCode status()
Returns theStatusCode
of the response.- Returns:
- (undocumented)
-
statusCode
public int statusCode()
Returns the numeric status code of the response.- Returns:
- (undocumented)
-
-