org.virtualmock
Class VM

java.lang.Object
  extended byorg.virtualmock.VM

public class VM
extends java.lang.Object

The main interface to the VirtualMock runtime system. The unit test class makes method calls to this class to perform VirtualMock tasks.

Version:
$Revision: 1.82 $
Author:
Chad Woolley

Field Summary
static AlwaysMatcher ALWAYS_MATCHER
          Predefined AlwaysMatcher.
static EqualsMatcher EQUALS_MATCHER
          Predefined EqualsMatcher.
 
Constructor Summary
VM(CallManager callManager, VerificationManager verificationManager)
          Creates a new VM object.
 
Method Summary
 void addMockClass(java.lang.Class classToMock)
          This tells VirtualMock that subsequent calls to this class will be intercepted by VirtualMock.
 junit.framework.TestCase getTestCase()
          Gets the TestCase class.
 void playbackCalls()
          Sets VirtualMock into Playback Mode (defaulting to unordered playback type).
 void recordArgMatcher(ArgMatcher argMatcher)
           Define an ArgMatcher for the last recorded call, which should only have a single argument.
 void recordArgMatchers(ArgMatcher[] argMatchers)
           Define an ArgMatcher for the last recorded call, which should have the same number of arguments as there are elements in the array that is passed in.
 void recordArgMatchers(ArgMatcher firstArgMatcher, ArgMatcher secondArgMatcher)
           Define an ArgMatcher for the last recorded call, which should only have a two arguments.
 void recordArgMatchers(ArgMatcher firstArgMatcher, ArgMatcher secondArgMatcher, ArgMatcher thirdArgMatcher)
           Define an ArgMatcher for the last recorded call, which should only have a three arguments.
 void recordException(java.lang.Throwable throwable)
          Specifies that a throwable will be thrown by the last recorded call.
 void recordReturnValue(boolean booleanValue)
          Specifies the boolean return value for the last recorded call.
 void recordReturnValue(byte byteValue)
          Specifies the byte return value for the last recorded call.
 void recordReturnValue(char charValue)
          Specifies the char return value for the last recorded call.
 void recordReturnValue(double doubleValue)
          Specifies the double return value for the last recorded call.
 void recordReturnValue(float floatValue)
          Specifies the float return value for the last recorded call.
 void recordReturnValue(int intValue)
          Specifies the int return value for the last recorded call.
 void recordReturnValue(long longValue)
          Specifies the long return value for the last recorded call.
 void recordReturnValue(java.lang.Object returnValue)
          Specifies the return value for the last recorded call.
 void recordReturnValue(short shortValue)
          Specifies the short return value for the last recorded call.
 void setTestCase(junit.framework.TestCase case1)
          Sets the TestCase class.
 void verify()
          Causes all verify-phase verifications to be performed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EQUALS_MATCHER

public static final EqualsMatcher EQUALS_MATCHER
Predefined EqualsMatcher.


ALWAYS_MATCHER

public static final AlwaysMatcher ALWAYS_MATCHER
Predefined AlwaysMatcher.

Constructor Detail

VM

public VM(CallManager callManager,
          VerificationManager verificationManager)
Creates a new VM object.

Parameters:
callManager - the CallManager to be used by this VM runtime.
verificationManager - the VerificationManager to be used by this VM runtime.
Method Detail

setTestCase

public void setTestCase(junit.framework.TestCase case1)
Sets the TestCase class.

Parameters:
case1 - the TestCase

getTestCase

public junit.framework.TestCase getTestCase()
Gets the TestCase class.

Returns:
the TestCase

addMockClass

public void addMockClass(java.lang.Class classToMock)
This tells VirtualMock that subsequent calls to this class will be intercepted by VirtualMock. This allows the "recording" of mock calls that will be expected to be called by the class under test. The recorded calls will later be matched against the actual calls that are made during the playback phase. It also allows other VirtualMock functions to be performed for the class.

Parameters:
classToMock - The class for which VirtualMock will intercept calls.

playbackCalls

public void playbackCalls()
Sets VirtualMock into Playback Mode (defaulting to unordered playback type). This means that the first matching and uninvoked call found will be played back, regardless of the order in which it was recorded.


