1 22 package org.jboss.test.cmp2.passivation.test; 23 24 import java.util.ArrayList ; 25 import java.util.Iterator ; 26 import java.util.List ; 27 28 import javax.rmi.PortableRemoteObject ; 29 30 import junit.framework.Test; 31 32 import org.jboss.test.JBossTestCase; 33 import org.jboss.test.cmp2.passivation.interfaces.RapidlyPassivatedEntity; 34 import org.jboss.test.cmp2.passivation.interfaces.RapidlyPassivatedEntityHome; 35 36 48 public class EntityPassivationUnitTestCase extends JBossTestCase 49 { 50 51 static final int ENTITY_PASSIVATION_TIMEOUT = 15 * 1000; 53 54 List mEntities = new ArrayList (getBeanCount()); 56 57 59 public static Test suite() 60 throws Exception 61 { 62 return getDeploySetup(EntityPassivationUnitTestCase.class, "cmp2-passivation.jar"); 63 } 64 65 67 public EntityPassivationUnitTestCase(String name) 68 { 69 super(name); 70 } 71 72 73 75 81 public void testPostPassivationLocalEJBIntegrity() 82 throws Exception 83 { 84 log.info("Waiting for entities to passivate"); 85 Thread.sleep(ENTITY_PASSIVATION_TIMEOUT); 86 for (Iterator i = mEntities.iterator(); i.hasNext();) 87 { 88 RapidlyPassivatedEntity e = (RapidlyPassivatedEntity)i.next(); 89 assertEquals(e.getIdViaEJBLocalObject(), e.getPrimaryKey()); 90 } 91 } 92 93 94 106 public void testPostPassivationRemoteEJBIntegrity() 107 throws Exception 108 { 109 log.info("Waiting for entities to passivate"); 110 Thread.sleep(ENTITY_PASSIVATION_TIMEOUT); 111 for (Iterator i = mEntities.iterator(); i.hasNext();) 112 { 113 RapidlyPassivatedEntity e = (RapidlyPassivatedEntity)i.next(); 114 assertEquals(e.getIdViaEJBObject(), e.getPrimaryKey()); 115 } 116 } 117 118 119 121 125 protected void setUp() throws Exception 126 { 127 super.setUp(); 128 Object homeObject = 129 getInitialContext().lookup(RapidlyPassivatedEntityHome.JNDI_NAME); 130 RapidlyPassivatedEntityHome home = 131 (RapidlyPassivatedEntityHome) PortableRemoteObject.narrow( 132 homeObject, 133 RapidlyPassivatedEntityHome.class); 134 135 for (int i = 0, n = getBeanCount(); i < n; ++i) 136 mEntities.add(home.create("nothing to see here")); 137 138 } 139 } 140 | Popular Tags |