|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--junit.framework.Assert | +--junit.framework.TestCase | +--org.apache.hivemind.test.HiveMindTestCase
Contains some support for creating HiveMind tests; this is useful enough that has been moved into the main framework, to simplify creation of tests in the dependent libraries.
Field Summary | |
protected org.apache.hivemind.test.StoreAppender |
_appender
|
protected java.lang.String |
_interceptedLoggerName
|
Constructor Summary | |
HiveMindTestCase()
|
Method Summary | |
protected void |
addControl(org.easymock.MockControl control)
Adds the control to the list of managed controls used by replayControls() and verifyControls() . |
protected void |
assertExceptionRegexp(java.lang.Throwable ex,
java.lang.String pattern)
Checks that the message for an exception matches a regular expression. |
protected void |
assertExceptionSubstring(java.lang.Throwable ex,
java.lang.String substring)
Checks that the provided substring exists in the exceptions message. |
protected static void |
assertListsEqual(java.lang.Object[] expected,
java.util.List actual)
Converts the actual list to an array and invokes assertListsEqual(Object[], Object[]) . |
protected static void |
assertListsEqual(java.lang.Object[] expected,
java.lang.Object[] actual)
Asserts that the two arrays are equal; same length and all elements equal. |
protected void |
assertLoggedMessage(java.lang.String message)
Asserts that some capture log event matches the given message exactly. |
protected void |
assertLoggedMessage(java.lang.String message,
java.util.List events)
Asserts that some capture log event matches the given message exactly. |
protected void |
assertLoggedMessagePattern(java.lang.String pattern)
|
protected void |
assertLoggedMessagePattern(java.lang.String pattern,
java.util.List events)
|
protected void |
assertLoggedMessages(java.lang.String[] messages)
Checks the messages for all logged events for exact match against the supplied list. |
protected Registry |
buildFrameworkRegistry(java.lang.String file)
Convienience method for invoking buildFrameworkRegistry(String[]) with only a single file. |
protected Registry |
buildFrameworkRegistry(java.lang.String[] files)
Builds a minimal registry, containing only the specified files, plus the master module descriptor (i.e., those visible on the classpath). |
protected Registry |
buildMinimalRegistry(Resource l)
Builds a registry from exactly the provided resource; this registry will not include the hivemind module. |
protected Location |
fabricateLocation(int line)
|
protected java.lang.Throwable |
findNestedException(ApplicationRuntimeException ex)
Digs down through (potentially) a stack of ApplicationRuntimeExceptions until it reaches the originating exception, which is returned. |
protected java.util.List |
getInterceptedLogEvents()
Gets the list of events most recently intercepted. |
protected Resource |
getResource(java.lang.String file)
Returns the given file as a Resource from the classpath. |
protected void |
interceptLogging(java.lang.String loggerName)
Sets up a StoreAppender to intercept logging for the specified
logger. |
protected boolean |
matches(java.lang.String input,
java.lang.String pattern)
|
protected org.easymock.MockControl |
newControl(java.lang.Class mockClass)
Creates a managed control via MockControl.createStrictControl(java.lang.Class) . |
protected java.lang.Object |
newMock(java.lang.Class mockClass)
Convienience for invoking newControl(Class) and then
invoking MockControl.getMock() on the result. |
protected void |
replayControls()
Invokes MockControl.replay() on all controls
created by newControl(Class) . |
protected void |
resetControls()
Invokes MockControl.reset() on all
controls. |
protected void |
tearDown()
Removes the StoreAppender that may have been setup by
interceptLogging(String) . |
protected static void |
unreachable()
Called when code should not be reachable (because a test is expected to throw an exception); throws AssertionFailedError always. |
protected void |
verifyControls()
Invokes MockControl.verify() on all
controls created by newControl(Class) . |
Methods inherited from class junit.framework.TestCase |
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, 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 |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.lang.String _interceptedLoggerName
protected org.apache.hivemind.test.StoreAppender _appender
Constructor Detail |
public HiveMindTestCase()
Method Detail |
protected Resource getResource(java.lang.String file)
Resource
from the classpath. Typically,
this is to find files in the same folder as the invoking class.
protected static void assertListsEqual(java.lang.Object[] expected, java.util.List actual)
assertListsEqual(Object[], Object[])
.
protected static void assertListsEqual(java.lang.Object[] expected, java.lang.Object[] actual)
protected static void unreachable()
protected void interceptLogging(java.lang.String loggerName)
StoreAppender
to intercept logging for the specified
logger. Captured log events can be recovered via
getInterceptedLogEvents()
.
protected java.util.List getInterceptedLogEvents()
StoreAppender
(it clears its list of log events).
interceptLogging(String)
,
StoreAppender#getEvents()
protected void tearDown() throws java.lang.Exception
StoreAppender
that may have been setup by
interceptLogging(String)
.
tearDown
in class junit.framework.TestCase
java.lang.Exception
protected void assertExceptionSubstring(java.lang.Throwable ex, java.lang.String substring)
protected void assertExceptionRegexp(java.lang.Throwable ex, java.lang.String pattern) throws java.lang.Exception
java.lang.Exception
protected java.lang.Throwable findNestedException(ApplicationRuntimeException ex)
protected void assertLoggedMessages(java.lang.String[] messages)
protected void assertLoggedMessage(java.lang.String message)
protected void assertLoggedMessage(java.lang.String message, java.util.List events)
message
- to search for; success is finding a logged message contain the parameter as a substringevents
- from getInterceptedLogEvents()
protected void assertLoggedMessagePattern(java.lang.String pattern) throws java.lang.Exception
java.lang.Exception
protected void assertLoggedMessagePattern(java.lang.String pattern, java.util.List events) throws java.lang.Exception
java.lang.Exception
protected Registry buildFrameworkRegistry(java.lang.String file) throws java.lang.Exception
buildFrameworkRegistry(String[])
with only a single file.
java.lang.Exception
protected Registry buildFrameworkRegistry(java.lang.String[] files) throws java.lang.Exception
getResource(String)
.
java.lang.Exception
protected Registry buildMinimalRegistry(Resource l) throws java.lang.Exception
hivemind
module.
java.lang.Exception
protected org.easymock.MockControl newControl(java.lang.Class mockClass)
MockControl.createStrictControl(java.lang.Class)
.
The created control is remembered, and will be
invoked by replayControls()
,
verifyControls()
, etc..
protected void addControl(org.easymock.MockControl control)
replayControls()
and verifyControls()
.
protected java.lang.Object newMock(java.lang.Class mockClass)
newControl(Class)
and then
invoking MockControl.getMock()
on the result.
protected void replayControls()
MockControl.replay()
on all controls
created by newControl(Class)
.
protected void verifyControls()
MockControl.verify()
on all
controls created by newControl(Class)
.
protected void resetControls()
MockControl.reset()
on all
controls.
protected Location fabricateLocation(int line)
protected boolean matches(java.lang.String input, java.lang.String pattern) throws java.lang.Exception
java.lang.Exception
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |