ColdBox Platform Version 3.7.0

coldbox.system.testing
Class BaseTestCase

WEB-INF.cftags.component
        extended by mxunit.framework.Assert
            extended by mxunit.framework.TestCase
                extended by coldbox.system.testing.BaseTestCase
Direct Known Subclasses:
BaseHandlerTest , BaseInterceptorTest , BaseModelTest , BasePluginTest

public class BaseTestCase
extends mxunit.framework.TestCase

A base test case for doing ColdBox Testing based on the MXUnit Framework


Method Summary
private void $abort()
          Facade for cfabort
private void $dump(any var, [boolean isAbort='false'])
          Facade for cfmx dump
private void $include([string template])
          Facade for cfinclude
private void $rethrow(any throwObject)
          Rethrow facade
private any $throw(string message, [string detail=''], [string type='Framework'])
          Facade for cfthrow
 any afterTests()
          The main teardown for ColdBox enabled applications after all tests execute
private any announceInterception(any state, [any interceptData='[runtime expression]'], [boolean async='false'], [boolean asyncAll='false'], [boolean asyncAllNoJoin='false'], [string asyncPriority='NORMAL'], [numeric asyncJoinTimeout='0'])
          Announce an interception to the system
 any beforeTests()
          The main setup method for running ColdBox Integration enabled tests
private any execute(string event, [boolean private='false'], [boolean prepostExempt='false'], [struct eventArguments='[runtime expression]'], [boolean renderResults='false'])
          Executes a framework lifecycle by executing an event
private string getAppMapping()
          Get the AppMapping used for this test case
private any getCacheBox()
          Get a reference to cachebox
private string getColdboxAppKey()
          Get the coldboxAppKey used to store the coldbox controller in application scope
private any<IColdboxApplicationCache> getColdboxOCM([string cacheName='default'])
          Get ColdboxOCM: coldbox
private string getConfigMapping()
          Get the ConfigMapping for this test case
private any getController()
          Get a reference to the ColdBox mock controller
private AbstractFlashScope getFlashScope()
          Returns to you the currently used flash ram object
private any getInterceptor([string interceptorName], [boolean deepSearch='false'])
          Get an interceptor
private any getLogBox()
          Get a logbox reference
private MockBox getMockBox()
          Get a reference to the MockBox framework
private ConfigBean getMockConfigBean([struct configStruct='[runtime expression]'])
          I will return to you a configBean according to the mocking configuration structure you send in
private MockController getMockController()
          I will return a mock controller object
private DatasourceBean getMockDatasource(string name, [string alias=''], [string dbtype=''], [string username=''], [string password=''])
          I will return to you a datasourceBean according to the mocking parameters sent
private any getMockModel(string name, [boolean clearMethods='false'])
          *ColdBox must be loaded for this to work
private any getMockPlugin(string path)
          Get a plugin mocked with capabilities
private RequestBuffer getMockRequestBuffer()
          I will return to you a mock request buffer object used mostly in interceptor calls
private RequestContext getMockRequestContext([boolean clearMethods='false'], [any decorator])
          Builds an empty functioning request context mocked with methods via MockBox
private any getModel([any name], [any dsl], [any<struct> initArguments='[runtime expression]'])
          Create or retrieve model objects by convention
private any getRequestContext()
          Get a reference to the current mock request context
private Util getUtil()
          Create and return a util object
private any getWireBox()
          Get the wirebox instance
private void metadataInspection()
          Inspect test case for annotations
private query querySim(string queryData)
          Query Simulator
private void reset()
          Reset the persistence of the unit test coldbox app, basically removes the controller from application scope
private void setAppMapping(string AppMapping)
          Set the AppMapping for this test case
private void setColdboxAppKey(string coldboxAppKey)
          Override the coldboxAppKey, used to store the coldbox controller in application scope
private void setConfigMapping(string ConfigMapping)
          Set the ConfigMapping for this test case
 any setup()
          This executes before any test method for integration tests
private void setupRequest(string event)
          Setup an initial request capture
 
