Newbie having issues testing Arquillian with Spring
richieloco May 28, 2013 5:17 PMHi,
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}
-----
-
pom.xml 14.5 KB