Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find good unit testing resources for EJB and J2EE? [closed]

Which online resources, tutorials or books can you recommended to get started with unit testing J2EE / EJB3 applications?

So far I have found ejb3unit, Jakarta Cactus (retired 2011/08) and the Maven Cargo plugin. It would be helpful if there are complete working examples, ready to run.

Target containers are the open source products GlassFish, JBoss and Apache OpenEJB.

like image 622
mjn Avatar asked Nov 14 '09 09:11

mjn


People also ask

How do I test Java EE?

The simplest way to unit test Java EE components is to use plain JUnit without any special runner and Mockito to mock away every other involved component. @Stateless public class TaskStore { @PersistenceContext EntityManager entityManager; public List<Task> listAll() { return entityManager. createNamedQuery("Task.

Which framework would you use to run integration tests in Java EE?

You can use arquillian-glassfish-embedded-3.1 (also 3.0), arquillian-jbossas-embedded-6 (and older versions), Tomcat, Weld, or Jetty (see Listing 9). After the configuration of dependencies, you can use Arquillian as the test runner. The unit tests are executed by Arquillian transparently.


2 Answers

EJB Unit Testing with Eclipse and OpenEJB
Article on Testing EJB
Glassfish EJB 3.0 Unit testing
JUnitEE Tutorial
Effective Unit Testing EJB 3.0 with OpenEJB
JUnitEE IBM Tutorial

like image 177
luvieere Avatar answered Nov 16 '22 02:11

luvieere


The next version NetBeans 6.8 includes a nice new feature: it generates Unit-Tests for EJB 3.1 with Embeddable Container code.

@Test
public void testHello() throws Exception {
  System.out.println("hello");
  HelloService instance = (HelloService)javax.ejb.embeddable.EJBContainer.createEJBContainer().getContext().lookup("java:global/classes/HelloService");
  String expResult = "";
  String result = instance.hello();
  assertEquals(expResult, result);
  // TODO review the generated test code and remove the default call to fail.
  fail("The test case is a prototype.");
}
like image 45
mjn Avatar answered Nov 16 '22 02:11

mjn