Search in sources :

Example 1 with InterfaceMockTransformer

use of org.powermock.core.transformers.impl.InterfaceMockTransformer 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 InterfaceMockTransformer

use of org.powermock.core.transformers.impl.InterfaceMockTransformer in project powermock by powermock.

the class ClassLoaderFactory method getMockTransformers.

private List<MockTransformer> getMockTransformers() {
    List<MockTransformer> mockTransformerChain = new ArrayList<MockTransformer>();
    mockTransformerChain.add(new ClassMockTransformer());
    mockTransformerChain.add(new InterfaceMockTransformer());
    return mockTransformerChain;
}
Also used : MockTransformer(org.powermock.core.transformers.MockTransformer) ClassMockTransformer(org.powermock.core.transformers.impl.ClassMockTransformer) InterfaceMockTransformer(org.powermock.core.transformers.impl.InterfaceMockTransformer) ArrayList(java.util.ArrayList) InterfaceMockTransformer(org.powermock.core.transformers.impl.InterfaceMockTransformer) ClassMockTransformer(org.powermock.core.transformers.impl.ClassMockTransformer)

Example 3 with InterfaceMockTransformer

use of org.powermock.core.transformers.impl.InterfaceMockTransformer in project powermock by powermock.

the class MockClassLoaderFactory method getMockTransformers.

protected List<MockTransformer> getMockTransformers(MockTransformer[] extraMockTransformers) {
    List<MockTransformer> mockTransformerChain = new ArrayList<MockTransformer>();
    mockTransformerChain.add(new ClassMockTransformer());
    mockTransformerChain.add(new InterfaceMockTransformer());
    Collections.addAll(mockTransformerChain, extraMockTransformers);
    return mockTransformerChain;
}
Also used : MockTransformer(org.powermock.core.transformers.MockTransformer) ClassMockTransformer(org.powermock.core.transformers.impl.ClassMockTransformer) InterfaceMockTransformer(org.powermock.core.transformers.impl.InterfaceMockTransformer) ArrayList(java.util.ArrayList) InterfaceMockTransformer(org.powermock.core.transformers.impl.InterfaceMockTransformer) ClassMockTransformer(org.powermock.core.transformers.impl.ClassMockTransformer)

Aggregations

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