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.ofloat4pk.Ofloat4pk; 33 import org.objectweb.jonas.jtests.beans.etype.ofloat4pk.Ofloat4pkHome; 34 import org.objectweb.jonas.jtests.util.JTestCase; 35 36 42 public abstract class A_EtypeOfloat4pk extends JTestCase { 43 44 private static final float DELTA = 0.01f; 45 46 public A_EtypeOfloat4pk(String name) { 47 super(name); 48 } 49 50 protected void setUp() { 51 super.setUp(); 52 useBeans("ofloat4pk", false); 53 } 54 55 58 abstract public Ofloat4pkHome getHome(); 59 60 63 public void testObjFloat4pkFindByPk() throws Exception { 64 Float pk = new Float (1.0); 65 Ofloat4pk bean = getHome().findByPrimaryKey(pk); 66 assertEquals("Pk", pk, bean.getPk()); 67 } 68 69 72 public void testObjFloat4pkFindByF1() throws Exception { 73 float f1 = 5.0f; 74 Collection cBeans = getHome().findByF1(new Float (f1 - DELTA), new Float (f1 + DELTA)); 75 int nb = 0; 76 Iterator iBeans = cBeans.iterator(); 77 while (iBeans.hasNext()) { 78 Ofloat4pk bean = (Ofloat4pk) javax.rmi.PortableRemoteObject.narrow(iBeans.next(), 79 Ofloat4pk.class); 80 assertEquals("F1", f1, (bean.getF1()).floatValue(), DELTA); 81 nb++; 82 } 83 assertEquals("Beans number: ", 2, nb); 84 } 85 86 89 public void testObjFloat4pkGetF1() throws Exception { 90 Float pk = new Float (2.0); 91 Ofloat4pk bean = getHome().findByPrimaryKey(pk); 92 Float f1 = bean.getF1(); 93 assertEquals("Pk", pk, bean.getPk()); 94 assertEquals("F1", 2.0, f1.floatValue(), DELTA); 95 } 96 97 100 public void testObjFloat4pkSetF1() throws Exception { 101 Float pk = new Float (3.0); 102 Ofloat4pk bean = getHome().findByPrimaryKey(pk); 103 float f1 = 30.0f; 104 bean.setF1(new Float (f1)); 105 assertEquals("Pk", pk, bean.getPk()); 106 assertEquals("F1", f1, (bean.getF1()).floatValue(), DELTA); 107 } 108 109 112 public void testObjFloat4pkCreate() throws Exception { 113 float f1 = 1959.65f; 114 Float pk = new Float (f1); 115 Ofloat4pk bean = getHome().create(pk, new Float (f1)); 116 assertEquals("Pk", pk, bean.getPk()); 117 assertEquals("F1", f1, (bean.getF1()).floatValue(), DELTA); 118 bean = getHome().findByPrimaryKey(pk); 119 bean.remove(); 121 } 122 123 126 public void testObjFloat4pkRemove() throws Exception { 127 Float pk = new Float (10000.0); 128 Ofloat4pk bean = getHome().findByPrimaryKey(pk); 129 Float f1 = bean.getF1(); 130 bean.remove(); 131 try { 132 getHome().findByPrimaryKey(pk); 133 fail("not removed"); 134 } catch (FinderException e) { 135 } 137 getHome().create(pk, f1); 139 } 140 141 } 142 | Popular Tags |