org.powermock.core.classloader
Class MockClassLoader
java.lang.Object
java.lang.ClassLoader
org.powermock.core.classloader.DeferSupportingClassLoader
org.powermock.core.classloader.MockClassLoader
public final class MockClassLoader
- extends DeferSupportingClassLoader
Mock all classes except system classes.
Notice that there are two different types of classes that are not mocked:
- system classes are deferred to another classloader
- testing framework classes are loaded, but not modified
- Author:
- Johan Haleby, Jan Kronquist
|
Field Summary |
static String |
MODIFY_ALL_CLASSES
Pass this string to the constructor to indicate that all classes should
be modified. |
| Methods inherited from class java.lang.ClassLoader |
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MODIFY_ALL_CLASSES
public static final String MODIFY_ALL_CLASSES
- Pass this string to the constructor to indicate that all classes should
be modified.
- See Also:
- Constant Field Values
MockClassLoader
public MockClassLoader(String[] classesToMock,
String[] packagesToDefer)
- Creates a new instance of the
MockClassLoader based on the
following parameters:
- 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.
MockClassLoader
public MockClassLoader(String[] classesToMock)
- Creates a new instance of the
MockClassLoader based on the
following parameters:
- Parameters:
classesToMock - The classes that must be modified to prepare for testability.
addClassesToModify
public void addClassesToModify(String... classes)
- Add classes that will be loaded by the mock classloader, i.e. these
classes will be byte-code manipulated to allow for testing. Any classes
contained in the
packagesToBeDeferred will be ignored. How ever
classes added here have precedence over additionally deferred (ignored)
packages (those ignored by the user using @PrepareForTest).
- Parameters:
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.
loadModifiedClass
protected Class<?> loadModifiedClass(String s)
throws ClassFormatError,
ClassNotFoundException
- Specified by:
loadModifiedClass in class DeferSupportingClassLoader
- Throws:
ClassFormatError
ClassNotFoundException
shouldModifyAll
public boolean shouldModifyAll()
setMockTransformerChain
public void setMockTransformerChain(List<MockTransformer> mockTransformerChain)
shouldModifyClass
protected boolean shouldModifyClass(String s)
- Specified by:
shouldModifyClass in class DeferSupportingClassLoader
shouldLoadUnmodifiedClass
protected boolean shouldLoadUnmodifiedClass(String className)
- Specified by:
shouldLoadUnmodifiedClass in class DeferSupportingClassLoader
Copyright © 2007-2014. All Rights Reserved.