Package org.jmock.lib.legacy
Class ClassImposteriser
- java.lang.Object
-
- org.jmock.lib.legacy.ClassImposteriser
-
- All Implemented Interfaces:
Imposteriser
public class ClassImposteriser extends Object implements Imposteriser
This class lets you imposterise abstract and concrete classes without calling the constructors of the mocked class.- Author:
- npryce
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClassImposteriser.ClassWithSuperclassToWorkAroundCglibBug
-
Field Summary
Fields Modifier and Type Field Description static ImposteriserINSTANCE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanImposterise(Class<?> type)Reports if the Imposteriser is able to imposterise a given type.<T> Timposterise(Invokable mockObject, Class<T> mockedType, Class<?>... ancilliaryTypes)Creates an imposter for a given type that forwardsInvocations to anInvokableobject.
-
-
-
Field Detail
-
INSTANCE
public static final Imposteriser INSTANCE
-
-
Method Detail
-
canImposterise
public boolean canImposterise(Class<?> type)
Description copied from interface:ImposteriserReports if the Imposteriser is able to imposterise a given type.- Specified by:
canImposterisein interfaceImposteriser- Parameters:
type- The type in question.- Returns:
- True if this imposteriser can imposterise type, false otherwise.
-
imposterise
public <T> T imposterise(Invokable mockObject, Class<T> mockedType, Class<?>... ancilliaryTypes)
Description copied from interface:ImposteriserCreates an imposter for a given type that forwardsInvocations to anInvokableobject.- Specified by:
imposterisein interfaceImposteriser- Type Parameters:
T- The static type of the imposter that is created.- Parameters:
mockObject- The object that is to receive invocations forwarded from the imposter.mockedType- The class representing the static type of the imposter.ancilliaryTypes- Other types for the imposter. It must be possible to dynamically cast the imposter to these types. These types must all be interfaces because Java only allows single inheritance of classes.- Returns:
- A new imposter. The imposter must implement the mockedType and all the ancialliaryTypes.
-
-