9
I'm trying to use Arquillian for some unit tests, however I can't find why they fail when deployed using Maven.
This is the class test:
package com.ndeveloper.spec.test;
import javax.inject.Inject;
import junit.framework.Assert;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.ndeveloper.spec.controller.GreetingBean;
@RunWith(Arquillian.class)
public class GreetingBeanTest {
@Inject
GreetingBean greetingBean;
@Deployment
public static JavaArchive createTestArchive()
{
return ShrinkWrap.create( JavaArchive.class,"test.jar").
addClass(GreetingBean.class).addAsManifestResource(
new ByteArrayAsset("<beans/>".getBytes()),
ArchivePaths.create("beans.xml"));
}
@Test
public void testInjection(){
Assert.assertEquals("Hello World", greetingBean.getGreeting());
}
}
And I'm using the jboss jboss-javaee6-webapp archetype. What's strange is that originally the test worked fine... However after using several times them. The following error started to appear:
Tests in error: com.ndeveloper.spec.test.GreetingBeanTest: Cannot obtain MBeanServerConnect to: service:jmx:rmi:///jndi/rmi://127.0.0.1:1090/jmxrmi
The surefire report says the following:
-------------------------------------------------------------------------------
Test set: com.ndeveloper.spec.test.GreetingBeanTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.309 sec <<< FAILURE!
com.ndeveloper.spec.test.GreetingBeanTest