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.pboolean.Pboolean; 35 import org.objectweb.jonas.jtests.beans.etype.pboolean.PbooleanHome; 36 import org.objectweb.jonas.jtests.util.JTestCase; 37 38 44 public abstract class A_EtypePboolean extends JTestCase { 45 46 public A_EtypePboolean(String name) { 47 super(name); 48 } 49 50 protected void setUp() { 51 super.setUp(); 52 useBeans("pboolean", true); 53 } 54 55 58 abstract public PbooleanHome getHome(); 59 60 63 public void testPrimBooleanFindByPk() throws Exception { 64 String pk = "pk1"; 65 Pboolean bean = getHome().findByPrimaryKey(pk); 66 Assert.assertEquals("Pk", pk, bean.getPk()); 67 } 68 69 72 public void testPrimBooleanFindByF1() throws Exception { 73 boolean f1 = true; 74 Collection cBeans = getHome().findByF1(f1); 75 Iterator iBeans = cBeans.iterator(); 76 while (iBeans.hasNext()) { 77 Pboolean bean = (Pboolean) javax.rmi.PortableRemoteObject.narrow(iBeans.next(), 78 Pboolean.class); 79 Assert.assertEquals("F1", f1, bean.getF1()); 80 } 81 } 82 83 86 public void testPrimBooleanFindByF1LiteralTrue() throws Exception { 87 Collection cBeans = getHome().findByF1LiteralTrue(); 88 Iterator iBeans = cBeans.iterator(); 89 while (iBeans.hasNext()) { 90 Pboolean bean = (Pboolean) javax.rmi.PortableRemoteObject.narrow(iBeans.next(), 91 Pboolean.class); 92 Assert.assertEquals("F1 of " + bean.getPk() + ": " 93 , true, bean.getF1()); 94 } 95 } 96 97 100 public void testPrimBooleanGetF1() throws Exception { 101 String pk = "pk2"; 102 Pboolean bean = getHome().findByPrimaryKey(pk); 103 boolean f1 = bean.getF1(); 104 Assert.assertEquals("Pk", pk, bean.getPk()); 105 Assert.assertEquals("F1", true, f1); 106 } 107 108 111 public void testPrimBooleanSetF1() throws Exception { 112 String pk = "pk3"; 113 Pboolean bean = getHome().findByPrimaryKey(pk); 114 boolean f1 = true; 115 bean.setF1(f1); 116 Assert.assertEquals("Pk", pk, bean.getPk()); 117 Assert.assertEquals("F1", f1, bean.getF1()); 118 } 119 120 123 public void testPrimBooleanCreate() throws Exception { 124 String pk = "pkcreated"; 125 boolean f1 = false; 126 Pboolean bean = getHome().create(pk, f1); 127 Assert.assertEquals("Pk", pk, bean.getPk()); 128 Assert.assertEquals("F1", f1, bean.getF1()); 129 bean = getHome().findByPrimaryKey(pk); 130 bean.remove(); 132 } 133 134 137 public void testPrimBooleanRemove() throws Exception { 138 String pk = "pktoremove"; 139 Pboolean bean = getHome().findByPrimaryKey(pk); 140 boolean f1 = bean.getF1(); 141 bean.remove(); 142 try { 143 getHome().findByPrimaryKey(pk); 144 fail("not removed"); 145 } catch (FinderException e) { 146 } 148 getHome().create(pk, f1); 150 } 151 152 } 153 | Popular Tags |