Methods inherited from class mxunit.framework.TestCase
TestCase, _getMockFactory, _setMockFactory, accept, addTrace, applyDecorators, clearDebug, createRequestScopeDebug, createResult, debug, disableAfterTests, disableBeforeTests, dump, enableAfterTests, enableBeforeTests, expectException, getAnnotation, getBaseTarget, getDebug, getDebugWrapper, getExpectedExceptionMessage, getExpectedExceptionType, getMockFactory, getRequiredDecoratorPaths, getRunnableMethods, getVariablesScope, initDebug, initProperties, injectMethod, injectProperty, invokeTestMethod, makePublic, mock, okToRunAfterTests, okToRunBeforeTests, orderedExpectation, print, println, restoreMethod, run, runBare, runTest, runTestRemote, setDebugWrapper, setExpectedExceptionMessage, setExpectedExceptionType, setMockingFramework, stopRequestScopeDebug, tearDown, toStringValue
 
Methods inherited from class mxunit.framework.Assert
addAssertDecorator, addAssertDecorators, assert, assertArrayEquals, assertEquals, assertEqualsCase, assertFalse, assertNotEquals, assertNotSame, assertQueryEquals, assertSame, assertStructEquals, assertTrue, clearClassVariables, fail, failEquals, failNotEquals, getActual, getExpected, getHashCode, getStringValue, getTestStyle, init, isPassByValueArray, normalizeArguments, setTestStyle, throwWrapper
 
Methods inherited from class WEB-INF.cftags.component
 

Method Detail

$abort

private void $abort()
Facade for cfabort


$dump

private void $dump(any var, [boolean isAbort='false'])
Facade for cfmx dump

Parameters:
var
isAbort - Abort also

$include

private void $include([string template])
Facade for cfinclude

Parameters:
template

$rethrow

private void $rethrow(any throwObject)
Rethrow facade

Parameters:
throwObject - The cfcatch object

$throw

private any $throw(string message, [string detail=''], [string type='Framework'])
Facade for cfthrow

Parameters:
message
detail
type

afterTests

public any afterTests()
The main teardown for ColdBox enabled applications after all tests execute

Overrides:
afterTests in class mxunit.framework.TestCase

announceInterception

private any announceInterception(any state, [any interceptData='[runtime expression]'], [boolean async='false'], [boolean asyncAll='false'], [boolean asyncAllNoJoin='false'], [string asyncPriority='NORMAL'], [numeric asyncJoinTimeout='0'])
Announce an interception to the system. If you use the asynchronous facilities, you will get a thread structure report as a result.

Parameters:
state - The interception state to execute
interceptData - A data structure used to pass intercepted information.
async - If true, the entire interception chain will be ran in a separate thread.
asyncAll - If true, each interceptor in the interception chain will be ran in a separate thread and then joined together at the end.
asyncAllNoJoin - If true, each interceptor in the interception chain will be ran in a separate thread but NOT joined together at the end.
asyncPriority - The thread priority to be used. Either LOW, NORMAL or HIGH. The default value is NORMAL
asyncJoinTimeout - The timeout in milliseconds for the join thread to wait for interceptor threads to finish. By default there is no timeout.

beforeTests

public any beforeTests()
The main setup method for running ColdBox Integration enabled tests

Overrides:
beforeTests in class mxunit.framework.TestCase

execute

private any execute(string event, [boolean private='false'], [boolean prepostExempt='false'], [struct eventArguments='[runtime expression]'], [boolean renderResults='false'])
Executes a framework lifecycle by executing an event. This method returns a request context object that can be used for assertions

Parameters:
event - The event to execute
private - Call a private event or not
prepostExempt - If true, pre/post handlers will not be fired.
eventArguments - A collection of arguments to passthrough to the calling event handler method
renderResults - If true, then it will try to do the normal rendering procedures and store the rendered content in the RC as cbox_rendered_content

getAppMapping

private string getAppMapping()
Get the AppMapping used for this test case


getCacheBox

private any getCacheBox()
Get a reference to cachebox


getColdboxAppKey

private string getColdboxAppKey()
Get the coldboxAppKey used to store the coldbox controller in application scope.


getColdboxOCM

