Class TestRouteResult

java.lang.Object
akka.http.javadsl.testkit.TestRouteResult

public abstract class TestRouteResult extends 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 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

      public TestRouteResult assertContentType(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(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 an Unmarshaller.
      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(Object expected, Object actual, String message)
    • assertEquals

      protected abstract void assertEquals(int expected, int actual, String message)
    • assertEqualsKind

      protected TestRouteResult assertEqualsKind(Object expected, Object actual, String kind)
    • assertEqualsKind

      protected TestRouteResult assertEqualsKind(int expected, int actual, String kind)
    • assertHeaderExists

      public TestRouteResult assertHeaderExists(String name, 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(String name)
      Assert that a header of the given type exists.
      Parameters:
      name - (undocumented)
      Returns:
      (undocumented)
    • assertHeaderKindNotExists

      public TestRouteResult assertHeaderKindNotExists(String name)
      Assert that a header of the given type does not exist.
      Parameters:
      name - (undocumented)
      Returns:
      (undocumented)
    • assertMediaType

      public TestRouteResult assertMediaType(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, String message)
    • contentType

      public ContentType contentType()
      Returns the response's content-type
      Returns:
      (undocumented)
    • contentTypeString

      public 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 given Unmarshaller.
      Parameters:
      unmarshaller - (undocumented)
      Returns:
      (undocumented)
    • entityBytes

      public akka.util.ByteString entityBytes()
      Returns the bytes of the response entity
      Returns:
      (undocumented)
    • entityString

      public String entityString()
      Returns the entity of the response interpreted as an UTF-8 encoded string.
      Returns:
      (undocumented)
    • fail

      protected abstract void fail(String message)
    • header

      public <T extends HttpHeader> T header(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 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 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 the StatusCode of the response.
      Returns:
      (undocumented)
    • statusCode

      public int statusCode()
      Returns the numeric status code of the response.
      Returns:
      (undocumented)