public class ClassImposteriser extends java.lang.Object implements Imposteriser
Modifier and Type | Class and Description |
---|---|
static class |
ClassImposteriser.ClassWithSuperclassToWorkAroundCglibBug |
Modifier and Type | Field and Description |
---|---|
private static java.lang.reflect.Method |
FINALIZE_METHOD |
private static net.sf.cglib.proxy.CallbackFilter |
IGNORED_METHODS |
static Imposteriser |
INSTANCE |
private static net.sf.cglib.core.NamingPolicy |
NAMING_POLICY_THAT_ALLOWS_IMPOSTERISATION_OF_CLASSES_IN_SIGNED_PACKAGES |
private org.objenesis.Objenesis |
objenesis |
Modifier | Constructor and Description |
---|---|
private |
ClassImposteriser() |
Modifier and Type | Method and Description |
---|---|
boolean |
canImposterise(java.lang.Class<?> type)
Reports if the Imposteriser is able to imposterise a given type.
|
private static java.lang.reflect.Method |
findFinalizeMethod() |
<T> T |
imposterise(Invokable mockObject,
java.lang.Class<T> mockedType,
java.lang.Class<?>... ancilliaryTypes)
Creates an imposter for a given type that forwards
Invocation s to an
Invokable object. |
private java.lang.Class<?>[] |
prepend(java.lang.Class<?> first,
java.lang.Class<?>... rest) |
private java.lang.Object |
proxy(java.lang.Class<?> proxyClass,
Invokable mockObject) |
private java.lang.Class<?> |
proxyClass(java.lang.Class<?> possibleMockedType,
java.lang.Class<?>... ancilliaryTypes) |
private void |
setConstructorsAccessible(java.lang.Class<?> mockedType,
boolean accessible) |
private boolean |
toStringMethodIsFinal(java.lang.Class<?> type) |
public static final Imposteriser INSTANCE
private static final java.lang.reflect.Method FINALIZE_METHOD
private static final net.sf.cglib.core.NamingPolicy NAMING_POLICY_THAT_ALLOWS_IMPOSTERISATION_OF_CLASSES_IN_SIGNED_PACKAGES
private static final net.sf.cglib.proxy.CallbackFilter IGNORED_METHODS
private final org.objenesis.Objenesis objenesis
public boolean canImposterise(java.lang.Class<?> type)
Imposteriser
canImposterise
in interface Imposteriser
type
- The type in question.public <T> T imposterise(Invokable mockObject, java.lang.Class<T> mockedType, java.lang.Class<?>... ancilliaryTypes)
Imposteriser
Invocation
s to an
Invokable
object.imposterise
in interface Imposteriser
T
- The static type of the imposter that is created.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.private boolean toStringMethodIsFinal(java.lang.Class<?> type)
private void setConstructorsAccessible(java.lang.Class<?> mockedType, boolean accessible)
private java.lang.Class<?> proxyClass(java.lang.Class<?> possibleMockedType, java.lang.Class<?>... ancilliaryTypes)
private java.lang.Object proxy(java.lang.Class<?> proxyClass, Invokable mockObject)
private java.lang.Class<?>[] prepend(java.lang.Class<?> first, java.lang.Class<?>... rest)
private static java.lang.reflect.Method findFinalizeMethod()