1 25 26 package org.objectweb.jonas.jtests.clients.transaction; 27 28 import javax.naming.NamingException ; 29 import javax.rmi.PortableRemoteObject ; 30 import junit.framework.Test; 31 import junit.framework.TestSuite; 32 import org.objectweb.jonas.jtests.beans.transacted.Simple; 33 import org.objectweb.jonas.jtests.beans.transacted.SimpleEHome; 34 import org.objectweb.jonas.jtests.beans.transacted.SimpleSHome; 35 import org.objectweb.jonas.jtests.util.JTestCase; 36 37 41 public class F_BeanToBeanTx extends JTestCase { 42 43 protected static SimpleSHome syhome = null; 44 protected static SimpleSHome sfhome = null; 45 protected static SimpleSHome slhome = null; 46 protected static SimpleEHome echome = null; 47 protected static SimpleEHome ec2home = null; 48 protected static SimpleEHome ebhome = null; 49 50 public F_BeanToBeanTx(String name) { 51 super(name); 52 } 53 54 protected void setUp() { 55 super.setUp(); 56 useBeans("transacted", true); 57 if (syhome == null) { 58 String BEAN_HOME = "transactedSimpleSYHome"; 59 try { 60 syhome = (SimpleSHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SimpleSHome.class); 61 } catch (NamingException e) { 62 fail("Cannot get " + BEAN_HOME + ":" + e); 63 } 64 } 65 if (sfhome == null) { 66 String BEAN_HOME = "transactedSimpleSFHome"; 67 try { 68 sfhome = (SimpleSHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SimpleSHome.class); 69 } catch (NamingException e) { 70 fail("Cannot get " + BEAN_HOME + ":" + e); 71 } 72 } 73 if (slhome == null) { 74 String BEAN_HOME = "transactedSimpleSLHome"; 75 try { 76 slhome = (SimpleSHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SimpleSHome.class); 77 } catch (NamingException e) { 78 fail("Cannot get " + BEAN_HOME + ":" + e); 79 } 80 } 81 if (echome == null) { 82 String BEAN_HOME = "transactedSimpleECHome"; 83 try { 84 echome = (SimpleEHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SimpleEHome.class); 85 } catch (NamingException e) { 86 fail("Cannot get " + BEAN_HOME + ":" + e); 87 } 88 } 89 if (ec2home == null) { 90 String BEAN_HOME = "transactedSimpleEC2Home"; 91 try { 92 ec2home = (SimpleEHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SimpleEHome.class); 93 } catch (NamingException e) { 94 fail("Cannot get " + BEAN_HOME + ":" + e); 95 } 96 } 97 if (ebhome == null) { 98 String BEAN_HOME = "transactedSimpleEBHome"; 99 try { 100 ebhome = (SimpleEHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SimpleEHome.class); 101 } catch (NamingException e) { 102 fail("Cannot get " + BEAN_HOME + ":" + e); 103 } 104 } 105 } 106 107 110 public void testSLToEC() throws Exception { 111 Simple s1 = slhome.create(); 112 Simple s2 = echome.create(30); 113 assertEquals(true, s1.call_requires_new_on(s2)); 114 s1.remove(); 115 s2.remove(); 116 } 117 118 121 public void testSLToEC2() throws Exception { 122 Simple s1 = slhome.create(); 123 Simple s2 = ec2home.create(30); 124 assertEquals(true, s1.call_requires_new_on(s2)); 125 s1.remove(); 126 s2.remove(); 127 } 128 129 132 public void testSFToEC() throws Exception { 133 Simple s1 = sfhome.create(); 134 Simple s2 = echome.create(30); 135 assertEquals(true, s1.call_requires_new_on(s2)); 136 s1.remove(); 137 s2.remove(); 138 } 139 140 143 public void testSFToEC2() throws Exception { 144 Simple s1 = sfhome.create(); 145 Simple s2 = ec2home.create(30); 146 assertEquals(true, s1.call_requires_new_on(s2)); 147 s1.remove(); 148 s2.remove(); 149 } 150 151 154 public void testSYToEC() throws Exception { 155 Simple s1 = syhome.create(); 156 Simple s2 = echome.create(30); 157 assertEquals(true, s1.call_requires_new_on(s2)); 158 s1.remove(); 159 s2.remove(); 160 } 161 162 165 public void testSYToEC2() throws Exception { 166 Simple s1 = syhome.create(); 167 Simple s2 = ec2home.create(30); 168 assertEquals(true, s1.call_requires_new_on(s2)); 169 s1.remove(); 170 s2.remove(); 171 } 172 173 176 public void testECToEC() throws Exception { 177 Simple s1 = echome.create(31); 178 Simple s2 = echome.create(32); 179 assertEquals(true, s1.call_requires_new_on(s2)); 180 s1.remove(); 181 s2.remove(); 182 } 183 184 187 public void testEC2ToEC2() throws Exception { 188 Simple s1 = ec2home.create(31); 189 Simple s2 = ec2home.create(32); 190 assertEquals(true, s1.call_requires_new_on(s2)); 191 s1.remove(); 192 s2.remove(); 193 } 194 195 198 public void testEBToEC() throws Exception { 199 Simple s1 = ebhome.create(31); 200 Simple s2 = echome.create(32); 201 assertEquals(true, s1.call_requires_new_on(s2)); 202 s1.remove(); 203 s2.remove(); 204 } 205 206 209 public void testEBToEC2() throws Exception { 210 Simple s1 = ebhome.create(31); 211 Simple s2 = ec2home.create(32); 212 assertEquals(true, s1.call_requires_new_on(s2)); 213 s1.remove(); 214 s2.remove(); 215 } 216 217 220 public void testSLToSY() throws Exception { 221 Simple s1 = slhome.create(); 222 Simple s2 = syhome.create(); 223 assertEquals(true, s1.call_requires_new_on(s2)); 224 s1.remove(); 225 s2.remove(); 226 } 227 228 231 public void testSFToSY() throws Exception { 232 Simple s1 = sfhome.create(); 233 Simple s2 = syhome.create(); 234 assertEquals(true, s1.call_requires_new_on(s2)); 235 s1.remove(); 236 s2.remove(); 237 } 238 239 242 public void testSYToSY() throws Exception { 243 Simple s1 = syhome.create(); 244 Simple s2 = syhome.create(); 245 assertEquals(true, s1.call_requires_new_on(s2)); 246 s1.remove(); 247 s2.remove(); 248 } 249 250 253 public void testECToSY() throws Exception { 254 Simple s1 = echome.create(31); 255 Simple s2 = syhome.create(); 256 assertEquals(true, s1.call_requires_new_on(s2)); 257 s1.remove(); 258 s2.remove(); 259 } 260 261 264 public void testEC2ToSY() throws Exception { 265 Simple s1 = ec2home.create(31); 266 Simple s2 = syhome.create(); 267 assertEquals(true, s1.call_requires_new_on(s2)); 268 s1.remove(); 269 s2.remove(); 270 } 271 272 public void testSupports2Required() throws Exception { 273 Simple s2 = sfhome.create(); 274 assertEquals(true, s2.supports_call_required()); 275 s2.remove(); 276 } 277 278 281 public void testEBToSY() throws Exception { 282 Simple s1 = ebhome.create(31); 283 Simple s2 = syhome.create(); 284 assertEquals(true, s1.call_requires_new_on(s2)); 285 s1.remove(); 286 s2.remove(); 287 } 288 289 public static Test suite() { 290 return new TestSuite(F_BeanToBeanTx.class); 291 } 292 293 public static void main (String args[]) { 294 String testtorun = null; 295 for (int argn = 0; argn < args.length; argn++) { 297 String s_arg = args[argn]; 298 Integer i_arg; 299 if (s_arg.equals("-n")) { 300 testtorun = args[++argn]; 301 } 302 } 303 if (testtorun == null) { 304 junit.textui.TestRunner.run(suite()); 305 } else { 306 junit.textui.TestRunner.run(new F_BeanToBeanTx(testtorun)); 307 } 308 } 309 } 310 | Popular Tags |