1 21 22 package org.objectweb.jonas.jtests.clients.entity; 23 24 import java.util.Collection ; 25 import javax.naming.NamingException ; 26 import javax.rmi.PortableRemoteObject ; 27 import junit.framework.Test; 28 import junit.framework.TestSuite; 29 import org.objectweb.jonas.jtests.beans.ebasic.*; 30 31 32 35 public class F_PkAutoEC extends A_Cmp2Util { 36 37 private static String BEAN_HOME_PKAUTO = "pkautoobjectcmp1Home"; 38 39 protected static pkautoObjectHome pkautoobjectcmp1home = null; 40 41 public F_PkAutoEC(String name) { 42 super(name); 43 } 44 45 protected static boolean isInit = false; 46 47 protected void setUp() { 48 super.setUp(); 49 boolean ok = false; 50 int nbtry = 0; 51 while (!ok && nbtry < 3) { 52 if (!isInit) { 53 useBeans("ebasic", true); 55 try { 57 pkautoobjectcmp1home = (pkautoObjectHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME_PKAUTO), 58 pkautoObjectHome.class); 59 } catch (NamingException e) { 60 fail("Cannot get bean home: " + e.getMessage()); 61 } 62 try { 64 Collection bpk = pkautoobjectcmp1home.findAll(); 65 if (bpk.isEmpty()) { 66 throw new Exception ("Table vide"); 67 } 68 } catch (Exception e) { 69 try { 71 utx.begin(); 72 for (int i = 1; i <= 10; i++) { 73 pkautoobjectcmp1home.create(10, 20); 74 } 75 } catch (Exception i) { 76 i.printStackTrace(System.out); 77 fail("InitialState creation problem: " + i); 78 } finally { 79 try { 80 utx.commit(); 81 } catch (Exception ii) { 82 } 83 } 84 } 85 isInit = true; 86 } 87 nbtry++; 90 try { 91 if (initStateOK()) { 92 ok = true; 93 } 94 } catch (Exception e) { 95 } 96 if (!ok) { 97 isInit = false; 98 unloadBeans("ebasic"); 99 } 100 } 101 } 102 103 104 108 boolean initStateOK() throws Exception { 109 msgerror = new StringBuffer (); 110 Collection bpk = pkautoobjectcmp1home.findAll(); 111 return (bpk.size() == 10); 112 } 113 114 117 public void testEmpty() throws Exception { 118 checkIsInitialState(); 119 } 120 121 123 public static Test suite() { 124 return new TestSuite(F_PkAutoEC.class); 125 } 126 127 public static void main (String args[]) { 128 String testtorun = null; 129 for (int argn = 0; argn < args.length; argn++) { 131 String s_arg = args[argn]; 132 Integer i_arg; 133 if (s_arg.equals("-n")) { 134 testtorun = args[++argn]; 135 } 136 } 137 if (testtorun == null) { 138 junit.textui.TestRunner.run(suite()); 139 } else { 140 junit.textui.TestRunner.run(new F_PkAutoEC(testtorun)); 141 } 142 } 143 } 144 145 | Popular Tags |