1 22 package org.jboss.test.jbossmq.stress; 23 24 import junit.framework.TestSuite; 25 import junit.framework.Assert; 26 27 import org.jboss.test.jbossmq.MQBase; 28 35 36 public class ExceptionListenerTest extends MQBase{ 37 38 public ExceptionListenerTest(String name) { 39 super(name); 40 } 41 49 50 51 public void runListener() throws Exception { 52 drainTopic(); 54 55 int ic = getIterationCount(); 56 long sleep = getRunSleep(); 57 IntRangeMessageFilter f1 = new IntRangeMessageFilter(javax.jms.Message .class, 58 "FAILSAFE_NR", 59 0, 60 ic); 61 62 TopicWorker sub1 = new TopicWorker(FAILSAFE_SUBSCRIBER, 63 TRANS_NONE, 64 f1); 65 Thread t1 = new Thread (sub1); 66 t1.start(); 67 68 sleep(5*sleep); 71 log.info("Awakened from sleep"); 72 73 Assert.assertEquals("Subscriber did not get correct number of messages "+sub1.getMessageHandled(), ic, 74 sub1.getMessageHandled()); 75 76 sub1.setStoped(); 77 t1.interrupt(); 78 sub1.close(); 79 80 } 81 82 public void runPublish() throws Exception { 83 int ic = getIterationCount(); 84 IntRangeMessageCreator c1 = new IntRangeMessageCreator("FAILSAFE_NR", 86 0); 87 TopicWorker pub1 = new TopicWorker(PUBLISHER, 88 TRANS_NONE, 89 c1, 90 ic/2); 91 pub1.connect(); 92 pub1.publish(); 93 94 Assert.assertEquals("Publisher did not publish correct number of messages "+pub1.getMessageHandled(), 95 ic/2, 96 pub1.getMessageHandled()); 97 98 99 pub1.close(); 100 } 101 public static junit.framework.Test suite() throws Exception { 102 103 TestSuite suite= new TestSuite(); 104 suite.addTest(new ExceptionListenerTest("runListener")); 105 106 return suite; 108 } 109 110 public static void main(String [] args) { 111 112 } 113 114 } | Popular Tags |