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 junit.framework.Assert; 33 34 import org.objectweb.jonas.jtests.beans.etype.pfloat.Pfloat; 35 import org.objectweb.jonas.jtests.beans.etype.pfloat.PfloatHome; 36 import org.objectweb.jonas.jtests.util.JTestCase; 37 38 44 public abstract class A_EtypePfloat extends JTestCase { 45 46 private static final float DELTA = 0.01f; 47 48 public A_EtypePfloat(String name) { 49 super(name); 50 } 51 52 protected void setUp() { 53 super.setUp(); 54 useBeans("pfloat", true); 55 } 56 57 60 abstract public PfloatHome getHome(); 61 62 65 public void testPrimFloatFindByPk() throws Exception { 66 String pk = "pk1"; 67 Pfloat bean = getHome().findByPrimaryKey(pk); 68 Assert.assertEquals("Pk", pk, bean.getPk()); 69 } 70 71 74 public void testPrimFloatFindByF1() throws Exception { 75 float f1 = 5.0f; 76 Collection cBeans = getHome().findByF1(f1 - DELTA, f1 + DELTA); 77 int nb = 0; 78 Iterator iBeans = cBeans.iterator(); 79 while (iBeans.hasNext()) { 80 Pfloat bean = (Pfloat) javax.rmi.PortableRemoteObject.narrow(iBeans.next(), 81 Pfloat.class); 82 Assert.assertEquals("F1", f1, bean.getF1(), DELTA); 83 nb++; 84 } 85 assertEquals("Beans number: ", 2, nb); 86 } 87 88 91 public void testPrimFloatFindByF1Literal5() throws Exception { 92 float f1 = 5.0f; 93 Collection cBeans = getHome().findByF1Literal5(); 94 int nb = 0; 95 Iterator iBeans = cBeans.iterator(); 96 while (iBeans.hasNext()) { 97 Pfloat bean = (Pfloat) javax.rmi.PortableRemoteObject.narrow(iBeans.next(), 98 Pfloat.class); 99 Assert.assertEquals("F1", f1, bean.getF1(), DELTA); 100 nb++; 101 } 102 assertEquals("Beans number: ", 2, nb); 103 } 104 105 108 public void testPrimFloatGetF1() throws Exception { 109 String pk = "pk2"; 110 Pfloat bean = getHome().findByPrimaryKey(pk); 111 float f1 = bean.getF1(); 112 Assert.assertEquals("Pk", pk, bean.getPk()); 113 Assert.assertEquals("F1", 2.0, f1, DELTA); 114 } 115 116 119 public void testPrimFloatSetF1() throws Exception { 120 String pk = "pk3"; 121 Pfloat bean = getHome().findByPrimaryKey(pk); 122 float f1 = 30.0f; 123 bean.setF1(f1); 124 Assert.assertEquals("Pk", pk, bean.getPk()); 125 Assert.assertEquals("F1", f1, bean.getF1(), DELTA); 126 } 127 128 131 public void testPrimFloatCreate() throws Exception { 132 String pk = "pkcreated"; 133 float f1 = 1959.65f; 134 Pfloat bean = getHome().create(pk, f1); 135 Assert.assertEquals("Pk", pk, bean.getPk()); 136 Assert.assertEquals("F1", f1, bean.getF1(), DELTA); 137 bean = getHome().findByPrimaryKey(pk); 138 bean.remove(); 140 } 141 142 145 public void testPrimFloatRemove() throws Exception { 146 String pk = "pktoremove"; 147 Pfloat bean = getHome().findByPrimaryKey(pk); 148 float f1 = bean.getF1(); 149 bean.remove(); 150 try { 151 getHome().findByPrimaryKey(pk); 152 fail("not removed"); 153 } catch (FinderException e) { 154 } 156 getHome().create(pk, f1); 158 } 159 160 } 161 | Popular Tags |