*
* {@inheritDoc}
*/
private void initialize(MockClassLoader classLoader) {
if (mockPolicies.length > 0) {
MockPolicyClassLoadingSettings classLoadingSettings = getClassLoadingSettings();
String[] fullyQualifiedNamesOfClassesToLoadByMockClassloader = classLoadingSettings
.getFullyQualifiedNamesOfClassesToLoadByMockClassloader();
classLoader.addClassesToModify(fullyQualifiedNamesOfClassesToLoadByMockClassloader);
if (testClass == null) {
throw new IllegalStateException("Internal error: testClass should never be null when calling initialize on a mock policy");
}
classLoader.addClassesToModify(testClass.getName());
Class<?>[] classes = testClass.getDeclaredClasses();
for (Class<?> clazz : classes) {
classLoader.addClassesToModify(clazz.getName());
}
Class<?>[] declaredClasses = testClass.getClasses();
for (Class<?> clazz : declaredClasses) {
classLoader.addClassesToModify(clazz.getName());
}
for (String string : classLoadingSettings.getStaticInitializersToSuppress()) {
classLoader.addClassesToModify(string);
MockRepository.addSuppressStaticInitializer(string);
}
invokeInitializeInterceptionSettingsFromClassLoader(classLoader);