org.easymock
Class MockControl<T>

java.lang.Object
  extended by org.easymock.MockControl<T>
Type Parameters:
T - type of the mock controlled
All Implemented Interfaces:
java.io.Serializable

Deprecated. Since EasyMock 2.0, static methods on EasyMock are used to create and control mock objects.

@Deprecated
public class MockControl<T>
extends java.lang.Object
implements java.io.Serializable

A MockControl object controls the behavior of its associated mock object. For more information, see the EasyMock documentation.

See Also:
Serialized Form

Field Summary
static ArgumentsMatcher ALWAYS_MATCHER
          Deprecated. Matches always.
static ArgumentsMatcher ARRAY_MATCHER
          Deprecated. Matches if each expected argument is equal to the corresponding actual argument for non-array arguments; array arguments are compared with the appropriate java.util.Arrays.equals() -method.
static ArgumentsMatcher EQUALS_MATCHER
          Deprecated. Matches if each expected argument is equal to the corresponding actual argument.
static org.easymock.internal.Range ONE
          Deprecated. Exactly one call.
static org.easymock.internal.Range ONE_OR_MORE
          Deprecated. One or more calls.
static org.easymock.internal.Range ZERO_OR_MORE
          Deprecated. Zero or more calls.
 
Constructor Summary
protected MockControl(org.easymock.internal.MocksControl ctrl, java.lang.Class<T> toMock)
          Deprecated.  
 
Method Summary
static
<T> MockControl<T>
createControl(java.lang.Class<T> toMock)
          Deprecated. Creates a mock control object for the specified interface.
static
<T> MockControl<T>
createNiceControl(java.lang.Class<T> toMock)
          Deprecated. Creates a mock control object for the specified interface.
static
<T> MockControl<T>
createStrictControl(java.lang.Class<T> toMock)
          Deprecated. Creates a mock control object for the specified interface.
<V1,V2 extends V1>
void
expectAndDefaultReturn(V1 ignored, V2 value)
          Deprecated. Same as setDefaultReturnValue(Object).
 void expectAndDefaultThrow(java.lang.Object ignored, java.lang.Throwable throwable)
          Deprecated. Same as setDefaultThrowable(Throwable).
 void expectAndReturn(int ignored, int value)
          Deprecated.  
 void expectAndReturn(int ignored, int value, int count)
          Deprecated.  
 void expectAndReturn(int ignored, int value, int min, int max)
          Deprecated.  
 void expectAndReturn(int ignored, int value, org.easymock.internal.Range range)
          Deprecated.  
<V1,V2 extends V1>
void
expectAndReturn(V1 ignored, V2 value)
          Deprecated. Same as setReturnValue(Object).
<V1,V2 extends V1>
void
expectAndReturn(V1 ignored, V2 value, int count)
          Deprecated. Same as setReturnValue(Object, int).
<V1,V2 extends V1>
void
expectAndReturn(V1 ignored, V2 value, int min, int max)
          Deprecated. Same as setReturnValue(Object, int, int).
