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 voidaddClassesToModify(String... classes) Add classes that will be loaded by the mock classloader, i.e.voidaddIgnorePackage(String... packagesToIgnore) Add packages or classes to ignore.private booleandeferConditionMatches(String name, String packageName) (package private) String[]private static String[]getPackagesToDefer(String[] additionalDeferPackages) (package private) booleanshouldDefer(String className) private booleanshouldDefer(String[] packages, String name) private booleanshouldIgnore(String className) private booleanshouldIgnore(String[] packages, String name) private booleanshouldLoadUnmodifiedClass(String className) private boolean(package private) booleanshouldMockClass(String className) (package private) booleanshouldModify(String className) private booleanprivate booleanshouldModifyClass(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_DEFERREDwill 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
-