6 Replies Latest reply on May 29, 2013 6:50 PM by aslak

    Newbie having issues testing Arquillian with Spring

    richieloco

      Hi,

       

      I've been experimenting with using Arquillian for my integration tests with my Spring managed project now for the past few days, so i'm completely new to it. I don't seem to be able to test it via the managed JBoss AS 7 on my local workstation.  Firstly, I was getting issues similar to user post on here https://community.jboss.org/message/756192 and after following through this post and removing a lot of noise from my pom.xml and test class I was able to get passed this.  I am now encountering an issue similar to post on here https://community.jboss.org/message/739951 - I have made sure that the JBoss HOME directory and it's parent are also writable. I've also made sure that the {noformat}standalone/data{noformat} and {noformat}standalone/logs{noformat} directories within JBoss are also writable.

       

      Below is a copy of what I get when I run {noformat}mvn -e clean -Parq-jbossas-managed{noformat} from within my eclipse project's directory.  I've also attached a copy of my pom.xml file (as it's too long to paste it all on here) and at the very bottom is a copy of my PlayerServiceTest class that has been annotated to use the Arquillian Spring Framework.

       

      Any help or nudges into the right direction would be very much appreciated

       

      Kind Regards,

      Rich

       

      -----

      {code}

      (null):terrorsyndicate_local RichieLoco$ mvn -e clean test -Parq-jbossas-managed

      [INFO] Error stacktraces are turned on.

      [INFO] Scanning for projects...

      [INFO]                                                                        

      [INFO] ------------------------------------------------------------------------

      [INFO] Building terrorsyndicate_local 0.0.1-SNAPSHOT

      [INFO] ------------------------------------------------------------------------

      [INFO]

      [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ terrorsyndicate_local ---

      [INFO] Deleting /Users/RichieLoco/Documents/workspace/terrorsyndicate_local/target

      [INFO]

      [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ terrorsyndicate_local ---

      [INFO] Using 'UTF-8' encoding to copy filtered resources.

      [INFO] Copying 4 resources

      [INFO]

      [INFO] --- maven-compiler-plugin:2.3.1:compile (default-compile) @ terrorsyndicate_local ---

      [INFO] Compiling 32 source files to /Users/RichieLoco/Documents/workspace/terrorsyndicate_local/target/classes

      [INFO]

      [INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ terrorsyndicate_local ---

      [INFO] Using 'UTF-8' encoding to copy filtered resources.

      [INFO] Copying 4 resources

      [INFO]

      [INFO] --- maven-compiler-plugin:2.3.1:testCompile (default-testCompile) @ terrorsyndicate_local ---

      [INFO] Compiling 2 source files to /Users/RichieLoco/Documents/workspace/terrorsyndicate_local/target/test-classes

      [INFO]

      [INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ terrorsyndicate_local ---

      [INFO] Surefire report directory: /Users/RichieLoco/Documents/workspace/terrorsyndicate_local/target/surefire-reports

       

       

      -------------------------------------------------------

      T E S T S

      -------------------------------------------------------

      Running com.richieloco.terrorsyndicate.local.GeneralSetupTest

      2013-05-28 21:53:48,150 INFO [com.richieloco.terrorsyndicate.local.GeneralSetupTest] - hi there!

      Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.117 sec

      Running com.richieloco.terrorsyndicate.local.service.PlayerServiceTest

      2013-05-28 21:53:48,396 DEBUG [org.jboss.logging] - Logging Provider: org.jboss.logging.Log4jLoggerProvider

      May 28, 2013 9:53:48 PM org.jboss.as.arquillian.container.managed.ManagedDeployableContainer startInternal

      INFO: Starting container with: [/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre/bin/java, -Xmx512m, -XX:MaxPermSize=128m, -ea, -Djboss.home.dir=/Users/RichieLoco/jboss-as-7.1.1.Final, -Dorg.jboss.boot.log.file=/Users/RichieLoco/jboss-as-7.1.1.Final/standalone/log/boot.log, -Dlogging.configuration=file:/Users/RichieLoco/jboss-as-7.1.1.Final/standalone/configuration/logging.properties, -Djboss.modules.dir=/Users/RichieLoco/jboss-as-7.1.1.Final/modules, -Djboss.bundles.dir=/Users/RichieLoco/jboss-as-7.1.1.Final/bundles, -jar, /Users/RichieLoco/jboss-as-7.1.1.Final/jboss-modules.jar, -mp, /Users/RichieLoco/jboss-as-7.1.1.Final/modules, -jaxpmodule, javax.xml.jaxp-provider, org.jboss.as.standalone, -server-config, standalone.xml]

      2013-05-28 21:53:48,753 INFO [org.xnio] - XNIO Version 3.0.0.GA

      2013-05-28 21:53:48,780 INFO [org.xnio.nio] - XNIO NIO Implementation Version 3.0.0.GA

      2013-05-28 21:53:48,802 INFO [org.jboss.remoting] - JBoss Remoting version 3.2.3.GA

      2013-05-28 21:53:48,834 DEBUG [org.xnio.nio] - Started channel thread 'Remoting "management-client" read-1', selector sun.nio.ch.KQueueSelectorImpl@23f4ebfe

      2013-05-28 21:53:48,834 DEBUG [org.xnio.nio] - Started channel thread 'Remoting "management-client" write-1', selector sun.nio.ch.KQueueSelectorImpl@21881a7

      21:53:49,195 INFO  [org.jboss.modules] JBoss Modules version 1.1.1.GA

      21:53:49,590 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA

      21:53:49,649 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting

      21:53:49,766 ERROR [org.jboss.msc.service.fail] MSC00001: Failed to start service jboss.deployment-mount-provider: org.jboss.msc.service.StartException in service jboss.deployment-mount-provider: JBAS015843: Failed to create temp file provider

                at org.jboss.as.server.deployment.DeploymentMountProvider$Factory$ServerDeploymentRepositoryImpl.start(DeploymentMountProvider.java:111) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_21]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_21]

                at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]

      {code}

      -----

       

      PlayerServiceTest.java

       

      -----

      {code}

      package com.richieloco.terrorsyndicate.local.service;

       

      import java.io.File;

      import java.util.Date;

       

      import junit.framework.Assert;

       

      import org.jboss.arquillian.container.test.api.Deployment;

      import org.jboss.arquillian.container.test.api.RunAsClient;

      import org.jboss.arquillian.junit.Arquillian;

      import org.jboss.arquillian.spring.integration.test.annotation.SpringConfiguration;

      import org.jboss.shrinkwrap.api.ShrinkWrap;

      import org.jboss.shrinkwrap.api.spec.WebArchive;

      import org.jboss.shrinkwrap.resolver.api.DependencyResolvers;

      import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;

      import org.junit.Test;

      import org.junit.runner.RunWith;

      import org.springframework.beans.factory.annotation.Autowired;

       

      import com.richieloco.terrorsyndicate.local.domain.Player;

       

      @RunWith(Arquillian.class)

      @SpringConfiguration("applicationContext.xml")

      public class PlayerServiceTest {

      @SuppressWarnings("deprecation")

      @Deployment

                public static WebArchive createTestArchive() {

       

                          File[] libs = DependencyResolvers.use(MavenDependencyResolver.class)

                                              .loadMetadataFromPom("pom.xml")

                                              .artifacts("org.springframework:spring-webmvc:3.2.2.RELEASE")

                                              .artifacts("org.hibernate:hibernate-search")

                                              .artifacts("org.hibernate:hibernate-core")

                                              .artifacts("org.hibernate.ogm:hibernate-ogm-core")

                                              .artifacts("org.hibernate.ogm:hibernate-ogm-infinispan")

                                              .artifacts("org.hibernate.ogm:hibernate-ogm-mongodb")

                                              .resolveAsFiles();

       

                          return ShrinkWrap.create(WebArchive.class, "terrorsyndicate_local-test.war")

                                              .addPackage(Player.class.getPackage())

                                              .addPackage(PlayerService.class.getPackage())

                                              .addAsResource("META-INF/persistence.xml", "persistence.xml")

                                              .addAsWebInfResource("WEB-INF/arquillian.xml", "arquillian.xml")

                                              .addAsWebInfResource("WEB-INF/applicationContext.xml","applicationContext.xml")

                                              .addAsWebInfResource("WEB-INF/log4j.properties","log4j.properties")

                                              .addAsLibraries(libs);

                }

       

      @Autowired

                private PlayerService playerService;

       

      @Test

      @RunAsClient

                public void testIsLoggerNotNull(){

      //                    Assert.assertNotNull("DI has failed as Logger is null!", log);

                }

       

      @Test

      @RunAsClient

                public void testIsDeployed(){

                          Assert.assertNotNull("DI has failed as PlayerService is null!", playerService);

                }

       

      @Test

      @RunAsClient

                public void testPlayerPersist() {

                          Player player = new Player();

                          player.setName("RichieLoco");

                          player.setGender(Player.Gender.MALE);

                          player.setJoinDate(new Date());

                          Assert.assertEquals(0, playerService.getAll().size());

                          try {

                                    playerService.save(player);

                          } catch (Exception ex) {

      //                              log.error("Could not persist player: ", ex);

                          }

                          Assert.assertEquals(1, playerService.getAll().size());

                }

      }

      {code}

      -----

        • 1. Re: Newbie having issues testing Arquillian with Spring
          aslak

          Heya

           

          Is there any usefull informtion in the JBoss AS server.log?

          • 2. Re: Newbie having issues testing Arquillian with Spring
            richieloco

            Thanks for getting back to me so soon.

             

            When I start up the JBoss instance manually it starts up fine. I've loaded up an example project as well (which didn't use Arquillian, just standard unit testing) and that also worked. It just seems to be when I bring down the JBoss instance and then attempt to start it via command "mvn -e clean -Parq-jbossas-managed".  When I do this it sort of leaves the server in a state where it appears to be running because I need to Ctrl-C to exit it.  This in itself doesn't actually write any output into my server.log

             

            However, inside my boot.log I'm getting the below:

             

            06:17:02,274 DEBUG [org.jboss.as.config] VM Arguments: -Xmx512m -XX:MaxPermSize=128m -ea -Djboss.home.dir=/Users/RichieLoco/jboss-as-7.1.1.Final -Dorg.jboss.boot.log.file=/Users/RichieLoco/jboss-as-7.1.1.Final/standalone/log/boot.log -Dlogging.configuration=file:/Users/RichieLoco/jboss-as-7.1.1.Final/standalone/configuration/logging.properties -Djboss.modules.dir=/Users/RichieLoco/jboss-as-7.1.1.Final/modules -Djboss.bundles.dir=/Users/RichieLoco/jboss-as-7.1.1.Final/bundles

            06:17:02,360 ERROR [org.jboss.msc.service.fail] MSC00001: Failed to start service jboss.deployment-mount-provider: org.jboss.msc.service.StartException in service jboss.deployment-mount-provider: JBAS015843: Failed to create temp file provider

                    at org.jboss.as.server.deployment.DeploymentMountProvider$Factory$ServerDeploymentRepositoryImpl.start(DeploymentMountProvider.java:111) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_21]

                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_21]

                    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]

             

            But this is the same as the console output that I get.  Anything else worth trying?

             

            Kind Regards,

            Rich

            • 3. Re: Newbie having issues testing Arquillian with Spring
              aslak

              I see you're using a very old version of Maven Surefire, 2.4.3. I believe it was in 2.9 we got fixed a bug that caused the shutdown to never be called. Try upgrading to 2.11 or something.

              • 4. Re: Newbie having issues testing Arquillian with Spring
                richieloco

                Hi, still no luck there.  I've updated the following (including the Java source and target version for the compiler as this was a mismatch from version of JVM):

                 

                -----

                 

                          <build>

                                    <finalName>${project.artifactId}</finalName>

                                    <plugins>

                                              <plugin>

                                <artifactId>maven-compiler-plugin</artifactId>

                                <version>3.0</version>

                                <configuration>

                                    <source>1.7</source>

                                    <target>1.7</target>

                                </configuration>

                            </plugin>

                            <plugin>

                                <groupId>org.apache.maven.plugins</groupId>

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

                                <version>2.12</version>

                                <configuration>

                                    <testFailureIgnore>true</testFailureIgnore>

                                </configuration>

                            </plugin>

                            <plugin>

                                <artifactId>maven-war-plugin</artifactId>

                                <version>2.3</version>

                                <configuration>

                                    <!-- Java EE 6 doesn't require web.xml, Maven needs to catch up! -->

                                    <failOnMissingWebXml>false</failOnMissingWebXml>

                                    <packagingExcludes>

                                        WEB-INF/lib/aether-*.jar,WEB-INF/lib/dom4j-*.jar,WEB-INF/lib/hibernate-core-*.jar,WEB-INF/lib/javassist-*.jar,WEB-INF/lib/jboss-*.jar,WEB-INF/lib/log4j-*.jar,WEB-INF/lib/maven-*.jar,WEB-INF/lib/plexus-*.jar,WEB-INF/lib/shrinkwrap-*.jar,WEB-INF/lib/solr-*.jar,WEB-INF/lib/hibernate-commons-*.jar,WEB-INF/lib/wagon-*.jar,WEB-INF/lib/xbean-*.jar,WEB-INF/lib/antlr-*.jar

                                    </packagingExcludes>

                                </configuration>

                            </plugin>

                                              <plugin>

                                      <groupId>org.jboss.as.plugins</groupId>

                                      <artifactId>jboss-as-maven-plugin</artifactId>

                                      <version>${version.org.jboss.as.plugins.maven.plugin}</version>

                                   </plugin>

                                    </plugins>

                          </build>

                 

                -----

                 

                This is still giving me the following error:

                 

                19:20:55,099 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting

                19:20:55,211 ERROR [org.jboss.msc.service.fail] MSC00001: Failed to start service jboss.deployment-mount-provider: org.jboss.msc.service.StartException in service jboss.deployment-mount-provider: JBAS015843: Failed to create temp file provider

                          at org.jboss.as.server.deployment.DeploymentMountProvider$Factory$ServerDeploymentRepositoryImpl.start(DeploymentMountProvider.java:111) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_21]

                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_21]

                          at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]

                19:20:55,099 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting

                19:20:55,211 ERROR [org.jboss.msc.service.fail] MSC00001: Failed to start service jboss.deployment-mount-provider: org.jboss.msc.service.StartException in service jboss.deployment-mount-provider: JBAS015843: Failed to create temp file provider

                          at org.jboss.as.server.deployment.DeploymentMountProvider$Factory$ServerDeploymentRepositoryImpl.start(DeploymentMountProvider.java:111) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_21]

                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_21]

                          at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]

                 

                Anything else that I can quickly try? Any further info that you need from me?

                 

                Cheers,

                Rich

                • 5. Re: Newbie having issues testing Arquillian with Spring
                  richieloco

                  Hey,

                   

                  I ended up downloading and unzippin JBoss AS 7.1 Final again.  I then just "chmod -R 777 $JBOSS_HOME/standalone/" directory (seeing as all my errors seem to be related to some sort of permissioning.  I then fired up my test case and it bloody worked! ok, well, the test itself still failed due to my method to create a test archive not working properly, but at least it started the server and executed the test case and then exit cleanly from the server again The new issue... well, that's for a different day and maybe a different discussion.

                   

                  Thanks for the help

                  Rich

                  • 6. Re: Newbie having issues testing Arquillian with Spring
                    aslak

                    Great!

                     

                    Happy testing!