recordArgMatcher

public void recordArgMatcher(ArgMatcher argMatcher)

Define an ArgMatcher for the last recorded call, which should only have a single argument.

This is an overloaded convenience method for setArgMatcher(ArgMatcher[]), which can be used to avoid creating an array if you only want to record a matcher for one argument.

Parameters:
argMatcher - The ArgMatcher that VirtualMock will use to verify this argument when the last recorded call is invoked.

recordArgMatchers

public void recordArgMatchers(ArgMatcher firstArgMatcher,
                              ArgMatcher secondArgMatcher)

Define an ArgMatcher for the last recorded call, which should only have a two arguments.

This is an overloaded convenience method for setArgMatcher(ArgMatcher[]), which can be used to avoid creating an array if you only want to record a matcher for two arguments.

Parameters:
firstArgMatcher - The ArgMatcher that VirtualMock will use to match the first argument when the last recorded call is invoked.
secondArgMatcher - The ArgMatcher that VirtualMock will use to match the second argument when the last recorded call is invoked.

recordArgMatchers

public void recordArgMatchers(ArgMatcher firstArgMatcher,
                              ArgMatcher secondArgMatcher,
                              ArgMatcher thirdArgMatcher)

Define an ArgMatcher for the last recorded call, which should only have a three arguments.

This is an overloaded convenience method for setArgMatcher(ArgMatcher[]), which can be used to avoid creating an array if you only want to record a matcher for three arguments.

Parameters:
firstArgMatcher - The ArgMatcher that VirtualMock will use to match the first argument when the last recorded call is invoked.
secondArgMatcher - The ArgMatcher that VirtualMock will use to match the second argument when the last recorded call is invoked.
thirdArgMatcher - The ArgMatcher that VirtualMock will use to match the third argument when the last recorded call is invoked.

recordArgMatchers

public void recordArgMatchers(ArgMatcher[] argMatchers)

Define an ArgMatcher for the last recorded call, which should have the same number of arguments as there are elements in the array that is passed in.

Parameters:
argMatchers - The array of ArgMatchers that VirtualMock will use to match the arguments when the last recorded call is invoked.

recordException

public void recordException(java.lang.Throwable throwable)
Specifies that a throwable will be thrown by the last recorded call.

Parameters:
throwable - the Throwable which the last recorded call will throw when it is invoked.

recordReturnValue

public void recordReturnValue(java.lang.Object returnValue)
Specifies the return value for the last recorded call.

Parameters:
returnValue - the value which the last recorded call will return when it is invoked.

recordReturnValue

public void recordReturnValue(int intValue)
Specifies the int return value for the last recorded call.

Parameters:
intValue - the int value which the last recorded call will return when it is invoked.

recordReturnValue

public void recordReturnValue(float floatValue)
Specifies the float return value for the last recorded call.

Parameters:
floatValue - the float value which the last recorded call will return when it is invoked.

recordReturnValue

public void recordReturnValue(double doubleValue)
Specifies the double return value for the last recorded call.

Parameters:
doubleValue - the double value which the last recorded call will return when it is invoked.

recordReturnValue

public void recordReturnValue(byte byteValue)
Specifies the byte return value for the last recorded call.

Parameters:
byteValue - the byte value which the last recorded call will return when it is invoked.

recordReturnValue

public void recordReturnValue(long longValue)
Specifies the long return value for the last recorded call.

Parameters:
longValue - the long value which the last recorded call will return when it is invoked.

recordReturnValue

public void recordReturnValue(short shortValue)
Specifies the short return value for the last recorded call.

Parameters:
shortValue - the short value which the last recorded call will return when it is invoked.

recordReturnValue

public void recordReturnValue(boolean booleanValue)
Specifies the boolean return value for the last recorded call.

Parameters:
booleanValue - the boolean value which the last recorded call will return when it is invoked.

recordReturnValue

public void recordReturnValue(char charValue)
Specifies the char return value for the last recorded call.

Parameters:
charValue - the char value which the last recorded call will return when it is invoked.

verify

public void verify()
Causes all verify-phase verifications to be performed.



Copyright © 2003-2005 Virtual Mock. All Rights Reserved.