For unit testing, you can use JUnit, TestNG and your favorite mocking framework (EasyMock, Mockito, PowerMock, JMockit, JMock).
For integration testing, you could start/stop an embeddable container (JBoss, OpenEJB, GlassFish v3) from your tests. Or, have a look at Arquillian, a very recent new player for integration testing of Java EE applications:
The mission of the Arquillian project is to provide a simple test harness that developers can use to produce a broad range of integration tests for their Java applications (most likely enterprise applications). A test case may be executed within the container, deployed alongside the code under test, or by coordinating with the container, acting as a client to the deployed code.
To avoid introducing unnecessary complexity into the developer's build environment, Arquillian integrates transparently with familiar testing frameworks (e.g. JUnit 4, TestNG 5), allowing tests to be launched using existing IDE, Ant and Maven test plugins without any add-ons.
Also check Improving the Testability of Java EE With Arquillian 1.0.0 Alpha 1 Released and the Arquillan space. Looks interesting IMO.
answered 2010-03-24T05:44:23.377