<V1,V2 extends V1>
void
expectAndReturn(V1 ignored, V2 value, org.easymock.internal.Range range)
          Deprecated. Same as setReturnValue(Object, Range).
 void expectAndThrow(java.lang.Object ignored, java.lang.Throwable throwable)
          Deprecated. Same as setThrowable(Throwable).
 void expectAndThrow(java.lang.Object ignored, java.lang.Throwable throwable, int count)
          Deprecated. Same as setThrowable(Throwable, int).
 void expectAndThrow(java.lang.Object ignored, java.lang.Throwable throwable, int min, int max)
          Deprecated. Same as setThrowable(Throwable, int, int).
 void expectAndThrow(java.lang.Object ignored, java.lang.Throwable throwable, org.easymock.internal.Range range)
          Deprecated. Same as setThrowable(Throwable, Range).
 T getMock()
          Deprecated. Returns the mock object.
 void replay()
          Deprecated. Switches the mock object from record state to replay state.
 void reset()
          Deprecated. Resets the mock control and the mock object to the state directly after creation.
 void setDefaultMatcher(ArgumentsMatcher matcher)
          Deprecated. Sets the default ArgumentsMatcher for all methods of the mock object.
 void setDefaultReturnValue(java.lang.Object value)
          Deprecated. Records that the mock object will by default allow the last method specified by a method call, and will react by returning the provided return value.
 void setDefaultThrowable(java.lang.Throwable throwable)
          Deprecated. Records that the mock object will by default allow the last method specified by a method call, and will react by throwing the provided Throwable.
 void setDefaultVoidCallable()
          Deprecated. Records that the mock object will by default allow the last method specified by a method call.
 void setMatcher(ArgumentsMatcher matcher)
          Deprecated. Sets the ArgumentsMatcher for the last method called on the mock object.
 void setReturnValue(java.lang.Object value)
          Deprecated. Records that the mock object will expect the last method call once, and will react by returning the provided return value.
 void setReturnValue(java.lang.Object value, int times)
          Deprecated. Records that the mock object will expect the last method call a fixed number of times, and will react by returning the provided return value.
 void setReturnValue(java.lang.Object value, int minCount, int maxCount)
          Deprecated. Records that the mock object will expect the last method call between minCount and maxCount times, and will react by returning the provided return value.
 void setReturnValue(java.lang.Object value, org.easymock.internal.Range range)
          Deprecated. Records that the mock object will expect the last method call a fixed number of times, and will react by returning the provided return value.
 void setThrowable(java.lang.Throwable throwable)
          Deprecated. Records that the mock object will expect the last method call once, and will react by throwing the provided Throwable.
 void setThrowable(java.lang.Throwable throwable, int times)
          Deprecated. Records that the mock object will expect the last method call a fixed number of times, and will react by throwing the provided Throwable.
 void setThrowable(java.lang.Throwable throwable, int minCount, int maxCount)
          Deprecated. Records that the mock object will expect the last method call between minCount and maxCount times, and will react by throwing the provided Throwable.
 void setThrowable(java.lang.Throwable throwable, org.easymock.internal.Range range)
          Deprecated.  
 void setVoidCallable()
          Deprecated. Records that the mock object will expect the last method call once, and will react by returning silently.
 void setVoidCallable(int times)
          Deprecated. Records that the mock object will expect the last method call a fixed number of times, and will react by returning silently.
 void setVoidCallable(int minCount, int maxCount)
          Deprecated. Records that the mock object will expect the last method call between minCount and maxCount times, and will react by returning silently.
 void setVoidCallable(org.easymock.internal.Range range)
          Deprecated.  
 void verify()
          Deprecated. Verifies that all expectations have been met.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ONE

public static final org.easymock.internal.Range ONE
Deprecated. 
Exactly one call.


ONE_OR_MORE

public static final org.easymock.internal.Range ONE_OR_MORE
Deprecated. 
One or more calls.


ZERO_OR_MORE

public static final org.easymock.internal.Range ZERO_OR_MORE
Deprecated. 
Zero or more calls.


EQUALS_MATCHER

public static final ArgumentsMatcher EQUALS_MATCHER
Deprecated. 
Matches if each expected argument is equal to the corresponding actual argument.


ALWAYS_MATCHER

public static final ArgumentsMatcher ALWAYS_MATCHER
Deprecated. 
Matches always.


ARRAY_MATCHER

public static final ArgumentsMatcher ARRAY_MATCHER
Deprecated. 
Matches if each expected argument is equal to the corresponding actual argument for non-array arguments; array arguments are compared with the appropriate java.util.Arrays.equals() -method.

Constructor Detail

MockControl

protected MockControl(org.easymock.internal.MocksControl ctrl,
                      java.lang.Class<T> toMock)
Deprecated. 
Method Detail

createControl

public static <T> MockControl<T> createControl(java.lang.Class<T> toMock)
Deprecated. 
Creates a mock control object for the specified interface. The MockControl and its associated mock object will not check the order of expected method calls. An unexpected method call on the mock object will lead to an AssertionError.

Type Parameters:
T - type of the mock controlled
Parameters:
toMock - the class of the interface to mock.
Returns:
the mock control.

createStrictControl

public static <T> MockControl<T> createStrictControl(java.lang.Class<T> toMock)
Deprecated. 
Creates a mock control object for the specified interface. The MockControl and its associated mock object will check the order of expected method calls. An unexpected method call on the mock object will lead to an AssertionError.

Type Parameters:
T - type of the mock controlled
Parameters:
toMock - the class of the interface to mock.
Returns:
the mock control.

createNiceControl

public static <T> MockControl<T> createNiceControl(java.lang.Class<T> toMock)
Deprecated. 
Creates a mock control object for the specified interface. The MockControl and its associated mock object will not check the order of expected method calls. An unexpected method call on the mock object will return an empty value (0, null, false).

Type Parameters:
T - type of the mock controlled
Parameters:
toMock - the class of the interface to mock.
Returns:
the mock control.

getMock

public T getMock()
Deprecated. 
Returns the mock object.

Returns:
the mock object of this control

reset

public final void reset()
Deprecated. 
Resets the mock control and the mock object to the state directly after creation.


replay

public void replay()
Deprecated. 
Switches the mock object from record state to replay state. For more information, see the EasyMock documentation.

Throws:
java.lang.IllegalStateException - if the mock object already is in replay state.

verify

public void verify()
Deprecated. 
Verifies that all expectations have been met. For more information, see the EasyMock documentation.

Throws:
java.lang.IllegalStateException - if the mock object is in record state.
java.lang.AssertionError - if any expectation has not been met.

setVoidCallable

public void setVoidCallable()
Deprecated. 
Records that the mock object will expect the last method call once, and will react by returning silently.

Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before, or if the last method called on the mock was no void method.

setThrowable

public void setThrowable(java.lang.Throwable throwable)
Deprecated. 
Records that the mock object will expect the last method call once, and will react by throwing the provided Throwable.

Parameters:
throwable - the Throwable to throw.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state or if no method was called on the mock object before.
java.lang.IllegalArgumentException - if the last method called on the mock cannot throw the provided Throwable.
java.lang.NullPointerException - if throwable is null.

setReturnValue

public void setReturnValue(java.lang.Object value)
Deprecated. 
Records that the mock object will expect the last method call once, and will react by returning the provided return value.

Parameters:
value - the return value.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return boolean.

setVoidCallable

public void setVoidCallable(int times)
Deprecated. 
Records that the mock object will expect the last method call a fixed number of times, and will react by returning silently.

Parameters:
times - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before, or if the last method called on the mock was no void method.

setThrowable

public void setThrowable(java.lang.Throwable throwable,
                         int times)
Deprecated. 
Records that the mock object will expect the last method call a fixed number of times, and will react by throwing the provided Throwable.

Parameters:
throwable - the Throwable to throw.
times - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state or if no method was called on the mock object before.
java.lang.IllegalArgumentException - if the last method called on the mock cannot throw the provided Throwable.
java.lang.NullPointerException - if throwable is null.

setReturnValue

public void setReturnValue(java.lang.Object value,
                           int times)
Deprecated. 
Records that the mock object will expect the last method call a fixed number of times, and will react by returning the provided return value.

Parameters:
value - the return value.
times - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return boolean.

setReturnValue

public void setReturnValue(java.lang.Object value,
                           org.easymock.internal.Range range)
Deprecated. 
Records that the mock object will expect the last method call a fixed number of times, and will react by returning the provided return value.

Parameters:
value - the return value.
range - the number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return boolean.

setDefaultVoidCallable

public void setDefaultVoidCallable()
Deprecated. 
Records that the mock object will by default allow the last method specified by a method call.

Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before, or if the last method called on the mock was no void method.

setDefaultThrowable

public void setDefaultThrowable(java.lang.Throwable throwable)
Deprecated. 
Records that the mock object will by default allow the last method specified by a method call, and will react by throwing the provided Throwable.

Parameters:
throwable - throwable the throwable to be thrown
Throws:
java.lang.IllegalArgumentException - if the last method called on the mock cannot throw the provided Throwable.
java.lang.NullPointerException - if throwable is null.
java.lang.IllegalStateException - if the mock object is in replay state, or if no method was called on the mock object before.

setDefaultReturnValue

public void setDefaultReturnValue(java.lang.Object value)
Deprecated. 
Records that the mock object will by default allow the last method specified by a method call, and will react by returning the provided return value.

Parameters:
value - the return value.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return boolean.

setMatcher

public void setMatcher(ArgumentsMatcher matcher)
Deprecated. 
Sets the ArgumentsMatcher for the last method called on the mock object. The matcher must be set before any behavior for the method is defined.

Parameters:
matcher - the matcher for the last method called
Throws:
java.lang.IllegalStateException - if called in replay state, or if no method was called on the mock object before.

setVoidCallable

public void setVoidCallable(int minCount,
                            int maxCount)
Deprecated. 
Records that the mock object will expect the last method call between minCount and maxCount times, and will react by returning silently.

Parameters:
minCount - the minimum number of times that the call is expected.
maxCount - the maximum number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before, or if the last method called on the mock was no void method.

setVoidCallable

public void setVoidCallable(org.easymock.internal.Range range)
Deprecated. 

setThrowable

public void setThrowable(java.lang.Throwable throwable,
                         int minCount,
                         int maxCount)
Deprecated. 
Records that the mock object will expect the last method call between minCount and maxCount times, and will react by throwing the provided Throwable.

Parameters:
throwable - the Throwable to throw.
minCount - the minimum number of times that the call is expected.
maxCount - the maximum number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state or if no method was called on the mock object before.
java.lang.IllegalArgumentException - if the last method called on the mock cannot throw the provided Throwable.
java.lang.NullPointerException - if throwable is null.

setThrowable

public void setThrowable(java.lang.Throwable throwable,
                         org.easymock.internal.Range range)
Deprecated. 

setReturnValue

public void setReturnValue(java.lang.Object value,
                           int minCount,
                           int maxCount)
