/*
 * This file is covered by the terms of the Common Public License v1.0.
 *
 * Copyright (c) SZEDER Gábor
 *
 * Parts of this software were developed within the JEOPARD research
 * project, which received funding from the European Union's Seventh
 * Framework Programme under grant agreement No. 216682.
 */

package de.fzi.cjunit.runners;

import java.util.ArrayList;
import java.util.List;

import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;

import de.fzi.cjunit.ConcurrentTest;

public class ConcurrentRunner extends BlockJUnit4ClassRunner {

	List<FrameworkMethod> testMethods;

	public ConcurrentRunner(Class<?> klass) throws InitializationError {
		super(klass);
	}

	@Override
	protected void collectInitializationErrors(List<Throwable> errors) {
		super.collectInitializationErrors(errors);
		validateConcurrentTestMethods(errors);
	}

	@Override
	protected List<FrameworkMethod> computeTestMethods() {
		if (testMethods == null) {
			testMethods = new ArrayList<FrameworkMethod>(
					super.computeTestMethods());
			testMethods.addAll(computeConcurrentTestMethods());
		}
		return testMethods;
	}

	protected List<FrameworkMethod> computeConcurrentTestMethods() {
		return getTestClass().getAnnotatedMethods(ConcurrentTest.class);
	}

	protected void validateConcurrentTestMethods(List<Throwable> errors) {
		validatePublicVoidNoArgMethods(ConcurrentTest.class, false,
				errors);
	}
}

@@ -574,16 +574,78 @@
 entTest;
+%0Aimport de.fzi.cjunit.runners.model.ConcurrentFrameworkMethod;
 %0A%0Apublic
@@ -1332,22 +1332,51 @@
 s() %7B%0A%09%09
-return
+List%3CFrameworkMethod%3E methods%0A%09%09%09%09=
  getTest
@@ -1395,32 +1395,39 @@
 nnotatedMethods(
+%0A%09%09%09%09%09%09
 ConcurrentTest.c
@@ -1429,24 +1429,273 @@
 est.class);%0A
+%09%09List%3CFrameworkMethod%3E concurrentMethods%0A%09%09%09%09= new ArrayList%3CFrameworkMethod%3E();%0A%09%09for (FrameworkMethod eachMethod : methods) %7B%0A%09%09%09concurrentMethods.add(new ConcurrentFrameworkMethod(%0A%09%09%09%09%09%09eachMethod.getMethod()));%0A%09%09%7D%0A%09%09return concurrentMethods;%0A
 %09%7D%0A%0A%09protect

create ConcurrentFrameworkMethods