I'd like some advice on the best approach to take when introducing Arquillian testing to a moderately complex legacy JEE application.
We use JBoss AS7, Postgres with some Infinispan, JMS, and Quartz. The application is comprised of a number of EJBs (8 of these, packaged as JARs), and web-services (7 of these, packaged as WARs) and is normally packaged and deployed as an EAR to JBoss AS7 via Maven's 'EAR' and 'JBoss AS' plugins. The target test-rig is JUnit/Arquillian tests on a managed JBoss AS7 (but I'm open to suggestions). The application was originally targeted at AS6 but has been ported to AS7 without significant code changes.
The EAR is structured like this:
/META-INF/MANIFEST.MF <- includes infinispan dependency
I'm able to modify the application structure a limited amount if it improves testability. There are a few inter-module dependencies.
- I've got the current (05/2012) Getting Started guide to work.
- I've tried to package a single EJB component as a JAR but was defeated by dependencies on other modules. I tried deploying these separately but couldn't make them visible to the module under test.
- I then tried to package the component, along with dependencies as a minimal EAR to avoid the class-loader issues I was seeing. This did not work either. I was trying to use the Maven dependency resolver in my JUnit test class to resolve and include the JAR dependencies automatically (using ShrinkWrap) . Maybe this was too ambitious; I seemed unable to specify wildcard / 'latest' versions of the components, or where I'd like them to be placed in the archive, and was seeing the component under test coming from a very temporary looking location (i.e. not ~/.m2/repository/...)
I'd like to make use of the Maven config we've got, to avoid manually tracking 101 class dependencies and inclusions for each component. I'd also like the tests to be 'real', i.e. involving all the necessary deployed components, but no more.
So, my question, really, is: What's the best approach to testing a legacy multi-module, Maven-built JBoss AS7 application (or components of that application) using Arquillian?
A couple of secondary, more specific questions:
- If I want to build a testable EAR (with e.g. Maven's maven-ear-plugin), what's the best way of getting this going? Do I rely on this plugin to also bundle the Arquillian stuff - example pom, please! - or do I build an EAR with ShrinkWrap? How then do I include (and poss. build the dependencies as JARs/WARs?
- Inter-component dependencies: My intuition says keep the tests as real as possible, but pragmatism says get something working, possibly by manually including .class files to satisfy all the dependencies. There are a lot so if I can automate this (maven dependency resolver? Is this configurable enough?), so much the better. How have others solved cross-class-loader issues? Particularly when an isolated EJB actually has dependencies on other components?
Thanks for your thoughts,