1 25 26 package org.objectweb.jonas.jtests.clients.entity; 27 28 import java.util.Collection ; 29 30 import javax.ejb.FinderException ; 31 32 import junit.framework.Assert; 33 34 import org.objectweb.jonas.jtests.beans.ebasic.Account; 35 import org.objectweb.jonas.jtests.beans.ebasic.AccountHome; 36 import org.objectweb.jonas.jtests.beans.ebasic.Person; 37 import org.objectweb.jonas.jtests.beans.ebasic.PersonHome; 38 import org.objectweb.jonas.jtests.util.JTestCase; 39 40 52 public abstract class A_VariousPKEC extends JTestCase { 53 54 public A_VariousPKEC(String name) { 55 super(name); 56 } 57 58 protected void setUp() { 59 super.setUp(); 60 useBeans("ebasic", true); 61 } 62 63 66 abstract public AccountHome getAccountHome(); 67 68 71 abstract public PersonHome getPersonHome(); 72 73 74 77 public void testSpkCreate() throws Exception { 78 int num = 1000; 79 String customer = "Gertrude"; 80 81 Account acc = getAccountHome().create(num, customer); 82 Assert.assertEquals("Number", num, acc.getNumberPrimitive()); 83 Assert.assertEquals("Customer", customer, acc.getCustomer()); 84 85 acc.remove(); 87 88 } 89 90 93 public void testSpkRemove() throws Exception { 94 int num = 0; 95 Account acc = null; 96 97 getAccountHome().remove(new Integer (num)); 98 try { 99 acc = getAccountHome().findByNumber(num); 100 fail("bean already exists after a remove !!"); 101 } catch (FinderException e) { 102 } 103 104 getAccountHome().create(num, "to be removed"); 106 107 } 108 109 112 public void testSpkFindByPrimaryKey() throws Exception { 113 int num = 10; 114 115 Account acc = getAccountHome().findByPrimaryKey(new Integer (num)); 116 Assert.assertEquals("Number", num, acc.getNumberPrimitive()); 117 118 } 119 120 123 public void testSpkFindAll() throws Exception { 124 Collection col = getAccountHome().findAll(); 125 } 126 127 130 public void testUpkCreate() throws Exception { 131 int num = 1000; 132 String name = "Gertrude"; 133 134 Person prs = getPersonHome().create(num, name); 135 Assert.assertEquals("Number", num, prs.getNumberPrimitive()); 136 Assert.assertEquals("Customer", name, prs.getName()); 137 138 prs.remove(); 140 141 } 142 143 146 public void testUpkRemove() throws Exception { 147 int num = 0; 148 Person prs = null; 149 150 getPersonHome().remove(new Integer (num)); 151 try { 152 prs = getPersonHome().findByNumber(num); 153 fail("bean already exists after a remove !!"); 154 } catch (FinderException e) { 155 } 156 157 getPersonHome().create(num, "to be removed"); 159 160 } 161 162 165 public void testUpkFindByPrimaryKey() throws Exception { 166 int num = 10; 167 168 Person prs = getPersonHome().findByPrimaryKey(new Integer (num)); 169 Assert.assertEquals("Number", num, prs.getNumberPrimitive()); 170 171 } 172 173 176 public void testUpkFindAll() throws Exception { 177 Collection col = getPersonHome().findAll(); 178 } 179 180 } 181 | Popular Tags |