mercredi 30 mars 2016

NoSuchMethodError when requesting an Authenticated action in a test

There is an action which i want to unit test.

def foo = Authenticated(BodyParsers.parse.json){...}

The problem is that the unit test throws an exception:

java.lang.NoSuchMethodError: pdi.jwt.package$.RichRequestHeader(Lplay/api/mvc/RequestHeader;)Lpdi/jwt/JwtPlayImplicits$RichRequestHeader;

When i use Action instead of Autenticate the tests are doing well and thats were google & co can not really provide help. Also the play docs are not helpful.

How can I test such an action?

Thats the testing request:

val Some(result) = route(FakeRequest(POST, "/foo").withHeaders(("Authorization",jwttoken)).withJsonBody(Json.toJson(content)))

P.S. The exception is thrown when I call contentAsString on the result object.

Aucun commentaire:

Enregistrer un commentaire