
io.fintrospect.testing.TestingFintrospectRoute.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fintrospect_2.10 Show documentation
Show all versions of fintrospect_2.10 Show documentation
Library that adds self-documentation to Finagle server endpoint services
package io.fintrospect.testing
import java.util.concurrent.TimeUnit
import com.twitter.finagle.http.path.Root
import com.twitter.finagle.http.{Request, Response}
import com.twitter.util.Await
import io.fintrospect.renderers.simplejson.SimpleJson
import io.fintrospect.{ModuleSpec, ServerRoute}
import scala.concurrent.duration.Duration
/**
* Mixin this and provide the route under test.
*/
trait TestingFintrospectRoute {
val route: ServerRoute[Request, Response]
/**
* get the response from the Route under test for this response. Default timeout is massively generous
* @param request to apply
* @param timeout defaults to 1s.
* @return response
*/
def responseFor(request: Request, timeout: Duration = Duration(1, TimeUnit.SECONDS)): Response = {
Await.result(ModuleSpec(Root, SimpleJson()).withRoute(route).toService.apply(request))
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy