public abstract class AbstractMuleContextTestCase extends AbstractMuleTestCase
AbstractMuleTestCase providing access to a MuleContext instance and tools for manage it.| Modifier and Type | Field and Description |
|---|---|
static int |
BLOCK_TIMEOUT
Default timeout used when blocking on
Publisher completion. |
protected Latch |
callbackCalled
Use this as a semaphore to the unit test to indicate when a callback has successfully been called.
|
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 String |
REACTOR_BLOCK_TIMEOUT_EXCEPTION_MESSAGE |
static int |
RECEIVE_TIMEOUT
Default timeout for waiting for responses
|
static String |
TEST_MESSAGE
Convenient test message for unit testing.
|
TestServicesConfigurationBuilder |
testServicesConfigurationBuilder |
Supplier<TestServicesConfigurationBuilder> |
testServicesConfigurationBuilderSupplier |
static String |
WORKING_DIRECTORY_SYSTEM_PROPERTY_KEY |
org.junit.rules.TemporaryFolder |
workingDirectory |
DEFAULT_TEST_TIMEOUT_SECS, globalTimeout, name, TEST_CONNECTOR, TEST_CONNECTOR_LOCATION, TEST_PAYLOAD, TEST_TIMEOUT_SYSTEM_PROPERTY, TESTING_MODE_PROPERTY_NAME| Constructor and Description |
|---|
AbstractMuleContextTestCase() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addBuilders(List<ConfigurationBuilder> builders) |
protected void |
configureMuleContext(MuleContextBuilder contextBuilder)
Override this method to set properties of the MuleContextBuilder before it is used to create the MuleContext.
|
protected MuleContext |
createMuleContext() |
protected <T> T |
createObject(Class<T> clazz)
Create an object of instance
clazz. |
protected <T> T |
createObject(Class<T> clazz,
Object... args)
Create an object of instance
clazz. |
static void |
disposeContext() |
void |
disposeContextPerTest() |
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
setUpMuleContext(). |
protected void |
doSetUpBeforeMuleContextCreation() |
protected void |
doTearDown()
Enables the adding of extra behavior on the tear down stage of a test before the mule context is disposed in
disposeContextPerTest(). |
protected void |
doTearDownAfterMuleContextDispose() |
protected static Event.Builder |
eventBuilder()
Creates a basic event builder with its context already set.
|
protected ConfigurationBuilder |
getBuilder() |
protected String |
getConfigurationResources() |
protected ClassLoader |
getExecutionClassLoader() |
protected File |
getFileInsideWorkingDirectory(String fileName) |
protected ObjectSerializer |
getObjectSerializer() |
protected <T> T |
getPayload(org.mule.runtime.api.message.Message message,
Class<T> clazz)
Uses
TransformationService to get representation of a message for a given Class |
protected Object |
getPayload(org.mule.runtime.api.message.Message message,
org.mule.runtime.api.metadata.DataType dataType)
Uses
TransformationService to get representation of a message for a given DataType |
protected byte[] |
getPayloadAsBytes(org.mule.runtime.api.message.Message message)
Uses
TransformationService to get byte[] representation of a message. |
protected String |
getPayloadAsString(org.mule.runtime.api.message.Message message)
Uses
TransformationService to get a String representation of a message. |
SensingNullMessageProcessor |
getSensingNullMessageProcessor() |
protected Properties |
getStartUpProperties() |
static Flow |
getTestFlowWithComponent(String name,
Class<?> clazz) |
TriggerableMessageSource |
getTriggerableMessageSource() |
protected File |
getWorkingDirectory() |
protected void |
initialiseObject(Object o)
A convenience method that will register an object in the registry using its hashcode as the key.
|
protected boolean |
isDisposeContextPerClass() |
protected boolean |
isGracefulShutdown()
Determines if the test case should perform graceful shutdown or not.
|
protected boolean |
isStartContext() |
protected boolean |
mockExprExecutorService()
Defines if a mock should be used for the
ExpressionExecutor. |
protected boolean |
mockHttpService()
Defines if a mock should be used for the
HttpService. |
protected Event |
process(Processor processor,
Event event) |
protected static void |
recordSchedulersOnInit(MuleContext context) |
protected void |
setDisposeContextPerClass(boolean val) |
protected void |
setStartContext(boolean startContext) |
void |
setUpMuleContext() |
protected static void |
verifyAndStopSchedulers() |
clearRequestContext, clearTestCaseName, clearTestEvents, collectThreadNames, createTestTimeoutRule, dumpFilteredThreadsInTest, getMavenProjectVersionProperty, getTestHeader, getTestTimeoutSecs, getTimeoutSystemProperty, initializeMuleTest, isDisabledInThisEnvironment, isDisabledInThisEnvironment, isFailOnTimeout, isOffline, newEvent, nullPayloadEvent, takeTestCaseName, testEventpublic static final String WORKING_DIRECTORY_SYSTEM_PROPERTY_KEY
public static final String REACTOR_BLOCK_TIMEOUT_EXCEPTION_MESSAGE
public TestServicesConfigurationBuilder testServicesConfigurationBuilder
public Supplier<TestServicesConfigurationBuilder> testServicesConfigurationBuilderSupplier
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.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
public static final int BLOCK_TIMEOUT
Publisher completion.protected Latch callbackCalled
protected boolean isDisposeContextPerClass()
protected void setDisposeContextPerClass(boolean val)
protected void doSetUpBeforeMuleContextCreation()
throws Exception
Exceptionprotected 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
Exceptionprotected ObjectSerializer getObjectSerializer()
ObjectSerializer to use on the test's MuleContextprotected ClassLoader getExecutionClassLoader()
protected void addBuilders(List<ConfigurationBuilder> builders)
protected boolean mockHttpService()
HttpService. If false an implementation will need to be provided.HttpService should be mocked.protected boolean mockExprExecutorService()
ExpressionExecutor. If false an implementation will need to be
provided.ExpressionExecutor should be mocked.protected void configureMuleContext(MuleContextBuilder contextBuilder)
protected ConfigurationBuilder getBuilder() throws Exception
Exceptionprotected String getConfigurationResources()
protected Properties getStartUpProperties()
protected void doTearDownAfterMuleContextDispose()
throws Exception
Exceptionpublic static void disposeContext()
throws RegistrationException,
org.mule.runtime.api.exception.MuleException
RegistrationExceptionorg.mule.runtime.api.exception.MuleExceptionprotected static void recordSchedulersOnInit(MuleContext context)
protected static void verifyAndStopSchedulers()
throws org.mule.runtime.api.exception.MuleException
org.mule.runtime.api.exception.MuleExceptionprotected 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 Flow getTestFlowWithComponent(String name, Class<?> clazz) throws Exception
Exceptionprotected static Event.Builder eventBuilder() throws org.mule.runtime.api.exception.MuleException
org.mule.runtime.api.exception.MuleExceptionprotected 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.classException - 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 parametersclassException - if there is a problem creating or initializing the objectprotected void initialiseObject(Object o) throws RegistrationException
o - the object to register and initialise itRegistrationExceptionpublic SensingNullMessageProcessor getSensingNullMessageProcessor()
public TriggerableMessageSource getTriggerableMessageSource()
protected File getWorkingDirectory()
protected File getFileInsideWorkingDirectory(String fileName)
fileName - name of the file. Can contain subfolders separated by File.separatorprotected String getPayloadAsString(org.mule.runtime.api.message.Message message) throws Exception
TransformationService to get a String representation of a message.message - message to get payload fromException - if there is an unexpected error obtaining the payload representationprotected byte[] getPayloadAsBytes(org.mule.runtime.api.message.Message message)
throws Exception
TransformationService to get byte[] representation of a message.message - message to get payload fromException - if there is an unexpected error obtaining the payload representationprotected Object getPayload(org.mule.runtime.api.message.Message message, org.mule.runtime.api.metadata.DataType dataType) throws Exception
TransformationService to get representation of a message for a given DataTypemessage - message to get payload fromdataType - dataType to be transformed toException - if there is an unexpected error obtaining the payload representationprotected <T> T getPayload(org.mule.runtime.api.message.Message message,
Class<T> clazz)
throws Exception
TransformationService to get representation of a message for a given Classmessage - message to get payload fromclazz - type of the payload to be transformed toException - if there is an unexpected error obtaining the payload representationCopyright © 2003–2017 MuleSoft, Inc.. All rights reserved.