use of org.powermock.modules.junit3.internal.PowerMockJUnit3RunnerDelegate in project powermock by powermock.
the class JUnit3TestSuiteChunkerImpl method runTest.
public void runTest(Test test, TestResult result) {
final Iterator<TestChunk> iterator = getChunkIterator();
for (PowerMockJUnit3RunnerDelegate delegate : delegates) {
TestChunk next = iterator.next();
final PowerMockJUnit3TestListener listener = new PowerMockJUnit3TestListener(next.getClassLoader());
result.addListener(listener);
delegate.runTest(test, result);
result.removeListener(listener);
}
}
use of org.powermock.modules.junit3.internal.PowerMockJUnit3RunnerDelegate in project powermock by powermock.
the class JUnit3TestSuiteChunkerImpl method tests.
public Enumeration<?> tests() {
final List<Object> tests = new LinkedList<Object>();
for (PowerMockJUnit3RunnerDelegate delegate : delegates) {
final Enumeration<?> delegateTests = delegate.tests();
while (delegateTests.hasMoreElements()) {
tests.add(delegateTests.nextElement());
}
}
Enumeration<?> allTests = new Enumeration<Object>() {
private volatile int count = 0;
public boolean hasMoreElements() {
return count != tests.size();
}
public Object nextElement() {
return tests.get(count++);
}
};
return allTests;
}
use of org.powermock.modules.junit3.internal.PowerMockJUnit3RunnerDelegate in project powermock by powermock.
the class JUnit3TestSuiteChunkerImpl method createDelegatorFromClassloader.
@Override
protected PowerMockJUnit3RunnerDelegate createDelegatorFromClassloader(ClassLoader classLoader, Class<?> testClass, final List<Method> methodsToTest) throws Exception {
final Class<?> testClassLoadedByMockedClassLoader = Class.forName(testClass.getName(), false, classLoader);
final Class<?> powerMockTestListenerArrayType = Class.forName(PowerMockTestListener[].class.getName(), false, classLoader);
Class<?> delegateClass = Class.forName(PowerMockJUnit3RunnerDelegateImpl.class.getName(), false, classLoader);
Constructor<?> con = delegateClass.getConstructor(Class.class, Method[].class, powerMockTestListenerArrayType);
final PowerMockJUnit3RunnerDelegate newDelegate = (PowerMockJUnit3RunnerDelegate) con.newInstance(testClassLoadedByMockedClassLoader, methodsToTest.toArray(new Method[0]), getPowerMockTestListenersLoadedByASpecificClassLoader(testClass, classLoader));
newDelegate.setName(name);
return newDelegate;
}
use of org.powermock.modules.junit3.internal.PowerMockJUnit3RunnerDelegate in project powermock by powermock.
the class JUnit3TestSuiteChunkerImpl method run.
public void run(TestResult result) {
final Iterator<TestChunk> iterator = getChunkIterator();
for (PowerMockJUnit3RunnerDelegate delegate : delegates) {
TestChunk next = iterator.next();
final PowerMockJUnit3TestListener listener = new PowerMockJUnit3TestListener(next.getClassLoader());
result.addListener(listener);
// Initialize mock policies for each test
new MockPolicyInitializerImpl(delegate.getTestClass()).initialize(this.getClass().getClassLoader());
delegate.run(result);
result.removeListener(listener);
}
}
Aggregations