1 25 26 package org.objectweb.jonas.jtests.clients.timer; 27 28 import javax.naming.NamingException ; 29 import javax.rmi.PortableRemoteObject ; 30 31 import junit.framework.Test; 32 import junit.framework.TestSuite; 33 34 import org.objectweb.jonas.jtests.beans.message.Sender1_1; 35 import org.objectweb.jonas.jtests.beans.message.Sender1_1Home; 36 import org.objectweb.jonas.jtests.util.JTestCase; 37 38 41 public class F_TimerMD extends JTestCase { 42 43 private static String BEAN_HOME = "messageSender1_1SFHome"; 45 protected static Sender1_1Home home = null; 46 47 public static final int CREATE_TIMER_MIN = 1500; 49 public static final int CREATE_TIMER_MAX = 1600; 50 51 55 public F_TimerMD(String name) { 56 super(name); 57 } 58 59 63 protected void setUp() { 64 super.setUp(); 65 useBeans("message", true); 66 } 67 68 69 public Sender1_1Home getHome() { 70 if (home == null) { 71 try { 72 home = (Sender1_1Home) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), Sender1_1Home.class); 73 } catch (NamingException e) { 74 fail("Cannot get bean home"); 75 } 76 } 77 return home; 78 } 79 80 85 public void testBasicSendOnTopic1() throws Exception { 86 Sender1_1 s = getHome().create(); 87 int val = 200; 88 s.sendOnDestination("JunitTopic1", val, 1); 89 assertEquals(2, s.check(val, 2, 4)); 90 s.remove(); 91 } 92 93 96 public void testTimerTopic1() throws Exception { 97 Sender1_1 s = getHome().create(); 98 int val = CREATE_TIMER_MIN + 4; 99 s.sendOnDestination("JunitTopic1", val, 1); 100 assertEquals(2, s.check(val, 2, 5)); 101 s.remove(); 102 } 103 104 107 public void testTimerQueue1() throws Exception { 108 Sender1_1 s = getHome().create(); 109 int val = CREATE_TIMER_MIN + 5; 110 s.sendOnDestination("JunitQueue1", val, 1); 111 assertEquals(1, s.check(val, 1, 6)); 112 s.remove(); 113 } 114 115 118 public void testTimersQueue1() throws Exception { 119 Sender1_1 s = getHome().create(); 120 int val = CREATE_TIMER_MIN + 6; 121 s.sendOnDestination("JunitQueue1", val, 5); 122 assertEquals(5, s.check(val, 5, 7)); 123 s.remove(); 124 } 125 126 129 public static Test suite() { 130 return new TestSuite(F_TimerMD.class); 131 } 132 133 public static void main (String args[]) { 134 String testtorun = null; 135 for (int argn = 0; argn < args.length; argn++) { 137 String sarg = args[argn]; 138 if (sarg.equals("-n")) { 139 testtorun = args[++argn]; 140 } 141 } 142 if (testtorun == null) { 143 junit.textui.TestRunner.run(suite()); 144 } else { 145 junit.textui.TestRunner.run(new F_TimerMD(testtorun)); 146 } 147 } 148 } 149 | Popular Tags |