Search in sources :

Example 1 with PrepareForTestExtractorImpl

use of org.powermock.tests.utils.impl.PrepareForTestExtractorImpl in project powermock by powermock.

the class PowerMockClassloaderExecutor method forClass.

public static SingleClassloaderExecutor forClass(Class<?> testClass, MockPolicyInitializer mockPolicyInitializer) {
    List<MockTransformer> mockTransformerChain = new ArrayList<MockTransformer>();
    mockTransformerChain.add(new ClassMockTransformer());
    mockTransformerChain.add(new InterfaceMockTransformer());
    MockClassLoader mockLoader = new MockClassLoader(new String[0], new String[0]);
    mockLoader.setMockTransformerChain(mockTransformerChain);
    mockLoader.addIgnorePackage(new PowerMockIgnorePackagesExtractorImpl().getPackagesToIgnore(testClass));
    mockLoader.addClassesToModify(new PrepareForTestExtractorImpl().getTestClasses(testClass));
    mockLoader.addClassesToModify(new StaticConstructorSuppressExtractorImpl().getTestClasses(testClass));
    mockPolicyInitializer.initialize(mockLoader);
    return new SingleClassloaderExecutor(mockLoader);
}
Also used : MockTransformer(org.powermock.core.transformers.MockTransformer) ClassMockTransformer(org.powermock.core.transformers.impl.ClassMockTransformer) InterfaceMockTransformer(org.powermock.core.transformers.impl.InterfaceMockTransformer) PowerMockIgnorePackagesExtractorImpl(org.powermock.tests.utils.impl.PowerMockIgnorePackagesExtractorImpl) StaticConstructorSuppressExtractorImpl(org.powermock.tests.utils.impl.StaticConstructorSuppressExtractorImpl) MockClassLoader(org.powermock.core.classloader.MockClassLoader) ArrayList(java.util.ArrayList) SingleClassloaderExecutor(org.powermock.classloading.SingleClassloaderExecutor) InterfaceMockTransformer(org.powermock.core.transformers.impl.InterfaceMockTransformer) ClassMockTransformer(org.powermock.core.transformers.impl.ClassMockTransformer) PrepareForTestExtractorImpl(org.powermock.tests.utils.impl.PrepareForTestExtractorImpl)

Example 2 with PrepareForTestExtractorImpl

use of org.powermock.tests.utils.impl.PrepareForTestExtractorImpl in project powermock by powermock.

the class PowerMockAgentTestInitializer method redefineClassesToPrepare.

private static void redefineClassesToPrepare(Class<?> testClass, String[] packagesToIgnore, JavaAgentClassRegister agentClassRegister) {
    final String[] classesToPrepare = new PrepareForTestExtractorImpl(true).getTestClasses(testClass);
    redefine(classesToPrepare, packagesToIgnore, agentClassRegister);
}
Also used : PrepareForTestExtractorImpl(org.powermock.tests.utils.impl.PrepareForTestExtractorImpl)

Aggregations

PrepareForTestExtractorImpl (org.powermock.tests.utils.impl.PrepareForTestExtractorImpl)2 ArrayList (java.util.ArrayList)1 SingleClassloaderExecutor (org.powermock.classloading.SingleClassloaderExecutor)1 MockClassLoader (org.powermock.core.classloader.MockClassLoader)1 MockTransformer (org.powermock.core.transformers.MockTransformer)1 ClassMockTransformer (org.powermock.core.transformers.impl.ClassMockTransformer)1 InterfaceMockTransformer (org.powermock.core.transformers.impl.InterfaceMockTransformer)1 PowerMockIgnorePackagesExtractorImpl (org.powermock.tests.utils.impl.PowerMockIgnorePackagesExtractorImpl)1 StaticConstructorSuppressExtractorImpl (org.powermock.tests.utils.impl.StaticConstructorSuppressExtractorImpl)1