Arquillian 1.0.0CR7 JBoss 7.0.1.Final all tests pass
scraatz Jan 31, 2012 6:30 AMHi, we are trying to switch our testing environment to Arquillian. After several fruitless hours we managed to deploy and start our tests without any errors. But then I got suspicious because all tests passed. That is not very probable so I created a test, that does nothing but fail(). This one passes too. It seems, that the test runner does not communicate with the in-container test. Beside the fact, that in my opinion the test should fail in that case, I seem to be doing something wrong. After spending several hours, I am hoping to get help here: This is my maven profile. I tried with and without the commented-out dependency:
<profile>
<!-- An optional Arquillian testing profile that executes tests
in your JBoss AS instance -->
<!-- This profile will start a new JBoss AS instance, and execute the
test, shutting it down when done -->
<!-- Run with: mvn clean test -Parq-jbossas-managed -->
<id>arq-jbossas-managed</id>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-managed</artifactId>
<version>7.0.2.Final</version>
</dependency>
<!-- <dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-managed</artifactId>
<version>${jboss.version}</version>
<scope>test</scope>
</dependency>
-->
<dependency>
<groupId>org.jboss.arquillian.testng</groupId>
<artifactId>arquillian-testng-container</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
This is my test:
public class CopyOfBenutzerTest extends Arquillian {
private Benutzer benutzer = null;
private Benutzer benutzerTest = null;
@Deployment(testable = true)
public static JavaArchive createTestArchive() {
/**
* Define a package filter that filters out all Test classes.
*/
Filter<ArchivePath> filter = new Filter<ArchivePath>() {
@Override
public boolean include(ArchivePath path) {
return !path.get().endsWith("Test.class");
}
};
return ShrinkWrap.create(JavaArchive.class, "besozial-test.jar")
.addPackages(true, filter, "de.comitatus.besozial.entity")
.addPackages(true, filter, "de.comitatus.besozial.session")
.addPackages(true, filter, "de.comitatus.besozial.dto").addClass(ArquillianTestBase.class)
.addClass(SessionTestBase.class).addClass(DBFixBase.class)
.addAsManifestResource(new ByteArrayAsset("<beans/>".getBytes()), ArchivePaths.create("beans.xml"))
.addAsManifestResource(new File("/test-persistence.xml"), ArchivePaths.create("persistence.xml"));
}
@Resource(mappedName = "java:/module/UserTransaction")
protected UserTransaction transaction;
@PersistenceContext
protected EntityManager em;
@Test
@RunAsClient
public void testNothingJustFailLocal() {
log().error("Starting test");
System.err.println("Starting test");
fail("sd jh");
}
@Test
public void testNothingJustFail() {
log().error("Starting test");
System.err.println("Starting test");
fail("sd jh");
}
@Test
public void testNewUser() {
log().error("Starting test");
System.err.println("Starting test");
beginTransaction();
benutzer = new Benutzer("test", "pwtest");
em.persist(benutzer);
commitTransaction();
beginTransaction();
benutzerTest = em.find(Benutzer.class, benutzer.getId().intValue());
commitTransaction();
assertNotNull("Id was generated.", benutzerTest.getId());
assertEquals("test", benutzerTest.getLogin());
assertNotSame("pwtest", benutzerTest.getPasswort()); // Passwort sollte jetzt verschluesselt sein
fail("sd jh");
}
@Test(dependsOnMethods = "testNewUser")
public void testAccessors() {
beginTransaction();
benutzer = em.find(Benutzer.class, benutzer.getId());
benutzer.setLogin("SLogin");
benutzer.setAktuell(true);
benutzer.setNickname("SNick");
benutzer.setFirstname("SFirst");
benutzer.setName("SName");
benutzer.setBirthday(java.sql.Date.valueOf("2010-05-04"));
benutzer.setFbUserId("SfbID");
benutzer.setFbAccessToken("123456");
benutzer.setFbAccessTokenExpires("123456");
benutzer.setUserImage("/ben/image");
benutzer.setEmail("ben@email.de");
em.merge(benutzer);
commitTransaction();
beginTransaction();
benutzerTest = null;
benutzerTest = em.find(Benutzer.class, benutzer.getId());
commitTransaction();
assertEquals("SLogin", benutzerTest.getLogin());
assertEquals(true, benutzerTest.getAktuell());
assertEquals("SNick", benutzerTest.getNickname());
assertEquals("SName", benutzerTest.getName());
assertEquals(java.sql.Date.valueOf("2010-05-04"), benutzerTest.getBirthday());
assertEquals("SfbID", benutzerTest.getFbUserId());
assertEquals("123456", benutzerTest.getFbAccessToken());
assertEquals("123456", benutzerTest.getFbAccessTokenExpires());
assertEquals("/ben/image", benutzerTest.getUserImage());
assertEquals("ben@email.de", benutzerTest.getEmail());
}
When I run the test, JBoss is startet, the EJB jar is deployed and all tests but the local fail test pass. Same behaviour in Eclipse Test Runner and maven test. Though I see some strange error messages in the server log:
31.01.2012 12:26:34 org.jboss.as.arquillian.container.managed.ManagedDeployableContainer startInternal INFO: Starting container with: [java, -Xmx512m, -XX:MaxPermSize=128m, -Djboss.home.dir=J:\\Appserver\\jboss-as-7.0.2.Final, -Dorg.jboss.boot.log.file=J:\\Appserver\\jboss-as-7.0.2.Final/standalone/log/boot.log, -Dlogging.configuration=file:J:\\Appserver\\jboss-as-7.0.2.Final/standalone/configuration/logging.properties, -Djboss.modules.dir=J:\\Appserver\\jboss-as-7.0.2.Final\modules, -jar, J:\Appserver\jboss-as-7.0.2.Final\jboss-modules.jar, -mp, J:\\Appserver\\jboss-as-7.0.2.Final\modules, -logmodule, org.jboss.logmanager, -jaxpmodule, javax.xml.jaxp-provider, org.jboss.as.standalone, -server-config, standalone.xml] 31.01.2012 12:26:34 org.jboss.remoting3.EndpointImpl <clinit> INFO: JBoss Remoting version 3.2.0.Beta2 31.01.2012 12:26:34 org.xnio.Xnio <clinit> INFO: XNIO Version 3.0.0.Beta3 31.01.2012 12:26:34 org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.0.0.Beta3 12:26:35,651 INFO [org.jboss.modules] JBoss Modules version 1.0.2.GA .... 12:26:39,236 INFO [org.jboss.as] (Controller Boot Thread) JBoss AS 7.0.2.Final "Arc" started in 3860ms - Started 115 of 175 services (57 services are passive or on-demand) 31.01.2012 12:26:40 org.jboss.as.arquillian.protocol.jmx.ArquillianServiceDeployer doServiceDeploy INFO: Deploy arquillian service: arquillian-service: 1080 assets 12:26:42,304 INFO [org.jboss.as.server.deployment] (pool-1-thread-1) Content added at location J:\Appserver\jboss-as-7.0.2.Final\standalone\data\content\ff\b06fe014723aa04626b4d4117df9e653bc3cf1\content 12:26:42,307 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) Starting deployment of "arquillian-service" 12:26:42,562 INFO [org.jboss.as.jpa] (MSC service thread 1-2) added javax.persistence.api dependency to arquillian-service 12:26:42,584 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-2) JBossOSGi Framework Core - 1.0.0.CR8 ... 12:26:45,168 INFO [org.jboss.osgi.framework.internal.FrameworkActive] (MSC service thread 1-1) OSGi Framework started 12:26:45,168 INFO [org.jboss.as.osgi] (MSC service thread 1-1) JBAS011920: Register module: Module "deployment.arquillian-service:main" from Service Module Loader 12:26:45,179 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-2) Install bundle: arquillian-service:0.0.0 12:26:45,318 INFO [org.jboss.as.server.controller] (pool-1-thread-1) Deployed "arquillian-service" 31.01.2012 12:26:45 org.jboss.remoting3.remote.RemoteConnection handleException ERROR: JBREM00200: Remote connection failed: java.io.IOException: Window open for non-existent channel 12:26:45,970 INFO [org.jboss.as.server.deployment] (pool-1-thread-1) Content added at location J:\Appserver\jboss-as-7.0.2.Final\standalone\data\content\be\a060002eb8a48903aca0b076e3f0eb658e1f54\content 12:26:45,974 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) Starting deployment of "besozial-test.jar" ... 12:26:52,496 INFO [org.jboss.as.server.controller] (pool-1-thread-1) Deployed "besozial-test.jar" 31.01.2012 12:26:54 de.comitatus.besozial.entity.benutzer.CopyOfBenutzerTest testNothingJustFailLocal ERROR: Starting test Starting test 12:26:54,708 INFO [org.jboss.weld] (MSC service thread 1-2) Stopping weld service 12:26:54,715 INFO [org.jboss.as.server.controller] (pool-1-thread-1) Undeployed "besozial-test.jar" 12:26:54,715 INFO [org.jboss.jpa] (MSC service thread 1-2) stopping Persistence Unit Service 'besozial-test.jar#beSozial' 12:26:54,744 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) Stopped deployment besozial-test.jar in 51ms PASSED: testNewUser PASSED: testNothingJustFail PASSED: testAccessors PASSED: removeTestdata FAILED: testNothingJustFailLocal java.lang.AssertionError: sd jh ... =============================================== Default test Tests run: 5, Failures: 1, Skips: 0 =============================================== 31.01.2012 12:26:54 org.jboss.as.arquillian.protocol.jmx.ArquillianServiceDeployer undeploy INFO: Undeploy arquillian service: arquillian-service: 1080 assets 12:26:55,051 INFO [org.jboss.as.osgi] (MSC service thread 1-1) JBAS011922: Unregister module: Module "deployment.arquillian-service:main" from Service Module Loader 12:26:55,052 ERROR [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-1) Cannot find bundle associated with module: deployment.arquillian-service:main 12:26:55,065 INFO [org.jboss.as.server.controller] (pool-1-thread-1) Undeployed "arquillian-service" 12:26:55,078 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) Stopped deployment arquillian-service in 29ms 31.01.2012 12:26:55 org.jboss.remoting3.remote.RemoteConnection handleException ERROR: JBREM00200: Remote connection failed: java.io.IOException: Eine vorhandene Verbindung wurde vom Remotehost geschlossen
When I switch back to CR5 of Arquillian, the system complains about some TestNG missing method. So I suspect that the test runner communicates with the container in that version. Forgot my arquillian.xml. Tried with and without protocol definition.
<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">
<engine>
<property name="deploymentExportPath">target</property>
</engine>
<container qualifier="jboss7" default="true">
<protocol type="jmx-as7">
<property name="executionType">REMOTE</property>
</protocol>
<configuration>
<property name="jbossHome">${target.environment.jbossHome}</property>
</configuration>
</container>
</arquillian>
Thanks for any help.
Stefan