public abstract class AbstractJmsFunctionalTestCase extends FunctionalTestCase
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 -
JmsVendorConfiguration
implementation)JmsVendorConfiguration
implementation)JmsVendorConfiguration
implementation)JmsVendorConfiguration
implementation)JmsVendorConfiguration
implementation)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.Modifier and Type | Class and Description |
---|---|
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 |
Modifier and Type | Field and Description |
---|---|
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 |
log |
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 |
callbackCalled, CLASSNAME_ANNOTATIONS_CONFIG_BUILDER, IGNORED_DOT_MULE_DIRS, LOCK_TIMEOUT, muleContext, RECEIVE_TIMEOUT, TEST_MESSAGE, TEST_PAYLOAD, WORKING_DIRECTORY_SYSTEM_PROPERTY_KEY, workingDirectory
DEFAULT_TEST_TIMEOUT_SECS, globalTimeout, logger, name, TEST_TIMEOUT_SYSTEM_PROPERTY, TESTING_MODE_PROPERTY_NAME
Constructor and Description |
---|
AbstractJmsFunctionalTestCase() |
AbstractJmsFunctionalTestCase(JmsVendorConfiguration config) |
Modifier and Type | Method and Description |
---|---|
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,
Map<String,Object> 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.getConfigFile() ). |
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) |
clearFlowAssertions, getComponent, getComponent, getConfigFile, getConfigFiles, getConfigResources, getFlowConstruct, getFunctionalTestComponent, getSubFlow, loadResource, loadResourceAsString, lookupFlowConstruct, runFlow, runFlow, runFlow, runFlowAndExpect, runFlowAndExpectProperty, runFlowNonBlocking, runFlowNonBlocking, runFlowNonBlocking, runFlowWithPayloadAndExpect, runSchedulersOnce, stopFlowConstruct, stopFlowSchedulers, testFlow, testFlow, testFlowNonBlocking, testFlowNonBlocking
addBuilders, configureMuleContext, createMuleContext, createObject, createObject, disposeContext, disposeContextPerTest, doSetUpBeforeMuleContextCreation, doTearDownAfterMuleContextDispose, getConfigurationResources, getFileInsideWorkingDirectory, getNonBlockingResponse, getNonBlockingTestEventUsingFlow, getSensingNullMessageProcessor, getTestConnector, getTestEvent, getTestEvent, getTestEvent, getTestEvent, getTestEvent, getTestEvent, getTestEvent, getTestEvent, getTestEventContext, getTestEventContext, getTestEventUsingFlow, getTestInboundEndpoint, getTestInboundEndpoint, getTestInboundEndpoint, getTestInboundEndpoint, getTestInboundEndpoint, getTestMuleMessage, getTestMuleMessage, getTestOutboundEndpoint, getTestOutboundEndpoint, getTestOutboundEndpoint, getTestOutboundEndpoint, getTestOutboundEndpoint, getTestService, getTestService, getTestService, getTestSession, getTestTransactedInboundEndpoint, getTestTransformer, getTriggerableMessageSource, getTriggerableMessageSource, getWorkingDirectory, initialiseObject, isDisposeContextPerClass, isGracefulShutdown, isStartContext, setDisposeContextPerClass, setStartContext, setUpMuleContext
clearExcludedFlag, clearRequestContext, clearTestCaseName, createTestTimeoutRule, dumpFilteredThreadsInTest, getTestHeader, getTestTimeoutSecs, getTimeoutSystemProperty, initializeMuleTest, isDisabledInThisEnvironment, isDisabledInThisEnvironment, isExcluded, isFailOnTimeout, isOffline, isTestIncludedInExclusionFile, takeTestCaseName
public static final String DEFAULT_INPUT_MESSAGE
public static final String DEFAULT_OUTPUT_MESSAGE
public static final String INBOUND_ENDPOINT_KEY
public static final String OUTBOUND_ENDPOINT_KEY
public static final String MIDDLE_ENDPOINT_KEY
public static final String MIDDLE2_ENDPOINT_KEY
public static final String MIDDLE3_ENDPOINT_KEY
public static final String BROADCAST_TOPIC_ENDPOINT_KEY
protected static final Log log
protected JmsVendorConfiguration jmsConfig
protected AbstractJmsFunctionalTestCase.Scenario scenarioNoTx
protected AbstractJmsFunctionalTestCase.Scenario scenarioCommit
protected AbstractJmsFunctionalTestCase.Scenario scenarioRollback
protected AbstractJmsFunctionalTestCase.Scenario scenarioNotReceive
protected AbstractJmsFunctionalTestCase.Scenario scenarioReceive
protected boolean purgeQueuesOnPreSetUp
protected boolean purgeQueuesOnTearDown
public AbstractJmsFunctionalTestCase()
public AbstractJmsFunctionalTestCase(JmsVendorConfiguration config)
public static Collection<?> jmsProviderConfigs()
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.JmsVendorConfiguration
instance to test
against.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'protected Properties getStartUpProperties()
JmsVendorConfiguration
implementation)JmsVendorConfiguration
implementation)JmsVendorConfiguration
implementation)JmsVendorConfiguration
implementation)JmsVendorConfiguration
implementation)getStartUpProperties
in class AbstractMuleContextTestCase
protected ConfigurationBuilder getBuilder() throws Exception
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.getConfigFile()
).getBuilder
in class FunctionalTestCase
Exception
public final JmsVendorConfiguration getJmsConfig()
JmsVendorConfiguration
implemetation to be used
with this testpublic final void setJmsConfig(JmsVendorConfiguration jmsConfig)
JmsVendorConfiguration
implemetation to be used
with this testjmsConfig
- the settings for this testprotected JmsVendorConfiguration createJmsConfig()
JmsVendorConfiguration
instance to be used by this test.protected final Connection getConnection(boolean topic, boolean xa) throws Exception
JmsVendorConfiguration.getConnection(boolean, boolean)
topic
- whether to use a topic or queue connection factory, for 1.1
implementations this proerty can be ignoredxa
- whether to create an XA connection factoryException
protected final String getInboundEndpoint()
getInboundQueueName()
in the form of an endpoint URI i.e.
jms://in.
This calls through to JmsVendorConfiguration.getInboundEndpoint()
protected final String getOutboundEndpoint()
getOutboundQueueName()
in the form of an endpoint URI i.e.
jms://out.
This calls through to JmsVendorConfiguration.getOutboundEndpoint()
protected final String getInboundQueueName()
JmsVendorConfiguration.getInboundDestinationName()
protected final String getDeadLetterQueueName()
JmsVendorConfiguration.getDeadLetterDestinationName()
protected final String getOutboundQueueName()
JmsVendorConfiguration.getOutboundDestinationName()
protected final long getSmallTimeout()
JmsVendorConfiguration.getSmallTimeout()
protected final long getTimeout()
JmsVendorConfiguration.getTimeout()
protected void checkConfig()
JmsVendorConfiguration
instance is not null
if it is an IllegalStateException
will be thrownprotected void dispatchMessage(Object payload, Map<String,Object> props) throws Exception
Exception
protected MuleMessage receiveMessage() throws Exception
Exception
protected MuleMessage receiveMessage(Object expected) throws Exception
Exception
protected MuleMessage receiveMessage(byte[] expected) throws Exception
Exception
public void runAsynchronousDispatching() throws Exception
Exception
protected void doSetUp() throws Exception
AbstractMuleContextTestCase
AbstractMuleContextTestCase.setUpMuleContext()
.
Under normal circumstances this method could be replaced by a
@Before
annotated method.
doSetUp
in class AbstractMuleContextTestCase
Exception
- if something fails that should halt the test caseprotected void doTearDown() throws Exception
AbstractMuleContextTestCase
AbstractMuleContextTestCase.disposeContextPerTest()
.
Under normal circumstances this method could be replace with a
@After
annotated method.
doTearDown
in class AbstractMuleContextTestCase
Exception
- if something fails that should halt the testcaseprotected MuleClient getClient()
public void send(AbstractJmsFunctionalTestCase.Scenario scenario) throws Exception
Exception
protected Destination createInputDestination(Session session, AbstractJmsFunctionalTestCase.Scenario scenario) throws JMSException
JMSException
protected Destination createOutputDestination(Session session, AbstractJmsFunctionalTestCase.Scenario scenario) throws JMSException
JMSException
public Message receive(AbstractJmsFunctionalTestCase.Scenario scenario) throws Exception
Exception
protected void purge(String destination) throws JMSException
destination
- destination name without any protocol specificsJMSException
protected void purgeTopics() throws Exception
Exception
protected void purgeTopic(String destination, String topic) throws Exception
Exception
public boolean isMultipleProviders()
public void setMultipleProviders(boolean multipleProviders)
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.