org.mule.transport.jms.integration
Class AbstractJmsFunctionalTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.mule.tck.AbstractMuleTestCase
              extended by org.mule.tck.FunctionalTestCase
                  extended by org.mule.transport.jms.integration.AbstractJmsFunctionalTestCase
All Implemented Interfaces:
junit.framework.Test, TestCaseWatchdogTimeoutHandler
Direct Known Subclasses:
AbstractJmsSingleTransactionSingleServiceTestCase, JmsClientAcknowledgeTransactionTestCase, JmsConnectorJndiTestCase, JmsCustomCorrelationIdTestCase, JmsDurableTopicTestCase, JmsExceptionStrategyTestCase, JmsMessageAwareTransformersMule2685TestCase, JmsMuleSideDurableTopicTestCase, JmsMuleSideDurableTopicXATxTestCase, JmsQueueMessageTypesTestCase, JmsQueueTestCase, JmsQueueWithCompressionTestCase, JmsQueueWithTransactionTestCase, JmsRemoteSyncMule2868TestCase, JmsReplyToPropertyTestCase, JmsSingleTransactionAlwaysBeginConfigurationTestCase, JmsSingleTransactionBeginOrJoinAndAlwaysBeginTestCase, JmsSingleTransactionComponentTestCase, JmsSingleTransactionNoneTestCase, JmsSingleTransactionRecieveAndSendTestCase, JmsSynchronousResponseTestCase, JmsTemporaryReplyToTestCase, JmsTopicTestCase, JmsTransformersTestCase, JmsXAAlwaysBeginTestCase, JmsXATransactionComponentTestCase

public abstract class AbstractJmsFunctionalTestCase
extends FunctionalTestCase

This is the base class for all integration tests that are part of the JMS integration test suite. This is a suite that can be run on multiple JMS providers since all configuration for the provider is abstracted into a single class which implements JmsVendorConfiguration. The implementation of this class is loaded by looking for the classname in a properties file called 'jms-vendor-configs.txt'in the root classpath.

This test case provides a number of support methods for testing Jms providers with Mule. This implementation is based around the concept of scenarios. Scenarios define an action or set of actions and are represented as implementations of AbstractJmsFunctionalTestCase.Scenario. Scenarios can be combined to create a test. The default scenarios are usually sufficient to create a test. These are: AbstractJmsFunctionalTestCase.ScenarioReceive AbstractJmsFunctionalTestCase.ScenarioNotReceive AbstractJmsFunctionalTestCase.ScenarioCommit AbstractJmsFunctionalTestCase.ScenarioRollback AbstractJmsFunctionalTestCase.NonTransactedScenario

This object will also add properties to the registry that can be accessed within XML config files using placeholders. The following properties are made available -

For each integration test there are 2 configuration files. One is provided by the JMS integration suite and defines the event flow for the test. The other is a vendor-specific config file that defines the connectors and possibly endpoints and transformers for the Jms connector being tested. These configurations are known as 'connector' files, they share the same file name as the generic configuration file prepended with 'connector-'. The location of these files must be

integration/<provider_name>/connector-<event_flow_config_name>

The 'provider_name' is obtained from the {@link org.mule.transport.jms.integration.JmsVendorConfiguration} implementation.

In order to know what objects to define in the 'connector-' files you must copy the connector files from the ActiveMQ (default) test suite and configure the objects to match the configuration in the ActiveMQ tests. Note that the object names must be consistently the same for things to work.


Nested Class Summary
protected  class AbstractJmsFunctionalTestCase.AbstractScenario
           
protected  class AbstractJmsFunctionalTestCase.NonTransactedScenario
           
protected static interface AbstractJmsFunctionalTestCase.Scenario
           
protected  class AbstractJmsFunctionalTestCase.ScenarioCommit
           
protected  class AbstractJmsFunctionalTestCase.ScenarioNotReceive
           
protected  class AbstractJmsFunctionalTestCase.ScenarioReceive
           
protected  class AbstractJmsFunctionalTestCase.ScenarioRollback
           
 
Nested classes/interfaces inherited from class org.mule.tck.AbstractMuleTestCase
AbstractMuleTestCase.TestInfo
 
Field Summary
static java.lang.String BROADCAST_TOPIC_ENDPOINT_KEY
           
static java.lang.String DEFAULT_INPUT_MESSAGE
           
static java.lang.String DEFAULT_OUTPUT_MESSAGE
           
static java.lang.String INBOUND_ENDPOINT_KEY
           
