org.mule.tck
Class AbstractMuleTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.mule.tck.AbstractMuleTestCase
All Implemented Interfaces:
Test, TestCaseWatchdogTimeoutHandler
Direct Known Subclasses:
AbstractConnectorTestCase, AbstractContainerContextTestCase, AbstractMessageAdapterTestCase, AbstractMessageReceiverTestCase, AbstractTransformerTestCase, AbstractTxThreadAssociationTestCase

public abstract class AbstractMuleTestCase
extends TestCase
implements TestCaseWatchdogTimeoutHandler

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 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
           
static String TEST_MESSAGE
          Convenient test message for unit testing.
 
Constructor Summary
AbstractMuleTestCase()
           
 
Method Summary
protected  MuleContext createMuleContext()
           
protected  AbstractMuleTestCase.TestInfo createTestInfo()
           
protected  TestCaseWatchdog createWatchdog()
           
protected  void disposeManager()
           
protected  void doSetUp()
           
protected  void doTearDown()
           
protected  ConfigurationBuilder getBuilder()
           
protected  String getConfigurationResources()
           
 String getName()
           
protected  Properties getStartUpProperties()
           
static TestConnector getTestConnector()
           
static MuleEvent getTestEvent(Object data)
           
static MuleEvent getTestEvent(Object data, ImmutableEndpoint endpoint)
           
static MuleEvent getTestEvent(Object data, Service service)
           
static MuleEvent getTestEvent(Object data, Service service, ImmutableEndpoint endpoint)
           
static MuleEventContext getTestEventContext(Object data)
           
static Endpoint getTestInboundEndpoint(String name)
           
protected  AbstractMuleTestCase.TestInfo getTestInfo()
           
static Endpoint getTestOutboundEndpoint(String name)
           
static Service getTestService()
           
static Service getTestService(String name, Class clazz)
           
static Service getTestService(String name, Class clazz, Map props)
           
static MuleSession getTestSession(Service service)
           
static Transformer getTestTransformer()
           
 void handleTimeout(long timeout, edu.emory.mathcs.backport.java.util.concurrent.TimeUnit unit)
           
protected  boolean isDisabledInThisEnvironment()
          Subclasses can override this method to skip the execution of the entire test class.
