Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play Framework: Configuring system properties

In play framework (2.2.1 & sbt 0.13) I have an IntegrationSpec that brings up a TestServer. I need to be able to set SSL specific System Properties for the TestServer. So far the only way I have been able to set it up correctly is passing them as command line properties like below

play -Djavax.net.ssl.keyStore=... -Djavax.net.ssl.keyStorePassword=.... -D... test

I want the tests to run simply using play test. For that in Build.scala I configured SBT javaOptions as follows

val main = play.Project(appName, appVersion, appDependencies).settings(
    Keys.fork in Test := false,
    javaOptions in Test += "-Dconfig.file=conf/application.test.conf")

And in application.test.conf I set all the system properties. With this the TestServer is not even using application.test.conf. I was not able to figure out why. So I thought I will try the following:

play -Dconfig.file=conf/application.test.conf test

The TestServer did use application.test.conf but none of the system properties (javax.net.ssl.keyStore="..." etc.) configured in the file were being used.

So I have two questions

  1. How to have this running only using play test? . (I do not want to pass a long Map of properties to FakeApplication in TestServer).
  2. When I run play -Dconfig.file=conf/application.test.conf test, why are the system properties configured in application.test.conf not being used?
like image 564
Prasanna Avatar asked Nov 11 '22 11:11

Prasanna


1 Answers

I'm not sure if this works for setting a property for reading the configuration file, but you can set your individual properties with System.setProperty like this:

System.setProperty("application.secret","psssst!")
like image 189
Arne Claassen Avatar answered Nov 15 '22 07:11

Arne Claassen