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