package org.laughingpanda.ejb_migration_example.ejb; import jdave.Specification; import jdave.junit4.JDaveRunner; import org.junit.runner.RunWith; import org.laughingpanda.ejb_migration_example.SearchParameters; import org.laughingpanda.ejb_migration_example.Person; import javax.ejb.CreateException; import javax.ejb.RemoveException; import javax.naming.NamingException; import java.rmi.RemoteException; import java.sql.SQLException; import java.util.List; /** * @author Timo Rantalaiho */ @RunWith(JDaveRunner.class) public class PersonManagerEjbInContainerSpec extends Specification { public class AfterCreation { private PersonEntity person; public PersonManagerBean create() throws NamingException, SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, CreateException, RemoteException { PersonManagerBean manager = new PersonManagerBean(); person = manager.create("john-" + System.currentTimeMillis(), "John", "Doe"); return manager; } public void destroy() throws SQLException, RemoveException, RemoteException { person.remove(); } public void findsPersonsFromDatabase() throws RemoteException { List results; results = context.findPersons(new SearchParameters("inexistent")); specify(results, does.not().contain(person)); results = context.findPersons(new SearchParameters("Jo")); specify(results, contain(person)); } } }