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 org.mule.runtime.api.component.location.ConfigurationComponentLocator |
componentLocator |
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.
|
protected static long |
NON_GRACEFUL_SHUTDOWN_TIMEOUT
Default shutdown timeout used when
isGracefulShutdown() is false. |
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 |
chain, DEFAULT_TEST_TIMEOUT_SECS, name, TEST_CONNECTOR, TEST_CONNECTOR_LOCATION, TEST_PAYLOAD, TEST_TIMEOUT_SYSTEM_PROPERTY| Constructor and Description |
|---|
AbstractMuleContextTestCase() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addBuilders(List<ConfigurationBuilder> builders) |
static Object |
awaitLatch(Object payload,
CountDownLatch latch) |
protected void |
configureMuleContext(MuleContextBuilder contextBuilder)
Override this method to set properties of the MuleContextBuilder before it is used to create the MuleContext.
|
protected DefaultMuleConfiguration |
createMuleConfiguration() |
protected MuleContext |
createMuleContext() |
protected MuleContext |
createMuleContext(String contextConfigurationId) |
static void |
disposeContext() |
void |
disposeContextPerTest() |
static void |
disposeOnlyMuleContext() |
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 boolean |
doTestClassInjection() |
static Map<QName,Object> |
getAppleFlowComponentLocationAnnotations() |
protected ConfigurationBuilder |
getBuilder() |
protected String |
getConfigurationResources() |
protected Optional<Properties> |
getDeploymentProperties() |
protected <B extends CoreEvent.Builder> |
getEventBuilder()
Allows subclasses to provide a builder configured in a different way
|
protected ClassLoader |
getExecutionClassLoader() |
protected File |
getFileInsideWorkingDirectory(String fileName) |
protected static Map<QName,Object> |
getFlowComponentLocationAnnotations(String rootComponentName) |
protected org.mule.runtime.api.serialization.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 Map<String,Object> |
getStartUpRegistryObjects() |
TriggerableMessageSource |
getTriggerableMessageSource() |
protected File |
getWorkingDirectory() |
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 CoreEvent |
process(Processor processor,
CoreEvent event) |
protected static void |
recordSchedulersOnInit(MuleContext context) |
protected void |
setDisposeContextPerClass(boolean val) |
protected void |
setStartContext(boolean startContext) |
void |
setUpMuleContext() |
static <T> T |
sleepFor(T payload,
long millis) |
protected static void |
verifyAndStopSchedulers() |
addMockComponentLocation, clearRequestContext, clearTestCaseName, clearTestEvents, collectThreadNames, createTestTimeoutRule, dumpFilteredThreadsInTest, getFeatureFlaggingService, getMavenProjectVersionProperty, getTestHeader, getTestTimeoutSecs, getTimeoutSystemProperty, initializeMuleTest, isDisabledInThisEnvironment, isDisabledInThisEnvironment, isFailOnTimeout, isOffline, newEvent, nullPayloadEvent, shutdownLogging, takeTestCaseName, testEventpublic static final String WORKING_DIRECTORY_SYSTEM_PROPERTY_KEY
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 static final long NON_GRACEFUL_SHUTDOWN_TIMEOUT
isGracefulShutdown() is false.protected org.mule.runtime.api.component.location.ConfigurationComponentLocator componentLocator
protected boolean isDisposeContextPerClass()
protected void setDisposeContextPerClass(boolean val)
protected void doSetUpBeforeMuleContextCreation()
throws Exception
Exceptionprotected boolean doTestClassInjection()
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
Exceptionprotected MuleContext createMuleContext(String contextConfigurationId) throws Exception
Exceptionprotected DefaultMuleConfiguration createMuleConfiguration()
protected Optional<Properties> getDeploymentProperties()
protected org.mule.runtime.api.serialization.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 void doTearDownAfterMuleContextDispose()
throws Exception
Exceptionpublic static void disposeContext()
throws org.mule.runtime.api.exception.MuleException
org.mule.runtime.api.exception.MuleExceptionpublic static void disposeOnlyMuleContext()
protected 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 testcaseprotected <B extends CoreEvent.Builder> B getEventBuilder() throws org.mule.runtime.api.exception.MuleException
AbstractMuleTestCasegetEventBuilder in class AbstractMuleTestCaseorg.mule.runtime.api.exception.MuleExceptionprotected boolean isStartContext()
protected void setStartContext(boolean startContext)
protected boolean isGracefulShutdown()
public 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 representationprotected CoreEvent process(Processor processor, CoreEvent event) throws Exception
Exceptionpublic static Map<QName,Object> getAppleFlowComponentLocationAnnotations()
protected static Map<QName,Object> getFlowComponentLocationAnnotations(String rootComponentName)
public static <T> T sleepFor(T payload,
long millis)
public static Object awaitLatch(Object payload, CountDownLatch latch)
Copyright © 2003–2021 MuleSoft, Inc.. All rights reserved.