jdave.mock
Class MockSupport

java.lang.Object
  extended by jdave.ContainmentSupport
      extended by jdave.mock.MockSupport
Direct Known Subclasses:
Specification

public class MockSupport
extends ContainmentSupport

Note, most of these methods are copied from jmock MockObjectTestCase. We do not want to derive from junit's TestCase as MockObjectTestCase does.

Author:
Joni Freeman

Constructor Summary
protected MockSupport()
           
 
Method Summary
 void checking(org.jmock.internal.ExpectationBuilder expectations)
          Specify expectations upon the mock objects in the test.
<T> T
dummy(java.lang.Class<T> typeToMock)
          Create a dummy mock object of type T with a name derived from its type.
<T> T
dummy(java.lang.Class<T> typeToMock, java.lang.String name)
          Create a dummy mock object of type T with a name derived from its type.
<T> T
mock(java.lang.Class<T> typeToMock)
          Create a mock object of type T with a name derived from its type.
<T> T
mock(java.lang.Class<T> typeToMock, java.lang.String name)
          Create a mock object of type T with an explicit name.
 org.jmock.Mockery mockery()
           
 org.jmock.Sequence sequence(java.lang.String name)
          Returns a new sequence that is used to constrain the order in which expectations can occur.
 void setDefaultResultForType(java.lang.Class<?> type, java.lang.Object result)
          Sets the result returned for the given type when no return value has been explicitly specified in the expectation.
 org.jmock.States states(java.lang.String name)
          Returns a new state machine that is used to constrain the order in which expectations can occur.
 void verifyMocks()
           
 
Methods inherited from class jdave.ContainmentSupport
contain, containAll, containAll, containAll, containAll, containAll, containAll, containAll, containAll, containAll, containAll, containAny, containAny, containAny, containAny, containAny, containAny, containAny, containAny, containAny, containAny, containExactly, containExactly, containExactly, containExactly, containExactly, containExactly, containExactly, containExactly, containExactly, containExactly, containInOrder, containInOrder, containInOrder, containInOrder, containInOrder, containInOrder, containInOrder, containInOrder, containInOrder, containInOrder, containInPartialOrder, containInPartialOrder, containInPartialOrder, containInPartialOrder, containInPartialOrder, containInPartialOrder, containInPartialOrder, containInPartialOrder, containInPartialOrder, containInPartialOrder, contains, containsAll, containsAll, containsAll, containsAll, containsAll, containsAll, containsAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, containsAny, containsAny, containsAny, containsAny, containsAny, containsAny, containsAny, containsExactly, containsExactly, containsExactly, containsExactly, containsExactly, containsExactly, containsExactly, containsExactly, containsExactly, containsExactly, containsInOrder, containsInOrder, containsInOrder, containsInOrder, containsInOrder, containsInOrder, containsInOrder, containsInOrder, containsInOrder, containsInOrder, containsInPartialOrder, containsInPartialOrder, containsInPartialOrder, containsInPartialOrder, containsInPartialOrder, containsInPartialOrder, containsInPartialOrder, containsInPartialOrder, containsInPartialOrder, containsInPartialOrder, newAllContainment, newAllContainment, newAllContainment, newAnyContainment, newAnyContainment, newAnyContainment, newExactContainment, newExactContainment, newExactContainment, newInOrderContainment, newInOrderContainment, newInOrderContainment, newInPartialOrderContainment, newInPartialOrderContainment, newInPartialOrderContainment, newObjectContainment
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockSupport

protected MockSupport()
Method Detail

mockery

public org.jmock.Mockery mockery()

verifyMocks

public void verifyMocks()

setDefaultResultForType

public void setDefaultResultForType(java.lang.Class<?> type,
                                    java.lang.Object result)
Sets the result returned for the given type when no return value has been explicitly specified in the expectation.

Parameters:
type - The type for which to return result.
result - The value to return when a method of return type type is invoked for which an explicit return value has has not been specified.

checking

public void checking(org.jmock.internal.ExpectationBuilder expectations)
Specify expectations upon the mock objects in the test.


mock

public <T> T mock(java.lang.Class<T> typeToMock,
                  java.lang.String name)
Create a mock object of type T with an explicit name.

Parameters:
typeToMock - The type to be mocked
name - The name of the new mock object that is used to identify the mock object in error messages
Returns:
A new mock object of type

mock

public <T> T mock(java.lang.Class<T> typeToMock)
Create a mock object of type T with a name derived from its type.

Parameters:
typeToMock - The type to be mocked
Returns:
A new mock object of type

dummy

public <T> T dummy(java.lang.Class<T> typeToMock,
                   java.lang.String name)
Create a dummy mock object of type T with a name derived from its type. All method invocations of dummy are ignored.

Parameters:
typeToMock - The type to be mocked
name - The name of the new mock object that is used to identify the mock object in error messages
Returns:
A new dummy mock object of type

dummy

public <T> T dummy(java.lang.Class<T> typeToMock)
Create a dummy mock object of type T with a name derived from its type. All method invocations of dummy are ignored.

Parameters:
typeToMock - The type to be mocked
Returns:
A new dummy mock object of type

sequence

public org.jmock.Sequence sequence(java.lang.String name)
Returns a new sequence that is used to constrain the order in which expectations can occur.

Parameters:
name - The name of the sequence.
Returns:
A new sequence with the given name.

states

public org.jmock.States states(java.lang.String name)
Returns a new state machine that is used to constrain the order in which expectations can occur.

Parameters:
name - The name of the state machine.
Returns:
A new state machine with the given name.


Copyright © 2008. All Rights Reserved.