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