protected  JmsVendorConfiguration jmsConfig
           
protected static Log logger
           
static java.lang.String MIDDLE_ENDPOINT_KEY
           
static java.lang.String MIDDLE2_ENDPOINT_KEY
           
static java.lang.String MIDDLE3_ENDPOINT_KEY
           
static java.lang.String OUTBOUND_ENDPOINT_KEY
           
protected  AbstractJmsFunctionalTestCase.Scenario scenarioCommit
           
protected  AbstractJmsFunctionalTestCase.Scenario scenarioNotReceive
           
protected  AbstractJmsFunctionalTestCase.Scenario scenarioNoTx
           
protected  AbstractJmsFunctionalTestCase.Scenario scenarioReceive
           
protected  AbstractJmsFunctionalTestCase.Scenario scenarioRollback
           
 
Fields inherited from class org.mule.tck.AbstractMuleTestCase
callbackCalled, CLASSNAME_ANNOTATIONS_CONFIG_BUILDER, DEFAULT_MULE_TEST_TIMEOUT_SECS, IGNORED_DOT_MULE_DIRS, LOCK_TIMEOUT, muleContext, numPorts, ports, PROPERTY_MULE_TEST_TIMEOUT, RECEIVE_TIMEOUT, TEST_MESSAGE, testTimeoutSecs
 
Constructor Summary
AbstractJmsFunctionalTestCase()
           
AbstractJmsFunctionalTestCase(JmsVendorConfiguration config)
           
 
Method Summary
 void after()
          Since we are using JUnit 4, but the Mule Test Framework assumes JUnit 3, we need to explicitly call the setUp and tearDown methods
 void before()
          Since we are using JUnit 4, but the Mule Test Framework assumes JUnit 3, we need to explicitly call the setUp and tearDown methods
protected  void checkConfig()
          Ensures that the JmsVendorConfiguration instance is not null if it is an IllegalStateException will be thrown
protected  javax.jms.Destination createInputDestination(javax.jms.Session session, AbstractJmsFunctionalTestCase.Scenario scenario)
          By default this will create a Queue, override to create a topic
protected  JmsVendorConfiguration createJmsConfig()
          Overriding classes must override this or inject this object.
protected  javax.jms.Destination createOutputDestination(javax.jms.Session session, AbstractJmsFunctionalTestCase.Scenario scenario)
          By default this will create a Queue, override to create a topic
protected  void dispatchMessage()
           
protected  void dispatchMessage(java.lang.Object payload)
           
protected  void dispatchMessage(java.lang.Object payload, java.util.Properties props)
           
protected  void doSetUp()
          Exactly the same a AbstractMuleTestCase.setUp() in normal JUnit test cases.
protected  void doTearDown()
          Exactly the same a AbstractMuleTestCase.tearDown() in normal JUnit test cases.
protected  ConfigurationBuilder getBuilder()
          This creates a SpringXmlConfigurationBuilder as expected but also figures out which 'connector' configuration file to load with the event flow configuration (obtained from the overriding \ class which implements FunctionalTestCase.getConfigResources()).
protected  MuleClient getClient()
           
protected  javax.jms.Connection getConnection(boolean topic, boolean xa)
          Create a connection factory for the Jms profider being tested.
protected  java.lang.String getDeadLetterQueueName()
          The test dead letter queue name.
protected  java.lang.String getInboundEndpoint()
          Returns the getInboundQueueName() in the form of an endpoint URI i.e.
protected  java.lang.String getInboundQueueName()
          The test inbound queue name.
 JmsVendorConfiguration getJmsConfig()
          Returns the JmsVendorConfiguration implemetation to be used with this test
protected  java.lang.String getOutboundEndpoint()
          Returns the getOutboundQueueName() in the form of an endpoint URI i.e.
protected  java.lang.String getOutboundQueueName()
          The test outbound queue name.
protected  long getSmallTimeout()
          Timeout in milliseconds used when checking that a message is NOT present.
protected  java.util.Properties getStartUpProperties()
          Adds the following properties to the registry so that the Xml configuration files can reference them.
protected  long getTimeout()
          The timeout in milliseconds used when waiting for a message to arrive.
 boolean isMultipleProviders()
           
static java.util.Collection jmsProviderConfigs()
          Finds the JmsVendorConfiguration instances to test with by looking in a file called "jms-vendor-configs.txt" which contains one or more fuly qualified classnames of JmsVendorConfiguration instances to load.
protected  void purge(java.lang.String destination)
          Purge destinations for clean test setup.
