org.mule.tck.junit4
Class FunctionalTestCase

java.lang.Object
  extended by org.mule.tck.junit4.AbstractMuleTestCase
      extended by org.mule.tck.junit4.AbstractMuleContextTestCase
          extended by org.mule.tck.junit4.FunctionalTestCase
Direct Known Subclasses:
AbstractLoanBrokerTestCase, AbstractScriptConfigBuilderTestCase, AbstractServiceAndFlowTestCase

public abstract class FunctionalTestCase
extends org.mule.tck.junit4.AbstractMuleContextTestCase

A base test case for tests that initialize Mule using a configuration file. The default configuration builder used is SpringXmlConfigurationBuilder. To use this test case, ensure you have the mule-modules-builders JAR file on your classpath. To use a different builder, just overload the getBuilder() method of this class to return the type of builder you want to use with your test.


Field Summary
 
Fields inherited from class org.mule.tck.junit4.AbstractMuleContextTestCase
callbackCalled, CLASSNAME_ANNOTATIONS_CONFIG_BUILDER, IGNORED_DOT_MULE_DIRS, LOCK_TIMEOUT, muleContext, RECEIVE_TIMEOUT, TEST_MESSAGE
 
Fields inherited from class org.mule.tck.junit4.AbstractMuleTestCase
DEFAULT_TEST_TIMEOUT_SECS, globalTimeout, logger, name, TEST_TIMEOUT_SYSTEM_PROPERTY
 
Constructor Summary
FunctionalTestCase()
           
 
Method Summary
 void clearFlowAssertions()
           
protected  ConfigurationBuilder getBuilder()
           
protected  Object getComponent(FlowConstruct flowConstruct)
          Returns an instance of the service's component object.
protected  Object getComponent(String serviceName)
          Returns an instance of the service's component object.
protected  String getConfigFile()
           
protected  String[] getConfigFiles()
           
protected  String getConfigResources()
          Deprecated. use getConfigFile instead.
protected  FlowConstruct getFlowConstruct(String flowName)
           
protected  FunctionalTestComponent getFunctionalTestComponent(String serviceName)
          A convenience method to get a type-safe reference to the FunctionTestComponent
protected  InputStream loadResource(String resourceName)
           
protected  String loadResourceAsString(String resourceName)
           
protected  Flow lookupFlowConstruct(String name)
          Retrieve a flow by name from the registry
protected
<T> MuleEvent
runFlow(String flowName)
          Runs the given flow with a default event
protected
<T> MuleEvent
runFlow(String flowName, T payload)
          Executes the given flow with a default message carrying the payload
protected
<T> void
runFlowAndExpect(String flowName, T expect)
          Run the flow specified by name and assert equality on the expected output
protected
<T> void
runFlowAndExpectProperty(String flowName, String propertyName, T expect)
          Runs the given flow and asserts for property name in the outbound scope to match the expected value
protected
<T,U> void
runFlowWithPayloadAndExpect(String flowName, T expect, U payload)
          Run the flow specified by name using the specified payload and assert equality on the expected output
protected  void stopFlowConstruct(String flowName)
           
protected  void testFlow(String flowName)
          Tests the given flow with a one-way message exchange pattern
protected  void testFlow(String flowName, MuleEvent event)
          Looks up the given flow in the registry and processes it with the given event.
 
Methods inherited from class org.mule.tck.junit4.AbstractMuleContextTestCase
addBuilders, configureMuleContext, createMuleContext, createObject, createObject, disposeContext, disposeContextPerTest, doSetUp, doSetUpBeforeMuleContextCreation, doTearDown, doTearDownAfterMuleContextDispose, getConfigurationResources, getSensingNullMessageProcessor, getStartUpProperties, getTestConnector, getTestEvent, getTestEvent, getTestEvent, getTestEvent, getTestEvent, getTestEvent, getTestEvent, getTestEvent, getTestEventContext, getTestEventContext, getTestEventUsingFlow, getTestInboundEndpoint, getTestInboundEndpoint, getTestInboundEndpoint, getTestInboundEndpoint, getTestInboundEndpoint, getTestOutboundEndpoint, getTestOutboundEndpoint, getTestOutboundEndpoint, getTestOutboundEndpoint, getTestOutboundEndpoint, getTestService, getTestService, getTestService, getTestSession, getTestTransactedInboundEndpoint, getTestTransformer, getTriggerableMessageSource, getTriggerableMessageSource, initialiseObject, isDisposeContextPerClass, isGracefulShutdown, isStartContext, setDisposeContextPerClass, setStartContext, setUpMuleContext
 
Methods inherited from class org.mule.tck.junit4.AbstractMuleTestCase
clearExcludedFlag, clearRequestContext, clearTestCaseName, createTestTimeoutRule, dumpFilteredThreadsInTest, getTestHeader, getTestTimeoutSecs, getTimeoutSystemProperty, initializeMuleTest, isDisabledInThisEnvironment, isDisabledInThisEnvironment, isExcluded, isFailOnTimeout, isOffline, isTestIncludedInExclusionFile, takeTestCaseName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FunctionalTestCase

public FunctionalTestCase()
Method Detail

getConfigResources

@Deprecated
protected String getConfigResources()
Deprecated. use getConfigFile instead.

Returns:

getBuilder

protected ConfigurationBuilder getBuilder()
                                   throws Exception
Overrides:
getBuilder in class org.mule.tck.junit4.AbstractMuleContextTestCase
Throws:
Exception

getConfigFile

protected String getConfigFile()
Returns:
a single file that defines a mule application configuration

getConfigFiles

protected String[] getConfigFiles()
Returns:
a several files that define a mule application configuration

getComponent

protected Object getComponent(String serviceName)
                       throws Exception
Returns an instance of the service's component object. Note that depending on the type of ObjectFactory used for the component, this may create a new instance of the object. If you plan to set properties on the returned object, make sure your component is declared as a singleton, otherwise this will not work.

Throws:
Exception

getComponent

protected Object getComponent(FlowConstruct flowConstruct)
                       throws Exception
Returns an instance of the service's component object. Note that depending on the type of ObjectFactory used for the component, this may create a new instance of the object. If you plan to set properties on the returned object, make sure your component is declared as a singleton, otherwise this will not work.

Throws:
Exception

getFunctionalTestComponent

protected FunctionalTestComponent getFunctionalTestComponent(String serviceName)
                                                      throws Exception
A convenience method to get a type-safe reference to the FunctionTestComponent

Parameters:
serviceName - service name as declared in the config
Returns:
test component
Throws:
Exception
Since:
2.2
See Also:
FunctionalTestComponent

getFlowConstruct

protected FlowConstruct getFlowConstruct(String flowName)
                                  throws Exception
Throws:
Exception

loadResourceAsString

protected String loadResourceAsString(String resourceName)
                               throws IOException
Throws:
IOException

loadResource

protected InputStream loadResource(String resourceName)
                            throws IOException
Throws:
IOException

stopFlowConstruct

protected void stopFlowConstruct(String flowName)
                          throws Exception
Throws:
Exception

testFlow

protected void testFlow(String flowName)
                 throws Exception
Tests the given flow with a one-way message exchange pattern

Parameters:
flowName - the name of the flow to be executed
Throws:
Exception

testFlow

protected void testFlow(String flowName,
                        MuleEvent event)
                 throws Exception
Looks up the given flow in the registry and processes it with the given event. A flow asserting is then executed by calling org.mule.tck.functional.FlowAssert.verify(String)

Parameters:
flowName - the name of the flow to be executed
event - the event ot execute with
Throws:
Exception

runFlow

protected <T> MuleEvent runFlow(String flowName)
                     throws Exception
Runs the given flow with a default event

Parameters:
flowName - the name of the flow to be executed
Returns:
the resulting MuleEvent
Throws:
Exception

runFlow

protected <T> MuleEvent runFlow(String flowName,
                                T payload)
                     throws Exception
Executes the given flow with a default message carrying the payload

Parameters:
flowName - the name of the flow to be executed
payload - the payload to use int he message
Returns:
the resulting MuleEvent
Throws:
Exception

runFlowAndExpect

protected <T> void runFlowAndExpect(String flowName,
                                    T expect)
                         throws Exception
Run the flow specified by name and assert equality on the expected output

Parameters:
flowName - The name of the flow to run
expect - The expected output
Throws:
Exception

runFlowAndExpectProperty

protected <T> void runFlowAndExpectProperty(String flowName,
                                            String propertyName,
                                            T expect)
                                 throws Exception
Runs the given flow and asserts for property name in the outbound scope to match the expected value

Parameters:
flowName - the name of the flow to be executed
propertyName - the name of the property to test
expect - the expected value
Throws:
Exception

runFlowWithPayloadAndExpect

protected <T,U> void runFlowWithPayloadAndExpect(String flowName,
                                                 T expect,
                                                 U payload)
                                    throws Exception
Run the flow specified by name using the specified payload and assert equality on the expected output

Parameters:
flowName - The name of the flow to run
expect - The expected output
payload - The payload of the input event
Throws:
Exception

lookupFlowConstruct

protected Flow lookupFlowConstruct(String name)
Retrieve a flow by name from the registry

Parameters:
name - Name of the flow to retrieve

clearFlowAssertions

public final void clearFlowAssertions()
                               throws Exception
Throws:
Exception


Copyright © 2003-2014 MuleSoft, Inc.. All Rights Reserved.