1 25 26 package org.objectweb.jonas.jtests.clients.entity; 27 28 import java.util.Collection ; 29 import java.util.Iterator ; 30 import javax.ejb.FinderException ; 31 32 import org.objectweb.jonas.jtests.beans.etype.odouble.Odouble; 33 import org.objectweb.jonas.jtests.beans.etype.odouble.OdoubleHome; 34 import org.objectweb.jonas.jtests.util.JTestCase; 35 36 42 public abstract class A_EtypeOdouble extends JTestCase { 43 44 private static final double DELTA = 0.01d; 45 46 public A_EtypeOdouble(String name) { 47 super(name); 48 } 49 50 protected void setUp() { 51 super.setUp(); 52 useBeans("odouble", true); 53 } 54 55 58 abstract public OdoubleHome getHome(); 59 60 63 public void testObjDoubleFindByPk() throws Exception { 64 String pk = "pk1"; 65 Odouble bean = getHome().findByPrimaryKey(pk); 66 assertEquals("Pk", pk, bean.getPk()); 67 } 68 69 72 public void testObjDoubleFindByF1() throws Exception { 73 double f1 = 5.0d; 74 Collection cBeans = getHome().findByF1(new Double (f1 - DELTA), new Double (f1 + DELTA)); 75 int nb = 0; 76 Iterator iBeans = cBeans.iterator(); 77 while (iBeans.hasNext()) { 78 Odouble bean = (Odouble) javax.rmi.PortableRemoteObject.narrow(iBeans.next(), 79 Odouble.class); 80 assertEquals("F1", f1, (bean.getF1()).doubleValue(), DELTA); 81 nb++; 82 } 83 assertEquals("Beans number: ", 2, nb); 84 } 85 86 89 public void testObjDoubleGetF1() throws Exception { 90 String pk = "pk2"; 91 Odouble bean = getHome().findByPrimaryKey(pk); 92 Double f1 = bean.getF1(); 93 assertEquals("Pk", pk, bean.getPk()); 94 assertEquals("F1", 2.0d, f1.doubleValue(), DELTA); 95 } 96 97 100 public void testObjDoubleGetF1Null() throws Exception { 101 String pk = "pknull"; 102 Odouble bean = getHome().findByPrimaryKey(pk); 103 Double f1 = bean.getF1(); 104 assertEquals("Pk", pk, bean.getPk()); 105 assertNull("F1 not null", f1); 106 } 107 108 111 public void testObjDoubleSetF1() throws Exception { 112 String pk = "pk3"; 113 Odouble bean = getHome().findByPrimaryKey(pk); 114 double f1 = 30.0d; 115 bean.setF1(new Double (f1)); 116 assertEquals("Pk", pk, bean.getPk()); 117 assertEquals("F1", f1, (bean.getF1()).doubleValue(), DELTA); 118 } 119 120 123 public void testObjDoubleSetF1Null() throws Exception { 124 String pk = "pkchangenull"; 125 Odouble bean = getHome().findByPrimaryKey(pk); 126 bean.setF1(null); 127 assertEquals("Pk", pk, bean.getPk()); 128 assertNull("F1", bean.getF1()); 129 } 130 131 134 public void testObjDoubleCreate() throws Exception { 135 String pk = "pkcreated"; 136 double f1 = 1959.65d; 137 Odouble bean = getHome().create(pk, new Double (f1)); 138 assertEquals("Pk", pk, bean.getPk()); 139 assertEquals("F1", f1, (bean.getF1()).doubleValue(), DELTA); 140 bean = getHome().findByPrimaryKey(pk); 141 bean.remove(); 143 } 144 145 148 public void testObjDoubleRemove() throws Exception { 149 String pk = "pktoremove"; 150 Odouble bean = getHome().findByPrimaryKey(pk); 151 Double f1 = bean.getF1(); 152 bean.remove(); 153 try { 154 getHome().findByPrimaryKey(pk); 155 fail("not removed"); 156 } catch (FinderException e) { 157 } 159 getHome().create(pk, f1); 161 } 162 163 } 164 | Popular Tags |