5 Replies Latest reply on Jun 30, 2013 3:52 PM by Pascal Kesseli

    tomee-remote ignores arquillian.xml

    Pascal Kesseli Newbie

      Hi everyone

       

      I switched from TomEE embedded to TomEE remote adapter in order to be able to test a JAX-RS web service. However, when replacing

       

      <dependency>   <groupId>org.apache.openejb</groupId>
         <artifactId>arquillian-tomee-embedded</artifactId>
         <version>${tomee.version}</version>
      </dependency>
      

       

      by

       

        <dependency>
         <groupId>org.apache.openejb</groupId>
         <artifactId>arquillian-tomee-remote</artifactId>
         <version>${tomee.version}</version>
        </dependency>
      

       

      my settings in arquillian.xml all of a sudden get ignored. I can tell because the remote adapter is now set up on port 8080 rather than a random port. Since I also specify the plus classifier in there, JAX-RS is still unavailable.

       

      Is this a known issue or how can I make this work in an Eclipse JUnit-Test?

       

      Thanks for any feedback and best regards

      Pascal

        • 1. Re: tomee-remote ignores arquillian.xml
          John Ament Master

          Hi,

           

          Just wondering, can you post your full pom.xml and arquillian.xml ?

          The whole files, preferrably.

           

          If you can also specify what version of tomee you're using, that'll help.

          Also, if you can explain what properties you think should be getting applied?

          • 2. Re: tomee-remote ignores arquillian.xml
            Kuba Marchwicki Newbie

            Hi Pascal,

            What worked for me when switching from embedded to remote tomee was putting Arquillian-tomee.properties file in the class path with classifier defined there. Take a look at the project https://github.com/kubamarchwicki/arquillian-examples/tree/tomee-remote/src/test/resources. There are branches with some different containers, including tomee-embedded. It show differences in configuration and in a way you need to build your tests.

             

            I was struggling with exactly the same - JAX-RS wasn't working cause plus was not picked up.

             

            Hope that helps you

            Kuba

             

            PS. Side note and forgive my ranting ;) but registering at JBoss Community to get this post posted was really painful. So many forms, to get so little done.

            • 3. Re: tomee-remote ignores arquillian.xml
              Pascal Kesseli Newbie

              Hi John

               

              Thanks for your reply. This is the full POM file:

               

              <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
                  <modelVersion>4.0.0</modelVersion>
                  <artifactId>codenation-server-impl</artifactId>
                  <packaging>war</packaging>
              
                  <parent>
                      <groupId>ch.codenation</groupId>
                      <artifactId>codenation-parent</artifactId>
                      <version>0.0.1-SNAPSHOT</version>
                      <relativePath>../codenation-parent/pom.xml</relativePath>
                  </parent>
              
                  <properties>
                      <tomee.classifier>jaxrs</tomee.classifier>
                      <war.plugin.version>2.3</war.plugin.version>
                      <surefire.version>2.15</surefire.version>
                  </properties>
              
                  <build>
                      <resources>
                          <resource>
                              <directory>src/main/resources</directory>
                              <targetPath>ch/codenation/service/resources</targetPath>
                          </resource>
                      </resources>
                      <testResources>
                          <testResource>
                              <directory>src/test/resources/container/arquillian</directory>
                              <includes>
                                  <include>arquillian.xml</include>
                              </includes>
                          </testResource>
                          <testResource>
                              <directory>src/test/resources</directory>
                              <targetPath>ch/codenation/test/service/resources</targetPath>
                              <excludes>
                                  <exclude>container/arquillian/arquillian.xml</exclude>
                              </excludes>
                          </testResource>
                      </testResources>
              
                      <plugins>
                          <plugin>
                              <groupId>org.apache.openejb.maven</groupId>
                              <artifactId>tomee-maven-plugin</artifactId>
                              <version>${tomee.version}</version>
                              <configuration>
                                  <tomeeVersion>${tomee.version}</tomeeVersion>
                                  <tomeeClassifier>${tomee.classifier}</tomeeClassifier>
                                  <path>${project.build.directory}/${project.artifactId}-${project.version}.war</path>
                              </configuration>
                          </plugin>
                          <plugin>
                              <groupId>org.apache.maven.plugins</groupId>
                              <artifactId>maven-war-plugin</artifactId>
                              <version>${war.plugin.version}</version>
                              <configuration>
                                  <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
                                  <webResources>
                                      <resource>
                                          <filtering>true</filtering>
                                          <directory>src/main/resources/webapp</directory>
                                          <targetPath>META-INF</targetPath>
                                          <includes>
                                              <include>context.xml</include>
                                          </includes>
                                      </resource>
                                  </webResources>
                              </configuration>
                          </plugin>
                      </plugins>
                  </build>
              
                  <profiles>
                      <profile>
                          <id>tomee-embedded</id>
                          <activation>
                              <activeByDefault>true</activeByDefault>
                          </activation>
                          <build>
                              <plugins>
                                  <plugin>
                                      <groupId>org.apache.maven.plugins</groupId>
                                      <artifactId>maven-surefire-plugin</artifactId>
                                      <version>${surefire.version}</version>
                                      <configuration>
                                          <includes>
                                              <include>**/AllTests.java</include>
                                          </includes>
                                      </configuration>
                                  </plugin>
                              </plugins>
                          </build>
                          <dependencies>
                              <dependency>
                                  <groupId>org.apache.openejb</groupId>
                                  <artifactId>arquillian-tomee-embedded</artifactId>
                                  <version>${tomee.version}</version>
                                  <scope>test</scope>
                              </dependency>
                          </dependencies>
                      </profile>
                      <profile>
                          <id>tomee-remote</id>
                          <build>
                              <plugins>
                                  <plugin>
                                      <groupId>org.apache.maven.plugins</groupId>
                                      <artifactId>maven-surefire-plugin</artifactId>
                                      <version>${surefire.version}</version>
                                      <configuration>
                                          <includes>
                                              <include>**/regression/**/*Test.java</include>
                                          </includes>
                                          <systemPropertyVariables>
                                              <tomee.httpPort>-1</tomee.httpPort>
                                              <tomee.stopPort>-1</tomee.stopPort>
                                              <tomee.ajpPort>-1</tomee.ajpPort>
                                              <tomee.classifier>plus</tomee.classifier>
                                              <tomee.version>${tomee.version}</tomee.version>
                                          </systemPropertyVariables>
                                      </configuration>
                                  </plugin>
                              </plugins>
                          </build>
                          <dependencies>
                              <dependency>
                                  <groupId>org.apache.openejb</groupId>
                                  <artifactId>arquillian-tomee-remote</artifactId>
                                  <version>${tomee.version}</version>
                                  <scope>test</scope>
                              </dependency>
                          </dependencies>
                      </profile>
                  </profiles>
              
                  <dependencies>
                      <dependency>
                          <groupId>ch.codenation</groupId>
                          <artifactId>codenation-maps</artifactId>
                          <version>${project.version}</version>
                      </dependency>
                      <dependency>
                          <groupId>org.jboss.arquillian.junit</groupId>
                          <artifactId>arquillian-junit-container</artifactId>
                          <scope>test</scope>
                      </dependency>
                      <dependency>
                          <groupId>org.jboss.shrinkwrap.resolver</groupId>
                          <artifactId>shrinkwrap-resolver-depchain</artifactId>
                          <scope>test</scope>
                          <type>pom</type>
                      </dependency>
              
                      <!-- Regression dependencies -->
                      <dependency>
                          <groupId>ch.codenation</groupId>
                          <artifactId>codenation-client-impl</artifactId>
                          <version>${project.version}</version>
                          <scope>test</scope>
                      </dependency>
                  </dependencies>
              </project>
              

               

              It features two profiles and is a bit longer than necessary, but I didn't want to cut things out here. The active profile is tomee-embedded. Its parent pom defines the following versions:

               

              <tomee.version>1.5.2</tomee.version>
              <shrinkwrap.resolvers.version>2.0.0-beta-5</shrinkwrap.resolvers.version>
              <arquillian.version>1.0.4.Final</arquillian.version>
              

               

              And arquillian.xml:

               

              <?xml version="1.0"?>
              <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="tomee-embedded" default="true">
                      <configuration>
                          <property name="httpPort">-1</property>
                          <property name="stopPort">-1</property>
                      </configuration>
                  </container>
                  <container qualifier="tomee-remote">
                      <configuration>
                          <property name="httpPort">-1</property>
                          <property name="stopPort">-1</property>
                          <property name="ajpPort">-1</property>
                          <property name="version">1.5.2</property>
                          <property name="classifier">plus</property>
                      </configuration>
                  </container>
              </arquillian>
              

               

              Running a JUnit test in eclipse with exactly these settings works. Console output tells me that the "-1" settings in arquillian.xml get considered:

               

              INFO: Destroying ProtocolHandler ["http-bio-53660"]
              

               

              However, if I adapt, just for testing purposes, the tomee-embedded profile to depend on the remote adapter rather than the embedded one

               

                          <dependencies>
                              <dependency>
                                  <groupId>org.apache.openejb</groupId>
                                  <artifactId>arquillian-tomee-remote</artifactId>
                                  <version>${tomee.version}</version>
                                  <scope>test</scope>
                              </dependency>
                          </dependencies>
              

               

              then port 8080 is used all of a sudden:

               

              INFO: Destroying ProtocolHandler ["http-bio-8080"]
              

               

              As you might have noticed, my second profile uses properties to get these settings across, in a simliar fashion as Kuba suggested (thanks for your input as well, and yes, it is quit a hassle :-). This works for the moment being, so it really is just a matter of preference.

               

              Thanks again and kind regards

              Pascal

              • 4. Re: tomee-remote ignores arquillian.xml
                John Ament Master

                Hmm, I was kind of hoping you were using tomee 1.5.1.

                 

                Yep, this is broken in tomee 1.5.2.  In the remote container, you need to specify the variables.

                 

                BTW, your arquillian config "tomee-embedded" is what the container would use.  You need to specify arquillian.launch to override it (though it'll still be futile).

                 

                https://docs.jboss.org/author/display/ARQ/Container+config+runtime+selection

                • 5. Re: tomee-remote ignores arquillian.xml
                  Pascal Kesseli Newbie

                  Hi again

                   

                  Thank you for that link, I'll be sure to incorporate that in my POM. As I said, it's far from being a showstopper, so I'll just stick with the properties variant until 1.5.3 is out.

                   

                  Thanks for coming back to me and best regards

                  Pascal