1

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?

Kricket
  • 4,049
  • 8
  • 33
  • 46
  • Does [this](http://stackoverflow.com/a/10105036/3916) help you in any way? – Vineet Reynolds Jan 18 '13 at 14:25
  • No, I had already tried stuff like that, to no avail... – Kricket Jan 18 '13 at 15:41
  • Could you please put up the full stack trace and pom.xml? – LightGuard Jan 20 '13 at 15:13
  • Seeing that this is a deployment failure in GlassFish preceding the test execution, it might be better to trim down the ShrinkWrap deployment to include the barebone dependencies for your EJB component. Or for that matter, expand your ShrinkWrap deployment to match the structure of the module. Additionally, it would be better to ensure that your EJBs can actually be deployed in GF; it's a tad pointless to attempt running an Arquillian test if the EJBs cannot be deployed by GF. – Vineet Reynolds Jan 21 '13 at 11:35
  • Yeah, looking at doing a better job with ShrinkWrap. It's tricky because there are a lot of EJBs, with all their dependencies and whatnot...but the regular EAR does deploy successfully to GF. – Kricket Jan 22 '13 at 08:52

0 Answers0