Got it working the following:
pom.xml:
... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <suiteXmlFiles> <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile> </suiteXmlFiles> <!-- This trick allows the JBoss EJB3StandaloneBootstrap to find and deploy our compiled EJBs!! --> <systemProperties> <property> <name>java.class.path</name> <value>target/classes</value> </property> </systemProperties> </configuration> </plugin> ...
public class EJB3Test extends AssertJUnit { @Configuration(groups = "integration.ejb3", beforeSuite = true) public static void startupEmbeddedJboss() { EJB3StandaloneBootstrap.boot(null); EJB3StandaloneBootstrap.scanClasspath(); } @Configuration(groups = "integration.ejb3", afterSuite = true) public static void shutdownEmbeddedJboss() { EJB3StandaloneBootstrap.shutdown(); } @Test(groups = "integration.ejb3") public void testSubtract() throws Exception { Calculator calculator = (Calculator) new InitialContext().lookup("CalculatorBean/local"); assertEquals(0, calculator.subtract(1, 1)); } }
Right it should works !
Another great features for EJB3StandaloneBootstrap class will be to have a method:
EJB3StandaloneBootstrap.scanClasspath(URL[] urls)