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
|
/**
|
12
|
* @author cmathew
|
13
|
* @date 16 Oct 2015
|
14
|
*
|
15
|
*/
|
16
|
public abstract class TestThread extends Thread {
|
17
|
Throwable throwable;
|
18
|
boolean isBlocked = false;
|
19
|
|
20
|
public TestThread() {
|
21
|
|
22
|
}
|
23
|
|
24
|
public TestThread(boolean blocking) {
|
25
|
isBlocked = blocking;
|
26
|
}
|
27
|
/**
|
28
|
* @return the throwable
|
29
|
*/
|
30
|
public Throwable getThrowable() {
|
31
|
return throwable;
|
32
|
}
|
33
|
|
34
|
/**
|
35
|
* @param throwable the throwable to set
|
36
|
*/
|
37
|
public void setThrowable(Throwable throwable) {
|
38
|
this.throwable = throwable;
|
39
|
}
|
40
|
|
41
|
public void unblock() {
|
42
|
isBlocked = false;
|
43
|
}
|
44
|
|
45
|
@Override
|
46
|
public final void run() {
|
47
|
try {
|
48
|
while(isBlocked) {};
|
49
|
doRun();
|
50
|
} catch(Exception ex) {
|
51
|
throwable = ex;
|
52
|
} catch(AssertionError ae) {
|
53
|
throwable = ae;
|
54
|
}
|
55
|
}
|
56
|
|
57
|
public abstract void doRun() throws Exception, AssertionError;
|
58
|
|
59
|
}
|