protected  void purgeTopic(java.lang.String destination, java.lang.String topic)
          Clear the specified topic
protected  void purgeTopics()
          Purge all of the topics which are created during testing TODO DZ: we should be getting this list dynamically, and only calling them for the topic tests
 javax.jms.Message receive(AbstractJmsFunctionalTestCase.Scenario scenario)
           
protected  MuleMessage receiveMessage()
           
protected  MuleMessage receiveMessage(byte[] expected)
           
protected  MuleMessage receiveMessage(java.lang.Object expected)
           
 void runAsynchronousDispatching()
           
 void send(AbstractJmsFunctionalTestCase.Scenario scenario)
           
 void setJmsConfig(JmsVendorConfiguration jmsConfig)
          Sets the JmsVendorConfiguration implemetation to be used with this test
 void setMultipleProviders(boolean multipleProviders)
           
protected  void suitePreSetUp()
          Run before any testcase setup.
 
Methods inherited from class org.mule.tck.FunctionalTestCase
getComponent, getComponent, getConfigResources, getFunctionalTestComponent, loadResource, loadResourceAsString
 
Methods inherited from class org.mule.tck.AbstractMuleTestCase
addBuilders, checkPorts, configureMuleContext, createMuleContext, createObject, createObject, createTestInfo, createWatchdog, disposeManager, findFreePorts, getConfigurationResources, getPorts, getSensingNullMessageProcessor, getTestConnector, getTestEvent, getTestEvent, getTestEvent, getTestEvent, getTestEvent, getTestEvent, getTestEventContext, getTestEventContext, getTestInboundEndpoint, getTestInboundEndpoint, getTestInboundEndpoint, getTestInboundEndpoint, getTestInboundEndpoint, getTestInboundEvent, getTestInboundEvent, getTestInboundEvent, getTestInfo, getTestOutboundEndpoint, getTestOutboundEndpoint, getTestOutboundEndpoint, getTestOutboundEndpoint, getTestOutboundEndpoint, getTestService, getTestService, getTestService, getTestSession, getTestTimeoutSecs, getTestTransactedInboundEndpoint, getTestTransformer, getTriggerableMessageSource, getTriggerableMessageSource, giveTheTestSomeTimeToCleanUpAndThenKillIt, handleTimeout, initialiseObject, initTestTimeoutSecs, isDisabledInThisEnvironment, isDisabledInThisEnvironment, isDisposeManagerPerSuite, isExcluded, isGracefulShutdown, isOffline, isPortFree, isStartContext, registerTestMethod, run, runBare, setDisposeManagerPerSuite, setFailOnTimeout, setName, setStartContext, setUp, suitePostTearDown, tearDown
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, runTest, 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, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_INPUT_MESSAGE

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

DEFAULT_OUTPUT_MESSAGE

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

INBOUND_ENDPOINT_KEY

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

OUTBOUND_ENDPOINT_KEY

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

MIDDLE_ENDPOINT_KEY

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

MIDDLE2_ENDPOINT_KEY

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

MIDDLE3_ENDPOINT_KEY

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

BROADCAST_TOPIC_ENDPOINT_KEY

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

logger

protected static final Log logger

jmsConfig

protected JmsVendorConfiguration jmsConfig

scenarioNoTx

protected AbstractJmsFunctionalTestCase.Scenario scenarioNoTx

scenarioCommit

protected AbstractJmsFunctionalTestCase.Scenario scenarioCommit

scenarioRollback

protected AbstractJmsFunctionalTestCase.Scenario scenarioRollback

scenarioNotReceive

protected AbstractJmsFunctionalTestCase.Scenario scenarioNotReceive

scenarioReceive

protected AbstractJmsFunctionalTestCase.Scenario scenarioReceive
Constructor Detail

AbstractJmsFunctionalTestCase

public AbstractJmsFunctionalTestCase()

AbstractJmsFunctionalTestCase

public AbstractJmsFunctionalTestCase(JmsVendorConfiguration config)
Method Detail

jmsProviderConfigs

public static java.util.Collection jmsProviderConfigs()
Finds the JmsVendorConfiguration instances to test with by looking in a file called "jms-vendor-configs.txt" which contains one or more fuly qualified classnames of JmsVendorConfiguration instances to load.

Returns:
a collection of JmsVendorConfiguration instance to test against.
Throws:
java.lang.Exception - if the 'jms-vendor-configs.txt' cannot be loaded or the classes defined within that file are not on the classpath TODO this method can return more than one provider, but our test class can only handle one at a time IMPORTANT: Only set one class in 'jms-vendor-configs.txt'

