1 package org.jboss.docs.cmp2.crimeportal; 2 3 import java.util.Collection ; 4 import java.util.HashSet ; 5 import java.util.Set ; 6 import java.util.Iterator ; 7 import javax.naming.InitialContext ; 8 import javax.ejb.EJBLocalObject ; 9 10 import junit.framework.Test; 11 import junit.framework.TestCase; 12 import junit.framework.TestSuite; 13 import net.sourceforge.junitejb.EJBTestCase; 14 15 public class CrimePortalTearDown extends EJBTestCase { 16 public static Test suite() { 17 TestSuite testSuite = new TestSuite("CrimePortalTearDown"); 18 testSuite.addTestSuite(CrimePortalTearDown.class); 19 return testSuite; 20 } 21 22 public CrimePortalTearDown(String name) { 23 super(name); 24 } 25 26 public void testTearDown() throws Exception { 27 InitialContext jndi = new InitialContext (); 28 29 OrganizationHome organizationHome = 31 (OrganizationHome) jndi.lookup("crimeportal/Organization"); 32 Iterator organizations = organizationHome.findAll().iterator(); 33 while(organizations.hasNext()) { 34 EJBLocalObject ejb = (EJBLocalObject )organizations.next(); 35 ejb.remove(); 36 } 37 38 GangsterHome gangsterHome = 40 (GangsterHome) jndi.lookup("crimeportal/Gangster"); 41 Iterator gangsters = gangsterHome.findAll().iterator(); 42 while(gangsters.hasNext()) { 43 EJBLocalObject ejb = (EJBLocalObject )gangsters.next(); 44 ejb.remove(); 45 } 46 47 JobHome jobHome = (JobHome) jndi.lookup("crimeportal/Job"); 49 Iterator jobs = jobHome.findAll().iterator(); 50 while(jobs.hasNext()) { 51 EJBLocalObject ejb = (EJBLocalObject )jobs.next(); 52 ejb.remove(); 53 } 54 } 55 } 56 | Popular Tags |