[2.1-RC4]Cannot change conf file for test

248 views
Skip to first unread message

rch850

unread,
Feb 5, 2013, 8:19:46 AM2/5/13
to play-fr...@googlegroups.com
Hi all,

I have trouble with testing of play app. I have application.conf for
development and jenkins.conf for Jenkins CI server. db.default.url of each
conf files point different url.

With Play 2.1 RC4, testing with jenkins.conf fails because it cannot connect
to db server. After short investigating, I found that I cannot change conf
file for testing.

play -Dconfig.file=conf/jenkins.conf run works. but 
play -Dconfig.file=conf/jenkins.conf test doesn't work.

Attachment is a simple example of this behavior.
Any workaround?

Thanks,
rch850.
conftest.zip

Alexander Strebkov

unread,
Feb 7, 2013, 8:10:09 AM2/7/13
to play-fr...@googlegroups.com
I've encountered the same problem. And problem exists in 2.1.0 as well.
"play test" does ignore any configuration changes specified with -D which worked fine in 2.0.4

Best regards,
Alexander

Alexander Strebkov

unread,
Feb 7, 2013, 11:13:50 PM2/7/13
to play-fr...@googlegroups.com

Aurélien Allienne

unread,
Feb 11, 2013, 4:40:06 AM2/11/13
to play-fr...@googlegroups.com

My workaround is simple : I just override some parameters in a map.

public class AbstractTest {

   
private static final int PORT = 3333;
   
public static final String BASE_PATH = "http://localhost:" + PORT;
   
private static Map<String, Object> additionalConfiguration;

   
@Before
   
public void startApp() {
        additionalConfiguration
= new HashMap<String, Object>();
        additionalConfiguration
.put("logger.root", "INFO");
        additionalConfiguration
.put("logger.play", "INFO");
        additionalConfiguration
.put("logger.application", "INFO");
   
}

   
public TestServer getTestServer() {
       
return Helpers.testServer(PORT, Helpers.fakeApplication(additionalConfiguration, new GlobalTest()));
   
}
}

rch850

unread,
Feb 11, 2013, 10:39:47 PM2/11/13
to play-fr...@googlegroups.com
Thanks all.

Suggested workaround is enough for me.


2013年2月11日月曜日 18時40分06秒 UTC+9 Aurélien Allienne:

Kenji Matsuoka

unread,
Feb 16, 2013, 6:13:27 PM2/16/13
to play-fr...@googlegroups.com
That bug has been marked as Won't Fix.  But according to http://www.scala-sbt.org/release/docs/Detailed-Topics/Forking.html, you can pass along arguments to the forked JVM.  It seems like this should work:

javaOptions in test += "-Dconfig.file=conf/jenkins.conf"
but I haven't tried it yet.
Reply all
Reply to author
Forward
0 new messages