org.mule.transport.jms.integration
Class AbstractJmsFunctionalTestCase

java.lang.Object
  extended by org.mule.tck.junit4.AbstractMuleTestCase
      extended by org.mule.tck.junit4.AbstractMuleContextTestCase
          extended by org.mule.tck.junit4.FunctionalTestCase
              extended by org.mule.transport.jms.integration.AbstractJmsFunctionalTestCase
Direct Known Subclasses:
AbstractJmsReliabilityTestCase, AbstractJmsSingleTransactionSingleServiceTestCase, JmsClientAcknowledgeTransactionTestCase, JmsConnectorJndiTestCase, JmsCustomCorrelationIdTestCase, JmsDeadLetterQueueTestCase, JmsDurableTopicTestCase, JmsExceptionStrategyTestCase, JmsMessageAwareTransformersMule2685TestCase, JmsMuleSideDurableTopicTestCase, JmsMuleSideDurableTopicXATxTestCase, JmsObjectToMessageTransformerInResponseTestCase, JmsQueueMessageTypesTestCase, JmsQueueTestCase, JmsQueueWithCompressionTestCase, JmsQueueWithTransactionTestCase, JmsRemoteSyncMule2868TestCase, JmsReplyToPropertyTestCase, JmsSingleTransactionAlwaysBeginConfigurationTestCase, JmsSingleTransactionBeginOrJoinAndAlwaysBeginTestCase, JmsSingleTransactionComponentTestCase, JmsSingleTransactionNoneTestCase, JmsSingleTransactionRecieveAndSendTestCase, JmsSingleTransactionTransactionalElementTestCase, 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 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
           
 
Field Summary
static String BROADCAST_TOPIC_ENDPOINT_KEY
           
static String DEFAULT_INPUT_MESSAGE
           
static String DEFAULT_OUTPUT_MESSAGE
           
static String INBOUND_ENDPOINT_KEY
           
protected  JmsVendorConfiguration jmsConfig
           
protected static Log logger
           
static String MIDDLE_ENDPOINT_KEY
           
static String MIDDLE2_ENDPOINT_KEY
           
static String MIDDLE3_ENDPOINT_KEY
           
static String OUTBOUND_ENDPOINT_KEY
           
protected  boolean purgeQueuesOnPreSetUp
           
protected  boolean purgeQueuesOnTearDown
           
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.junit4.AbstractMuleContextTestCase
callbackCalled, CLASSNAME_ANNOTATIONS_CONFIG_BUILDER, IGNORED_DOT_MULE_DIRS, LOCK_TIMEOUT, muleContext, RECEIVE_TIMEOUT, TEST_MESSAGE
 
Fields inherited from class org.mule.tck.junit4.AbstractMuleTestCase
DEFAULT_TEST_TIMEOUT_SECS, globalTimeout, name, TEST_TIMEOUT_SYSTEM_PROPERTY
 
Constructor Summary
AbstractJmsFunctionalTestCase()
           
AbstractJmsFunctionalTestCase(JmsVendorConfiguration config)
           
 
Method Summary
protected  void checkConfig()
          Ensures that the JmsVendorConfiguration instance is not null if it is an IllegalStateException will be thrown
