2.0.2 breakage of integration tests (using play.api.libs.ws.WS)?

307 views
Skip to first unread message

scott clasen

unread,
Jun 26, 2012, 8:46:42 PM6/26/12
to play-fr...@googlegroups.com
Hey All-

   I have a play app that has an integration test that is usually run via 'play test-only *Integration*' 

This uses play WS to talk to a rest api of a running play app. Worked just fine till upgrading to 2.0.2 today

Now when running this spec, I get blood on the screen, no play app started.

[error]     RuntimeException: There is no started application (Play.scala:44)
[error] play.api.Play$$anonfun$current$1.apply(Play.scala:44)
[error] play.api.Play$$anonfun$current$1.apply(Play.scala:44)
[error] play.api.Play$.current(Play.scala:44)
[error] play.api.libs.ws.WS$.client(WS.scala:43)
[error] play.api.libs.ws.WS$WSRequest.execute(WS.scala:119)
[error] play.api.libs.ws.WS$WSRequestHolder.get(WS.scala:300)


[error]     RuntimeException: There is no started application (Play.scala:44)
[error] play.api.Play$$anonfun$current$1.apply(Play.scala:44)
[error] play.api.Play$$anonfun$current$1.apply(Play.scala:44)
[error] play.api.Play$.current(Play.scala:44)
[error] play.api.libs.ws.WS$.client(WS.scala:43)

Was there a change in 2.0.2 that would cause this breakage? How to work around?

peter hausel

unread,
Jun 26, 2012, 10:20:12 PM6/26/12
to play-fr...@googlegroups.com
That error usually happens if the functional test runner could not create the NettyServer instance. 

Can you check if there is any other play app running in the background on the same localhost port?
Can you check if the app is working in the dev mode after upgrading to 2.0.2?

Thanks,
Peter

scott clasen

unread,
Jun 26, 2012, 11:34:52 PM6/26/12
to play-fr...@googlegroups.com
So in this case Im not using FakeApplication, FakeServer, etc.. 

Im deploying to a heroku app, and then running an integration test against it from my desk.

The integration test just uses WS to test the rest api that this app presents, using  calls like  Promise.await(WS.get(https:://server/some/rest/path))

Worked just fine in 2.0.1 and prior.  Its just a pure specs2 Specification, the only play classes imported are WS and play.test.Helpers._

peter hausel

unread,
Jun 27, 2012, 12:01:26 AM6/27/12
to play-fr...@googlegroups.com
Hi Scott,

I see! I suspect then the issue is related to the fact that now you can configure timeouts in WS ie 
(which fix was back ported due to a request by the community). 

Since in your case probably there is no play application running in the context of your call, you see this exception. I would advise to either add a running(FakeApplication(...)) block to your test or add
new play.core.StaticApplication(new java.io.File(".")) before any WS calls.


Thanks,
Peter

scott clasen

unread,
Jun 27, 2012, 12:35:28 AM6/27/12
to play-fr...@googlegroups.com
Aha! much better with new play.core.StaticApplication(new java.io.File("."))  in there, thanks Peter.

scott clasen

unread,
Jun 27, 2012, 1:17:14 AM6/27/12
to play-fr...@googlegroups.com
One other question, has the WS client been changed to auto follow redirects, I am getting some followed links for responses of Created and Found that are following the Location header that were not previously.

Would like to turn that off..

scott clasen

unread,
Jun 27, 2012, 1:18:54 AM6/27/12
to play-fr...@googlegroups.com
Looks like ws.followRedirects=false should do it.

Mariot Chauvin

unread,
Jun 27, 2012, 4:49:59 AM6/27/12
to play-fr...@googlegroups.com
Scott or Peter,

Is the  ws.followRedirects a new option ?
Or the default value is now set to true ?

Cheers,

Mariot

2012/6/27 scott clasen <scott....@gmail.com>
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/fsmI-_-i_0IJ.

To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

scott clasen

unread,
Jun 27, 2012, 12:24:14 PM6/27/12
to play-fr...@googlegroups.com
its a new option, there are apparently a bunch of ws  options, followRedirects=true by default so I set it to false in config.
Mariot

2012/6/27 scott clasen <scott....@gmail.com>

To post to this group, send email to play-framework@googlegroups.com.
To unsubscribe from this group, send email to play-framework+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages