public final class MockClassLoader extends DeferSupportingClassLoader
Modifier and Type | Field and Description |
---|---|
static String |
MODIFY_ALL_CLASSES
Pass this string to the constructor to indicate that all classes should
be modified.
|
Constructor and 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 and 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) |
boolean |
shouldModifyAll() |
protected boolean |
shouldModifyClass(String s) |
addIgnorePackage, findResource, findResources, getResource, getResourceAsStream, getResources, loadClass, shouldDefer, shouldIgnore, shouldIgnore, shouldModify
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
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 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 boolean shouldModifyAll()
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–2015. All rights reserved.