Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.activemq.usecases
Class AvailableConsumerTest  view AvailableConsumerTest download AvailableConsumerTest.java

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.activemq.usecases.AvailableConsumerTest
All Implemented Interfaces:
junit.framework.Test

public class AvailableConsumerTest
extends junit.framework.TestCase

TODO this test case relies on a perfect distribution of messages, dispatched one by one to each consumer. So this test case can only really work with an explicit setting of 'prefetch = 1' or something similar. The default out of the box dispatcher eagerly dispatches messages as quickly as possible. Ensures that if there is a network of brokers that a message is always dispatched to an available consumer * regardless of which broker it is on.

Version:
$Revision: 1.1 $

Nested Class Summary
private static class AvailableConsumerTest.BlockingConsumer
           
private static class AvailableConsumerTest.BrokerThread
           
private static class AvailableConsumerTest.MessagePublisher
           
 
Field Summary
private static long BROKER_INITIALIZATION_DELAY
           
private static org.apache.commons.logging.Log log
           
 
Fields inherited from class junit.framework.TestCase
 
Constructor Summary
AvailableConsumerTest()
           
 
Method Summary
private static void cleanupSimulation(AvailableConsumerTest.BrokerThread[] brokers, AvailableConsumerTest.MessagePublisher[] publishers, AvailableConsumerTest.BlockingConsumer[] consumers)
           
private static AvailableConsumerTest.BrokerThread[] createBrokers(java.lang.String[] brokerURLs)
           
private static AvailableConsumerTest.BlockingConsumer[] createConsumers(java.lang.String brokerURL, int numConsumers, java.lang.String queue)
           
private static AvailableConsumerTest.MessagePublisher[] createPublishers(java.lang.String brokerURL, int numPublishers, java.lang.String queue)
           
private static java.lang.String createReliableURL(java.lang.String[] brokerURLs)
           
private  void runSimulation(java.lang.String[] brokerURLs, int numConsumers, java.lang.String queue)
           
 void testOneBroker()
           
 void testTenBrokers()
           
 void testTwoBrokers()
           
private static void waitUntilNumBlocked(AvailableConsumerTest.BlockingConsumer[] consumers, int expectedNumBlocked)
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static final transient org.apache.commons.logging.Log log

BROKER_INITIALIZATION_DELAY

private static final long BROKER_INITIALIZATION_DELAY
See Also:
Constant Field Values
Constructor Detail

AvailableConsumerTest

public AvailableConsumerTest()
Method Detail

testOneBroker

public void testOneBroker()
                   throws java.lang.Throwable

testTwoBrokers

public void testTwoBrokers()
                    throws java.lang.Throwable

testTenBrokers

public void testTenBrokers()
                    throws java.lang.Throwable

runSimulation

private void runSimulation(java.lang.String[] brokerURLs,
                           int numConsumers,
                           java.lang.String queue)
                    throws java.lang.Throwable

cleanupSimulation

private static void cleanupSimulation(AvailableConsumerTest.BrokerThread[] brokers,
                                      AvailableConsumerTest.MessagePublisher[] publishers,
                                      AvailableConsumerTest.BlockingConsumer[] consumers)

createBrokers

private static AvailableConsumerTest.BrokerThread[] createBrokers(java.lang.String[] brokerURLs)
                                                           throws java.lang.InterruptedException

createConsumers

private static AvailableConsumerTest.BlockingConsumer[] createConsumers(java.lang.String brokerURL,
                                                                        int numConsumers,
                                                                        java.lang.String queue)
                                                                 throws javax.jms.JMSException

createPublishers

private static AvailableConsumerTest.MessagePublisher[] createPublishers(java.lang.String brokerURL,
                                                                         int numPublishers,
                                                                         java.lang.String queue)
                                                                  throws javax.jms.JMSException

createReliableURL

private static java.lang.String createReliableURL(java.lang.String[] brokerURLs)

waitUntilNumBlocked

private static void waitUntilNumBlocked(AvailableConsumerTest.BlockingConsumer[] consumers,
                                        int expectedNumBlocked)
                                 throws java.lang.InterruptedException