5 Replies Latest reply on Nov 10, 2015 7:31 AM by raneves

    arquillian.xml: load properties from file




      Is there a way to use settings stored in a properties file in arquillian.xml?


      What I want to archive:

      I've to set the "schema" property value within the "persistence-dbunit" extension to a non-static value (due to multi-developer environment).


      I know one can use a system property like the following:

      <property name="schema">${arquillian.db.user}</property>

      Unfortunately this is not an option as I do not want to force every developer to specify the settings in the commandline or to create a Enclipse run configuration per test class.


      Is there something like "include properties file" in arquillian.xml in order to set some system properties ?


      Thanks a lot!




        • 1. Re: arquillian.xml: load properties from file

          Hi Wolfgang,


          I think you can also use system-wide properties (env) in arquillian.xml (eg. JBOSS_HOME is used this way for jboss/wildfly container setup). Wouldn't it work?




          • 2. Re: arquillian.xml: load properties from file

            Hi Bartosz,


            That's what I indicated above using <property name="schema">${arquillian.db.user}</property>.

            I will give the properties-maven-plugin a try for setting the system propery arquillian.db.user based on a value fetched from a property file.




            • 3. Re: arquillian.xml: load properties from file

              Right, I was low on coffee But on the other hand if you set it as env variable (on the OS level) do you really need to set it up in Eclipse for each and every test configuration? In such case it is global and should be fetched without any additional steps. Obviously each and every developer will need to set it, but only once.

              • 4. Re: Re: arquillian.xml: load properties from file

                For the one who might be interested in, this is my working solution:


                Goal: setting a user-specific configuration value in arquillian.xml using a value fetched from a file.

                E.g. setting the "schema" value in "persistence-dbunit" extension in order to have ever developer running tests against his own schema in a central database (no, neither a local Oracle XE was an option nor using In-Memory DB H2).



                1. Use a system property im arquillian.xml:

                <extension qualifier="persistence-dbunit">

                    <property name="schema">${arquillian.db.user}</property>



                2. Load a user-specific property file using properties-maven-plugin (every developer has his own file following a naming convention including the login name):













                                         <!-- load the necessary properties from file, notice the usage of the "user.name" system property -->








                3. Inject the loaded property "db.user" (is defined in the file loaded in step 2) as the system property "arquillian.db.user" expected by arquillian-xml (see setp 1):






                               <!-- Set the system property -->






                That's it.


                In terms of running JUnit tests out of Eclipse:

                Unfortunately there is no way to configure default settings for all JUnit tests in Eclipse.

                So there are 2 ways to inject the necessary system property (at least I know of):

                1. Set the system property in each and every JUnit launch configuration (boring...)
                2. Set the system property as default VM Argument in the JRE definition: Preferences => Java => Installed JREs => Select your JRE + Edit => Default VM arguments= "-Darquillian.db.user=theDBUser" (without the quotes)
                  Now each and every JUnit Run started using "Run as" => "JUnit Test" knows about the system property arquillian.db.user.

                • 5. Re: arquillian.xml: load properties from file



                  I using spring for load properties file. like that:


                  in applicationContextTest.xml:


                          location="classpath:/conf/app.testProperties, classpath:/conf/buildInfo.testProperties"



                  in my Deployment:

                              .addAsResource("conf/app.testProperties", "app.properties")