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

Quick Search    Search Deep

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

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.activemq.usecases.SystemTest
All Implemented Interfaces:
javax.jms.MessageListener, junit.framework.Test
Direct Known Subclasses:
NonPersistentDurableTopicSystemTest, NonPersistentNonDurableTopicSystemTest, PersistentDurableTopicSystemTest, PersistentNonDurableTopicSystemTest, QueueSystemTest

public class SystemTest
extends junit.framework.TestCase
implements javax.jms.MessageListener


Field Summary
static java.lang.String ACTIVEMQ_SERVER
           
private  org.activemq.broker.impl.BrokerContainerImpl broker
           
private  java.lang.String brokerUrl
           
private  javax.jms.MessageConsumer consumer
           
private  int consumerCount
           
private  boolean init
           
private  boolean isDurable
           
private  boolean isEmbeddedBroker
           
private  boolean isPersistent
           
private  boolean isTopic
           
static java.lang.String LAST_MESSAGE
           
private static Logger log
           
private  int messageCount
           
private static int msgCounter
           
private  int producerCount
           
static java.util.Map ProducerMap
           
private  int subjectCount
           
private  boolean testStillRunning
           
static java.lang.String TOOL_DEFAULT
           
static boolean TRANSACTED_FALSE
           
 
Fields inherited from class junit.framework.TestCase
 
Constructor Summary
protected SystemTest()
          Default constructor
protected SystemTest(boolean isTopic, boolean isPersistent, boolean isDurable, int producerCount, int consumerCount, int subjectCount, int messageCount, java.lang.String testTitle)
          Constructor
 
Method Summary
private  void createBroker()
          Sets up and starts the broker.
private static javax.jms.Connection createConnectionFactory(java.lang.String url, boolean embeddedBroker)
          Creates the connection to the broker.
private static javax.jms.Destination createDestination(javax.jms.Session session, java.lang.String subject, boolean isTopic)
          Creates the session destination.
protected  org.activemq.store.PersistenceAdapter createPersistenceAdapter()
          Returns the persistence adapter.
private static javax.jms.Session createSession(javax.jms.Connection connection, boolean isTransacted)
          Creates the connection session.
private  void destoryBroker()
          Closes the broker.
protected  void doTest()
          Executes the unit test by running the producers and consumers.
protected  java.lang.String[] getSubjects()
          Generates the topic/queue destinations.
 void onMessage(javax.jms.Message message)
          Processes the received message.
protected  void publish()
          Creates the message producer threads.
protected  void publish(int x, java.lang.String subject)
          Creates the producer and send the messages.
protected  java.util.Map resetProducerMap()
          Returns the message entries and clears the map for another set of messages to be processed.
protected  void setUp()
          Sets up the resources of the unit test.
protected  void subscribe()
          Suscribes the consumers to the topic/queue destinations.
protected  void subscribe(java.lang.String subject)
          Suscribes the consumer to the topic/queue specified by the subject.
protected  void tearDown()
          Clears up the resources used in the unit test.
 void testParameterSettings(java.lang.String strTestTitle)
          Prints the test settings.
protected  void timerLoop()
          Validates the result of the producing and consumption of messages by the server.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, 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 Logger log

ACTIVEMQ_SERVER

public static final java.lang.String ACTIVEMQ_SERVER
See Also:
Constant Field Values

TRANSACTED_FALSE

public static final boolean TRANSACTED_FALSE
See Also:
Constant Field Values

TOOL_DEFAULT

public static final java.lang.String TOOL_DEFAULT
See Also:
Constant Field Values

LAST_MESSAGE

public static final java.lang.String LAST_MESSAGE
See Also:
Constant Field Values

msgCounter

private static int msgCounter

ProducerMap

public static java.util.Map ProducerMap

producerCount

private int producerCount

consumerCount

private int consumerCount

subjectCount

private int subjectCount

messageCount

private int messageCount

isPersistent

private boolean isPersistent

isDurable

private boolean isDurable

isTopic

private boolean isTopic

isEmbeddedBroker

private boolean isEmbeddedBroker

init

private boolean init

testStillRunning

private boolean testStillRunning

broker

private org.activemq.broker.impl.BrokerContainerImpl broker

brokerUrl

private java.lang.String brokerUrl

consumer

private javax.jms.MessageConsumer consumer
Constructor Detail

SystemTest

protected SystemTest()
Default constructor


SystemTest

protected SystemTest(boolean isTopic,
                     boolean isPersistent,
                     boolean isDurable,
                     int producerCount,
                     int consumerCount,
                     int subjectCount,
                     int messageCount,
                     java.lang.String testTitle)
Constructor

Method Detail

publish

protected void publish()
                throws javax.jms.JMSException
Creates the message producer threads.


publish

protected void publish(int x,
                       java.lang.String subject)
                throws java.lang.Exception
Creates the producer and send the messages.


getSubjects

protected java.lang.String[] getSubjects()
Generates the topic/queue destinations.


subscribe

protected void subscribe()
                  throws javax.jms.JMSException
Suscribes the consumers to the topic/queue destinations.


subscribe

protected void subscribe(java.lang.String subject)
                  throws javax.jms.JMSException
Suscribes the consumer to the topic/queue specified by the subject.


onMessage

public void onMessage(javax.jms.Message message)
Processes the received message.

Specified by:
onMessage in interface javax.jms.MessageListener

timerLoop

protected void timerLoop()
Validates the result of the producing and consumption of messages by the server. It checks for duplicate messages, message count and order.


resetProducerMap

protected java.util.Map resetProducerMap()
Returns the message entries and clears the map for another set of messages to be processed.


createConnectionFactory

private static javax.jms.Connection createConnectionFactory(java.lang.String url,
                                                            boolean embeddedBroker)
                                                     throws javax.jms.JMSException
Creates the connection to the broker.


createSession

private static javax.jms.Session createSession(javax.jms.Connection connection,
                                               boolean isTransacted)
                                        throws javax.jms.JMSException
Creates the connection session.


createDestination

private static javax.jms.Destination createDestination(javax.jms.Session session,
                                                       java.lang.String subject,
                                                       boolean isTopic)
                                                throws javax.jms.JMSException
Creates the session destination.


setUp

protected void setUp()
              throws java.lang.Exception
Sets up the resources of the unit test.


tearDown

protected void tearDown()
                 throws java.lang.Exception
Clears up the resources used in the unit test.


doTest

protected void doTest()
               throws java.lang.Exception
Executes the unit test by running the producers and consumers. It checks for duplicate messages, message count and order.


createBroker

private void createBroker()
                   throws java.lang.Exception
Sets up and starts the broker.


destoryBroker

private void destoryBroker()
                    throws java.lang.Exception
Closes the broker.


createPersistenceAdapter

protected org.activemq.store.PersistenceAdapter createPersistenceAdapter()
Returns the persistence adapter. Sets up the testing database to be used when the messages are persistent. It attempts to recreate the tables everytime the test is executed.


testParameterSettings

public void testParameterSettings(java.lang.String strTestTitle)
Prints the test settings.