spray-test

Spray Routing Doesn't match anything

我与影子孤独终老i 提交于 2019-12-25 12:29:40
问题 I have tried many things, but no matter what I do in my tests (which simply sends a PUT request to "create a user") the logs do not enter any of the pathPrefix and just go to the end and fail to match anything. Can anyone offer insight? Below is the class I have written as well as the simple test (which doesn't even check anything yet) I know overall it is rather rudimentary and I am not doing things great, but it's just something I threw together to the point where I felt i could do a few

How can I simulate a POST request with a json body in SprayTest?

一笑奈何 提交于 2019-12-22 05:32:15
问题 If I have an endpoint that unmarshalls json like this: (path("signup")& post) { entity(as[Credentials]) { credentials => … How can I test that with a Spray test spec: "The Authentication service" should { "create a new account if none exists" in { Post("/api/authentication/signup", """{"email":"foo", "password":"foo:" }""") ~> authenticationRoute ~> check { handled === true } } } That obviously doesn't work for several reasons. What would be the correct way? 回答1: The trick is to set the

How can I fix the missing implicit value for parameter ta: TildeArrow in a test spec

放肆的年华 提交于 2019-12-18 14:15:41
问题 I'm working on a simple test spec using spray and I can't get it to compile correctly, don't know if I'm doing anything wrong. My version of scala is 2.9.3 and spray 1.0.1 (Updating either of them is not a suitable option). Here's my test spec's code: import org.specs2.mutable.Specification import spray.testkit.Specs2RouteTest import spray.http._ import akka.util.Duration import java.util.concurrent.TimeUnit import service.MyProxy abstract class MyTestSpec extends Specification with

Request was not handled with spray-testkit

感情迁移 提交于 2019-12-11 12:32:54
问题 My service route: get( path("add" / IntNumber / IntNumber)( (a, b) => complete((a + b).toString()) ) ) ~ post( path("add") ( formFields('a.as[Int], 'b.as[Int]) { (a, b) => complete((a + b).toString()) }) ) my spec: import spray.http.FormData class RouteDefinitionSpec extends org.specs2.mutable.Specification with org.specs2.ScalaCheck with spray.testkit.Specs2RouteTest with RouteDefinition { def actorRefFactory = system "the route" should { "add with get requests" in { prop { (a: Int, b: Int)

spray-testkit: could not find implicit value for parameter ta:

妖精的绣舞 提交于 2019-12-11 09:36:13
问题 First time spray user close to ripping hair out. trait SampleService extends SimpleRoutingApp with JsonProtocol with SprayJsonSupport { implicit val system: ActorSystem = ActorSystem("test") implicit def context: ExecutionContext = system.dispatcher startServer(interface = "localhost", port = 8888) { path("test") { _ => get { complete { "test" } } } } } import org.scalatest.FlatSpec import spray.testkit.ScalatestRouteTest class ApiSpec extends FlatSpec with ScalatestRouteTest with

How can I simulate a POST request with a json body in SprayTest?

流过昼夜 提交于 2019-12-05 08:13:45
If I have an endpoint that unmarshalls json like this: (path("signup")& post) { entity(as[Credentials]) { credentials => … How can I test that with a Spray test spec: "The Authentication service" should { "create a new account if none exists" in { Post("/api/authentication/signup", """{"email":"foo", "password":"foo:" }""") ~> authenticationRoute ~> check { handled === true } } } That obviously doesn't work for several reasons. What would be the correct way? 4lex1v The trick is to set the correct Content-Type: Post("/api/authentication/signup", HttpBody(MediaTypes.`application/json`, """{

Basic Spray-Testkit usage to test a route does not work

青春壹個敷衍的年華 提交于 2019-12-02 07:51:39
问题 I am trying to use spray route and want to test it with Spray-TestKit. I am using : - Scala 2.10.3 - Akka 2.3.3 - Spray 1.3.1 I create a trait extending HttpService, where I define a route : trait MyService extends HttpService with CoreAccess { import greentee.am.endpoint.tsmsp.tsmSPJsonSupport._ val myRoute = { path("resources"/"ping") { get { complete(OK, "pong") } } } } I deleted part of the route which was not relevant. CoreAccess is a trait extending Actor, because I have methods in that