public class MockClassLoader extends DeferSupportingClassLoader
Modifier and Type | Field | Description |
---|---|---|
static String |
MODIFY_ALL_CLASSES |
Pass this string to the constructor to indicate that all classes should
be modified.
|
Constructor | Description |
---|---|
MockClassLoader(String[] classesToMock) |
Creates a new instance of the
MockClassLoader based on the
following parameters: |
MockClassLoader(String[] classesToMock,
String[] packagesToDefer) |
Creates a new instance of the
MockClassLoader based on the
following parameters: |
MockClassLoader(String[] classesToMock,
String[] packagesToDefer,
UseClassPathAdjuster useClassPathAdjuster) |
Creates a new instance of the
MockClassLoader based on the
following parameters: |
MockClassLoader(String[] classesToMock,
UseClassPathAdjuster useClassPathAdjuster) |
Creates a new instance of the
MockClassLoader based on the
following parameters: |
Modifier and Type | Method | Description |
---|---|---|
void |
addClassesToModify(String... classes) |
Add classes that will be loaded by the mock classloader, i.e.
|
protected Class<?> |
loadModifiedClass(String s) |
|
void |
setMockTransformerChain(List<MockTransformer> mockTransformerChain) |
|
protected boolean |
shouldLoadUnmodifiedClass(String className) |
|
protected boolean |
shouldModifyClass(String s) |
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
addIgnorePackage, cache, findResource, findResources, getResource, getResourceAsStream, getResources, loadClass, shouldModify
public static final String MODIFY_ALL_CLASSES
public MockClassLoader(String[] classesToMock, String[] packagesToDefer, UseClassPathAdjuster useClassPathAdjuster)
MockClassLoader
based on the
following parameters:classesToMock
- The classes that must be modified to prepare for testability.packagesToDefer
- Classes in these packages will be defered to the system
class-loader.public MockClassLoader(String[] classesToMock, String[] packagesToDefer)
MockClassLoader
based on the
following parameters:classesToMock
- The classes that must be modified to prepare for testability.packagesToDefer
- Classes in these packages will be defered to the system
class-loader.public MockClassLoader(String[] classesToMock, UseClassPathAdjuster useClassPathAdjuster)
MockClassLoader
based on the
following parameters:classesToMock
- The classes that must be modified to prepare for testability.public MockClassLoader(String[] classesToMock)
MockClassLoader
based on the
following parameters:classesToMock
- The classes that must be modified to prepare for testability.public final void addClassesToModify(String... classes)
packagesToBeDeferred
will be ignored. How ever
classes added here have precedence over additionally deferred (ignored)
packages (those ignored by the user using @PrepareForTest).classes
- The fully qualified name of the classes that will be appended
to the list of classes that will be byte-code modified to
enable testability.protected Class<?> loadModifiedClass(String s) throws ClassFormatError, ClassNotFoundException
loadModifiedClass
in class DeferSupportingClassLoader
ClassFormatError
ClassNotFoundException
public void setMockTransformerChain(List<MockTransformer> mockTransformerChain)
protected boolean shouldModifyClass(String s)
shouldModifyClass
in class DeferSupportingClassLoader
protected boolean shouldLoadUnmodifiedClass(String className)
shouldLoadUnmodifiedClass
in class DeferSupportingClassLoader
Copyright © 2007–2019. All rights reserved.