1 25 26 package org.objectweb.jonas.jtests.clients.distribution; 27 28 import java.rmi.NoSuchObjectException ; 29 import javax.naming.NamingException ; 30 import javax.rmi.PortableRemoteObject ; 31 32 import junit.framework.Test; 33 import junit.framework.TestSuite; 34 35 import org.objectweb.carol.util.perfs.CarolJRMPPerformanceHelper; 36 import org.objectweb.jonas.jtests.beans.folder.File; 37 import org.objectweb.jonas.jtests.beans.folder.Folder; 38 import org.objectweb.jonas.jtests.beans.folder.FolderHome; 39 import org.objectweb.jonas.jtests.util.JTestCase; 40 41 46 public class F_Frontal extends JTestCase { 47 48 protected static FolderHome fhome = null; 49 protected Folder folder = null; 50 51 public F_Frontal(String name) { 52 super(name); 53 } 54 55 protected void setUp() { 56 super.setUp(); 57 if (fhome == null) { 58 useBeans("folder", true); 59 try { 60 fhome = (FolderHome) PortableRemoteObject.narrow(ictx.lookup("FolderSYHome"), FolderHome.class); 61 assertNotNull(fhome); 62 } catch (NamingException e) { 63 fail("Cannot get bean home"); 64 } 65 } 66 if (folder == null) { 67 try { 68 folder = fhome.create(); 69 assertNotNull(folder); 70 } catch (Exception e) { 71 fail("Cannot create folder session " + e); 72 } 73 } 74 } 75 76 public void testSetRollbackOnly() throws Exception { 77 Folder f1 = fhome.createForRollback(); 78 f1.getIntTS(2); 79 f1.remove(); 80 } 81 82 85 public void testCreate1F() throws Exception { 86 File f = folder.newFile("file1"); 87 assertNotNull(f); 88 f.remove(); 89 } 90 91 public void testAccessOnRemovedEntity() throws Exception { 92 File f = folder.newFile("file1"); 93 File f2 = folder.getFile("file1"); 94 f2.remove(); 95 try { 96 f.getName(); 97 fail("Should not access deleted object"); 98 } catch (NoSuchObjectException e) { 99 } catch (Exception e) { 100 fail("Bab Exception:" + e); 101 } 102 } 103 104 107 public void testSerializedReference() throws Exception { 108 String mfolder = CarolJRMPPerformanceHelper.getMarshalBytes(folder); 109 } 111 112 115 public void testSendRef() throws Exception { 116 for (int i = 0; i < 20; i++) { 117 folder.sendRef(folder); 118 } 119 } 120 121 124 public void testSendInt() throws Exception { 125 for (int i = 0; i < 20; i++) { 126 folder.sendInt(1); 127 } 128 } 129 130 133 public void testGetRef() throws Exception { 134 for (int i = 0; i < 20; i++) { 135 folder.getRef(folder); 136 } 137 } 138 139 142 public void testGetInt() throws Exception { 143 for (int i = 0; i < 20; i++) { 144 folder.getInt(1); 145 } 146 } 147 148 151 public void testSendRefTS() throws Exception { 152 for (int i = 0; i < 20; i++) { 153 folder.sendRefTS(folder); 154 } 155 } 156 157 160 public void testSendIntTS() throws Exception { 161 for (int i = 0; i < 20; i++) { 162 folder.sendIntTS(1); 163 } 164 } 165 166 169 public void testGetRefTS() throws Exception { 170 for (int i = 0; i < 20; i++) { 171 folder.getRefTS(folder); 172 } 173 } 174 175 178 public void testGetIntTS() throws Exception { 179 for (int i = 0; i < 20; i++) { 180 folder.getIntTS(1); 181 } 182 } 183 184 public static Test suite() { 185 return new TestSuite(F_Frontal.class); 186 } 187 188 public static void main (String args[]) { 189 String testtorun = null; 190 for (int argn = 0; argn < args.length; argn++) { 192 String s_arg = args[argn]; 193 Integer i_arg; 194 if (s_arg.equals("-n")) { 195 testtorun = args[++argn]; 196 } 197 } 198 if (testtorun == null) { 199 junit.textui.TestRunner.run(suite()); 200 } else { 201 junit.textui.TestRunner.run(new F_Frontal(testtorun)); 202 } 203 } 204 } 205 | Popular Tags |