|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.mule.tck.AbstractMuleTestCase
public abstract class AbstractMuleTestCase
AbstractMuleTestCase
is a base class for Mule testcases. This
implementation provides services to test code for creating mock and test objects.
Nested Class Summary | |
---|---|
static class |
AbstractMuleTestCase.TestInfo
|
Field Summary | |
---|---|
protected Latch |
callbackCalled
Use this as a semaphore to the unit test to indicate when a callback has successfully been called. |
static java.lang.String |
CLASSNAME_ANNOTATIONS_CONFIG_BUILDER
If the annotations module is on the classpath, also enable annotations config builder |
static int |
DEFAULT_MULE_TEST_TIMEOUT_SECS
Default test watchdog timeout in seconds. |
static java.lang.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 Log |
logger
|
protected static MuleContext |
muleContext
|
protected int |
numPorts
|
java.util.List<java.lang.Integer> |
ports
|
static java.lang.String |
PROPERTY_MULE_TEST_TIMEOUT
Name of a property to override the default test watchdog timeout. |
static int |
RECEIVE_TIMEOUT
Default timeout for waiting for responses |
static java.lang.String |
TEST_MESSAGE
Convenient test message for unit testing. |
protected int |
testTimeoutSecs
Timeout used for the test watchdog |
Constructor Summary | |
---|---|
AbstractMuleTestCase()
|
Method Summary | ||
---|---|---|
protected void |
addBuilders(java.util.List<ConfigurationBuilder> builders)
|
|
void |
checkPorts(boolean failIfTaken,
java.lang.String prefix)
Iterate through the ports and log whether each is available |
|
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
|
createObject(java.lang.Class<T> clazz)
Create an object of instance clazz . |
|
protected
|
createObject(java.lang.Class<T> clazz,
java.lang.Object... args)
Create an object of instance clazz . |
|
protected AbstractMuleTestCase.TestInfo |
createTestInfo()
|
|
protected TestCaseWatchdog |
createWatchdog()
|
|
protected void |
disposeManager()
|
|
protected void |
doSetUp()
Exactly the same a setUp() in normal JUnit test cases. |
|
protected void |
doTearDown()
Exactly the same a tearDown() in normal JUnit test cases. |
|
java.util.List<java.lang.Integer> |
findFreePorts(int numberOfPorts)
Find a given number of available ports |
|
protected ConfigurationBuilder |
getBuilder()
|
|
protected java.lang.String |
getConfigurationResources()
|
|
java.util.List<java.lang.Integer> |
getPorts()
|
|
SensingNullMessageProcessor |
getSensingNullMessageProcessor()
|
|
protected java.util.Properties |
getStartUpProperties()
|
|
static TestConnector |
getTestConnector()
|
|
static MuleEvent |
getTestEvent(java.lang.Object data)
|
|
static MuleEvent |
getTestEvent(java.lang.Object data,
ImmutableEndpoint endpoint)
|
|
static MuleEvent |
getTestEvent(java.lang.Object data,
MessageExchangePattern mep)
|
|
static MuleEvent |
getTestEvent(java.lang.Object data,
Service service)
|
|
static MuleEvent |
getTestEvent(java.lang.Object data,
Service service,
ImmutableEndpoint endpoint)
|
|
static MuleEvent |
getTestEvent(java.lang.Object data,
Service service,
MessageExchangePattern mep)
|
|
static MuleEventContext |
getTestEventContext(java.lang.Object data)
|
|
static MuleEventContext |
getTestEventContext(java.lang.Object data,
MessageExchangePattern mep)
|
|
static InboundEndpoint |
getTestInboundEndpoint(MessageExchangePattern mep)
|
|
static InboundEndpoint |
getTestInboundEndpoint(java.lang.String name)
|
|
static InboundEndpoint |
getTestInboundEndpoint(java.lang.String name,
java.util.List<Transformer> transformers)
|
|
static InboundEndpoint |
getTestInboundEndpoint(java.lang.String name,
java.lang.String uri)
|
|
static InboundEndpoint |
getTestInboundEndpoint(java.lang.String name,
java.lang.String uri,
java.util.List<Transformer> transformers,
Filter filter,
java.util.Map<java.lang.Object,java.lang.Object> properties,
Connector connector)
|
|
static MuleEvent |
getTestInboundEvent(java.lang.Object data)
|
|
static MuleEvent |
getTestInboundEvent(java.lang.Object data,
MessageExchangePattern mep)
|
|
static MuleEvent |
getTestInboundEvent(java.lang.Object data,
MuleSession session)
|
|
protected AbstractMuleTestCase.TestInfo |
getTestInfo()
|
|
static OutboundEndpoint |
getTestOutboundEndpoint(java.lang.String name)
|
|
static OutboundEndpoint |
getTestOutboundEndpoint(java.lang.String name,
java.util.List<Transformer> transformers)
|
|
static OutboundEndpoint |
getTestOutboundEndpoint(java.lang.String name,
java.lang.String uri)
|
|
static OutboundEndpoint |
getTestOutboundEndpoint(java.lang.String name,
java.lang.String uri,
java.util.List<Transformer> transformers,
Filter filter,
java.util.Map<java.lang.Object,java.lang.Object> properties)
|
|
static OutboundEndpoint |
getTestOutboundEndpoint(java.lang.String name,
java.lang.String uri,
java.util.List<Transformer> transformers,
Filter filter,
java.util.Map<java.lang.Object,java.lang.Object> properties,
Connector connector)
|
|
static Service |
getTestService()
|
|
static Service |
getTestService(java.lang.String name,
java.lang.Class<?> clazz)
|
|
static Service |
getTestService(java.lang.String name,
java.lang.Class<?> clazz,
java.util.Map<?,?> props)
|
|
static MuleSession |
getTestSession(Service service,
MuleContext context)
|
|
int |
getTestTimeoutSecs()
|
|
static InboundEndpoint |
getTestTransactedInboundEndpoint(MessageExchangePattern mep)
|
|
static Transformer |
getTestTransformer()
|
|
TriggerableMessageSource |
getTriggerableMessageSource()
|
|
TriggerableMessageSource |
getTriggerableMessageSource(MessageProcessor listener)
|
|
protected void |
giveTheTestSomeTimeToCleanUpAndThenKillIt(java.lang.String messageIfNeedToKill)
|
|
void |
handleTimeout(long timeout,
edu.emory.mathcs.backport.java.util.concurrent.TimeUnit unit)
|
|
protected void |
initialiseObject(java.lang.Object o)
A convenience method that will register an object in the registry using its hashcode as the key. |
|
protected void |
initTestTimeoutSecs()
|
|
protected boolean |
isDisabledInThisEnvironment()
Subclasses can override this method to skip the execution of the entire test class. |
|
protected boolean |
isDisabledInThisEnvironment(java.lang.String testMethodName)
Should this test run? |
|
protected boolean |
isDisposeManagerPerSuite()
|
|
protected boolean |
isExcluded()
Indicates whether this test has been explicitly disabled through the configuration file loaded by TestInfo. |
|
protected boolean |
isGracefulShutdown()
Determines if the test case should perform graceful shutdown or not. |
|
boolean |
isOffline(java.lang.String method)
|
|
boolean |
isPortFree(int port)
Check and log is a given port is available |
|
protected boolean |
isStartContext()
|
|
protected void |
registerTestMethod()
|
|
void |
run(junit.framework.TestResult result)
|
|
void |
runBare()
Shamelessly copy from Spring's ConditionalTestCase so in MULE-2.0 we can extend this class from ConditionalTestCase. |
|
protected void |
setDisposeManagerPerSuite(boolean val)
|
|
void |
setFailOnTimeout(boolean failOnTimeout)
|
|
void |
setName(java.lang.String name)
|
|
protected void |
setStartContext(boolean startContext)
|
|
protected void |
setUp()
Normal JUnit method |
|
protected void |
suitePostTearDown()
Run after all testcase teardowns. |
|
protected void |
suitePreSetUp()
Run before any testcase setup. |
|
protected void |
tearDown()
Normal JUnit method |
Methods inherited from class junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, runTest, toString |
Methods inherited from class junit.framework.Assert |
---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.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 java.lang.String PROPERTY_MULE_TEST_TIMEOUT
DEFAULT_MULE_TEST_TIMEOUT_SECS
,
Constant Field Valuespublic static final int DEFAULT_MULE_TEST_TIMEOUT_SECS
public static final java.lang.String CLASSNAME_ANNOTATIONS_CONFIG_BUILDER
protected static MuleContext muleContext
protected final transient Log logger
protected int numPorts
public java.util.List<java.lang.Integer> ports
public static final java.lang.String TEST_MESSAGE
public static final long LOCK_TIMEOUT
public static final int RECEIVE_TIMEOUT
protected Latch callbackCalled
protected int testTimeoutSecs
Constructor Detail |
---|
public AbstractMuleTestCase()
Method Detail |
---|
protected void registerTestMethod()
protected void initTestTimeoutSecs()
public void setName(java.lang.String name)
setName
in class junit.framework.TestCase
protected AbstractMuleTestCase.TestInfo createTestInfo()
protected AbstractMuleTestCase.TestInfo getTestInfo()
public void run(junit.framework.TestResult result)
run
in interface junit.framework.Test
run
in class junit.framework.TestCase
public void runBare() throws java.lang.Throwable
isDisabledInThisEnvironment
to skip a single test.
runBare
in class junit.framework.TestCase
java.lang.Throwable
protected boolean isDisabledInThisEnvironment()
true
if the test class should not be run.protected boolean isExcluded()
protected boolean isDisabledInThisEnvironment(java.lang.String testMethodName)
testMethodName
- name of the test method
public boolean isOffline(java.lang.String method)
protected boolean isDisposeManagerPerSuite()
protected void setDisposeManagerPerSuite(boolean val)
public int getTestTimeoutSecs()
protected TestCaseWatchdog createWatchdog()
public void handleTimeout(long timeout, edu.emory.mathcs.backport.java.util.concurrent.TimeUnit unit)
handleTimeout
in interface TestCaseWatchdogTimeoutHandler
protected void giveTheTestSomeTimeToCleanUpAndThenKillIt(java.lang.String messageIfNeedToKill)
protected final void setUp() throws java.lang.Exception
setUp
in class junit.framework.TestCase
java.lang.Exception
doSetUp()
protected MuleContext createMuleContext() throws java.lang.Exception
java.lang.Exception
protected void addBuilders(java.util.List<ConfigurationBuilder> builders)
protected void configureMuleContext(MuleContextBuilder contextBuilder)
protected ConfigurationBuilder getBuilder() throws java.lang.Exception
java.lang.Exception
protected java.lang.String getConfigurationResources()
protected java.util.Properties getStartUpProperties()
protected void suitePreSetUp() throws java.lang.Exception
java.lang.Exception
protected void suitePostTearDown() throws java.lang.Exception
java.lang.Exception
protected final void tearDown() throws java.lang.Exception
tearDown
in class junit.framework.TestCase
java.lang.Exception
doTearDown()
protected void disposeManager()
protected void doSetUp() throws java.lang.Exception
setUp()
in normal JUnit test cases. this is called before a test
method has been called.
java.lang.Exception
- if something fails that should halt the testcaseprotected void doTearDown() throws java.lang.Exception
tearDown()
in normal JUnit test cases. this is called after a test
method has been called.
java.lang.Exception
- if something fails that should halt the testcasepublic static InboundEndpoint getTestInboundEndpoint(java.lang.String name) throws java.lang.Exception
java.lang.Exception
public static OutboundEndpoint getTestOutboundEndpoint(java.lang.String name) throws java.lang.Exception
java.lang.Exception
public static InboundEndpoint getTestInboundEndpoint(MessageExchangePattern mep) throws java.lang.Exception
java.lang.Exception
public static InboundEndpoint getTestTransactedInboundEndpoint(MessageExchangePattern mep) throws java.lang.Exception
java.lang.Exception
public static InboundEndpoint getTestInboundEndpoint(java.lang.String name, java.lang.String uri) throws java.lang.Exception
java.lang.Exception
public static OutboundEndpoint getTestOutboundEndpoint(java.lang.String name, java.lang.String uri) throws java.lang.Exception
java.lang.Exception
public static InboundEndpoint getTestInboundEndpoint(java.lang.String name, java.util.List<Transformer> transformers) throws java.lang.Exception
java.lang.Exception
public static OutboundEndpoint getTestOutboundEndpoint(java.lang.String name, java.util.List<Transformer> transformers) throws java.lang.Exception
java.lang.Exception
public static InboundEndpoint getTestInboundEndpoint(java.lang.String name, java.lang.String uri, java.util.List<Transformer> transformers, Filter filter, java.util.Map<java.lang.Object,java.lang.Object> properties, Connector connector) throws java.lang.Exception
java.lang.Exception
public static OutboundEndpoint getTestOutboundEndpoint(java.lang.String name, java.lang.String uri, java.util.List<Transformer> transformers, Filter filter, java.util.Map<java.lang.Object,java.lang.Object> properties) throws java.lang.Exception
java.lang.Exception
public static OutboundEndpoint getTestOutboundEndpoint(java.lang.String name, java.lang.String uri, java.util.List<Transformer> transformers, Filter filter, java.util.Map<java.lang.Object,java.lang.Object> properties, Connector connector) throws java.lang.Exception
java.lang.Exception
public static MuleEvent getTestEvent(java.lang.Object data, Service service) throws java.lang.Exception
java.lang.Exception
public static MuleEvent getTestEvent(java.lang.Object data, Service service, MessageExchangePattern mep) throws java.lang.Exception
java.lang.Exception
public static MuleEvent getTestEvent(java.lang.Object data) throws java.lang.Exception
java.lang.Exception
public static MuleEvent getTestEvent(java.lang.Object data, MessageExchangePattern mep) throws java.lang.Exception
java.lang.Exception
public static MuleEvent getTestInboundEvent(java.lang.Object data, MuleSession session) throws java.lang.Exception
java.lang.Exception
public static MuleEvent getTestInboundEvent(java.lang.Object data) throws java.lang.Exception
java.lang.Exception
public static MuleEvent getTestInboundEvent(java.lang.Object data, MessageExchangePattern mep) throws java.lang.Exception
java.lang.Exception
public static MuleEventContext getTestEventContext(java.lang.Object data) throws java.lang.Exception
java.lang.Exception
public static MuleEventContext getTestEventContext(java.lang.Object data, MessageExchangePattern mep) throws java.lang.Exception
java.lang.Exception
public static Transformer getTestTransformer() throws java.lang.Exception
java.lang.Exception
public static MuleEvent getTestEvent(java.lang.Object data, ImmutableEndpoint endpoint) throws java.lang.Exception
java.lang.Exception
public static MuleEvent getTestEvent(java.lang.Object data, Service service, ImmutableEndpoint endpoint) throws java.lang.Exception
java.lang.Exception
public static MuleSession getTestSession(Service service, MuleContext context)
public static TestConnector getTestConnector() throws java.lang.Exception
java.lang.Exception
public static Service getTestService() throws java.lang.Exception
java.lang.Exception
public static Service getTestService(java.lang.String name, java.lang.Class<?> clazz) throws java.lang.Exception
java.lang.Exception
public static Service getTestService(java.lang.String name, java.lang.Class<?> clazz, java.util.Map<?,?> props) throws java.lang.Exception
java.lang.Exception
protected boolean isStartContext()
protected void setStartContext(boolean startContext)
public void setFailOnTimeout(boolean failOnTimeout)
protected boolean isGracefulShutdown()
protected <T> T createObject(java.lang.Class<T> clazz) throws java.lang.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
java.lang.Exception
- if there is a problem creating or initializing the objectprotected <T> T createObject(java.lang.Class<T> clazz, java.lang.Object... args) throws java.lang.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 parameters
class
java.lang.Exception
- if there is a problem creating or initializing the objectprotected void initialiseObject(java.lang.Object o) throws RegistrationException
o
- the object to register and initialise it
RegistrationException
public SensingNullMessageProcessor getSensingNullMessageProcessor()
public TriggerableMessageSource getTriggerableMessageSource(MessageProcessor listener)
public TriggerableMessageSource getTriggerableMessageSource()
public java.util.List<java.lang.Integer> findFreePorts(int numberOfPorts)
numberOfPorts
- The number of free ports to find
public void checkPorts(boolean failIfTaken, java.lang.String prefix)
failIfTaken
- If true, fails the current test if the port is not availablepublic boolean isPortFree(int port)
port
- the port number to check
public java.util.List<java.lang.Integer> getPorts()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |