Package akka.http.javadsl.testkit
Class TestRouteResult
java.lang.Object
akka.http.javadsl.testkit.TestRouteResult
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
ConstructorDescriptionTestRouteResult
(scala.concurrent.Future<RouteResult> _result, scala.concurrent.duration.FiniteDuration awaitAtMost, scala.concurrent.ExecutionContext ec, akka.stream.Materializer materializer) -
Method Summary
Modifier and TypeMethodDescriptionassertContentType
(ContentType expected) Assert on the content type of the response.assertContentType
(String expected) Assert on the content type of the response.assertEntity
(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
.assertEntityBytes
(akka.util.ByteString expected) Assert on the response entity to equal the given bytes.protected abstract void
assertEquals
(int expected, int actual, String message) protected abstract void
assertEquals
(Object expected, Object actual, String message) protected TestRouteResult
assertEqualsKind
(int expected, int actual, String kind) protected TestRouteResult
assertEqualsKind
(Object expected, Object actual, String kind) assertHeaderExists
(HttpHeader expected) Assert that a given header instance exists in the response.assertHeaderExists
(String name, String value) Assert that a header of the given name and value exists.assertHeaderKindExists
(String name) Assert that a header of the given type exists.Assert that a header of the given type does not exist.assertMediaType
(MediaType expected) Assert on the media type of the response.assertMediaType
(String expected) Assert on the media type of the response.assertRejections
(Rejection... expectedRejections) Assert that a given header instance exists in the response.assertRejections
(scala.collection.immutable.Seq<Rejection> expectedRejections) assertStatusCode
(int expected) Assert on the numeric status code.assertStatusCode
(StatusCode expected) Assert on the status code.protected abstract void
assertTrue
(boolean predicate, String message) Returns the response's content-typeReturns a string representation of the response's content-typeentity()
<T> T
entity
(Unmarshaller<HttpEntity, T> unmarshaller) Returns the entity of the response unmarshalled with the givenUnmarshaller
.
akka.util.ByteString
Returns the bytes of the response entityReturns the entity of the response interpreted as an UTF-8 encoded string.protected abstract void
<T extends HttpHeader>
TReturns the first header of the response which is of the given class.Returns the media-type of the the response's content-typeReturns a string representation of the media-type of the response's content-typeExpects the route to have been rejected with a single rejection.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.response()
status()
Returns theStatusCode
of the response.int
Returns the numeric status code of the response.
-
Constructor Details
-
TestRouteResult
public TestRouteResult(scala.concurrent.Future<RouteResult> _result, scala.concurrent.duration.FiniteDuration awaitAtMost, scala.concurrent.ExecutionContext ec, akka.stream.Materializer materializer)
-
-
Method Details
-
assertContentType
Assert on the content type of the response.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertContentType
Assert on the content type of the response.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertEntity
Assert on the response entity to be a UTF8 representation of the given string.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertEntityAs
Assert on the response entity to equal the given object after applying anUnmarshaller
.- Parameters:
unmarshaller
- (undocumented)expected
- (undocumented)- Returns:
- (undocumented)
-
assertEntityBytes
Assert on the response entity to equal the given bytes.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertEquals
-
assertEquals
-
assertEqualsKind
-
assertEqualsKind
-
assertHeaderExists
Assert that a header of the given name and value exists.- Parameters:
name
- (undocumented)value
- (undocumented)- Returns:
- (undocumented)
-
assertHeaderExists
Assert that a given header instance exists in the response.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertHeaderKindExists
Assert that a header of the given type exists.- Parameters:
name
- (undocumented)- Returns:
- (undocumented)
-
assertHeaderKindNotExists
Assert that a header of the given type does not exist.- Parameters:
name
- (undocumented)- Returns:
- (undocumented)
-
assertMediaType
Assert on the media type of the response.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertMediaType
Assert on the media type of the response.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertRejections
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
Assert on the numeric status code.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertStatusCode
Assert on the status code.- Parameters:
expected
- (undocumented)- Returns:
- (undocumented)
-
assertTrue
-
contentType
Returns the response's content-type- Returns:
- (undocumented)
-
contentTypeString
Returns a string representation of the response's content-type- Returns:
- (undocumented)
-
entity
-
entity
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
Returns the entity of the response interpreted as an UTF-8 encoded string.- Returns:
- (undocumented)
-
fail
-
header
Returns the first header of the response which is of the given class.- Parameters:
clazz
- (undocumented)- Returns:
- (undocumented)
-
mediaType
Returns the media-type of the the response's content-type- Returns:
- (undocumented)
-
mediaTypeString
Returns a string representation of the media-type of the response's content-type- Returns:
- (undocumented)
-
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
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
-
status
Returns theStatusCode
of the response.- Returns:
- (undocumented)
-
statusCode
public int statusCode()Returns the numeric status code of the response.- Returns:
- (undocumented)
-