Package org.powermock.core.classloader
Class MockClassLoaderConfiguration
java.lang.Object
org.powermock.core.classloader.MockClassLoaderConfiguration
The instance of the class provides information about classes which have to be mocked, loaded without modification
or defer to system class loader.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate an instance of configuration without any classes to mock or ignore.MockClassLoaderConfiguration
(String[] classesToMock, String[] packagesToDefer) Create an instance of configuration -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addClassesToModify
(String... classes) Add classes that will be loaded by the mock classloader, i.e.void
addIgnorePackage
(String... packagesToIgnore) Add packages or classes to ignore.private boolean
deferConditionMatches
(String name, String packageName) (package private) String[]
private static String[]
getPackagesToDefer
(String[] additionalDeferPackages) (package private) boolean
shouldDefer
(String className) private boolean
shouldDefer
(String[] packages, String name) private boolean
shouldIgnore
(String className) private boolean
shouldIgnore
(String[] packages, String name) private boolean
shouldLoadUnmodifiedClass
(String className) private boolean
(package private) boolean
shouldMockClass
(String className) (package private) boolean
shouldModify
(String className) private boolean
private boolean
shouldModifyClass
(String className)
-
Field Details
-
PACKAGES_TO_BE_DEFERRED
-
PACKAGES_TO_LOAD_BUT_NOT_MODIFY
-
specificClassesToLoadButNotModify
-
modify
-
deferPackages
-
-
Constructor Details
-
MockClassLoaderConfiguration
public MockClassLoaderConfiguration()Create an instance of configuration without any classes to mock or ignore. -
MockClassLoaderConfiguration
Create an instance of configuration- Parameters:
classesToMock
- classes that should be modified byMockClassLoader
.packagesToDefer
- classes/packages that should be deferred to system class loader.
-
-
Method Details
-
addIgnorePackage
Add packages or classes to ignore. Loading of all classes that locate in the added packages will be delegate to a system classloader.Package should be specified with using mask. Example:
configuration.addIgnorePackage("org.powermock.example.*");
- Parameters:
packagesToIgnore
- fully qualified names of classes or names of packages that end by.*
-
addClassesToModify
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 thePACKAGES_TO_BE_DEFERRED
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.
-
shouldDefer
-
shouldMockClass
-
getDeferPackages
String[] getDeferPackages() -
shouldDefer
-
deferConditionMatches
-
shouldIgnore
-
shouldLoadUnmodifiedClass
-
shouldLoadWithMockClassloaderWithoutModifications
-
shouldModifyClass
-
shouldIgnore
-
shouldModify
-
shouldModifyAll
private boolean shouldModifyAll() -
getPackagesToDefer
-