protected  Destination createInputDestination(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  Destination createOutputDestination(Session session, AbstractJmsFunctionalTestCase.Scenario scenario)
          By default this will create a Queue, override to create a topic
protected  void dispatchMessage()
           
protected  void dispatchMessage(Object payload)
           
protected  void dispatchMessage(Object payload, Properties props)
           
protected  void doSetUp()
          Enables the adding of extra behavior on the set up stage of a test right after the creation of the mule context in AbstractMuleContextTestCase.setUpMuleContext().
protected  void doTearDown()
          Enables the adding of extra behavior on the tear down stage of a test before the mule context is disposed in AbstractMuleContextTestCase.disposeContextPerTest().
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  Connection getConnection(boolean topic, boolean xa)
          Create a connection factory for the Jms profider being tested.
protected  String getDeadLetterQueueName()
          The test dead letter queue name.
protected  String getInboundEndpoint()
          Returns the getInboundQueueName() in the form of an endpoint URI i.e.
protected  String getInboundQueueName()
          The test inbound queue name.
 JmsVendorConfiguration getJmsConfig()
          Returns the JmsVendorConfiguration implemetation to be used with this test
protected  String getOutboundEndpoint()
          Returns the getOutboundQueueName() in the form of an endpoint URI i.e.
protected  String getOutboundQueueName()
          The test outbound queue name.
protected  long getSmallTimeout()
          Timeout in milliseconds used when checking that a message is NOT present.
protected  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 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(String destination)
          Purge destinations for clean test setup.
protected  void purgeTopic(String destination, 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
 Message receive(AbstractJmsFunctionalTestCase.Scenario scenario)
           
protected  MuleMessage receiveMessage()
           
protected  MuleMessage receiveMessage(byte[] expected)
           
protected  MuleMessage receiveMessage(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)
           
 
Methods inherited from class org.mule.tck.junit4.FunctionalTestCase
clearFlowAssertions, getComponent, getComponent, getConfigResources, getFlowConstruct, getFunctionalTestComponent, loadResource, loadResourceAsString, stopFlowConstruct, testFlow, testFlow
 
Methods inherited from class org.mule.tck.junit4.AbstractMuleContextTestCase
addBuilders, configureMuleContext, createMuleContext, createObject, createObject, disposeContext, disposeContextPerTest, getConfigurationResources, getSensingNullMessageProcessor, getTestConnector, getTestEvent, getTestEvent, getTestEvent, getTestEvent, getTestEvent, getTestEvent, getTestEvent, getTestEventContext, getTestEventContext, getTestEventUsingFlow, getTestInboundEndpoint, getTestInboundEndpoint, getTestInboundEndpoint, getTestInboundEndpoint, getTestInboundEndpoint, getTestOutboundEndpoint, getTestOutboundEndpoint, getTestOutboundEndpoint, getTestOutboundEndpoint, getTestOutboundEndpoint, getTestService, getTestService, getTestService, getTestSession, getTestTransactedInboundEndpoint, getTestTransformer, getTriggerableMessageSource, getTriggerableMessageSource, initialiseObject, isDisposeContextPerClass, isGracefulShutdown, isStartContext, setDisposeContextPerClass, setStartContext, setUpMuleContext
 
Methods inherited from class org.mule.tck.junit4.AbstractMuleTestCase
clearExcludedFlag, clearRequestContext, createTestTimeoutRule, getTestHeader, getTestTimeoutSecs, getTimeoutSystemProperty, initializeMuleTest, isDisabledInThisEnvironment, isDisabledInThisEnvironment, isExcluded, isFailOnTimeout, isOffline, isTestIncludedInExclusionFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INPUT_MESSAGE

public static final String DEFAULT_INPUT_MESSAGE
See Also:
Constant Field Values

DEFAULT_OUTPUT_MESSAGE

public static final String DEFAULT_OUTPUT_MESSAGE
See Also:
Constant Field Values

INBOUND_ENDPOINT_KEY

public static final String INBOUND_ENDPOINT_KEY
See Also:
Constant Field Values

OUTBOUND_ENDPOINT_KEY

public static final String OUTBOUND_ENDPOINT_KEY
See Also:
Constant Field Values

MIDDLE_ENDPOINT_KEY

public static final String MIDDLE_ENDPOINT_KEY
See Also:
Constant Field Values

MIDDLE2_ENDPOINT_KEY

public static final String MIDDLE2_ENDPOINT_KEY
See Also:
Constant Field Values

MIDDLE3_ENDPOINT_KEY

public static final String MIDDLE3_ENDPOINT_KEY
See Also:
Constant Field Values

BROADCAST_TOPIC_ENDPOINT_KEY

public static final 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

purgeQueuesOnPreSetUp

protected boolean purgeQueuesOnPreSetUp

purgeQueuesOnTearDown

protected boolean purgeQueuesOnTearDown
Constructor Detail

AbstractJmsFunctionalTestCase

public AbstractJmsFunctionalTestCase()

AbstractJmsFunctionalTestCase

public AbstractJmsFunctionalTestCase(JmsVendorConfiguration config)
Method Detail

jmsProviderConfigs

public static 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:
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'

getStartUpProperties

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

Overrides:
getStartUpProperties in class AbstractMuleContextTestCase

getBuilder

protected ConfigurationBuilder getBuilder()
                                   throws 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:
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 Connection getConnection(boolean topic,
                                         boolean xa)
                                  throws 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:
Exception

getInboundEndpoint

protected final 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 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 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 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 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 Exception
Throws:
Exception

dispatchMessage

protected void dispatchMessage(Object payload)
                        throws Exception
Throws:
Exception

dispatchMessage

protected void dispatchMessage(Object payload,
                               Properties props)
                        throws Exception
Throws:
Exception

receiveMessage

protected MuleMessage receiveMessage()
                              throws Exception
Throws:
Exception

receiveMessage

protected MuleMessage receiveMessage(Object expected)
                              throws Exception
Throws:
Exception

receiveMessage

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

runAsynchronousDispatching

public void runAsynchronousDispatching()
                                throws Exception
Throws:
Exception

doSetUp

protected void doSetUp()
                throws Exception
Description copied from class: AbstractMuleContextTestCase
Enables the adding of extra behavior on the set up stage of a test right after the creation of the mule context in AbstractMuleContextTestCase.setUpMuleContext().

Under normal circumstances this method could be replaced by a @Before annotated method.

Overrides:
doSetUp in class AbstractMuleContextTestCase
Throws:
Exception - if something fails that should halt the test case

doTearDown

protected void doTearDown()
                   throws Exception
Description copied from class: AbstractMuleContextTestCase
Enables the adding of extra behavior on the tear down stage of a test before the mule context is disposed in AbstractMuleContextTestCase.disposeContextPerTest().

Under normal circumstances this method could be replace with a @After annotated method.

Overrides:
doTearDown in class AbstractMuleContextTestCase
Throws:
Exception - if something fails that should halt the testcase

getClient

protected MuleClient getClient()

send

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

createInputDestination

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

Throws:
JMSException

createOutputDestination

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

Throws:
JMSException

receive

public Message receive(AbstractJmsFunctionalTestCase.Scenario scenario)
                throws Exception
Throws:
Exception

purge

protected void purge(String destination)
              throws 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.

Parameters:
destination - destination name without any protocol specifics
Throws:
JMSException

purgeTopics

protected void purgeTopics()
                    throws 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:
Exception

purgeTopic

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

Throws:
Exception

isMultipleProviders

public boolean isMultipleProviders()

setMultipleProviders

public void setMultipleProviders(boolean multipleProviders)


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