Package org.jmock.imposters
Class ByteBuddyClassImposteriser
java.lang.Object
org.jmock.imposters.ByteBuddyClassImposteriser
- All Implemented Interfaces:
Imposteriser
This class lets you imposterise abstract and concrete classes
without calling the constructors of the mocked class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static class
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
canImposterise
(Class<?> type) Reports if the Imposteriser is able to imposterise a given type.private boolean
defaultPackage
(Class<?> mockedType) <T> T
imposterise
(Invokable mockObject, Class<T> mockedType, Class<?>... ancilliaryTypes) Creates an imposter for a given type that forwardsInvocation
s to anInvokable
object.mockTypeKey
(Class<?> mockedType, Class<?>... ancilliaryTypes) private boolean
protectedPackageNameSpaces
(Class<?> mockedType) private <T> T
private Class<?>
proxyClass
(Invokable mockObject, Class<?> mockedType, Class<?>... ancilliaryTypes) private void
setConstructorsAccessible
(Class<?> mockedType, boolean accessible) private boolean
toStringMethodIsFinal
(Class<?> type)
-
Field Details
-
INSTANCE
-
JMOCK_KEY
- See Also:
-
objenesis
private final org.objenesis.Objenesis objenesis -
types
-
-
Constructor Details
-
ByteBuddyClassImposteriser
private ByteBuddyClassImposteriser()
-
-
Method Details
-
canImposterise
Description copied from interface:Imposteriser
Reports if the Imposteriser is able to imposterise a given type.- Specified by:
canImposterise
in interfaceImposteriser
- Parameters:
type
- The type in question.- Returns:
- True if this imposteriser can imposterise type, false otherwise.
-
imposterise
Description copied from interface:Imposteriser
Creates an imposter for a given type that forwardsInvocation
s to anInvokable
object.- Specified by:
imposterise
in 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.
-
toStringMethodIsFinal
-
setConstructorsAccessible
-
proxy
-
proxyClass
private Class<?> proxyClass(Invokable mockObject, Class<?> mockedType, Class<?>... ancilliaryTypes) throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException -
mockTypeKey
-
defaultPackage
-
protectedPackageNameSpaces
-