public abstract class AbstractMuleContextTestCase extends AbstractMuleTestCase
AbstractMuleTestCase
providing access to a MuleContext
instance and tools for manage it.Modifier and Type | Field and Description |
---|---|
protected Latch |
callbackCalled
Use this as a semaphore to the unit test to indicate when a callback has successfully been called.
|
static String |
CLASSNAME_ANNOTATIONS_CONFIG_BUILDER
If the annotations module is on the classpath, also enable annotations config builder
|
static String[] |
IGNORED_DOT_MULE_DIRS
Top-level directories under
.mule which are not deleted on each
test case recycle. |
static long |
LOCK_TIMEOUT
Default timeout for multithreaded tests (using CountDownLatch, WaitableBoolean, etc.),
in milliseconds.
|
protected static MuleContext |
muleContext
The context used to run this test.
|
static int |
RECEIVE_TIMEOUT
Default timeout for waiting for responses
|
static String |
TEST_MESSAGE
Convenient test message for unit testing.
|
static String |
TEST_PAYLOAD |
static String |
WORKING_DIRECTORY_SYSTEM_PROPERTY_KEY |
org.junit.rules.TemporaryFolder |
workingDirectory |
DEFAULT_TEST_TIMEOUT_SECS, globalTimeout, logger, name, TEST_TIMEOUT_SYSTEM_PROPERTY, TESTING_MODE_PROPERTY_NAME
Constructor and Description |
---|
AbstractMuleContextTestCase() |
clearExcludedFlag, clearRequestContext, clearTestCaseName, createTestTimeoutRule, dumpFilteredThreadsInTest, getTestHeader, getTestTimeoutSecs, getTimeoutSystemProperty, initializeMuleTest, isDisabledInThisEnvironment, isDisabledInThisEnvironment, isExcluded, isFailOnTimeout, isOffline, isTestIncludedInExclusionFile, takeTestCaseName
public static final String TEST_PAYLOAD
public static final String WORKING_DIRECTORY_SYSTEM_PROPERTY_KEY
public org.junit.rules.TemporaryFolder workingDirectory
public static final String[] IGNORED_DOT_MULE_DIRS
.mule
which are not deleted on each
test case recycle. This is required, e.g. to play nice with transaction manager
recovery service object store.public static final String CLASSNAME_ANNOTATIONS_CONFIG_BUILDER
protected static MuleContext muleContext
disposeContextPerClass
.
The context will be started only when startContext
is true.public static final String TEST_MESSAGE
public static final long LOCK_TIMEOUT
public static final int RECEIVE_TIMEOUT
protected Latch callbackCalled
protected boolean isDisposeContextPerClass()
protected void setDisposeContextPerClass(boolean val)
protected void doSetUpBeforeMuleContextCreation() throws Exception
Exception
protected void doSetUp() throws Exception
setUpMuleContext()
.
Under normal circumstances this method could be replaced by a
@Before
annotated method.
Exception
- if something fails that should halt the test caseprotected MuleContext createMuleContext() throws Exception
Exception
protected void addBuilders(List<ConfigurationBuilder> builders)
protected void configureMuleContext(MuleContextBuilder contextBuilder)
protected ConfigurationBuilder getBuilder() throws Exception
Exception
protected String getConfigurationResources()
protected Properties getStartUpProperties()
protected void doTearDownAfterMuleContextDispose() throws Exception
Exception
public static void disposeContext()
protected void doTearDown() throws Exception
disposeContextPerTest()
.
Under normal circumstances this method could be replace with a
@After
annotated method.
Exception
- if something fails that should halt the testcasepublic static InboundEndpoint getTestInboundEndpoint(String name) throws Exception
Exception
public static OutboundEndpoint getTestOutboundEndpoint(String name) throws Exception
Exception
public static InboundEndpoint getTestInboundEndpoint(MessageExchangePattern mep) throws Exception
Exception
public static InboundEndpoint getTestTransactedInboundEndpoint(MessageExchangePattern mep) throws Exception
Exception
public static InboundEndpoint getTestInboundEndpoint(String name, String uri) throws Exception
Exception
public static OutboundEndpoint getTestOutboundEndpoint(String name, String uri) throws Exception
Exception
public static InboundEndpoint getTestInboundEndpoint(String name, List<Transformer> transformers) throws Exception
Exception
public static OutboundEndpoint getTestOutboundEndpoint(String name, List<Transformer> transformers) throws Exception
Exception
public static InboundEndpoint getTestInboundEndpoint(String name, String uri, List<Transformer> transformers, Filter filter, Map<Object,Object> properties, Connector connector) throws Exception
Exception
public static OutboundEndpoint getTestOutboundEndpoint(String name, String uri, List<Transformer> transformers, Filter filter, Map<Object,Object> properties) throws Exception
Exception
public static OutboundEndpoint getTestOutboundEndpoint(String name, String uri, List<Transformer> transformers, Filter filter, Map<Object,Object> properties, Connector connector) throws Exception
Exception
protected MuleMessage getTestMuleMessage()
MuleMessage
with a test payloadprotected MuleMessage getTestMuleMessage(Object message)
message
- MuleMessage
with message as payloadpublic static MuleEvent getTestEvent(Object data, FlowConstruct service) throws Exception
Exception
public static MuleEvent getTestEvent(Object data, FlowConstruct service, MessageExchangePattern mep) throws Exception
Exception
public static MuleEvent getTestEvent(Object data, MuleContext muleContext) throws Exception
Exception
public static MuleEvent getTestEventUsingFlow(Object data) throws Exception
Exception
public static MuleEvent getTestEvent(Object data, MessageExchangePattern mep) throws Exception
Exception
public static MuleEvent getTestEvent(Object data, MuleSession session) throws Exception
Exception
public static MuleEventContext getTestEventContext(Object data) throws Exception
Exception
public static MuleEventContext getTestEventContext(Object data, MessageExchangePattern mep) throws Exception
Exception
public static Transformer getTestTransformer() throws Exception
Exception
public static MuleEvent getTestEvent(Object data, InboundEndpoint endpoint) throws Exception
Exception
@Deprecated public static MuleEvent getTestEvent(Object data, Service service, InboundEndpoint endpoint) throws Exception
Exception
@Deprecated public static MuleSession getTestSession(Service service, MuleContext context)
public static TestConnector getTestConnector() throws Exception
Exception
@Deprecated public static Service getTestService() throws Exception
Exception
@Deprecated public static Service getTestService(String name, Class<?> clazz) throws Exception
Exception
@Deprecated public static Service getTestService(String name, Class<?> clazz, Map<?,?> props) throws Exception
Exception
protected boolean isStartContext()
protected void setStartContext(boolean startContext)
protected boolean isGracefulShutdown()
protected <T> T createObject(Class<T> clazz) throws Exception
clazz
. It will then register the object with the registry so that any
dependencies are injected and then the object will be initialised.
Note that if the object needs to be configured with additional state that cannot be passed into the constructor you should
create an instance first set any additional data on the object then call initialiseObject(Object)
.T
- Object of this type will be returnedclazz
- the class to create an instance of.class
Exception
- if there is a problem creating or initializing the objectprotected <T> T createObject(Class<T> clazz, Object... args) throws Exception
clazz
. It will then register the object with the registry so that any
dependencies are injected and then the object will be initialised.
Note that if the object needs to be configured with additional state that cannot be passed into the constructor you should
create an instance first set any additional data on the object then call initialiseObject(Object)
.T
- Object of this type will be returnedclazz
- the class to create an instance of.args
- constructor parametersclass
Exception
- if there is a problem creating or initializing the objectprotected void initialiseObject(Object o) throws RegistrationException
o
- the object to register and initialise itRegistrationException
public SensingNullMessageProcessor getSensingNullMessageProcessor()
public TriggerableMessageSource getTriggerableMessageSource(MessageProcessor listener)
public TriggerableMessageSource getTriggerableMessageSource()
protected File getWorkingDirectory()
protected File getFileInsideWorkingDirectory(String fileName)
fileName
- name of the file. Can contain subfolders separated by File.separator
protected MuleEvent getNonBlockingTestEventUsingFlow(Object payload, ReplyToHandler replyToHandler) throws Exception
Exception
protected MuleEvent getNonBlockingResponse(SensingNullReplyToHandler replyToHandler, MuleEvent result) throws Exception
Exception
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.