1
|
/**
|
2
|
* Copyright (C) 2015 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.httpinvoker;
|
10
|
|
11
|
import java.util.HashSet;
|
12
|
import java.util.Set;
|
13
|
|
14
|
import org.junit.After;
|
15
|
|
16
|
/**
|
17
|
* @author cmathew
|
18
|
* @date 16 Oct 2015
|
19
|
*
|
20
|
*/
|
21
|
public abstract class ThreadedTest extends TestConfig {
|
22
|
|
23
|
private Set<TestThread> threadPool = new HashSet<TestThread>();
|
24
|
|
25
|
protected void invokeThread(TestThread thread) {
|
26
|
threadPool.add(thread);
|
27
|
thread.start();
|
28
|
}
|
29
|
|
30
|
@After
|
31
|
public void cleanup() throws Throwable {
|
32
|
try {
|
33
|
for(TestThread thread : threadPool) {
|
34
|
if(thread.isAlive()) {
|
35
|
thread.join();
|
36
|
}
|
37
|
}
|
38
|
|
39
|
for(TestThread thread : threadPool) {
|
40
|
if(thread.getThrowable() != null) {
|
41
|
throw thread.getThrowable();
|
42
|
}
|
43
|
}
|
44
|
} finally {
|
45
|
threadPool.clear();
|
46
|
}
|
47
|
}
|
48
|
}
|