Deprecated. 
Records that the mock object will expect the last method call between minCount and maxCount times, and will react by returning the provided return value.

Parameters:
value - the return value.
minCount - the minimum number of times that the call is expected.
maxCount - the maximum number of times that the call is expected.
Throws:
java.lang.IllegalStateException - if the mock object is in replay state, if no method was called on the mock object before. or if the last method called on the mock does not return boolean.

setDefaultMatcher

public void setDefaultMatcher(ArgumentsMatcher matcher)
Deprecated. 
Sets the default ArgumentsMatcher for all methods of the mock object. The matcher must be set before any behavior is defined on the mock object.

Parameters:
matcher - the default matcher for this control
Throws:
java.lang.IllegalStateException - if called in replay state, or if any behavior is already defined on the mock object.

expectAndReturn

public <V1,V2 extends V1> void expectAndReturn(V1 ignored,
                                               V2 value)
Deprecated. 
Same as setReturnValue(Object). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Type Parameters:
V1 - mocked method return type
V2 - returned value type
Parameters:
ignored - an ignored value.
value - value returned by the mock

expectAndReturn

public void expectAndReturn(int ignored,
                            int value)
Deprecated. 

expectAndReturn

public <V1,V2 extends V1> void expectAndReturn(V1 ignored,
                                               V2 value,
                                               org.easymock.internal.Range range)
Deprecated. 
Same as setReturnValue(Object, Range). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Type Parameters:
V1 - mocked method return type
V2 - returned value type
Parameters:
ignored - an ignored value.
value - value returned by the mock
range - range of number of calls

expectAndReturn

public void expectAndReturn(int ignored,
                            int value,
                            org.easymock.internal.Range range)
Deprecated. 

expectAndReturn

public <V1,V2 extends V1> void expectAndReturn(V1 ignored,
                                               V2 value,
                                               int count)
Deprecated. 
Same as setReturnValue(Object, int). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Type Parameters:
V1 - mocked method return type
V2 - returned value type
Parameters:
ignored - an ignored value.
value - value returned by the mock
count - number of times the call is expected

expectAndReturn

public void expectAndReturn(int ignored,
                            int value,
                            int count)
Deprecated. 

expectAndReturn

public <V1,V2 extends V1> void expectAndReturn(V1 ignored,
                                               V2 value,
                                               int min,
                                               int max)
Deprecated. 
Same as setReturnValue(Object, int, int). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Type Parameters:
V1 - mocked method return type
V2 - returned value type
Parameters:
ignored - an ignored value.
value - value returned by the mock
min - minimum number of times the call is expected
max - maximum number of times the call is expected

expectAndReturn

public void expectAndReturn(int ignored,
                            int value,
                            int min,
                            int max)
Deprecated. 

expectAndThrow

public void expectAndThrow(java.lang.Object ignored,
                           java.lang.Throwable throwable)
Deprecated. 
Same as setThrowable(Throwable). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.
throwable - to be thrown on the call

expectAndThrow

public void expectAndThrow(java.lang.Object ignored,
                           java.lang.Throwable throwable,
                           org.easymock.internal.Range range)
Deprecated. 
Same as setThrowable(Throwable, Range). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.
throwable - to be thrown on the call
range - range of number of calls

expectAndThrow

public void expectAndThrow(java.lang.Object ignored,
                           java.lang.Throwable throwable,
                           int count)
Deprecated. 
Same as setThrowable(Throwable, int). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.
throwable - to be thrown on the call
count - number of times the call is expected

expectAndThrow

public void expectAndThrow(java.lang.Object ignored,
                           java.lang.Throwable throwable,
                           int min,
                           int max)
Deprecated. 
Same as setThrowable(Throwable, int, int). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.
throwable - to be thrown on the call
min - minimum number of times the call is expected
max - maximum number of times the call is expected

expectAndDefaultReturn

public <V1,V2 extends V1> void expectAndDefaultReturn(V1 ignored,
                                                      V2 value)
Deprecated. 
Same as setDefaultReturnValue(Object). For explanation, see "Convenience Methods for Return Values" in the EasyMock documentation.

Type Parameters:
V1 - mocked method return type
V2 - returned value type
Parameters:
ignored - an ignored value.
value - value returned by the mock

expectAndDefaultThrow

public void expectAndDefaultThrow(java.lang.Object ignored,
                                  java.lang.Throwable throwable)
Deprecated. 
Same as setDefaultThrowable(Throwable). For explanation, see "Convenience Methods for Throwables" in the EasyMock documentation.

Parameters:
ignored - an ignored value.
throwable - to be thrown on the call


Copyright © 2001-2009 OFFIS, Tammo Freese, Henri Tremblay. This documentation is provided under the terms of the Apache 2 licence.