How to run multiple functional specifications using TestServer in Play 2.0.1?

I am having problems running several functional specifications (using specs2), in particular tests that run TestServer, open the HTMLUNIT browser and go to the page to check the element. This page loads the elements that we test on ajax request. Waiting for an item with an error message below.

Code snippet:

trait CommonSteps extends BaseSpecfication { val testServer: TestServer = TestServer(3333) val testServerBaseURL: String = "http://localhost:3333/" override def map(fs: => Fragments) = Step(testServer.start()) ^ super.map(fs) ^ Step(testServer.stop()) } class FunctionalTest1 extends Specification with CommonSteps { def is = ... ... extends When[...] { val browser: TestBrowser = TestBrowser.of(HTMLUNIT) browser.goTo(testServerBaseURL + "/some_path") browser } ... extends Then[...] { browser.await.until("element that is loaded on ajax request").isPresent() ... } } 

We get the error:

 Caused by: java.sql.SQLException: Attempting to obtain a connection from a pool that has already been shutdown. Stack trace of location where pool was shutdown follows: java.lang.Thread.getStackTrace(Thread.java:1479) com.jolbox.bonecp.BoneCP.captureStackTrace(BoneCP.java:543) com.jolbox.bonecp.BoneCP.shutdown(BoneCP.java:159) com.jolbox.bonecp.BoneCPDataSource.close(BoneCPDataSource.java:123) play.api.db.BoneCPApi.shutdownPool(DB.scala:387) play.api.db.BoneCPPlugin$$anonfun$onStop$1.apply(DB.scala:252) play.api.db.BoneCPPlugin$$anonfun$onStop$1.apply(DB.scala:250) scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59) scala.collection.immutable.List.foreach(List.scala:45) play.api.db.BoneCPPlugin.onStop(DB.scala:250) play.api.Play$$anonfun$stop$1$$anonfun$apply$1.apply(Play.scala:75) play.api.Play$$anonfun$stop$1$$anonfun$apply$1.apply(Play.scala:74) scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59) scala.collection.immutable.List.foreach(List.scala:45) play.api.Play$$anonfun$stop$1.apply(Play.scala:74) play.api.Play$$anonfun$stop$1.apply(Play.scala:74) scala.Option.map(Option.scala:133) play.api.Play$.stop(Play.scala:73) play.core.server.NettyServer.stop(NettyServer.scala:73) 

While the test runs on stand-alone startup, we get an error when starting two or more of them together.

This seems to be related to this issue , although my example is the Scala Play app. Can anyone confirm that this issue has been fixed in a newer version of Play? Or, is there a workaround to avoid this error in Play 2.0.1.

+6
source share
1 answer

This issue will be fixed in Play 2.0.2, which is currently in RC state. It is safe to upgrade from 2.0.1 to 2.0.2, since everything is backward compatible.

Thanks to @ guillaume-bort for providing this information.

+3
source

Source: https://habr.com/ru/post/918764/


All Articles