In order to use local JUnit tests to test an EJB module that is deployed on a server, you need to configure the tests to act as a remote client of the EJB module. This means you can only access the EJB module through its remote interfaces.
Usually, you have some entity beans and a session bean with remote interfaces that provides clients access to the entity beans. You have to generate tests for the session bean's bean class and modify the test file to reference the session bean and test each of its business methods.
To generate tests for an EJB module:
protected void setUp() throws NamingException, CreateException, RemoteException { ServiceLocator sl = new ServiceLocator(); newSessionHome = (NewSessionRemoteHome)sl.getRemoteHome("ejb/NewSessionBean", NewSessionRemoteHome.class); }
try { NewSessionRemote newSession = newSessionHome.create(); assertEquals("name", newSession.getName(new Integer(1))); } catch (Exception e) { fail(e.toString()); }