1 25 26 package org.objectweb.jonas.jtests.clients.jms; 27 28 import javax.naming.NamingException ; 29 import javax.rmi.PortableRemoteObject ; 30 import junit.framework.Test; 31 import junit.framework.TestSuite; 32 import org.objectweb.jonas.jtests.util.JTestCase; 33 import org.objectweb.jonas.jtests.beans.message.Sender; 34 import org.objectweb.jonas.jtests.beans.message.SenderHome; 35 import org.objectweb.jonas.jtests.beans.message.Sender1_1; 36 import org.objectweb.jonas.jtests.beans.message.Sender1_1Home; 37 38 public class F_RollbackMDB extends JTestCase { 39 40 private static String BEAN_HOME = "messageSenderSFHome"; 41 private static String BEAN1_1_HOME = "messageSender1_1SFHome"; 42 protected static SenderHome home = null; 43 protected static Sender1_1Home home1 = null; 44 45 46 public F_RollbackMDB(String name) { 47 super(name); 48 } 49 50 51 public SenderHome getHome() { 52 if (home == null) { 53 try { 54 home = (SenderHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SenderHome.class); 55 } catch (NamingException e) { 56 fail("Cannot get bean home"); 57 } 58 } 59 return home; 60 } 61 62 public Sender1_1Home getHome1() { 63 if (home1 == null) { 64 try { 65 home1 = (Sender1_1Home) PortableRemoteObject.narrow(ictx.lookup(BEAN1_1_HOME), Sender1_1Home.class); 66 } catch (NamingException e) { 67 fail("Cannot get bean home1"); 68 } 69 } 70 return home1; 71 } 72 73 78 protected void setUp() { 79 super.setUp(); 80 useBeans("message", true); 81 } 82 83 87 90 public void testRollbackSendOnTopic1() throws Exception { 91 Sender s = getHome().create(); 92 int val = 204; 93 utx.begin(); 94 s.sendOnTopic("JunitTopic1", val, 1); 95 utx.rollback(); 96 assertEquals(0, s.check(val, 2, 4)); 97 s.remove(); 98 } 99 100 104 public void testRollbackSendOnDestTopic1() throws Exception { 105 Sender1_1 s = getHome1().create(); 106 int val = 204; 107 utx.begin(); 108 s.sendOnDestination("JunitTopic1", val, 1); 109 utx.rollback(); 110 assertEquals(0, s.check(val, 2, 4)); 111 s.remove(); 112 } 113 114 118 public void testRollbackSendOnQueue1() throws Exception { 119 Sender s = getHome().create(); 120 int val = 104; 121 utx.begin(); 122 s.sendOnQueue("JunitQueue1", val, 1); 123 utx.rollback(); 124 assertEquals(0, s.check(val, 1, 4)); 125 s.remove(); 126 } 127 128 133 public void testRollbackSendOnDestQueue1() throws Exception { 134 Sender1_1 s = getHome1().create(); 135 int val = 104; 136 utx.begin(); 137 s.sendOnDestination("JunitQueue1", val, 1); 138 utx.rollback(); 139 assertEquals(0, s.check(val, 1, 4)); 140 s.remove(); 141 } 142 143 148 public void testRollbackOnlyOnQueue3() throws Exception { 149 Sender s = getHome().create(); 150 int val = 114; 151 int nb = 25; 152 s.sendOnQueue("JunitQueue3", val, nb); 153 assertEquals(nb, s.check(val, nb, 10)); 154 s.remove(); 155 } 156 157 163 public void testRollbackOnlyOnDestQueue3() throws Exception { 164 Sender1_1 s = getHome1().create(); 165 int val = 114; 166 int nb = 25; 167 s.sendOnDestination("JunitQueue3", val, nb); 168 assertEquals(nb, s.check(val, nb, 10)); 169 s.remove(); 170 } 171 172 175 public static Test suite() { 176 return new TestSuite(F_RollbackMDB.class); 177 } 178 179 public static void main (String args[]) { 180 String testtorun = null; 181 for (int argn = 0; argn < args.length; argn++) { 183 String s_arg = args[argn]; 184 Integer i_arg; 185 if (s_arg.equals("-n")) { 186 testtorun = args[++argn]; 187 } 188 } 189 if (testtorun == null) { 190 junit.textui.TestRunner.run(suite()); 191 } else { 192 junit.textui.TestRunner.run(new F_RollbackMDB(testtorun)); 193 } 194 } 195 } 196 | Popular Tags |