com.hammingweight.hammock
Class AMockObject

java.lang.Object
  extended by com.hammingweight.hammock.AMockObject
All Implemented Interfaces:
IHammockExceptionErrors, IMockObject
Direct Known Subclasses:
MockAuthenticator, MockBinaryMessage, MockChoice, MockClientSession, MockCommandListener, MockCommConnection, MockConnection, MockContact, MockContactList, MockContentConnection, MockContentHandler, MockContentHandlerServer, MockControl, MockControllable, MockDatagram, MockDataInput, MockDataOutput, MockEvent, MockEventList, MockFileConnection, MockFileSystemListener, MockFramePositioningControl, MockGUIControl, MockHeaderSet, MockHttpConnection, MockHttpsConnection, MockInputConnection, MockItemCommandListener, MockItemStateListener, MockKvmSerializable, MockLocationListener, MockMarshal, MockMessage, MockMessageConnection, MockMessageListener, MockMetaDataControl, MockMIDIControl, MockMultipartMessage, MockOperation, MockOutputConnection, MockPIMItem, MockPIMList, MockPitchControl, MockPlayer, MockPlayerListener, MockProximityListener, MockRateControl, MockRecordControl, MockRequestListener, MockResponseListener, MockSecureConnection, MockSecurityInfo, MockServerSocketConnection, MockServiceConnection, MockSessionNotifier, MockSocketConnection, MockSourceStream, MockStopTimeControl, MockStreamConnection, MockStreamConnectionNotifier, MockTempoControl, MockTextMessage, MockTimeBase, MockToDo, MockToDoList, MockToneControl, MockUDPDatagramConnection, MockVideoControl, MockVolumeControl

public abstract class AMockObject
extends java.lang.Object
implements IMockObject, IHammockExceptionErrors

The AMockObject class is extended by mock objects so that they can use the Hammock framework.

Since:
Hammock 1.0
Author:
C.A. Meijer

Field Summary
 
Fields inherited from interface com.hammingweight.hammock.IHammockExceptionErrors
ARGUMENT_MATCHER_ALREADY_SET, CANT_SET_VOID_RETURN_VALUE, CLASS_IS_NOT_THROWABLE, DOES_NOT_SUBCLASS_MOCK_OBJECT, HANDLER_NOT_SET, INCORRECT_MOCK_OBJECT, INCORRECT_RETURN_CLASS, INCORRECT_THROWABLE_CLASS, METHOD_CANNOT_BE_EVALUATED, METHOD_INVOKED_OUT_OF_SEQUENCE, METHOD_INVOKED_TOO_MANY_TIMES, METHOD_INVOKED_UNEXPECTED_NUMBER_OF_TIMES, NO_RETURN_VALUE, NO_RETURN_VALUE_SET, NUM_INVOCATIONS_ALREADY_SET, RETURN_VALUE_ALREADY_SET, WRONG_ARGUMENT_CLASS, WRONG_NUMBER_OF_ARGS
 
Constructor Summary
AMockObject()
           
 
Method Summary
static void assertReturnNotNull(MockMethod method, java.lang.Object returnValue)
          A convenience method that verifies that a value isn't null and throws a HammockException if it is.
 IInvocationHandler getInvocationHandler()
          Returns the invocation handler associated with this object.
 void setInvocationHandler(IInvocationHandler handler)
          Sets the invocation handler associated with this object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AMockObject

public AMockObject()
Method Detail

getInvocationHandler

public IInvocationHandler getInvocationHandler()
Returns the invocation handler associated with this object.

Specified by:
getInvocationHandler in interface IMockObject
Returns:
The invocation handler.
Throws:
HammockException - if no handler has been set.

setInvocationHandler

public void setInvocationHandler(IInvocationHandler handler)
Sets the invocation handler associated with this object.

Specified by:
setInvocationHandler in interface IMockObject
Parameters:
handler - The invocation handler to be used by the mock object.
Throws:
HammockException - if a handler has already been set.

assertReturnNotNull

public static final void assertReturnNotNull(MockMethod method,
                                             java.lang.Object returnValue)
A convenience method that verifies that a value isn't null and throws a HammockException if it is. This method is used to check that methods that return a primitive value don't try to return null which is valid only as a value for an Object reference and not a primitive type.

Parameters:
method - The method that is checking that a return value is not null.
returnValue - the return value to be checked.