1 25 26 package org.objectweb.jonas.jtests.clients.timer; 27 28 import org.objectweb.jonas.jtests.beans.transacted.Simple; 29 import org.objectweb.jonas.jtests.beans.transacted.SimpleEHome; 30 31 35 public abstract class A_TimerEntity extends A_Timer { 36 37 41 public A_TimerEntity(String name) { 42 super(name); 43 } 44 45 48 protected abstract SimpleEHome getHome(); 49 50 53 public void testTimer2() throws Exception { 54 int duration = 4; 55 int intervalduration = 3; 56 Simple s = getSimple(10); 57 int expected = s.getTimerCount(); 58 int id = s.setTimer(duration, intervalduration); 59 try { 60 assertEquals("timer expired too quickly", expected, s.getTimerCount()); 61 sleep(1000 * duration + 1500); 62 expected++; 63 assertEquals("timer did not expire first", expected, s.getTimerCount()); 64 for (int i = 0; i < 3; i++) { 65 sleep(1000 * intervalduration); 66 expected++; 67 assertEquals("timer did not expired at " + i, expected, s.getTimerCount()); 68 } 69 } finally { 70 s.remove(); } 72 } 73 74 77 public void testTimerInEjbPostCreate() throws Exception { 78 Simple s = getHome().createWithTimer(10, 2000); 79 sleep(4000); 80 s.remove(); 81 } 82 83 86 public void testTimerInEjbPostCreate2() throws Exception { 87 Simple s = getHome().createWithTimer(10, 2); 88 sleep(1000); 89 s.remove(); 90 } 91 92 95 public void testCancelInTimeout() throws Exception { 96 int duration = 2; 97 int intervalduration = -1; 98 Simple s = getSimple(100); 99 int id = s.setTimer(duration, intervalduration); 100 sleep(6000); 103 s.remove(); 104 } 105 } 106 | Popular Tags |