I'm trying to get some unit tests running for an already-existing project, using Arquillian.
My basic test:
@RunWith(Arquillian.class)
public class InferenceTest {
@EJB private InferenceEJB inferenceEJB;
@Deployment
public static JavaArchive createDeployment() {
return ShrinkWrap.create(JavaArchive.class)
.addClasses(...my classes...)
.addPackages(false, ...packages from my classes...)
.addAsManifestResource(
EmptyAsset.INSTANCE,
ArchivePaths.create("beans.xml")
);
}
@Test
public void testInference() throws NamingException {
assertNotNull("Successfully injected an EJB", inferenceEJB);
}
}
When I run this with maven (mvn test), I get a mountain of problems. Basically, they boil down to three things:
- "SEVERE" messages indicating that some EJB (that's not being tested here, and is not injected into anything used by this test) was not resolved, e.g.
SEVERE: Exception while deploying the app [e03a719e-27d5-4cdd-af7f-70831402560c] : Cannot resolve reference Local ejb-ref name=......ExportEJB/managerEJB,Local 3.x interface =.......DataManagerEntity,ejb-link=null,lookup=,mappedName=,jndi-name=,refType=Session PlainTextActionReporterFAILUREDescription: deploy AdminCommandError occurred during deployment: Exception while deploying the app [e03a719e-27d5-4cdd-af7f-70831402560c] : Cannot resolve reference Local ejb-ref name=.......ExportEJB/managerEJB,Local 3.x interface =........DataManagerEntity,ejb-link=null,lookup=,mappedName=,jndi-name=,refType=Session. Please see server.log for more details.
- The test fails because inferenceEJB is null.
I've tried to solve the first problem by adding all concerned classes/packages to the @Deployment, but with no success. And I have no idea what's causing the last one.
Anybody have any ideas?