+htk add RouteTest.testAppRoute

This commit is contained in:
Johannes Rudolph 2015-07-17 14:02:23 +02:00
parent 4c24b72b31
commit 4fe85b8b56
2 changed files with 7 additions and 2 deletions

View file

@ -10,7 +10,7 @@ import scala.concurrent.duration._
import akka.stream.ActorMaterializer import akka.stream.ActorMaterializer
import akka.http.scaladsl.server import akka.http.scaladsl.server
import akka.http.javadsl.model.HttpRequest import akka.http.javadsl.model.HttpRequest
import akka.http.javadsl.server.{ AllDirectives, Route, Directives } import akka.http.javadsl.server.{ HttpApp, AllDirectives, Route, Directives }
import akka.http.impl.util.JavaMapping.Implicits._ import akka.http.impl.util.JavaMapping.Implicits._
import akka.http.impl.server.RouteImplementation import akka.http.impl.server.RouteImplementation
import akka.http.scaladsl.model.HttpResponse import akka.http.scaladsl.model.HttpResponse
@ -50,5 +50,10 @@ abstract class RouteTest extends AllDirectives {
def run(request: HttpRequest): TestResponse = runRoute(underlying, request) def run(request: HttpRequest): TestResponse = runRoute(underlying, request)
} }
/**
* Creates a [[TestRoute]] for the main route of an [[HttpApp]].
*/
def testAppRoute(app: HttpApp): TestRoute = testRoute(app.createRoute)
protected def createTestResponse(response: HttpResponse): TestResponse protected def createTestResponse(response: HttpResponse): TestResponse
} }

View file

@ -16,7 +16,7 @@ import akka.http.scaladsl.Http.ServerBinding
abstract class HttpApp abstract class HttpApp
extends AllDirectives extends AllDirectives
with HttpServiceBase { with HttpServiceBase {
protected def createRoute(): Route def createRoute(): Route
/** /**
* Starts an HTTP server on the given interface and port. Creates the route by calling the * Starts an HTTP server on the given interface and port. Creates the route by calling the