Package akka.http.javadsl.testkit
Class TestRouteResult
- java.lang.Object
-
- akka.http.javadsl.testkit.TestRouteResult
-
public abstract class TestRouteResult extends java.lang.ObjectA 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 TestRouteResultassertContentType(ContentType expected)Assert on the content type of the response.TestRouteResultassertContentType(java.lang.String expected)Assert on the content type of the response.TestRouteResultassertEntity(java.lang.String expected)Assert on the response entity to be a UTF8 representation of the given string.<T> TestRouteResultassertEntityAs(Unmarshaller<HttpEntity,T> unmarshaller, T expected)Assert on the response entity to equal the given object after applying anUnmarshaller.TestRouteResultassertEntityBytes(akka.util.ByteString expected)Assert on the response entity to equal the given bytes.protected abstract voidassertEquals(int expected, int actual, java.lang.String message)protected abstract voidassertEquals(java.lang.Object expected, java.lang.Object actual, java.lang.String message)protected TestRouteResultassertEqualsKind(int expected, int actual, java.lang.String kind)protected TestRouteResultassertEqualsKind(java.lang.Object expected, java.lang.Object actual, java.lang.String kind)TestRouteResultassertHeaderExists(HttpHeader expected)Assert that a given header instance exists in the response.TestRouteResultassertHeaderExists(java.lang.String name, java.lang.String value)Assert that a header of the given name and value exists.TestRouteResultassertHeaderKindExists(java.lang.String name)Assert that a header of the given type exists.TestRouteResultassertHeaderKindNotExists(java.lang.String name)Assert that a header of the given type does not exist.TestRouteResultassertMediaType(MediaType expected)Assert on the media type of the response.TestRouteResultassertMediaType(java.lang.String expected)Assert on the media type of the response.TestRouteResultassertRejections(Rejection... expectedRejections)Assert that a given header instance exists in the response.TestRouteResultassertRejections(scala.collection.immutable.Seq<Rejection> expectedRejections)TestRouteResultassertStatusCode(int expected)Assert on the numeric status code.TestRouteResultassertStatusCode(StatusCode expected)Assert on the status code.protected abstract voidassertTrue(boolean predicate, java.lang.String message)ContentTypecontentType()Returns the response's content-typejava.lang.StringcontentTypeString()Returns a string representation of the response's content-typeHttpEntity.Strictentity()<T> Tentity(Unmarshaller<HttpEntity,T> unmarshaller)Returns the entity of the response unmarshalled with the givenUnmarshaller.akka.util.ByteStringentityBytes()Returns the bytes of the response entityjava.lang.StringentityString()Returns the entity of the response interpreted as an UTF-8 encoded string.protected abstract voidfail(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.MediaTypemediaType()Returns the media-type of the the response's content-typejava.lang.StringmediaTypeString()Returns a string representation of the media-type of the response's content-typeRejectionrejection()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.HttpResponseresponse()StatusCodestatus()Returns theStatusCodeof the response.intstatusCode()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 theStatusCodeof the response.- Returns:
- (undocumented)
-
statusCode
public int statusCode()
Returns the numeric status code of the response.- Returns:
- (undocumented)
-
-