3 Replies Latest reply on Jul 22, 2013 8:26 AM by Karel Piwko

    newbie variable expansion in pom.xml and arquillian.xml

    jrhite_boss Newbie

      I'm a complete newbie to arquillian and have only the most basic exposure to maven.

       

      I'm try to get at environment variables in arquillian.xml. Specifically my JBOSS_HOME dir. I don't want to hardcode this as I can't make assumptions about how other developers on my team are setup.

       

      I read this related thread, but after some debugging, in the arquillian.xml file it seems that variables like ${JBOSS_HOME} get passed straight through as is and don't get expanded to their actual values. I read a related thread on this:

       

      https://community.jboss.org/thread/174152

       

      My pom.xml looks like:

       

            <plugin>

              <artifactId>maven-surefire-plugin</artifactId>

              <version>2.12</version>

              <configuration>

                <systemPropertyVariables>

                  <JBOSS_HOME>${env.JBOSS_HOME}</JBOSS_HOME>

                </systemPropertyVariables>

                <systemProperties>

                  <arquillian.launch>jbossas-managed</arquillian.launch>

                </systemProperties>

                <skip>false</skip>

              </configuration>

            </plugin>

       

      And my arquillian.xml file looks like:

       

          <arquillian xmlns="http://jboss.org/schema/arquillian"

              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

              xsi:schemaLocation="

              http://jboss.org/schema/arquillian

              http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

            

               <container qualifier="jbossas-managed" default="true">

                  <configuration>

                      <property name="jbossHome">${JBOSS_HOME}</property>

                  </configuration>

              </container>

          </arquillian>

       

      When I hardcode the path to jboss_home in my arquillian.xml file my tests run fine. If I don't, I see the error:

       

      org.jboss.arquillian.container.spi.ConfigurationException: jbossHome '${JBOSS_HOME}' must exist

                at org.jboss.arquillian.container.spi.client.deployment.Validate.configurationDirectoryExists(Validate.java:139)

        <...snip...>

       

       

      2 questions:

      1. Why isn't ${JBOSS_HOME} getting expanded in the arquillian.xml file?
      2. In pom.xml, are the lines:

                <systemProperties>

                  <arquillian.launch>jbossas-managed</arquillian.launch>

                </systemProperties>

                <skip>false</skip>

       

      even needed?

       

       

      I've been out of touch with the full-blown JEE world for a while and need to catch up on maven and tools for testing EJB3s, etc...Not sure if maven is worth it, but arquillian sure looks nice!

       

      Thanks much.

        • 1. Re: newbie variable expansion in pom.xml and arquillian.xml
          Karel Piwko Master

          Hi,

           

          ad 1. Where do you run you tests from? If it is Maven (CLI), it should work, if it's IDE than it is likely ignoring surefire configuration.

           

          I'd suggest to try ${env.JBOS_HOME:default/path} in arquillian.xml and removing surefire related conf. To make this work in IDE even better, you can use following approach:

           

          a/ Enable filtering

          https://github.com/kpiwko/html5-demoapp/blob/javaone-sfo-2012/pom.xml#L248

          b/ Making sure that you use resources plugin 2.5+

          c/ use plain ${foobar} in arquillian.xml

          d/ make sure that property you want to filter is defined in <properties> in your pom.xml

           

          ad 2. You can safely remove all those lines. arquillian.launch property is only needed if you have multiple containers configuration;-)

          • 2. Re: newbie variable expansion in pom.xml and arquillian.xml
            jrhite_boss Newbie

            Ah, yes, I'm running from Eclipse. Thanks for the insight!

             

            I took the steps you recommended, and then also added an Eclipse ENV JBOSS_HOME variable to the run configuration for the JUnit test.

             

            I added the property <JBOSS_HOME>${env.JBOSS_HOME}</JBOSS_HOME> to the pom.xml which is now correctly being resolved and passed along to the arquillian.xml file. And my tests are running. :-)

             

             

            1. From the link you provided at line 248:

            https://github.com/kpiwko/html5-demoapp/blob/javaone-sfo-2012/pom.xml#L248

             

            is the really correct? It seems non-sensical to both include and exclude the same thing (ie: **/arquillian.xml and **/arquillian.launch are both included and excluded at the same time). I'm assuming it's a typo and that including src/test/resources and excluding src/main/resources was the intention (instead src/test/resources was provided twice).

             

            2. I also commented out the surefire plugin, but is this really recommended? The documentation in the Arquillian Getting Started Guide is pretty specific about using surefire instead of the default version:

             

            (Optional) We recommend upgrading the Maven Surefire Plugin from the default version, for reasons described inthis FAQ. You can set the version of the Surefire Plugin by appending this <plugin> element inside the <plugins>element, just below the Maven Compiler Plugin:

            • 3. Re: newbie variable expansion in pom.xml and arquillian.xml
              Karel Piwko Master

              Thanks, there's indeed a typo, <filtering>true</filtering> where included, and it should be false where excluded ;-). This remove the possibility to break your binary resources if you're unlucky and they contain the ${foo} string.

               

              As for Surefire, I meant to remove <configuration> element, keeping <plugin> with a specific version is definitely recommened!

              1 of 1 people found this helpful