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_BasicMDB 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 public F_BasicMDB(String name) { 46 super(name); 47 } 48 49 public SenderHome getHome() { 50 if (home == null) { 51 try { 52 home = (SenderHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SenderHome.class); 53 } catch (NamingException e) { 54 fail("Cannot get bean home"); 55 } 56 } 57 return home; 58 } 59 60 public Sender1_1Home getHome1() { 61 if (home1 == null) { 62 try { 63 home1 = (Sender1_1Home) PortableRemoteObject.narrow(ictx.lookup(BEAN1_1_HOME), Sender1_1Home.class); 64 } catch (NamingException e) { 65 fail("Cannot get bean home1"); 66 } 67 } 68 return home1; 69 } 70 71 76 protected void setUp() { 77 super.setUp(); 78 useBeans("message", true); 79 } 80 81 85 90 public void testBasicSendOnTopic1() throws Exception { 91 Sender s = getHome().create(); 92 int val = 200; 93 s.sendOnTopic("JunitTopic1", val, 1); 94 assertEquals(2, s.check(val, 2, 4)); 95 s.remove(); 96 } 97 98 103 public void testBasicSendOnTopic2() throws Exception { 104 Sender s = getHome().create(); 105 int val = 200; 106 s.sendOnTopic("JunitTopic2", val, 1); 107 assertEquals(2, s.check(val, 2, 4)); 108 s.remove(); 109 } 110 111 116 public void testMultipleSendOnTopic1() throws Exception { 117 Sender s = getHome().create(); 118 int val = 210; 119 int nb = 10; 120 s.sendOnTopic("JunitTopic1", val, nb); 121 assertEquals(nb * 2, s.check(val, nb * 2, 8)); 122 s.remove(); 123 } 124 125 130 public void testBasicSendOnTopic1Tx() throws Exception { 131 Sender s = getHome().create(); 132 int val = 201; 133 s.sendOnTopicTx("JunitTopic1", val, 1); 134 assertEquals(2, s.check(val, 2, 4)); 135 s.remove(); 136 } 137 138 143 public void testMutipleSendOnTopic1Tx() throws Exception { 144 Sender s = getHome().create(); 145 int val = 211; 146 int nb = 10; 147 s.sendOnTopicTx("JunitTopic1", val, nb); 148 assertEquals(2 * nb, s.check(val, 2 * nb, 4)); 149 s.remove(); 150 } 151 152 155 public void testCommitSendOnTopic1() throws Exception { 156 157 Sender s = getHome().create(); 158 int val = 206; 159 utx.begin(); 160 s.sendOnTopic("JunitTopic1", val, 1); 161 utx.commit(); 162 assertEquals(2, s.check(val, 2, 4)); 163 s.remove(); 164 } 165 166 169 public void testNCommitSendOnTopic1() throws Exception { 170 171 Sender s = getHome().create(); 172 int val = 206; 173 int nb = 12; 174 utx.begin(); 175 s.sendOnTopic("JunitTopic1", val, nb); 176 utx.commit(); 177 assertEquals(2*nb, s.check(val, 2*nb, 4)); 178 s.remove(); 179 } 180 181 184 public void testManySendOnTopic() throws Exception { 185 186 Sender s = getHome().create(); 187 int val = 2060; 188 int nb = 120; 189 s.sendOnTopic("JunitTopic1", val, nb); 190 assertEquals(2*nb, s.check(val, 2*nb, 80)); 191 s.remove(); 192 } 193 194 199 public void testManySendOnTopicTx() throws Exception { 200 Sender s = getHome().create(); 201 int val = 2110; 202 int nb = 100; 203 s.sendOnTopicTx("JunitTopic1", val, nb); 204 assertEquals(2 * nb, s.check(val, 2 * nb, 80)); 205 s.remove(); 206 } 207 208 212 216 public void testBasicSendOnQueue1() throws Exception { 217 218 Sender s = getHome().create(); 219 int val = 100; 220 s.sendOnQueue("JunitQueue1", val, 1); 221 assertEquals(1, s.check(val, 1, 4)); 222 s.remove(); 223 } 224 225 229 public void testMultipleSendOnQueue1() throws Exception { 230 Sender s = getHome().create(); 231 int val = 100; 232 int nb = 5; 233 s.sendOnQueue("JunitQueue1", val, nb); 234 assertEquals(nb, s.check(val, nb, 8)); 235 s.remove(); 236 } 237 238 242 public void testBasicSendOnQueue1Tx() throws Exception { 243 Sender s = getHome().create(); 244 int val = 101; 245 s.sendOnQueueTx("JunitQueue1", val, 1); 246 assertEquals(1, s.check(val, 1, 4)); 247 s.remove(); 248 } 249 250 254 public void testMultipleSendOnQueue1Tx() throws Exception { 255 Sender s = getHome().create(); 256 int val = 121; 257 int nb = 20; 258 s.sendOnQueueTx("JunitQueue1", val, nb); 259 assertEquals(nb, s.check(val, nb, 10)); 260 s.remove(); 261 } 262 263 267 public void testBasicSendOnQueue2() throws Exception { 268 Sender s = getHome().create(); 269 int val = 102; 270 s.sendOnQueue("JunitQueue2", val, 1); 271 assertEquals(1, s.check(val, 1, 4)); 272 s.remove(); 273 } 274 275 279 public void testBasicSendOnQueue2Tx() throws Exception { 280 Sender s = getHome().create(); 281 int val = 103; 282 s.sendOnQueueTx("JunitQueue2", val, 1); 283 assertEquals(1, s.check(val, 1, 4)); 284 s.remove(); 285 } 286 287 288 292 public void testRollbackSendOnQueue2() throws Exception { 293 Sender s = getHome().create(); 294 int val = 105; 295 utx.begin(); 296 s.sendOnQueue("JunitQueue2", val, 1); 297 utx.rollback(); 298 assertEquals(0, s.check(val, 1, 4)); 299 s.remove(); 300 } 301 302 303 307 public void testCommitSendOnQueue1() throws Exception { 308 Sender s = getHome().create(); 309 int val = 106; 310 utx.begin(); 311 s.sendOnQueue("JunitQueue1", val, 1); 312 utx.commit(); 313 assertEquals(1, s.check(val, 1, 4)); 314 s.remove(); 315 } 316 317 318 322 public void testCommitSendOnQueue2() throws Exception { 323 Sender s = getHome().create(); 324 int val = 107; 325 utx.begin(); 326 s.sendOnQueue("JunitQueue2", val, 1); 327 utx.commit(); 328 assertEquals(1, s.check(val, 1, 4)); 329 s.remove(); 330 } 331 332 333 334 338 343 public void testBasicSendOnDestTopic1() throws Exception { 344 Sender1_1 s = getHome1().create(); 345 int val = 200; 346 s.sendOnDestination("JunitTopic1", val, 1); 347 assertEquals(2, s.check(val, 2, 4)); 348 s.remove(); 349 } 350 351 356 public void testBasicSendOnDestTopic2() throws Exception { 357 Sender1_1 s = getHome1().create(); 358 int val = 200; 359 s.sendOnDestination("JunitTopic2", val, 1); 360 assertEquals(2, s.check(val, 2, 4)); 361 s.remove(); 362 } 363 364 369 public void testMultipleSendOnDestTopic1() throws Exception { 370 Sender1_1 s = getHome1().create(); 371 int val = 210; 372 int nb = 10; 373 s.sendOnDestination("JunitTopic1", val, nb); 374 assertEquals(nb * 2, s.check(val, nb * 2, 8)); 375 s.remove(); 376 } 377 378 383 public void testBasicSendOnDestTopic1Tx() throws Exception { 384 Sender1_1 s = getHome1().create(); 385 int val = 201; 386 s.sendOnDestinationTx("JunitTopic1", val, 1); 387 assertEquals(2, s.check(val, 2, 4)); 388 s.remove(); 389 } 390 391 396 public void testMutipleSendOnDestTopic1Tx() throws Exception { 397 Sender1_1 s = getHome1().create(); 398 int val = 211; 399 int nb = 10; 400 s.sendOnDestinationTx("JunitTopic1", val, nb); 401 assertEquals(2*nb, s.check(val, 2*nb, 4)); 402 s.remove(); 403 } 404 405 408 public void testCommitSendOnDestTopic1() throws Exception { 409 410 Sender1_1 s = getHome1().create(); 411 int val = 206; 412 utx.begin(); 413 s.sendOnDestination("JunitTopic1", val, 1); 414 utx.commit(); 415 assertEquals(2, s.check(val, 2, 4)); 416 s.remove(); 417 } 418 419 422 public void testNCommitSendOnDestTopic1() throws Exception { 423 424 Sender1_1 s = getHome1().create(); 425 int val = 206; 426 int nb = 12; 427 utx.begin(); 428 s.sendOnDestination("JunitTopic1", val, nb); 429 utx.commit(); 430 assertEquals(2 * nb, s.check(val, 2 * nb, 4)); 431 s.remove(); 432 } 433 434 437 public void testManySendOnDestTopic() throws Exception { 438 439 Sender1_1 s = getHome1().create(); 440 int val = 2061; 441 int nb = 100; 442 s.sendOnDestination("JunitTopic1", val, nb); 443 assertEquals(2*nb, s.check(val, 2*nb, 80)); 444 s.remove(); 445 } 446 447 452 public void testManySendOnDestTopicTx() throws Exception { 453 Sender1_1 s = getHome1().create(); 454 int val = 2111; 455 int nb = 100; 456 s.sendOnDestinationTx("JunitTopic1", val, nb); 457 assertEquals(2 * nb, s.check(val, 2 * nb, 80)); 458 s.remove(); 459 } 460 461 465 469 public void testBasicSendOnDestQueue1() throws Exception { 470 471 Sender1_1 s = getHome1().create(); 472 int val = 100; 473 s.sendOnDestination("JunitQueue1", val, 1); 474 assertEquals(1, s.check(val, 1, 4)); 475 s.remove(); 476 } 477 478 482 public void testMultipleSendOnDestQueue1() throws Exception { 483 Sender1_1 s = getHome1().create(); 484 int val = 100; 485 int nb = 20; 486 s.sendOnDestination("JunitQueue1", val, nb); 487 assertEquals(nb, s.check(val, nb, 8)); 488 s.remove(); 489 } 490 491 495 public void testBasicSendOnDestQueue1Tx() throws Exception { 496 Sender1_1 s = getHome1().create(); 497 int val = 101; 498 s.sendOnDestinationTx("JunitQueue1", val, 1); 499 assertEquals(1, s.check(val, 1, 4)); 500 s.remove(); 501 } 502 503 507 public void testMultipleSendOnDestQueue1Tx() throws Exception { 508 Sender1_1 s = getHome1().create(); 509 int val = 121; 510 int nb = 20; 511 s.sendOnDestinationTx("JunitQueue1", val, nb); 512 assertEquals(nb, s.check(val, nb, 10)); 513 s.remove(); 514 } 515 516 520 public void testBasicSendOnDestQueue2() throws Exception { 521 Sender1_1 s = getHome1().create(); 522 int val = 102; 523 s.sendOnDestination("JunitQueue2", val, 1); 524 assertEquals(1, s.check(val, 1, 4)); 525 s.remove(); 526 } 527 528 532 public void testBasicSendOnDestQueue2Tx() throws Exception { 533 Sender1_1 s = getHome1().create(); 534 int val = 103; 535 s.sendOnDestinationTx("JunitQueue2", val, 1); 536 assertEquals(1, s.check(val, 1, 4)); 537 s.remove(); 538 } 539 540 541 545 public void testRollbackSendOnDestQueue2() throws Exception { 546 Sender1_1 s = getHome1().create(); 547 int val = 105; 548 utx.begin(); 549 s.sendOnDestination("JunitQueue2", val, 1); 550 utx.rollback(); 551 assertEquals(0, s.check(val, 1, 4)); 552 s.remove(); 553 } 554 555 556 560 public void testCommitSendOnDestQueue1() throws Exception { 561 Sender1_1 s = getHome1().create(); 562 int val = 106; 563 utx.begin(); 564 s.sendOnDestination("JunitQueue1", val, 1); 565 utx.commit(); 566 assertEquals(1, s.check(val, 1, 4)); 567 s.remove(); 568 } 569 570 571 575 public void testCommitSendOnDestQueue2() throws Exception { 576 Sender1_1 s = getHome1().create(); 577 int val = 107; 578 utx.begin(); 579 s.sendOnDestination("JunitQueue2", val, 1); 580 utx.commit(); 581 assertEquals(1, s.check(val, 1, 4)); 582 s.remove(); 583 } 584 585 586 587 590 public static Test suite() { 591 return new TestSuite(F_BasicMDB.class); 592 } 593 594 public static void main (String args[]) { 595 String testtorun = null; 596 for (int argn = 0; argn < args.length; argn++) { 598 String s_arg = args[argn]; 599 Integer i_arg; 600 if (s_arg.equals("-n")) { 601 testtorun = args[++argn]; 602 } 603 } 604 if (testtorun == null) { 605 junit.textui.TestRunner.run(suite()); 606 } else { 607 junit.textui.TestRunner.run(new F_BasicMDB(testtorun)); 608 } 609 } 610 } 611 | Popular Tags |