1 package org.apache.ojb.ejb.odmg; 2 3 17 18 import javax.ejb.EJBHome ; 19 import javax.rmi.PortableRemoteObject ; 20 import java.util.List ; 21 22 import junit.framework.TestCase; 23 import org.apache.ojb.ejb.ContextHelper; 24 import org.apache.ojb.ejb.VOHelper; 25 26 32 public class PersonArticleClientODMG extends TestCase 33 { 34 PersonArticleManagerODMGRemote bean; 35 36 public PersonArticleClientODMG(String s) 37 { 38 super(s); 39 } 40 41 public PersonArticleClientODMG() 42 { 43 super(PersonArticleClientODMG.class.getName()); 44 } 45 46 public static void main(String [] args) 47 { 48 String [] arr = {PersonArticleClientODMG.class.getName()}; 49 junit.textui.TestRunner.main(arr); 50 } 51 52 protected void setUp() throws Exception 53 { 54 super.setUp(); 55 init(); 56 } 57 58 protected void init() throws Exception 59 { 60 try 61 { 62 Object object = PortableRemoteObject.narrow( 63 ContextHelper.getContext().lookup(PersonArticleManagerODMGHome.JNDI_NAME), EJBHome .class); 64 bean = ((PersonArticleManagerODMGHome) object).create(); 65 } 66 catch (Exception e) 67 { 68 e.printStackTrace(); 69 throw e; 70 } 71 } 72 73 public void testNestedStoreDelete() throws Exception 74 { 75 int personsBefore = bean.personCount(); 76 int articlesBefore = bean.articleCount(); 77 78 List articleList = VOHelper.createNewArticleList(6); 79 List personList = VOHelper.createNewPersonList(4); 80 articleList = bean.storeArticles(articleList); 82 personList = bean.storePersons(personList); 83 84 int personsAfterStore = bean.personCount(); 85 int articlesAfterStore = bean.articleCount(); 86 assertEquals("wrong number of articles after store", articlesBefore + 6, articlesAfterStore); 87 assertEquals("wrong number of persons after store", personsBefore + 4, personsAfterStore); 88 89 bean.deleteArticles(articleList); 91 bean.deletePersons(personList); 92 93 int personsAfterDelete = bean.personCount(); 94 int articlesAfterDelete = bean.articleCount(); 95 assertEquals("wrong number of articles after delete", articlesBefore, articlesAfterDelete); 96 assertEquals("wrong number of persons after delete", personsBefore, personsAfterDelete); 97 } 98 } 99 | Popular Tags |