1 22 package org.jboss.ejb3.test.timer.unit; 23 24 import java.util.Date ; 25 26 import org.jboss.ejb3.test.timer.TimerTester; 27 import org.jboss.test.JBossTestCase; 28 import junit.framework.Test; 29 30 36 37 public class RemoteUnitTestCase 38 extends JBossTestCase 39 { 40 org.jboss.logging.Logger log = getLog(); 41 42 static boolean deployed = false; 43 static int test = 0; 44 45 public RemoteUnitTestCase(String name) 46 { 47 48 super(name); 49 50 } 51 52 public void testNewTransaction() throws Exception 53 { 54 TimerTester test = (TimerTester) getInitialContext().lookup("TransactionalTimerTesterBean/remote"); 55 test.startTimer(5000); 56 test.accessTimer(); 57 Thread.sleep(6000); 58 assertTrue(test.isTimerCalled()); 59 } 60 61 public void testPersistence() throws Exception 63 { 64 TimerTester test = (TimerTester) getInitialContext().lookup("TimerTesterService/remote"); 65 long when = System.currentTimeMillis() + 5000; 66 test.setTimer(new Date (when)); 67 68 redeploy("timer-test.jar"); 69 70 test = (TimerTester) getInitialContext().lookup("TimerTesterService/remote"); 71 long wait = 1000 + (when - System.currentTimeMillis()); 72 if(wait > 0) 73 Thread.sleep(wait); 74 assertTrue(test.isTimerCalled()); 75 } 76 77 public void testService() throws Exception 78 { 79 TimerTester test = (TimerTester) getInitialContext().lookup("TimerTesterService/remote"); 80 test.startTimer(5000); 81 test.accessTimer(); 82 Thread.sleep(6000); 83 assertTrue(test.isTimerCalled()); 84 test.startTimerViaEJBContext(5000); 85 test.accessTimer(); 86 Thread.sleep(6000); 87 assertTrue(test.isTimerCalled()); 88 } 89 90 public void testSimple() throws Exception 91 { 92 TimerTester test = (TimerTester) this.getInitialContext().lookup("TimerTesterBean/remote"); 93 test.startTimer(5000); 94 test.accessTimer(); 95 Thread.sleep(6000); 96 assertTrue(test.isTimerCalled()); 97 test.startTimerViaEJBContext(5000); 98 test.accessTimer(); 99 Thread.sleep(6000); 100 assertTrue(test.isTimerCalled()); 101 } 102 103 public void testSimple21() throws Exception 104 { 105 TimerTester test = (TimerTester) this.getInitialContext().lookup("TimerTesterBean21"); 106 test.startTimer(5000); 107 test.accessTimer(); 108 Thread.sleep(6000); 109 assertTrue(test.isTimerCalled()); 110 test.startTimerViaEJBContext(5000); 111 test.accessTimer(); 112 Thread.sleep(6000); 113 assertTrue(test.isTimerCalled()); 114 } 115 116 public void testRollback() throws Exception 117 { 118 TimerTester test = (TimerTester) this.getInitialContext().lookup("TimerTesterBean/remote"); 119 test.startTimerAndRollback(5000); 120 Thread.sleep(6000); 121 assertFalse(test.isTimerCalled()); 122 } 123 124 public static Test suite() throws Exception 125 { 126 return getDeploySetup(RemoteUnitTestCase.class, "timer-test.jar"); 127 } 128 129 } 130 | Popular Tags |