1 22 package org.jboss.ejb3.test.factoryxml.unit; 23 24 import org.jboss.ejb3.test.factoryxml.Entity1; 25 import org.jboss.ejb3.test.factoryxml.Entity2; 26 import org.jboss.ejb3.test.factoryxml.MyService; 27 import org.jboss.ejb3.test.factoryxml.Session1; 28 import org.jboss.ejb3.test.factoryxml.Session2; 29 import org.jboss.ejb3.test.factoryxml.Stateful1; 30 import org.jboss.ejb3.test.factoryxml.Util; 31 import org.jboss.test.JBossTestCase; 32 import junit.framework.Test; 33 34 40 41 public class FactoryUnitTestCase 42 extends JBossTestCase 43 { 44 org.jboss.logging.Logger log = getLog(); 45 46 static boolean deployed = false; 47 static int test = 0; 48 49 public FactoryUnitTestCase(String name) 50 { 51 52 super(name); 53 54 } 55 56 public void testMe() throws Exception 57 { 58 Session1 session1 = (Session1) this.getInitialContext().lookup("factoryxml-test/Session1Bean/remote"); 59 Session2 session2 = (Session2) this.getInitialContext().lookup("factoryxml-test/Session2Bean/remote"); 60 MyService service = (MyService) this.getInitialContext().lookup("factoryxml-test/MyServiceBean/remote"); 61 assertNotNull(service); 62 63 int oneF = session1.create1FromFactory(); 64 int oneM = session1.create1FromManager(); 65 int twoF = session1.create2FromFactory(); 66 int twoM = session1.create2FromManager(); 67 session1.doUtil(new Util()); 68 69 session2.find1FromFactory(oneF); 70 assertNotNull(session2.find1FromManager(oneM)); 71 session2.find2FromFactory(twoF); 72 assertNotNull(session2.find2FromManager(twoM)); 73 assertNotNull(service.find2FromManager(twoM)); 74 assertNotNull(session2.findUtil1FromManager(1)); 75 assertNotNull(session2.findUtil2FromManager(2)); 76 77 } 78 79 public void testExtended() throws Exception 80 { 81 Stateful1 stateful1 = (Stateful1) this.getInitialContext().lookup("factoryxml-test/Stateful1Bean/remote"); 82 Session2 session2 = (Session2) this.getInitialContext().lookup("factoryxml-test/Session2Bean/remote"); 83 84 int oneId = stateful1.create1(); 85 int twoId = stateful1.create2(); 86 87 stateful1.update1(); 88 stateful1.update2(); 89 90 { 91 Entity1 one = session2.find1FromManager(oneId); 92 assertEquals(one.getString(), "changed"); 93 94 Entity2 two = session2.find2FromManager(twoId); 95 assertEquals(two.getString(), "changed"); 96 } 97 98 stateful1.never(); 99 100 { 101 Entity1 one = session2.find1FromManager(oneId); 102 assertEquals(one.getString(), "changed"); 103 104 Entity2 two = session2.find2FromManager(twoId); 105 assertEquals(two.getString(), "changed"); 106 } 107 108 stateful1.checkout(); 109 110 { 111 Entity1 one = session2.find1FromManager(oneId); 112 assertEquals(one.getString(), "never"); 113 114 Entity2 two = session2.find2FromManager(twoId); 115 assertEquals(two.getString(), "never"); 116 } 117 } 118 119 public static Test suite() throws Exception 120 { 121 return getDeploySetup(FactoryUnitTestCase.class, "factoryxml-test.ear"); 122 } 123 124 } 125 | Popular Tags |