private any<IColdboxApplicationCache> getColdboxOCM([string cacheName='default'])
Get ColdboxOCM: coldbox.system.cache.CacheManager or new CacheBox providers coldbox.system.cache.IColdboxApplicationCache

Parameters:
cacheName - The cache name to retrieve

getConfigMapping

private string getConfigMapping()
Get the ConfigMapping for this test case


getController

private any getController()
Get a reference to the ColdBox mock controller


getFlashScope

private AbstractFlashScope getFlashScope()
Returns to you the currently used flash ram object


getInterceptor

private any getInterceptor([string interceptorName], [boolean deepSearch='false'])
Get an interceptor

Parameters:
interceptorName - The name of the interceptor to search for
deepSearch - By default we search the cache for the interceptor reference. If true, we search all the registered interceptor states for a match.

getLogBox

private any getLogBox()
Get a logbox reference


getMockBox

private MockBox getMockBox()
Get a reference to the MockBox framework


getMockConfigBean

private ConfigBean getMockConfigBean([struct configStruct='[runtime expression]'])
I will return to you a configBean according to the mocking configuration structure you send in

Parameters:
configStruct - A memento of name-value pairs to init

getMockController

private MockController getMockController()
I will return a mock controller object


getMockDatasource

private DatasourceBean getMockDatasource(string name, [string alias=''], [string dbtype=''], [string username=''], [string password=''])
I will return to you a datasourceBean according to the mocking parameters sent

Parameters:
name - The name of the DSN on the ColdFusion administrator
alias - The alias to use, if not passed the name will be used also as the alias
dbtype - The db type metadata
username - The dsn username metadata
password - The password metadata

getMockModel

private any getMockModel(string name, [boolean clearMethods='false'])
*ColdBox must be loaded for this to work. Get a mock model object by convention. You can optional clear all the methods on the model object if you wanted to. The object is created but not initiated, that would be your job.

Parameters:
name - The name of the model to mock
clearMethods - If true, all methods in the target mock object will be removed. You can then mock only the methods that you want to mock

getMockPlugin

private any getMockPlugin(string path)
Get a plugin mocked with capabilities

Parameters:
path - The path of the plugin to mock

getMockRequestBuffer

private RequestBuffer getMockRequestBuffer()
I will return to you a mock request buffer object used mostly in interceptor calls


getMockRequestContext

private RequestContext getMockRequestContext([boolean clearMethods='false'], [any decorator])
Builds an empty functioning request context mocked with methods via MockBox. You can also optionally wipe all methods on it.

Parameters:
clearMethods - Clear Methods on it?
decorator - The class path to the decorator to build into the mock request context

getModel

private any getModel([any name], [any dsl], [any<struct> initArguments='[runtime expression]'])
Create or retrieve model objects by convention

Parameters:
name - The mapping name or CFC instance path to try to build up
dsl - The dsl string to use to retrieve the instance model object, mutually exclusive with 'name'
initArguments - The constructor structure of arguments to passthrough when initializing the instance

getRequestContext

private any getRequestContext()
Get a reference to the current mock request context


getUtil

private Util getUtil()
Create and return a util object


getWireBox

private any getWireBox()
Get the wirebox instance


metadataInspection

private void metadataInspection()
Inspect test case for annotations


querySim

private query querySim(string queryData)
Query Simulator

Parameters:
queryData - The data to create queries

reset

private void reset()
Reset the persistence of the unit test coldbox app, basically removes the controller from application scope


setAppMapping

private void setAppMapping(string AppMapping)
Set the AppMapping for this test case

Parameters:
AppMapping

setColdboxAppKey

private void setColdboxAppKey(string coldboxAppKey)
Override the coldboxAppKey, used to store the coldbox controller in application scope.

Parameters:
coldboxAppKey

setConfigMapping

private void setConfigMapping(string ConfigMapping)
Set the ConfigMapping for this test case

Parameters:
ConfigMapping

setup

public any setup()
This executes before any test method for integration tests.


setupRequest

private void setupRequest(string event)
Setup an initial request capture. I basically look at the FORM/URL scopes and create the request collection out of them.

Parameters:
event - The event to setup the request context with

ColdBox Platform Version 3.7.0