before

public void before()
            throws java.lang.Exception
Since we are using JUnit 4, but the Mule Test Framework assumes JUnit 3, we need to explicitly call the setUp and tearDown methods

Throws:
java.lang.Exception - if, well, anything goes wrong

after

public void after()
           throws java.lang.Exception
Since we are using JUnit 4, but the Mule Test Framework assumes JUnit 3, we need to explicitly call the setUp and tearDown methods

Throws:
java.lang.Exception - if, well, anything goes wrong

suitePreSetUp

protected void suitePreSetUp()
                      throws java.lang.Exception
Description copied from class: AbstractMuleTestCase
Run before any testcase setup. This is called once only before the test suite runs.

Overrides:
suitePreSetUp in class AbstractMuleTestCase
Throws:
java.lang.Exception

getStartUpProperties

protected java.util.Properties getStartUpProperties()
Adds the following properties to the registry so that the Xml configuration files can reference them.

Overrides:
getStartUpProperties in class AbstractMuleTestCase
Returns:

getBuilder

protected ConfigurationBuilder getBuilder()
                                   throws java.lang.Exception
This creates a SpringXmlConfigurationBuilder as expected but also figures out which 'connector' configuration file to load with the event flow configuration (obtained from the overriding \ class which implements FunctionalTestCase.getConfigResources()).

Overrides:
getBuilder in class FunctionalTestCase
Returns:
The config builder used to create the Mule instance for this test
Throws:
java.lang.Exception

getJmsConfig

public final JmsVendorConfiguration getJmsConfig()
Returns the JmsVendorConfiguration implemetation to be used with this test

Returns:
settings for this test

setJmsConfig

public final void setJmsConfig(JmsVendorConfiguration jmsConfig)
Sets the JmsVendorConfiguration implemetation to be used with this test

Parameters:
jmsConfig - the settings for this test

createJmsConfig

protected JmsVendorConfiguration createJmsConfig()
Overriding classes must override this or inject this object. It is responsible for creating the JmsVendorConfiguration instance to be used by this test.

Returns:
the settings for this test

getConnection

protected final javax.jms.Connection getConnection(boolean topic,
                                                   boolean xa)
                                            throws java.lang.Exception
Create a connection factory for the Jms profider being tested. This calls through to JmsVendorConfiguration.getConnection(boolean, boolean)

Parameters:
topic - whether to use a topic or queue connection factory, for 1.1 implementations this proerty can be ignored
xa - whether to create an XA connection factory
Returns:
a new JMS connection
Throws:
java.lang.Exception

getInboundEndpoint

protected final java.lang.String getInboundEndpoint()
Returns the getInboundQueueName() in the form of an endpoint URI i.e. jms://in.

This calls through to JmsVendorConfiguration.getInboundEndpoint()

Returns:
the Inbound JMS endpoint

getOutboundEndpoint

protected final java.lang.String getOutboundEndpoint()
Returns the getOutboundQueueName() in the form of an endpoint URI i.e. jms://out.

This calls through to JmsVendorConfiguration.getOutboundEndpoint()

Returns:
the Outbound JMS endpoint

getInboundQueueName

protected final java.lang.String getInboundQueueName()
The test inbound queue name. For consistency this should always be 'in'. Note that you need to make sure that this queue is available in the the JMS provider being tested.

This calls through to JmsVendorConfiguration.getInboundDestinationName()

Returns:
The test inbound destination name

getDeadLetterQueueName

protected final java.lang.String getDeadLetterQueueName()
The test dead letter queue name. For consistency this should always be 'dlq'. Note that you need to make sure that this queue is available in the the JMS provider being tested.

This calls through to JmsVendorConfiguration.getDeadLetterDestinationName()

Returns:
The test inbound destination name

getOutboundQueueName

protected final java.lang.String getOutboundQueueName()
The test outbound queue name. For consistency this should always be 'out'. Note that you need to make sure that this queue is available in the the JMS provider being tested.

This calls through to JmsVendorConfiguration.getOutboundDestinationName()

Returns:
The test outbound destination name

getSmallTimeout

protected final long getSmallTimeout()
Timeout in milliseconds used when checking that a message is NOT present. This is usually 1000-2000ms. It is customizable so that slow connections i.e. over a wAN can be accounted for.

This calls through to JmsVendorConfiguration.getSmallTimeout()

Returns:
timeout in milliseconds used when checking that a message is NOT present

