2012-06-22 1 views
6

Ich habe Probleme beim Ausführen mehrerer funktionaler Spezifikationen (mit specs2), insbesondere Tests, die einen TestServer starten, einen HTMLUNIT-Browser öffnen und zu einer Seite navigieren, um ein Element zu überprüfen. Die fragliche Seite lädt die Elemente, die wir auf einer Ajax-Anfrage testen. Das Warten auf das aktuelle Element wird mit der folgenden Fehlermeldung abgebrochen.Wie führe ich mehrere funktionale Spezifikationen mit TestServer in Play 2.0.1 aus?

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() 
    ... 
    } 

} 

Wir den Fehler:

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) 

Während der Test funktioniert, wenn in Isolation führen wir den Fehler, wenn sie zusammen zwei oder mehr von ihnen laufen.

Es scheint mit this issue verwandt zu sein, obwohl mein Beispiel eine Scala Play App ist. Kann jemand bestätigen, dass dieses Problem in einer neueren Version von Play behoben ist? Oder gibt es eine Problemumgehung, um diesen Fehler in Play 2.0.1 zu vermeiden.

Antwort

3

Dieses Problem wird in Play 2.0.2 behoben, das sich derzeit im RC-Status befindet. Es ist sicher, von 2.0.1 auf 2.0.2 zu aktualisieren, da alles abwärtskompatibel ist.

Dank @ Guillaume-Bort für die Bereitstellung dieser Informationen.

+0

Weitere Informationen finden Sie hier: https://groups.google.com/forum/?fromgroups=#!topic/play-framework/znFuqeRz84w – blackbox

Verwandte Themen