Open damageco opened 11 years ago
Hi,
i've got a similar issue :
import org.junit.runner._
import org.specs2.mutable._
import org.specs2.runner._
import play.api.test._
import play.api.test.Helpers._
@RunWith(classOf[JUnitRunner])
class TeddyTest extends Specification {
"Teddy" should {
"find an empty collection first" in new WithApplication() {
val result = route(FakeRequest(GET, "/teddies")).get
status(result) must equalTo(OK)
}
}
}
give me :
[info] TeddyTest
[info]
[info] Teddy should
[error] ! find an empty collection first
[error] IllegalStateException: Shutting down (CouchbaseClient.java:898)
[error] com.couchbase.client.ViewConnection.checkState(ViewConnection.java:228)
[error] com.couchbase.client.CouchbaseClient.addOp(CouchbaseClient.java:898)
[error] com.couchbase.client.CouchbaseClient.asyncGetView(CouchbaseClient.java:348)
[error] org.ancelin.play2.couchbase.ClientWrapper$class.view(ClientWrapper.scala:177)
[error] org.ancelin.play2.couchbase.Couchbase$.view(Couchbase.scala:38)
[error] org.ancelin.play2.couchbase.crud.CouchbaseCrudSource.view(CrudSource.scala:126)
[error] org.ancelin.play2.couchbase.crud.CouchbaseCrudSourceController$$anonfun$find$2.apply(CrudSource.scala:271)
[error] org.ancelin.play2.couchbase.crud.CouchbaseCrudSourceController$$anonfun$find$2.apply(CrudSource.scala:268)
[error] play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:217)
[error] play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:109)
[error] play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:109)
[error] play.utils.Threads$.withContextClassLoader(Threads.scala:18)
[error] play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:108)
[error] play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:106)
[error] play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2.apply(Action.scala:106)
[error] play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2.apply(Action.scala:99)
[error] akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:137)
In the running application, it works fine.
No matter, thanks for the plugin :)
Hi guys,
I don't really understand what's happening here, I'll try to investigate later, but it seems that the following code works (even if your code is supposed to do exactly the same thing) :
class ApplicationSpec extends Specification {
"Application" should {
"find an some urls" in {
running(FakeApplication()) {
val home = route(FakeRequest(GET, "/urls/")).get
val content = contentAsString(home)
status(home) must equalTo(OK)
contentType(home) must beSome.which(_ == "application/json")
Json.parse(content).as[JsArray].value.size must equalTo(22)
}
}
}
}
Hi,
I have also observed the above problem, but the problem seems to be related to creating multiple fake applications, for instance
"generate a new cookie when we do a request with _chk and a tmp cookie set" in {
running(FakeApplication()) {
val cookiesAllocated = CookieGenerator.getAllocatedCookies
val Some(track) = route(FakeRequest(GET, "/track.gif?_chk").withCookies(Cookie("rtttmp","")))
status(track) must equalTo(OK)
cookies(track).get("rtt") must beSome
val Some(rtt) = cookies(track).get("rtt")
IdEncoder.decodeUserId(rtt.value) must beGreaterThan(0l)
CookieGenerator.getAllocatedCookies must beEqualTo(cookiesAllocated+1)
}
}
"generate a new cookie when we do a request with idt cookie set" in {
running(FakeApplication()) {
val cookiesAllocated = CookieGenerator.getAllocatedCookies
val Some(track) = route(FakeRequest(GET, "/track.gif").withCookies(Cookie("idt","hghjhgj")))
status(track) must equalTo(OK)
cookies(track).get("rtt") must beSome
cookies(track).get("rtt").get.httpOnly must beFalse
val Some(rtt) = cookies(track).get("rtt")
IdEncoder.decodeUserId(rtt.value) must beGreaterThan(0l)
CookieGenerator.getAllocatedCookies must beEqualTo(cookiesAllocated+1)
}
}
My first case passes and my second case fails. When i comment out the first case, the second case passes. So my guess is that some component cannot handle multiple initializations
Nice catch, I'll investigate around the plugin initialization
Hello,
I've got problem while running tests with the plug-in. Here is my code :
here is the stacktrace :
Connection to database closed before the test run. Any idea on what append ?
David