1 25 26 package org.objectweb.jonas.jtests.clients.session; 27 28 import junit.framework.Test; 29 import junit.framework.TestSuite; 30 import javax.rmi.PortableRemoteObject ; 31 import org.objectweb.jonas.jtests.beans.local.Target; 32 import org.objectweb.jonas.jtests.beans.local.TargetSFHome; 33 import org.objectweb.jonas.jtests.beans.local.TargetSLHome; 34 35 36 41 public class F_ClientViewSF extends A_ClientView { 42 43 protected static String BEAN_HOME = "EJB/localTargetSFHome"; 44 protected static TargetSFHome home = null; 45 46 public F_ClientViewSF(String name) { 47 super(name); 48 } 49 50 54 public void testIsIdenticalOnBeans() throws Exception { 55 Target tr1 = (Target) getHome().create(); 56 Target tr2 = (Target) getHome().create(); 57 assertTrue(!tr1.isIdentical(tr2)); 58 tr1.remove(); 59 tr2.remove(); 60 } 61 62 65 public void testCreateWithParameter() throws Exception { 66 String s1 = "String1"; 67 TargetSFHome tsfh = (TargetSFHome)getHome(); 68 Target tr = tsfh.create(s1, 1000); 69 assertEquals(tr.getString(), s1); 70 assertEquals(tr.getNumber(), 1000); 71 assertTrue(!tr.isCreatedViaCreateXX()); 72 tr.remove(); 73 } 74 75 79 public void testCreateMethod() throws Exception { 80 String s2 = "String2"; 81 TargetSFHome tsfh = (TargetSFHome)getHome(); 82 Target tr = tsfh.createXX(s2,2000); 83 assertEquals(tr.getString(),s2); 84 assertEquals(tr.getNumber(),2000); 85 assertTrue(tr.isCreatedViaCreateXX()); 86 tr.remove(); 87 } 88 89 92 public void testSerialization() throws Exception { 93 final int tnb1 = 30; 94 final int tnb2 = 20; 95 Target [] tarray1 = new Target[tnb1]; 96 Target [] tarray2 = new Target[tnb2]; 97 TargetSFHome tsfh = (TargetSFHome)getHome(); 98 for (int i = 0; i < tnb1; i++) { 99 tarray1[i] = tsfh.create("seri", i); 100 } 101 for (int i = 0; i < tnb1; i++) { 102 assertEquals(tarray1[i].getNumber(), i); 103 } 104 for (int i = 0; i < tnb2; i++) { 105 tarray2[i] = tsfh.create("seri", i); 106 } 107 for (int i = 0; i < tnb2; i++) { 108 assertEquals(tarray2[i].getNumber(), i); 109 } 110 for (int i = 0; i < tnb1; i++) { 111 assertEquals(tarray1[i].getNumber(), i); 112 } 113 for (int i = 0; i < tnb2; i++) { 114 tarray2[i].remove(); 115 } 116 for (int i = 0; i < tnb1; i++) { 117 tarray1[i].remove(); 118 } 119 } 120 121 122 125 protected void setUp() { 126 super.setUp(); 127 useBeans("local", false); 128 } 129 130 public TargetSLHome getHome() throws Exception { 131 if (home == null) { 132 home = (TargetSFHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME),TargetSFHome.class) ; 133 } 134 assertTrue(home != null); 135 return home; 136 } 137 138 public static Test suite() { 139 return new TestSuite(F_ClientViewSF.class); 140 } 141 142 143 144 public static void main (String args[]) throws Exception { 145 String testtorun = null; 146 for (int argn = 0; argn < args.length; argn++) { 148 String s_arg = args[argn]; 149 Integer i_arg; 150 if (s_arg.equals("-n")) { 151 testtorun = args[++argn]; 152 } 153 } 154 if (testtorun == null) { 155 junit.textui.TestRunner.run(suite()); 156 } else { 157 junit.textui.TestRunner.run(new F_ClientViewSF(testtorun)); 158 159 } 160 } 161 } 162 | Popular Tags |