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 CrimePortalSetUp extends EJBTestCase 16 implements CrimePortalTestConstants { 17 18 public static Test suite() { 19 TestSuite testSuite = new TestSuite("CrimePortalSetUp"); 20 testSuite.addTestSuite(CrimePortalSetUp.class); 21 return testSuite; 22 } 23 24 public CrimePortalSetUp(String name) { 25 super(name); 26 } 27 28 29 34 public void testSetUp() throws Exception { 35 InitialContext jndi = new InitialContext (); 36 37 OrganizationHome organizationHome = 38 (OrganizationHome) jndi.lookup("crimeportal/Organization"); 39 40 GangsterHome gangsterHome = 41 (GangsterHome) jndi.lookup("crimeportal/Gangster"); 42 43 JobHome jobHome = (JobHome) jndi.lookup("crimeportal/Job"); 44 45 Organization yakuza = 47 organizationHome.create("Yakuza", "Japanese Gangsters"); 48 Organization mafia = 49 organizationHome.create("Mafia", "Italian Bad Guys"); 50 Organization triads = 51 organizationHome.create("Triads", "Kung Fu Movie Extras"); 52 53 Gangster yojimbo = gangsterHome.create(YOJIMBO, "Yojimbo", "Bodyguard"); 55 yojimbo.setBadness(7); 56 yojimbo.setOrganization(yakuza); 57 58 Gangster takeshi = gangsterHome.create(TAKESHI, "Takeshi", "Master"); 59 takeshi.setBadness(10); 60 takeshi.setOrganization(yakuza); 61 62 Gangster yuriko = gangsterHome.create(YURIKO, "Yuriko", "Four finger"); 63 yuriko.setBadness(4); 64 yuriko.setOrganization(yakuza); 65 66 Gangster chow = gangsterHome.create(CHOW, "Chow", "Killer"); 67 chow.setBadness(9); 68 chow.setOrganization(triads); 69 70 Gangster shogi = gangsterHome.create(SHOGI, "Shogi", "Lightning"); 71 shogi.setBadness(8); 72 shogi.setOrganization(triads); 73 74 Gangster valentino = 75 gangsterHome.create(VALENTINO, "Valentino", "Pizza-Face"); 76 valentino.setBadness(4); 77 valentino.setOrganization(mafia); 78 79 Gangster toni = gangsterHome.create(TONI, "Toni", "Toohless"); 80 toni.setBadness(2); 81 toni.setOrganization(mafia); 82 83 Gangster corleone = 84 gangsterHome.create(CORLEONE, "Corleone", "Godfather"); 85 corleone.setBadness(6); 86 corleone.setOrganization(mafia); 87 88 yakuza.setTheBoss(takeshi); 90 triads.setTheBoss(chow); 91 mafia.setTheBoss(corleone); 92 93 Job jewler = jobHome.create("10th Street Jeweler Heist"); 95 jewler.setScore(5000); 96 jewler.setSetupCost(50); 97 98 Job train = jobHome.create("The Greate Train Robbery"); 99 train.setScore(2000000); 100 train.setSetupCost(500000); 101 102 Job liquorStore = jobHome.create("Cheap Liquor Snatch and Grab"); 103 liquorStore.setScore(50); 104 liquorStore.setSetupCost(0); 105 106 jewler.getGangsters().add(valentino); 108 jewler.getGangsters().add(corleone); 109 110 train.getGangsters().add(yojimbo); 111 train.getGangsters().add(chow); 112 113 liquorStore.getGangsters().add(chow); 114 } 115 } 116 | Popular Tags |