getTimeout

protected final long getTimeout()
The timeout in milliseconds used when waiting for a message to arrive. This is usually 3000-5000ms. However, it is customizable so that slow connections i.e. over a wAN can be accounted for.

This calls through to JmsVendorConfiguration.getTimeout()

Returns:
The timeout used when waiting for a message to arrive

checkConfig

protected void checkConfig()
Ensures that the JmsVendorConfiguration instance is not null if it is an IllegalStateException will be thrown


dispatchMessage

protected void dispatchMessage()
                        throws java.lang.Exception
Throws:
java.lang.Exception

dispatchMessage

protected void dispatchMessage(java.lang.Object payload)
                        throws java.lang.Exception
Throws:
java.lang.Exception

dispatchMessage

protected void dispatchMessage(java.lang.Object payload,
                               java.util.Properties props)
                        throws java.lang.Exception
Throws:
java.lang.Exception

receiveMessage

protected MuleMessage receiveMessage()
                              throws java.lang.Exception
Throws:
java.lang.Exception

receiveMessage

protected MuleMessage receiveMessage(java.lang.Object expected)
                              throws java.lang.Exception
Throws:
java.lang.Exception

receiveMessage

protected MuleMessage receiveMessage(byte[] expected)
                              throws java.lang.Exception
Throws:
java.lang.Exception

runAsynchronousDispatching

public void runAsynchronousDispatching()
                                throws java.lang.Exception
Throws:
java.lang.Exception

doSetUp

protected void doSetUp()
                throws java.lang.Exception
Description copied from class: AbstractMuleTestCase
Exactly the same a AbstractMuleTestCase.setUp() in normal JUnit test cases. this is called before a test method has been called.

Overrides:
doSetUp in class AbstractMuleTestCase
Throws:
java.lang.Exception - if something fails that should halt the testcase

doTearDown

protected void doTearDown()
                   throws java.lang.Exception
Description copied from class: AbstractMuleTestCase
Exactly the same a AbstractMuleTestCase.tearDown() in normal JUnit test cases. this is called after a test method has been called.

Overrides:
doTearDown in class AbstractMuleTestCase
Throws:
java.lang.Exception - if something fails that should halt the testcase

getClient

protected MuleClient getClient()

send

public void send(AbstractJmsFunctionalTestCase.Scenario scenario)
          throws java.lang.Exception
Throws:
java.lang.Exception

createInputDestination

protected javax.jms.Destination createInputDestination(javax.jms.Session session,
                                                       AbstractJmsFunctionalTestCase.Scenario scenario)
                                                throws javax.jms.JMSException
By default this will create a Queue, override to create a topic

Parameters:
session -
scenario -
Returns:
Throws:
javax.jms.JMSException

createOutputDestination

protected javax.jms.Destination createOutputDestination(javax.jms.Session session,
                                                        AbstractJmsFunctionalTestCase.Scenario scenario)
                                                 throws javax.jms.JMSException
By default this will create a Queue, override to create a topic

Parameters:
session -
scenario -
Returns:
Throws:
javax.jms.JMSException

receive

public javax.jms.Message receive(AbstractJmsFunctionalTestCase.Scenario scenario)
                          throws java.lang.Exception
Throws:
java.lang.Exception

purge

protected void purge(java.lang.String destination)
              throws javax.jms.JMSException
Purge destinations for clean test setup. Especially applicable to WMQ tests, as messages from other tests may still exist from other tests' runs.

Well-behaving tests should drain both inbound and outbound destinations, as well as any intermediary ones. Typically this method is called from suitePreSetUp() and AbstractMuleTestCase.suitePostTearDown(), with proper super calls.

Parameters:
destination - destination name without any protocol specifics
Throws:
javax.jms.JMSException
See Also:
suitePreSetUp(), AbstractMuleTestCase.suitePostTearDown()

purgeTopics

protected void purgeTopics()
                    throws java.lang.Exception
Purge all of the topics which are created during testing TODO DZ: we should be getting this list dynamically, and only calling them for the topic tests

Throws:
java.lang.Exception

purgeTopic

protected void purgeTopic(java.lang.String destination,
                          java.lang.String topic)
                   throws java.lang.Exception
Clear the specified topic

Parameters:
destination -
topic -
Throws:
java.lang.Exception

isMultipleProviders

public boolean isMultipleProviders()

setMultipleProviders

public void setMultipleProviders(boolean multipleProviders)


Copyright © 2003-2010 MuleSoft, Inc.. All Rights Reserved.