1 25 26 package org.objectweb.jonas.jtests.clients.jms; 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.Sender; 35 import org.objectweb.jonas.jtests.beans.message.Sender1_1Home; 36 import org.objectweb.jonas.jtests.beans.message.SenderHome; 37 import org.objectweb.jonas.jtests.util.JTestCase; 38 39 public class G_BasicMDB extends JTestCase { 40 41 private static String BEAN_HOME = "messageSenderSFHome"; 42 private static String BEAN1_1_HOME = "messageSender1_1SFHome"; 43 protected static SenderHome home = null; 44 protected static Sender1_1Home home1 = null; 45 46 public G_BasicMDB(String name) { 47 super(name); 48 } 49 50 51 public void testEmpty() throws Exception { 52 } 53 54 public SenderHome getHome() { 55 if (home == null) { 56 try { 57 home = (SenderHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SenderHome.class); 58 } catch (NamingException e) { 59 fail("Cannot get bean home"); 60 } 61 } 62 return home; 63 } 64 65 public Sender1_1Home getHome1() { 66 if (home1 == null) { 67 try { 68 home1 = (Sender1_1Home) PortableRemoteObject.narrow(ictx.lookup(BEAN1_1_HOME), Sender1_1Home.class); 69 } catch (NamingException e) { 70 fail("Cannot get bean home1"); 71 } 72 } 73 return home1; 74 } 75 76 81 protected void setUp() { 82 super.setUp(); 83 useBeans("message", true); 84 } 85 86 90 95 public void testCreateSendOnTopicRemove() throws Exception { 96 Sender s = getHome().create(); 97 int val = 200; 98 s.sendOnTopic("JunitTopic1", val, 1); 99 assertEquals(2, s.check(val, 2, 4)); 100 s.remove(); 101 102 } 103 104 105 108 public void testCreateBeginSendOnTopicCommitRemove() throws Exception { 109 110 Sender s = getHome().create(); 111 int val = 206; 112 utx.begin(); 113 s.sendOnTopic("JunitTopic1", val, 1); 114 utx.commit(); 115 assertEquals(2, s.check(val, 2, 4)); 116 s.remove(); 117 118 } 119 120 121 122 126 130 public void testCreateSendOnQueueRemove() throws Exception { 131 132 Sender s = getHome().create(); 133 int val = 100; 134 s.sendOnQueue("JunitQueue1", val, 1); 135 assertEquals(1, s.check(val, 1, 4)); 136 s.remove(); 137 138 } 139 140 141 142 143 146 public static Test suite() { 147 return new TestSuite(G_BasicMDB.class); 148 } 149 150 public static void main (String args[]) { 151 String testtorun = null; 152 for (int argn = 0; argn < args.length; argn++) { 154 String s_arg = args[argn]; 155 Integer i_arg; 156 if (s_arg.equals("-n")) { 157 testtorun = args[++argn]; 158 } 159 } 160 if (testtorun == null) { 161 junit.textui.TestRunner.run(suite()); 162 } else { 163 junit.textui.TestRunner.run(new G_BasicMDB(testtorun)); 164 } 165 } 166 } 167 | Popular Tags |