org.unitils.mock.core
Class PartialMockObject<T>

java.lang.Object
  extended by org.unitils.mock.core.MockObject<T>
      extended by org.unitils.mock.core.PartialMockObject<T>
All Implemented Interfaces:
ObjectToInjectHolder<T>, MockFactory, Mock<T>, PartialMock<T>

public class PartialMockObject<T>
extends MockObject<T>
implements PartialMock<T>

Implementation of a PartialMock.

Author:
Filip Neven, Tim Ducheyne, Kenny Claes

Field Summary
 
Fields inherited from class org.unitils.mock.core.MockObject
alwaysMatchingBehaviorDefiningInvocations, matchingInvocationBuilderThreadLocal, mockedType, mockProxy, name, oneTimeMatchingBehaviorDefiningInvocations, scenarioThreadLocal
 
Constructor Summary
PartialMockObject(java.lang.String name, java.lang.Class<?> mockedClass, java.lang.Object testObject)
          Creates a mock of the given type for the given scenario.
 
Method Summary
protected  MockProxy<T> createMockProxy()
           
 
Methods inherited from class org.unitils.mock.core.MockObject
assertInvoked, assertInvokedInSequence, assertNotInvoked, createAlwaysMatchingBehaviorDefiningInvocations, createAlwaysMatchingBehaviorDefiningMatchingInvocationHandler, createAssertInvokedInSequenceVerifyingMatchingInvocationHandler, createAssertInvokedVerifyingMatchingInvocationHandler, createAssertNotInvokedVerifyingMatchingInvocationHandler, createMatchingInvocationBuilder, createMock, createOneTimeMatchingBehaviorDefiningInvocations, createOneTimeMatchingBehaviorDefiningMatchingInvocationHandler, createScenario, getCurrentScenario, getMatchingInvocationBuilder, getMock, getMockedType, getName, getObjectToInject, getObjectToInjectType, getScenario, oncePerforms, onceRaises, onceRaises, onceReturns, performs, raises, raises, resetBehavior, returns, startMatchingInvocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.unitils.mock.Mock
assertInvoked, assertInvokedInSequence, assertNotInvoked, getMock, oncePerforms, onceRaises, onceRaises, onceReturns, performs, raises, raises, resetBehavior, returns
 

Constructor Detail

PartialMockObject

public PartialMockObject(java.lang.String name,
                         java.lang.Class<?> mockedClass,
                         java.lang.Object testObject)
Creates a mock of the given type for the given scenario. There is no .class literal for generic types. Therefore you need to pass the raw type when mocking generic types. E.g. Mock<List<String>> myMock = new MockObject("myMock", List.class, this); If the mocked type does not correspond to the declared type, a ClassCastException will occur when the mock is used.

Parameters:
name - The name of the mock, e.g. the field-name, not null
mockedClass - The mock type that will be proxied, use the raw type when mocking generic types, not null
testObject - The test object, not null
Method Detail

createMockProxy

protected MockProxy<T> createMockProxy()
Overrides:
createMockProxy in class MockObject<T>


Copyright © 2009. All Rights Reserved.