5 Replies Latest reply on Apr 5, 2012 5:58 AM by Sueleyman Vurucu

    External properties in arquillian.xml

    Sueleyman Vurucu Expert

      Hi @ all,

       

      I have problems to set system properties in arquillian.xml.

       

      I do folowing things:

       

      1. Define properties in surfire.

      2. Refrence the surfire properties in arquillian.xml

       

      My surfire conf:

       

       

      <plugin>
                      <artifactId>maven-surefire-plugin</artifactId>
                      <version>${version-surfire}</version>
                      <inherited>true</inherited>
                      <configuration>
                          <enableAssertions>true</enableAssertions>
      
                          <configuration>
      
                              <enableAssertions>true</enableAssertions>
                              <!-- -DserverProfile=standalone-full-my.xml -DwmsEar=com.my.company:my-ear:ear:3.0.0-SNAPSHOT -->
                              <systemPropertiesFile>
                                  ${user.home}/mvntest.properties
                              </systemPropertiesFile>
                              <systemPropertyVariables>
                                  <serverProfileSurfire>${serverProfile}</serverProfileSurfire>
                                  <earSurfire>${ear}</earSurfire>
                                  <serverDirSurfire>${serverDir}</serverDirSurfire>
                              </systemPropertyVariables>
                          </configuration>
                      </configuration>
                  </plugin>
      

       

       

      My arquillian.xml

       

      <?xml version="1.0" encoding="UTF-8"?>
      <arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://jboss.org/schema/arquillian"
        xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
      
        <container qualifier="jboss7" default="true">
          <protocol type="Servlet 3.0">
            <property name="executionType">MANAGED</property>
          </protocol>
      
        <configuration>
              <property name="serverConfig">${serverProfileSurfire}</property>
            <property name="jbossHome">${serverDirSurfire:F:\IDE\jboss-as-7.1.1.Final}</property>
            <property name="javaVmArguments">-Xmx512m -XX:MaxPermSize=128m -Xrunjdwp:transport=dt_socket,address=8086,server=y,suspend=n</property>
            <property name="allowConnectingToRunningServer">true</property>
          </configuration>
        </container>
      
      </arquillian>
      

       

       

      Surfire can read the properties from the prop file and set this. But Arquillian throw the Exception which is shown below:

       

       

      java.lang.IllegalStateException: JBAS014805: Could not get main file: ${serverProfileSurfire}. Specified files must be relative to the configuration dir: F:\IDE\jboss-as-7.1.1.Final\standalone\configuration
          at org.jboss.as.controller.persistence.ConfigurationFile.determineMainFile(ConfigurationFile.java:148)
          at org.jboss.as.controller.persistence.ConfigurationFile.<init>(ConfigurationFile.java:90)
          at org.jboss.as.server.ServerEnvironment.<init>(ServerEnvironment.java:375)
          at org.jboss.as.server.Main.determineEnvironment(Main.java:242)
          at org.jboss.as.server.Main.main(Main.java:83)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:601)
          at org.jboss.modules.Module.run(Module.java:260)
          at org.jboss.modules.Main.main(Main.java:291)
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 7.219 sec <<< FAILURE!
      

       

       

      I try to set the propertis with mvn -DserverProfile , too but the same result.

       

      What I'm doing wrong ?

        • 1. Re: External properties in arquillian.xml
          Sueleyman Vurucu Expert

          So the first problem tih the commad line argument was my mistake. I change the surefire config to:

                         <plugin>
                          <artifactId>maven-surefire-plugin</artifactId>
                          <version>${version-surfire}</version>
                          <inherited>true</inherited>
                          <configuration>
                                  <enableAssertions>true</enableAssertions>
                                  <!-- -DserverProfile=standalone-full-my.xml -DwmsEar=com.my.company:my-ear:ear:3.0.0-SNAPSHOT -->
                                  <systemPropertiesFile>
                                      ${user.home}/mvntest.properties
                                  </systemPropertiesFile>
                                  <systemPropertyVariables>
                                      <serverProfileSurfire>${serverProfile}</serverProfileSurfire>
                                      <earSurfire>${ear}</earSurfire>
                                      <serverDirSurfire>${serverDir}</serverDirSurfire>
                                  </systemPropertyVariables>
                           </configuration>
                      </plugin>

           

          So I can set the property by mvn -DserverProfile=... But not via propertyfile.

          • 2. Re: External properties in arquillian.xml
            Aslak Knutsen Master

            Does it work if you put a value directly in serverProfileSurfire in the surefire config (not a reference to another variable)?

            • 3. Re: External properties in arquillian.xml
              Aslak Knutsen Master

              have you tried setting systemPropertiesFile on one line?

               

              <systemPropertiesFile>${user.home}/mvntest.properties</systemPropertiesFile>

               

              I know a few of the other surefire config options are sensitive to this..

              • 4. Re: External properties in arquillian.xml
                Sueleyman Vurucu Expert

                Hi Aslak,

                 

                thanks but both suggestions won't work

                • 5. Re: External properties in arquillian.xml
                  Sueleyman Vurucu Expert

                  Hi Aslak,

                   

                  this funky behavior is not the domain of arquillian. Surfire is the problem.

                   

                  I change the configuration to

                                      <systemPropertyVariables>
                                              <
                  serverProfile>${serverProfile}</serverProfile>
                                              <
                  ear>${ear}</ear>
                                              <
                  serverDir>${serverDir}</serverDir>
                                      </systemPropertyVariables>

                   

                  and know I can set the properties via properyfile and commandline. The commandline arg overrides the propertyfile. That is the behaviour what I want.

                  Without the reference to surfire variable I can't set the property over command line.

                  If I use different names like <serverDirSurfire>${serverDir}</serverDirSurfire> then I can't set the property over file.

                   

                  It was little bit painfull but it works know.