Package org.apache.tapestry5.test.ioc
Class TestBase
-
- org.testng.Assert
-
- org.apache.tapestry5.test.ioc.TestUtils
-
- org.apache.tapestry5.test.ioc.TestBase
-
- Direct Known Subclasses:
IOCTestCase
public class TestBase extends TestUtils
Deprecated.In 5.4, with no replacementManages a set of EasyMock mock objects. Used as a base class for test cases. Extends fromAssert
to bring in all the public static assert methods without requiring extra imports. Provides a common mock factory method,newMock(Class)
. A single standard mock control is used for all mock objects. Standard mocks do not care about the exact order in which methods are invoked, though they are as rigorous as strict mocks when checking that parameters are the correct values. This base class is created with the intention of use within a TestNG test suite; if using JUnit, you can get the same functionality usingMockTester
. This class is thread safe (it uses a thread local to store the mock control). In theory, this should allow TestNG to execute tests in parallel. This class was originally in the tapestry-ioc module as was moved to tapestry-test; the package name was not changed to ensure backwards compatibility.- See Also:
EasyMock.createControl()
,MockTester
-
-
Constructor Summary
Constructors Constructor Description TestBase()
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
discardMockControl()
Deprecated.Discards any mock objects created during the test.protected static <T> org.easymock.IExpectationSetters<T>
expect(T value)
Deprecated.Convenience forEasyMock.expect(Object)
.protected org.easymock.IMocksControl
getMocksControl()
Deprecated.protected static <T> org.easymock.Capture<T>
newCapture()
Deprecated.A factory method to create EasyMock Capture objects.protected <T> T
<T> mockClass)
Deprecated.Creates a new mock object of the indicated type.protected void
replay()
Deprecated.Switches each mock object created bynewMock(Class)
into replay mode (out of the initial training mode).protected static void
setAnswer(org.easymock.IAnswer<?> answer)
Deprecated.Convienience forEasyMock.expectLastCall()
withIExpectationSetters.andAnswer(org.easymock.IAnswer)
.protected static void
throwable)
Deprecated.Convienience forEasyMock.expectLastCall()
withIExpectationSetters.andThrow(Throwable)
.protected void
verify()
Deprecated.Verifies that all trained methods have been invoked on all mock objects (created bynewMock(Class)
, then switches each mock object back to training mode.-
Methods inherited from class org.apache.tapestry5.test.ioc.TestUtils
assertArraysEqual, assertListsEquals, assertListsEquals, assertMessageContains, create, get, set, showLists, unreachable
-
Methods inherited from class org.testng.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEqualsNoOrder, assertEqualsNoOrder, assertFalse, assertFalse, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, fail
-
-
-
-
Constructor Detail
-
TestBase
public TestBase()
Deprecated.
-
-
Method Detail
-
getMocksControl
protected final org.easymock.IMocksControl getMocksControl()
Deprecated.- Returns:
- the
IMocksControl
for this thread.
-
discardMockControl
public final void discardMockControl()
Deprecated.Discards any mock objects created during the test.
-
newMock
protected final <T> T <T> mockClass)
Deprecated.Creates a new mock object of the indicated type. The shared mock control does not check order, but does fail on any unexpected method invocations.- Type Parameters:
T
- the type of the mock object- Parameters:
mockClass
- the class to mock- Returns:
- the mock object, ready for training
-
replay
protected final void replay()
Deprecated.Switches each mock object created bynewMock(Class)
into replay mode (out of the initial training mode).
-
verify
protected final void verify()
Deprecated.Verifies that all trained methods have been invoked on all mock objects (created bynewMock(Class)
, then switches each mock object back to training mode.
-
setThrowable
protected static void throwable)
Deprecated.Convienience forEasyMock.expectLastCall()
withIExpectationSetters.andThrow(Throwable)
.- Parameters:
throwable
- the exception to be thrown by the most recent method call on any mock
-
setAnswer
protected static void setAnswer(org.easymock.IAnswer<?> answer)
Deprecated.Convienience forEasyMock.expectLastCall()
withIExpectationSetters.andAnswer(org.easymock.IAnswer)
.- Parameters:
answer
- callback for the most recent method invocation
-
expect
protected static <T> org.easymock.IExpectationSetters<T> expect(T value)
Deprecated.Convenience forEasyMock.expect(Object)
.- Parameters:
value
- to expect- Returns:
- expectation setter, for setting return value, etc.
-
newCapture
protected static <T> org.easymock.Capture<T> newCapture()
Deprecated.A factory method to create EasyMock Capture objects.- Returns:
- new Capture
-
-