scala - "Not Implemented" error when testing a Scalatra route with ScalaTest -


i writing tests several scalatra routes. i'm using scala 2.10.2, scalatra 2.2.1, , scalatest 1.9.2; i'm new @ using 3 of these. i'm using eclipse scala ide 3.0.1 scalatest plugin.

for scalatrabootstrap have

context.mount(new accountscontroller, "/accounts") context.mount(new profilescontroller, "/profiles") 

inside profilescontroller have following route

val addimage =   (apioperation[int]("addimage")     parameters (pathparam[string]("context").description("profile context"),     pathparam[int]("id").description("profile id"),     parameter("body", "body data",       datatype[scalatrarecord],       paramtype = paramtype.body))) post("/:context/:id/images", operation(addimage)) { ... } 

this tested with

test("add profile image") {   val json = jobject("name" -> jstring("asdf")) merge jobject("image_file_url" -> jstring("test.png"))   val bytes = compact(render(json)).getbytes("utf-8")   post("/profiles/users/1/images", bytes, map("content-type" -> "application/json")) {     status should be(200)   } } 

this passees test.

inside accountscontroller have following route

val addcontact =   (apioperation[int]("addcontact")   parameters (     parameter("contact", "new contact data",       datatype[contact],       paramtype = paramtype.body))) post("/contacts", operation(addcontact)) { ... } 

tested with

test("add contact") {   val json = jobject("name" -> jstring(rand.nextstring(10))) merge jobject("email" -> jstring(rand.nextstring(10)))   val bytes = compact(render(json)).getbytes("utf-8")   post("/accounts/contacts", bytes, map("content-type" -> "application/json")) {     status should be(200)   } } 

this fails; status 500, , body "not implemented." route works fine in production. tested get("/accounts/contacts") route make sure didn't have typos, , route works fine. far can tell, difference between 2 routes profile route has 2 path params , uses different data type body param (the test succeeds uses scalatrarecord, test fails uses contact; contact inherits scalatrarecord); tried adding bogus path params account route , tried changing type of body param match profile's param, ran same error.

i don't understand why 1 route pass test while other route give me "not implemented" error. have ideas how can fix this?


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -