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.pshort.Pshort; 35 import org.objectweb.jonas.jtests.beans.etype.pshort.PshortHome; 36 import org.objectweb.jonas.jtests.util.JTestCase; 37 38 44 public abstract class A_EtypePshort extends JTestCase { 45 46 public A_EtypePshort(String name) { 47 super(name); 48 } 49 50 protected void setUp() { 51 super.setUp(); 52 useBeans("pshort", true); 53 } 54 55 58 abstract public PshortHome getHome(); 59 60 63 public void testPrimShortFindByPk() throws Exception { 64 String pk = "pk1"; 65 Pshort bean = getHome().findByPrimaryKey(pk); 66 Assert.assertEquals("Pk", pk, bean.getPk()); 67 } 68 69 72 public void testPrimShortFindByF1() throws Exception { 73 short f1 = (short) 5; 74 Collection cBeans = getHome().findByF1(f1); 75 int nb = 0; 76 Iterator iBeans = cBeans.iterator(); 77 while (iBeans.hasNext()) { 78 Pshort bean = (Pshort) javax.rmi.PortableRemoteObject.narrow(iBeans.next(), 79 Pshort.class); 80 Assert.assertEquals("F1", f1, bean.getF1()); 81 nb++; 82 } 83 assertEquals("Beans number: ", 2, nb); 84 } 85 86 89 public void testPrimShortFindByF1Literal5() throws Exception { 90 short f1 = (short) 5; 91 Collection cBeans = getHome().findByF1Literal5(); 92 int nb = 0; 93 Iterator iBeans = cBeans.iterator(); 94 while (iBeans.hasNext()) { 95 Pshort bean = (Pshort) javax.rmi.PortableRemoteObject.narrow(iBeans.next(), 96 Pshort.class); 97 Assert.assertEquals("F1", f1, bean.getF1()); 98 nb++; 99 } 100 assertEquals("Beans number: ", 2, nb); 101 } 102 103 106 public void testPrimShortGetF1() throws Exception { 107 String pk = "pk2"; 108 Pshort bean = getHome().findByPrimaryKey(pk); 109 short f1 = bean.getF1(); 110 Assert.assertEquals("Pk", pk, bean.getPk()); 111 Assert.assertEquals("F1", (short) 2, f1); 112 } 113 114 117 public void testPrimShortSetF1() throws Exception { 118 String pk = "pk3"; 119 Pshort bean = getHome().findByPrimaryKey(pk); 120 short f1 = (short) 30; 121 bean.setF1(f1); 122 Assert.assertEquals("Pk", pk, bean.getPk()); 123 Assert.assertEquals("F1", f1, bean.getF1()); 124 } 125 126 129 public void testPrimShortCreate() throws Exception { 130 String pk = "pkcreated"; 131 short f1 = (short) 1959; 132 Pshort bean = getHome().create(pk, f1); 133 Assert.assertEquals("Pk", pk, bean.getPk()); 134 Assert.assertEquals("F1", f1, bean.getF1()); 135 bean = getHome().findByPrimaryKey(pk); 136 bean.remove(); 138 } 139 140 143 public void testPrimShortRemove() throws Exception { 144 String pk = "pktoremove"; 145 Pshort bean = getHome().findByPrimaryKey(pk); 146 short f1 = bean.getF1(); 147 bean.remove(); 148 try { 149 getHome().findByPrimaryKey(pk); 150 fail("not removed"); 151 } catch (FinderException e) { 152 } 154 getHome().create(pk, f1); 156 } 157 158 } 159 | Popular Tags |