protected  boolean isDisabledInThisEnvironment(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.
 boolean isOffline(String method)
           
protected  boolean isStartContext()
           
protected  void registerTestMethod()
           
 void run(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 setName(String name)
           
protected  void setStartContext(boolean startContext)
           
protected  void setUp()
           
protected  void suitePostTearDown()
          Run after all testcase teardowns.
protected  void suitePreSetUp()
          Run before any testcase setup.
protected  void tearDown()
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IGNORED_DOT_MULE_DIRS

public static final String[] IGNORED_DOT_MULE_DIRS
Top-level directories under .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.


muleContext

protected static MuleContext muleContext

logger

protected final transient Log logger

TEST_MESSAGE

public static final String TEST_MESSAGE
Convenient test message for unit testing.

See Also:
Constant Field Values

LOCK_TIMEOUT

public static final long LOCK_TIMEOUT
Default timeout for multithreaded tests (using CountDownLatch, WaitableBoolean, etc.), in milliseconds. The higher this value, the more reliable the test will be, so it should be set high for Continuous Integration. However, this can waste time during day-to-day development cycles, so you may want to temporarily lower it while debugging.

See Also:
Constant Field Values

callbackCalled

protected Latch callbackCalled
Use this as a semaphore to the unit test to indicate when a callback has successfully been called.

Constructor Detail

AbstractMuleTestCase

public AbstractMuleTestCase()
Method Detail

registerTestMethod

protected void registerTestMethod()

setName

public void setName(String name)
Overrides:
setName in class TestCase

createTestInfo

protected AbstractMuleTestCase.TestInfo createTestInfo()

getTestInfo

protected AbstractMuleTestCase.TestInfo getTestInfo()

getName

public String getName()
Overrides:
getName in class TestCase

run

public void run(TestResult result)
Specified by:
run in interface Test
Overrides:
run in class TestCase

runBare

public void runBare()
             throws Throwable
Shamelessly copy from Spring's ConditionalTestCase so in MULE-2.0 we can extend this class from ConditionalTestCase. Subclasses can override isDisabledInThisEnvironment to skip a single test.

Overrides:
runBare in class TestCase
Throws:
Throwable

isDisabledInThisEnvironment

protected boolean isDisabledInThisEnvironment()
Subclasses can override this method to skip the execution of the entire test class.

Returns:
true if the test class should not be run.

isExcluded

protected boolean isExcluded()
Indicates whether this test has been explicitly disabled through the configuration file loaded by TestInfo.

Returns:
whether the test has been explicitly disabled

isDisabledInThisEnvironment

protected boolean isDisabledInThisEnvironment(String testMethodName)
Should this test run?

Parameters:
testMethodName - name of the test method
Returns:
whether the test should execute in the current envionment

isOffline

public boolean isOffline(String method)

isDisposeManagerPerSuite

protected boolean isDisposeManagerPerSuite()

setDisposeManagerPerSuite

protected void setDisposeManagerPerSuite(boolean val)

createWatchdog

protected TestCaseWatchdog createWatchdog()

handleTimeout

public void handleTimeout(long timeout,
                          edu.emory.mathcs.backport.java.util.concurrent.TimeUnit unit)
Specified by:
handleTimeout in interface TestCaseWatchdogTimeoutHandler

setUp

protected final void setUp()
                    throws Exception
Overrides:
setUp in class TestCase
Throws:
Exception

createMuleContext

protected MuleContext createMuleContext()
                                 throws Exception
Throws:
Exception

getBuilder

protected ConfigurationBuilder getBuilder()
                                   throws Exception
Throws:
Exception

getConfigurationResources

protected String getConfigurationResources()

getStartUpProperties

protected Properties getStartUpProperties()

suitePreSetUp

protected void suitePreSetUp()
                      throws Exception
Run before any testcase setup.

Throws:
Exception

suitePostTearDown

protected void suitePostTearDown()
                          throws Exception
Run after all testcase teardowns.

Throws:
Exception

tearDown

protected final void tearDown()
                       throws Exception
Overrides:
tearDown in class TestCase
Throws:
Exception

disposeManager

protected void disposeManager()

doSetUp

protected void doSetUp()
                throws Exception
Throws:
Exception

doTearDown

protected void doTearDown()
                   throws Exception
Throws:
Exception

getTestInboundEndpoint

public static Endpoint getTestInboundEndpoint(String name)
                                       throws Exception
Throws:
Exception

getTestOutboundEndpoint

public static Endpoint getTestOutboundEndpoint(String name)
                                        throws Exception
Throws:
Exception

getTestEvent

public static MuleEvent getTestEvent(Object data,
                                     Service service)
                              throws Exception
Throws:
Exception

getTestEvent

public static MuleEvent getTestEvent(Object data)
                              throws Exception
Throws:
Exception

getTestEventContext

public static MuleEventContext getTestEventContext(Object data)
                                            throws Exception
Throws:
Exception

getTestTransformer

public static Transformer getTestTransformer()
                                      throws Exception
Throws:
Exception

getTestEvent

public static MuleEvent getTestEvent(Object data,
                                     ImmutableEndpoint endpoint)
                              throws Exception
Throws:
Exception

getTestEvent

public static MuleEvent getTestEvent(Object data,
                                     Service service,
                                     ImmutableEndpoint endpoint)
                              throws Exception
Throws:
Exception

getTestSession

public static MuleSession getTestSession(Service service)

getTestConnector

public static TestConnector getTestConnector()
                                      throws Exception
Throws:
Exception

getTestService

public static Service getTestService()
                              throws Exception
Throws:
Exception

getTestService

public static Service getTestService(String name,
                                     Class clazz)
                              throws Exception
Throws:
Exception

getTestService

public static Service getTestService(String name,
                                     Class clazz,
                                     Map props)
                              throws Exception
Throws:
Exception

isStartContext

protected boolean isStartContext()

setStartContext

protected void setStartContext(boolean startContext)


Copyright © 2003-2008 MuleSource, Inc.. All Rights Reserved.