+htk add RouteTest.testAppRoute
This commit is contained in:
parent
4c24b72b31
commit
4fe85b8b56
2 changed files with 7 additions and 2 deletions
|
|
@ -10,7 +10,7 @@ import scala.concurrent.duration._
|
|||
import akka.stream.ActorMaterializer
|
||||
import akka.http.scaladsl.server
|
||||
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.server.RouteImplementation
|
||||
import akka.http.scaladsl.model.HttpResponse
|
||||
|
|
@ -50,5 +50,10 @@ abstract class RouteTest extends AllDirectives {
|
|||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import akka.http.scaladsl.Http.ServerBinding
|
|||
abstract class HttpApp
|
||||
extends AllDirectives
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue