1 45 package org.openejb.test.entity.bmp; 46 47 53 public class BmpHomeIntfcTests extends BasicBmpTestClient { 54 55 public BmpHomeIntfcTests() { 56 super("HomeIntfc."); 57 } 58 59 protected void setUp() throws Exception { 60 super.setUp(); 61 Object obj = initialContext.lookup("client/tests/entity/bmp/BasicBmpHome"); 62 ejbHome = (BasicBmpHome) javax.rmi.PortableRemoteObject.narrow(obj, BasicBmpHome.class); 63 } 64 65 public void test01_create() { 69 try { 70 ejbObject = ejbHome.create("First Bean"); 71 assertNotNull("The EJBObject is null", ejbObject); 72 } catch (Exception e) { 73 fail("Received Exception " + e.getClass() + " : " + e.getMessage()); 74 } 75 } 76 77 public void test02_findByPrimaryKey() { 78 try { 79 ejbPrimaryKey = ejbObject.getPrimaryKey(); 80 ejbObject = ejbHome.findByPrimaryKey((Integer ) ejbPrimaryKey); 81 assertNotNull("The EJBObject is null", ejbObject); 82 } catch (Exception e) { 83 fail("Received Exception " + e.getClass() + " : " + e.getMessage()); 84 } 85 } 86 87 public void test03_findByLastName() { 88 Integer [] keys = new Integer [3]; 89 try { 90 ejbObject = ejbHome.create("David Blevins"); 91 keys[0] = (Integer ) ejbObject.getPrimaryKey(); 92 93 ejbObject = ejbHome.create("Dennis Blevins"); 94 keys[1] = (Integer ) ejbObject.getPrimaryKey(); 95 96 ejbObject = ejbHome.create("Claude Blevins"); 97 keys[2] = (Integer ) ejbObject.getPrimaryKey(); 98 } catch (Exception e) { 99 fail("Received exception while preparing the test: " + e.getClass() + " : " + e.getMessage()); 100 } 101 102 try { 103 java.util.Collection objects = ejbHome.findByLastName("Blevins"); 104 assertNotNull("The Collection is null", objects); 105 assertEquals("The Collection is not the right size.", keys.length, objects.size()); 106 Object [] objs = objects.toArray(); 107 for (int i = 0; i < objs.length; i++) { 108 ejbObject = (BasicBmpObject) javax.rmi.PortableRemoteObject.narrow(objs[i], BasicBmpObject.class); 109 assertEquals("The primary keys are not equal.", keys[i], ejbObject.getPrimaryKey()); 111 } 112 } catch (Exception e) { 113 fail("Received Exception " + e.getClass() + " : " + e.getMessage()); 114 } 115 } 116 117 public void test04_findEmptyEnumeration() { 118 try { 119 java.util.Enumeration emptyEnumeration = ejbHome.findEmptyEnumeration(); 120 assertNotNull("The enumeration is null", emptyEnumeration); 121 assertFalse("The enumeration is not empty", emptyEnumeration.hasMoreElements()); 122 } catch (Exception e) { 123 fail("Received Exception " + e.getClass() + " : " + e.getMessage()); 124 } 125 } 126 } 127 | Popular Tags |