User: pra Date: 02/03/07 00:45:25 Added: src/main/org/jboss/test/jbossmq/stress ClientFailTest.java DurableSubOne.java DurableSubTwo.java DurableSubscriberTest.java ExceptionListen.java ExceptionListenerTest.java FailedDurableSub.java MDSOne.java MDSTtwo.java MassivFailingSub.java MassiveTest.java MultipleDurableSubscribers.java QueueSubOne.java QueueSubTwo.java QueueTest.java RunPublishOne.java RunPublishTwo.java Log: Added a number of stress tests that should be run by special ant targets since most of the tests requires the server to be restarted during the test Revision Changes Path 1.1 jbosstest/src/main/org/jboss/test/jbossmq/stress/ClientFailTest.java Index: ClientFailTest.java =================================================================== /* * JBoss, the OpenSource EJB server * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.jbossmq.stress; import javax.jms.*; import javax.naming.*; import org.jboss.test.JBossTestCase; import junit.framework.TestSuite; import org.apache.log4j.Category; /** * Test failing clients. * * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a> * @version $Revision: 1.1 $ */ public class ClientFailTest extends JBossTestCase{ final Category log = getLog(); // Provider specific static String TOPIC_FACTORY = "ConnectionFactory"; static String QUEUE_FACTORY = "ConnectionFactory"; static String TEST_QUEUE = "queue/testQueue"; static String TEST_TOPIC = "topic/testTopic"; static Context context; //static QueueConnection queueConnection; static TopicConnectionFactory topicFactory; public ClientFailTest(String name) throws Exception { super(name); } Thread getTopicRunner() { Thread sendThread = new Thread() { /** * Main processing method for the JBossMQPerfStressTestCase object */ public void run() { try { TopicConnection topicConnection = topicFactory.createTopicConnection(); TopicSession session = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = (Topic)context.lookup(TEST_TOPIC); TopicPublisher publisher = session.createPublisher(topic); while(true) { try { Thread.sleep(1000); }catch(InterruptedException ex) { } } /* waitForSynchMessage(); BytesMessage message = session.createBytesMessage(); message.writeBytes(PERFORMANCE_TEST_DATA_PAYLOAD); long startTime = System.currentTimeMillis(); for (int i = 0; i < iterationCount; i++) { publisher.publish(topic, message, persistence, 4, 1000L); getLog().debug(" Sent #"+i); if (transacted == TRANS_INDIVIDUAL) { session.commit(); } } if (transacted == TRANS_TOTAL) { session.commit(); } long endTime = System.currentTimeMillis(); session.close(); long pTime = endTime - startTime; log.debug(" sent all messages in " + ((double)pTime / 1000) + " seconds. "); */ } catch (Exception e) { log.error("error", e); } } }; return sendThread; } public void testFailStopTopicPub() throws Exception { final int iterationCount = getIterationCount(); for (int i = 0; i<iterationCount;i++) { Thread t = getTopicRunner(); log.debug("Starting thread " + t.getName()); t.start(); log.debug("Sleeping a while"); Thread.sleep(1500); log.debug("Stopping thread " + t.getName()); t.stop(); } //System.exit(0); } /** * The JUnit setup method * * @exception Exception Description of Exception */ protected void setUp() throws Exception { if (context == null) { context = getInitialContext(); /* QueueConnectionFactory queueFactory = (QueueConnectionFactory)context.lookup(QUEUE_FACTORY); queueConnection = queueFactory.createQueueConnection(); */ topicFactory = (TopicConnectionFactory)context.lookup(TOPIC_FACTORY); //topicConnection = topicFactory.createTopicConnection(); getLog().debug("Connection to JBossMQ established."); } } public static junit.framework.Test suite() throws Exception{ TestSuite suite= new TestSuite(); suite.addTest(new ClientFailTest("testFailStopTopicPub")); return suite; } public static void main(String[] args) { try { ClientFailTest ct = new ClientFailTest("testFailConnect"); ct.setUp(); Thread t = ct.getTopicRunner(); t.run(); ct.log.debug("Exiting"); //Thread.sleep(1000); }catch(Exception ex) { System.out.println("Ex: " +ex); } } } // ClientFailTest 1.1 jbosstest/src/main/org/jboss/test/jbossmq/stress/DurableSubOne.java Index: DurableSubOne.java =================================================================== /* * JBoss, the OpenSource EJB server * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.jbossmq.stress; import junit.framework.TestSuite; /** * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a> * @version $Revision: 1.1 $ */ public class DurableSubOne extends DurableSubscriberTest{ public DurableSubOne(String name) { super(name); } public static junit.framework.Test suite() throws Exception{ TestSuite suite= new TestSuite(); suite.addTest(new DurableSubOne("runDurableSubscriberPartOne")); //suite.addTest(new DurableSubscriberTest("testBadClient")); return suite; } public static void main(String[] args) { } } // DurableSubOne 1.1 jbosstest/src/main/org/jboss/test/jbossmq/stress/DurableSubTwo.java Index: DurableSubTwo.java =================================================================== /* * JBoss, the OpenSource EJB server * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.jbossmq.stress; import junit.framework.TestSuite; /** * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a> * @version $Revision: 1.1 $ */ public class DurableSubTwo extends DurableSubscriberTest{ public DurableSubTwo(String name) { super(name); } public static junit.framework.Test suite() throws Exception{ TestSuite suite= new TestSuite(); suite.addTest(new DurableSubTwo ("runDurableSubscriberPartTwo")); //suite.addTest(new DurableSubscriberTest("testBadClient")); return suite; } public static void main(String[] args) { } } // DurableSubTwo 1.1 jbosstest/src/main/org/jboss/test/jbossmq/stress/DurableSubscriberTest.java Index: DurableSubscriberTest.java =================================================================== /* * JBoss, the OpenSource EJB server * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.jbossmq.stress; import junit.framework.TestSuite; import junit.framework.Assert; import org.jboss.test.jbossmq.MQBase; /** * Durable subscriber tests. * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a> * @version $Revision: 1.1 $ */ public class DurableSubscriberTest extends MQBase { public DurableSubscriberTest(String name) { super(name); } /** * Test setting up a durable subscription. Disconnect after half * the messages have been sent. Connect later to see if they are still there. * This test is done it two parts to be able to take down the server in * between */ public void runDurableSubscriberPartOne() throws Exception { try { // Clean testarea up drainTopic(); int ic = getIterationCount(); // Set up a durable subscriber IntRangeMessageFilter f1 = new IntRangeMessageFilter(javax.jms.Message.class, "DURABLE_NR", 0, ic/2); TopicWorker sub1 = new TopicWorker(SUBSCRIBER, TRANS_NONE, f1); sub1.setDurable("john", "needle", "sub2"); Thread t1 = new Thread(sub1); t1.start(); // Publish IntRangeMessageCreator c1 = new IntRangeMessageCreator("DURABLE_NR", 0); TopicWorker pub1 = new TopicWorker(PUBLISHER, TRANS_NONE, c1, ic/2); pub1.connect(); pub1.publish(); Assert.assertEquals("Publisher did not publish correct number of messages "+pub1.getMessageHandled(), ic/2, pub1.getMessageHandled()); // let sub1 have some time to handle the messages. log.debug("Sleeping for " + ((ic*10)/60000) + " minutes"); sleep(ic*10); Assert.assertEquals("Subscriber did not get correct number of messages "+sub1.getMessageHandled(), ic/2, sub1.getMessageHandled()); // Take down first sub sub1.close(); t1.stop(); //Publish some more pub1.publish(ic/2); Assert.assertEquals("Publisher did not publish correct number of messages "+pub1.getMessageHandled(),ic, pub1.getMessageHandled()); pub1.close(); }catch(Throwable t) { log.error("Error in test: " +t,t); throw new Exception(t.getMessage()); } } /** * Part two of durable subscriber test, part one should be run before * this is run. */ public void runDurableSubscriberPartTwo() throws Exception { try { int ic = getIterationCount(); // Set up a durable subscriber IntRangeMessageFilter f1 = new IntRangeMessageFilter(javax.jms.Message.class, "DURABLE_NR", 0, ic/2); TopicWorker sub1 = new TopicWorker(SUBSCRIBER, TRANS_NONE, f1); sub1.setDurable("john", "needle", "sub2"); // Start up subscription again Thread t2 = new Thread(sub1); t2.start(); log.debug("Sleeping for " + ((ic*10)/60000) + " minutes"); sleep(ic*10); Assert.assertEquals("Subscriber did not get correct number of messages "+sub1.getMessageHandled(), ic/2, sub1.getMessageHandled()); //OK, take everything down sub1.unsubscribe(); sub1.close(); t2.stop(); }catch(Throwable t) { log.error("Error in test: " +t,t); throw new Exception(t.getMessage()); } } public void testDurableSubscriber() throws Exception { runDurableSubscriberPartOne(); runDurableSubscriberPartTwo(); } public void runGoodClient() throws Exception { TopicWorker sub1 = new TopicWorker(CONNECTOR, TRANS_NONE, null); sub1.setDurable("john", "needle", "sub2"); Thread t1 = new Thread(sub1); t1.start(); try{ Thread.sleep(2000); }catch(InterruptedException e){} // Take it down abruptly t1.stop(); sub1.close(); Assert.assertNull("Error in connecting durable sub",sub1.getException()); } /** * Test connecting as a durable subscriber and diconecction without taking * the connection down properly */ public void runBadClient() throws Exception { TopicWorker sub1 = new TopicWorker(CONNECTOR, TRANS_NONE, null); sub1.setDurable("john", "needle", "sub2"); Thread t1 = new Thread(sub1); t1.start(); try{ Thread.sleep(2000); }catch(InterruptedException e){} // Take it down abruptly t1.stop(); //sub1.close(); Assert.assertNull("Error in connecting durable sub",sub1.getException()); } public static junit.framework.Test suite() throws Exception{ TestSuite suite= new TestSuite(); suite.addTest(new DurableSubscriberTest("runGoodClient")); suite.addTest(new DurableSubscriberTest("testDurableSubscriber")); //suite.addTest(new DurableSubscriberTest("testBadClient")); return suite; } public static void main(String[] args) { } } // DurableSubscriberTest 1.1 jbosstest/src/main/org/jboss/test/jbossmq/stress/ExceptionListen.java Index: ExceptionListen.java =================================================================== /* * JBoss, the OpenSource EJB server * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.jbossmq.stress; import junit.framework.TestSuite; /** * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a> * @version $Revision: 1.1 $ */ public class ExceptionListen extends ExceptionListenerTest{ public ExceptionListen(String name) { super(name); } public static junit.framework.Test suite() throws Exception{ TestSuite suite= new TestSuite(); suite.addTest(new ExceptionListen("runListener")); //suite.addTest(new DurableSubscriberTest("testBadClient")); return suite; } public static void main(String[] args) { } } // ExceptionListen 1.1 jbosstest/src/main/org/jboss/test/jbossmq/stress/ExceptionListenerTest.java Index: ExceptionListenerTest.java =================================================================== /* * JBoss, the OpenSource EJB server * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.jbossmq.stress; import junit.framework.TestSuite; import junit.framework.Assert; import org.jboss.test.jbossmq.MQBase; /** * Exception listener tests- * * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a> * @version $Revision: 1.1 $ */ public class ExceptionListenerTest extends MQBase{ public ExceptionListenerTest(String name) { super(name); } /* To catch the old typ of error, we need a consumer that has not consumed anything before the server goes down. To govern this we need a publisher method to be used in the tests. Big question is: when are we satisfyed with the listeners result??? */ public void runListener() throws Exception { // Clean testarea up drainTopic(); int ic = getIterationCount(); long sleep = getRunSleep(); IntRangeMessageFilter f1 = new IntRangeMessageFilter(javax.jms.Message.class, "FAILSAFE_NR", 0, ic); TopicWorker sub1 = new TopicWorker(FAILSAFE_SUBSCRIBER, TRANS_NONE, f1); Thread t1 = new Thread(sub1); t1.start(); // Now we must wait until JBoss has been restarted before we check // messages sleep(5*sleep); log.info("Awakened from sleep"); Assert.assertEquals("Subscriber did not get correct number of messages "+sub1.getMessageHandled(), ic, sub1.getMessageHandled()); sub1.setStoped(); t1.interrupt(); t1.stop(); sub1.close(); } public void runPublish() throws Exception { int ic = getIterationCount(); // This does NOT work perfect, since both sends will have base 0 IntRangeMessageCreator c1 = new IntRangeMessageCreator("FAILSAFE_NR", 0); TopicWorker pub1 = new TopicWorker(PUBLISHER, TRANS_NONE, c1, ic/2); pub1.connect(); pub1.publish(); Assert.assertEquals("Publisher did not publish correct number of messages "+pub1.getMessageHandled(), ic/2, pub1.getMessageHandled()); pub1.close(); } public static junit.framework.Test suite() throws Exception{ TestSuite suite= new TestSuite(); suite.addTest(new ExceptionListenerTest("runListener")); //suite.addTest(new DurableSubscriberTest("testBadClient")); return suite; } public static void main(String[] args) { } } // ExceptionListenerTest 1.1 jbosstest/src/main/org/jboss/test/jbossmq/stress/FailedDurableSub.java Index: FailedDurableSub.java =================================================================== /* * JBoss, the OpenSource EJB server * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.jbossmq.stress; import junit.framework.TestSuite; import junit.framework.Assert; /** * * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a> * @version $Revision: 1.1 $ */ public class FailedDurableSub extends DurableSubscriberTest { public FailedDurableSub(String name) { super(name); } /** * Do a durable subscription and fail to disconnect. Should be run * in a separate VM from test, testing if a new connection is possible! * * This did not work before in JBossMQ, but seems to work fine now. */ public static junit.framework.Test suite() throws Exception{ TestSuite suite= new TestSuite(); suite.addTest(new FailedDurableSub("runBadClient")); //suite.addTest(new DurableSubscriberTest("testBadClient")); return suite; } public static void main(String[] args) { } } // FailedDurableSub 1.1 jbosstest/src/main/org/jboss/test/jbossmq/stress/MDSOne.java Index: MDSOne.java =================================================================== /* * JBoss, the OpenSource EJB server * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.jbossmq.stress; import junit.framework.TestSuite; /** * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a> * @version $Revision: 1.1 $ */ public class MDSOne extends MultipleDurableSubscribers{ public MDSOne(String name) { super(name); } public static junit.framework.Test suite() throws Exception{ TestSuite suite= new TestSuite(); suite.addTest(new MDSOne("runDurableSubscriberPartOne")); //suite.addTest(new DurableSubscriberTest("testBadClient")); return suite; } public static void main(String[] args) { } } // MDSOne 1.1 jbosstest/src/main/org/jboss/test/jbossmq/stress/MDSTtwo.java Index: MDSTtwo.java =================================================================== /* * JBoss, the OpenSource EJB server * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.jbossmq.stress; import junit.framework.TestSuite; /** * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a> * @version $Revision: 1.1 $ */ public class MDSTtwo extends MultipleDurableSubscribers{ public MDSTtwo(String name) { super(name); } public static junit.framework.Test suite() throws Exception{ TestSuite suite= new TestSuite(); suite.addTest(new MDSTtwo("runDurableSubscriberPartTwo")); //suite.addTest(new DurableSubscriberTest("testBadClient")); return suite; } public static void main(String[] args) { } } // MDSTtwo 1.1 jbosstest/src/main/org/jboss/test/jbossmq/stress/MassivFailingSub.java Index: MassivFailingSub.java =================================================================== /* * JBoss, the OpenSource EJB server * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.jbossmq.stress; import junit.framework.TestSuite; /** * Test failing clients. * * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a> * @version $Revision: 1.1 $ */ public class MassivFailingSub extends MassiveTest{ public MassivFailingSub(String name) { super(name); } public static junit.framework.Test suite() throws Exception{ TestSuite suite= new TestSuite(); suite.addTest(new MassivFailingSub ("runMassivTestFailingSub")); return suite; } public static void main(String[] args) { } } // MassivFailingSub 1.1 jbosstest/src/main/org/jboss/test/jbossmq/stress/MassiveTest.java Index: MassiveTest.java =================================================================== /* * JBoss, the OpenSource EJB server * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.jbossmq.stress; import javax.jms.Message; import javax.jms.BytesMessage; import javax.jms.JMSException; import junit.framework.TestSuite; import junit.framework.Assert; import org.jboss.test.jbossmq.MQBase; /** * * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a> * @version $Revision: 1.1 $ */ public class MassiveTest extends MQBase{ static byte[] PERFORMANCE_TEST_DATA_PAYLOAD = new byte[10 * 1024]; public MassiveTest(String name) { super(name); } /** * Should be run with large iteration count!!!!! */ public void runMassiveTest() throws Exception { // Clean testarea up drainTopic(); int ic = getIterationCount(); // Set up a durable subscriber IntRangeMessageFilter f1 = new IntRangeMessageFilter(javax.jms.BytesMessage.class, "MASSIVE_NR", 0, ic); TopicWorker sub1 = new TopicWorker(SUBSCRIBER, TRANS_NONE, f1); Thread t1 = new Thread(sub1); t1.start(); // Publish ByteIntRangeMessageCreator c1 = new ByteIntRangeMessageCreator("MASSIVE_NR", 0); TopicWorker pub1 = new TopicWorker(PUBLISHER, TRANS_NONE, c1, ic); pub1.connect(); pub1.publish(); Assert.assertEquals("Publisher did not publish correct number of messages "+pub1.getMessageHandled(), ic, pub1.getMessageHandled()); log.debug("Sleeping for " + ((ic*10)/60000) + " minutes"); // let sub1 have some time to handle the messages. try{ Thread.sleep(ic*10); }catch(InterruptedException e){} log.debug("Woke up"); Assert.assertEquals("Subscriber did not get correct number of messages "+sub1.getMessageHandled(), ic, sub1.getMessageHandled()); // Take down first sub sub1.close(); t1.stop(); pub1.close(); } public void runMassivTestFailingSub() throws Exception { // Clean testarea up drainTopic(); int ic = getIterationCount(); // Set up a subscriber IntRangeMessageFilter f1 = new IntRangeMessageFilter(javax.jms.BytesMessage.class, "MASSIVE_NR", 0, ic); TopicWorker sub1 = new TopicWorker(SUBSCRIBER, TRANS_NONE, f1); Thread t1 = new Thread(sub1); t1.start(); // Set up a failing sub FailingSubWorker sub2 = new FailingSubWorker(); sub2.setSubscriberAttrs(SUBSCRIBER, TRANS_NONE, f1); Thread tf = new Thread(sub2); tf.start(); // Publish ByteIntRangeMessageCreator c1 = new ByteIntRangeMessageCreator("MASSIVE_NR", 0); TopicWorker pub1 = new TopicWorker(PUBLISHER, TRANS_NONE, c1, ic); pub1.connect(); pub1.publish(); Assert.assertEquals("Publisher did not publish correct number of messages "+pub1.getMessageHandled(), ic, pub1.getMessageHandled()); log.debug("Sleeping for " + ((ic*10)/60000) + " minutes"); // let sub1 have some time to handle the messages. try{ Thread.sleep(ic*10); }catch(InterruptedException e){} log.debug("Woke up"); Assert.assertEquals("Subscriber did not get correct number of messages "+sub1.getMessageHandled(), ic, sub1.getMessageHandled()); // Take down sub1.close(); t1.stop(); pub1.close(); sub2.setStoped(); tf.interrupt(); tf.stop(); sub2.close(); } public static junit.framework.Test suite() throws Exception{ TestSuite suite= new TestSuite(); suite.addTest(new MassiveTest("runMassiveTest")); //suite.addTest(new DurableSubscriberTest("testBadClient")); return suite; } public static void main(String[] args) { try { MassiveTest t = new MassiveTest("runMassiveTest"); t.setUp(); t.runMassiveTest(); }catch(Exception ex) { System.err.println("Ex: " +ex); ex.printStackTrace(); } } public class ByteIntRangeMessageCreator extends IntRangeMessageCreator{ int start = 0; public ByteIntRangeMessageCreator(String property) { super(property); } public ByteIntRangeMessageCreator(String property, int start) { super(property); this.start = start; } public Message createMessage(int nr) throws JMSException { if (session ==null) throw new JMSException("Session not allowed to be null"); BytesMessage msg = session.createBytesMessage(); msg.writeBytes(PERFORMANCE_TEST_DATA_PAYLOAD); msg.setStringProperty(property, String.valueOf(start+nr)); return msg; } } public class FailingSubWorker extends TopicWorker { int check = 0; //Only reveice firts message public void onMessage(Message msg) { check++; if (check > 1) log.warn("Got called while asleep!! " +check); while(!stopRequested) { sleep(2000); } } } } // MassiveTest 1.1 jbosstest/src/main/org/jboss/test/jbossmq/stress/MultipleDurableSubscribers.java Index: MultipleDurableSubscribers.java =================================================================== /* * JBoss, the OpenSource EJB server * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.jbossmq.stress; import javax.jms.JMSException; import junit.framework.TestSuite; import junit.framework.Assert; import org.jboss.test.jbossmq.MQBase; /** * According to JMS spec, 6.11.1 to have several durable subscriptions under * one client id. We test for this here. * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a> * @version $Revision: 1.1 $ */ public class MultipleDurableSubscribers extends MQBase{ class PiggyBackWorker extends TopicWorker{ public PiggyBackWorker(TopicWorker worker) { super(); connection = worker.connection; destination = worker.destination; session = worker.session; } public void connect() { log.debug("In null connect"); // Does nothing } public void subscribe() throws JMSException{ super.subscribe(); log.debug("Message consumer set up " + consumer); } } public MultipleDurableSubscribers(String name) { super(name); } // This is build the same way as Durable test, to make it possible to take // server down in between. /** * Test setting up a durable subscription. Disconnect after half * the messages have been sent. Connect later to see if they are still there. * This test is done it two parts to be able to take down the server in * between */ public void runDurableSubscriberPartOne() throws Exception { try { // Clean testarea up drainTopic(); int ic = getIterationCount(); // Set up a durable subscriber IntRangeMessageFilter f1 = new IntRangeMessageFilter(javax.jms.Message.class, "DURABLE_NR", 0, ic/2); TopicWorker sub1 = new TopicWorker(SUBSCRIBER, TRANS_NONE, f1); sub1.setDurable("john", "needle", "sub1"); Thread t1 = new Thread(sub1); t1.start(); log.debug("Sub1 set up"); sleep(5000L); TopicWorker sub2 = new PiggyBackWorker(sub1); sub2.setSubscriberAttrs(SUBSCRIBER, TRANS_NONE, f1); sub2.setDurable("john", "needle", "sub2"); Thread t2 = new Thread(sub2); t2.start(); log.debug("Sub2 setup"); // Publish IntRangeMessageCreator c1 = new IntRangeMessageCreator("DURABLE_NR", 0); TopicWorker pub1 = new TopicWorker(PUBLISHER, TRANS_NONE, c1, ic/2); pub1.connect(); pub1.publish(); Assert.assertEquals("Publisher did not publish correct number of messages "+pub1.getMessageHandled(), ic/2, pub1.getMessageHandled()); // let sub1 have some time to handle the messages. log.debug("Sleeping for " + ((ic*10)/60000) + " minutes"); sleep(ic*10); Assert.assertEquals("Subscriber1 did not get correct number of messages "+sub1.getMessageHandled(), ic/2, sub1.getMessageHandled()); Assert.assertEquals("Subscriber2 did not get correct number of messages "+sub1.getMessageHandled(), ic/2, sub2.getMessageHandled()); // Take down subs sub1.close(); t1.stop(); sub2.close(); t2.stop(); //Publish some more pub1.publish(ic/2); Assert.assertEquals("Publisher did not publish correct number of messages "+pub1.getMessageHandled(),ic, pub1.getMessageHandled()); pub1.close(); }catch(Throwable t) { log.error("Error in test: " +t,t); throw new Exception(t.getMessage()); } } /** * Part two of durable subscriber test, part one should be run before * this is run. */ public void runDurableSubscriberPartTwo() throws Exception { try { int ic = getIterationCount(); // Set up a durable subscriber IntRangeMessageFilter f1 = new IntRangeMessageFilter(javax.jms.Message.class, "DURABLE_NR", 0, ic/2); TopicWorker sub1 = new TopicWorker(SUBSCRIBER, TRANS_NONE, f1); sub1.setDurable("john", "needle", "sub1"); // Start up subscription again Thread t1 = new Thread(sub1); t1.start(); sleep(5000L); TopicWorker sub2 = new PiggyBackWorker(sub1); sub2.setSubscriberAttrs(SUBSCRIBER, TRANS_NONE, f1); sub2.setDurable("john", "needle", "sub2"); Thread t2 = new Thread(sub2); t2.start(); log.debug("Sleeping for " + ((ic*10)/60000) + " minutes"); sleep(ic*10); Assert.assertEquals("Subscriber did not get correct number of messages "+sub1.getMessageHandled(), ic/2, sub1.getMessageHandled()); Assert.assertEquals("Subscriber did not get correct number of messages "+sub1.getMessageHandled(), ic/2, sub2.getMessageHandled()); //OK, take everything down sub1.unsubscribe(); sub2.unsubscribe(); sub1.close(); t1.stop(); sub2.close(); t2.stop(); }catch(Throwable t) { log.error("Error in test: " +t,t); throw new Exception(t.getMessage()); } } public void testDurableSubscriber() throws Exception { runDurableSubscriberPartOne(); runDurableSubscriberPartTwo(); } public static void main(String[] args) { } } // MultipleDurableSubscribers 1.1 jbosstest/src/main/org/jboss/test/jbossmq/stress/QueueSubOne.java Index: QueueSubOne.java =================================================================== /* * JBoss, the OpenSource EJB server * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.jbossmq.stress; import junit.framework.TestSuite; /** * * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a> * @version $Revision: 1.1 $ */ public class QueueSubOne extends QueueTest{ public QueueSubOne(String name) { super(name); } public static junit.framework.Test suite() throws Exception{ TestSuite suite= new TestSuite(); suite.addTest(new QueueSubOne("runQueueSubscriberPartOne")); return suite; } public static void main(String[] args) { } } // QueueSubOne 1.1 jbosstest/src/main/org/jboss/test/jbossmq/stress/QueueSubTwo.java Index: QueueSubTwo.java =================================================================== /* * JBoss, the OpenSource EJB server * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.jbossmq.stress; import junit.framework.TestSuite; /** * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a> * @version $Revision: 1.1 $ */ public class QueueSubTwo extends QueueTest{ public QueueSubTwo(String name) { super(name); } public static junit.framework.Test suite() throws Exception{ TestSuite suite= new TestSuite(); suite.addTest(new QueueSubOne("runQueueSubscriberPartTwo")); return suite; } public static void main(String[] args) { } } // QueueSubTwo 1.1 jbosstest/src/main/org/jboss/test/jbossmq/stress/QueueTest.java Index: QueueTest.java =================================================================== /* * JBoss, the OpenSource EJB server * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.jbossmq.stress; import junit.framework.TestSuite; import junit.framework.Assert; import org.jboss.test.jbossmq.MQBase; /** * Test queue recover. * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a> * @version $Revision: 1.1 $ */ public class QueueTest extends MQBase{ public QueueTest(String name) { super(name); } /** * This test is done it two parts to be able to take down the server in * between */ public void runQueueSubscriberPartOne() throws Exception { try { // Clean testarea up drainQueue(); int ic = getIterationCount(); // Set up a durable subscriber IntRangeMessageFilter f1 = new IntRangeMessageFilter(javax.jms.Message.class, "QUEUE_NR", 0, ic/2); QueueWorker sub1 = new QueueWorker(SUBSCRIBER, TRANS_NONE, f1); Thread t1 = new Thread(sub1); t1.start(); // Publish IntRangeMessageCreator c1 = new IntRangeMessageCreator("QUEUE_NR", 0); QueueWorker pub1 = new QueueWorker(PUBLISHER, TRANS_NONE, c1, ic/2); pub1.connect(); pub1.publish(); Assert.assertEquals("Publisher did not publish correct number of messages "+pub1.getMessageHandled(), ic/2, pub1.getMessageHandled()); // let sub1 have some time to handle the messages. log.debug("Sleeping for " + ((ic*10)/60000) + " minutes"); // let sub1 have some time to handle the messages. sleep(ic*10); Assert.assertEquals("Subscriber did not get correct number of messages "+sub1.getMessageHandled(), ic/2, sub1.getMessageHandled()); // Take down first sub sub1.close(); t1.stop(); //Publish some more pub1.publish(ic/2); Assert.assertEquals("Publisher did not publish correct number of messages "+pub1.getMessageHandled(),ic, pub1.getMessageHandled()); pub1.close(); }catch(Throwable t) { log.error("Error in test: " +t,t); throw new Exception(t.getMessage()); } } /** * Part two of durable subscriber test, part one should be run before * this is run. */ public void runQueueSubscriberPartTwo() throws Exception { try { int ic = getIterationCount(); // Set up a durable subscriber IntRangeMessageFilter f1 = new IntRangeMessageFilter(javax.jms.Message.class, "QUEUE_NR", 0, ic/2); QueueWorker sub1 = new QueueWorker(SUBSCRIBER, TRANS_NONE, f1); // Start up subscription again Thread t2 = new Thread(sub1); t2.start(); log.debug("Sleeping for " + ((ic*10)/60000) + " minutes"); sleep(ic*10); Assert.assertEquals("Subscriber did not get correct number of messages "+sub1.getMessageHandled(), ic/2, sub1.getMessageHandled()); //OK, take everything down sub1.close(); t2.stop(); }catch(Throwable t) { log.error("Error in test: " +t,t); throw new Exception(t.getMessage()); } } /** * Test queue without taking the server down. */ public void testQueueSubscriber() throws Exception { runQueueSubscriberPartOne(); runQueueSubscriberPartTwo(); } public static junit.framework.Test suite() throws Exception{ TestSuite suite= new TestSuite(); suite.addTest(new QueueSubOne("testQueueSubscriber")); return suite; } public static void main(String[] args) { } } // QueueTest 1.1 jbosstest/src/main/org/jboss/test/jbossmq/stress/RunPublishOne.java Index: RunPublishOne.java =================================================================== /* * JBoss, the OpenSource EJB server * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.jbossmq.stress; import junit.framework.TestSuite; /** * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a> * @version $Revision: 1.1 $ */ public class RunPublishOne extends ExceptionListenerTest{ public RunPublishOne(String name) { super(name); } public static junit.framework.Test suite() throws Exception{ TestSuite suite= new TestSuite(); suite.addTest(new RunPublishOne("runPublish")); return suite; } public static void main(String[] args) { } } // RunPublishOne 1.1 jbosstest/src/main/org/jboss/test/jbossmq/stress/RunPublishTwo.java Index: RunPublishTwo.java =================================================================== /* * JBoss, the OpenSource EJB server * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.jbossmq.stress; import junit.framework.TestSuite; /** * Test failing clients. * * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a> * @version $Revision: 1.1 $ */ public class RunPublishTwo extends ExceptionListenerTest{ public RunPublishTwo(String name) { super(name); } public void runPublishTwo() throws Exception{ runPublish(); runPublish(); } public static junit.framework.Test suite() throws Exception{ TestSuite suite= new TestSuite(); suite.addTest(new RunPublishTwo("runPublishTwo")); return suite; } public static void main(String[] args) { } } // RunPublishTwo
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development