-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestUtils.java
More file actions
69 lines (55 loc) · 1.7 KB
/
Copy pathTestUtils.java
File metadata and controls
69 lines (55 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package de.tum.cit.ase.ares.api;
import java.util.concurrent.Callable;
import java.util.function.*;
import org.apiguardian.api.API;
import org.apiguardian.api.API.Status;
import de.tum.cit.ase.ares.api.internal.*;
/**
* Utilities for writing tests with Ares in the form of static methods.
*
* @author Christian Femers
*/
@API(status = Status.MAINTAINED)
public final class TestUtils {
private TestUtils() {
}
public static void invokeBlacklisted(Runnable action) {
BlacklistedInvoker.invoke(action);
}
public static <T, R> R invokeBlacklisted(T t, Function<T, R> action) {
return BlacklistedInvoker.invoke(t, action);
}
public static <T> void invokeBlacklisted(T t, Consumer<T> action) {
BlacklistedInvoker.invoke(t, action);
}
public static <R> R invokeBlacklisted(Supplier<R> action) {
return BlacklistedInvoker.invoke(action);
}
public static <R> R invokeCheckedBlacklisted(Callable<R> action) throws Exception {
return BlacklistedInvoker.invokeChecked(action);
}
public static void privilegedThrow(Runnable possiblyThrowingAction) {
try {
possiblyThrowingAction.run();
} catch (Throwable t) {
throw new PrivilegedException(t);
}
}
public static <R> R privilegedThrow(Callable<R> possiblyThrowingAction) throws Exception {
try {
return possiblyThrowingAction.call();
} catch (Throwable t) {
throw new PrivilegedException(t);
}
}
public static void privilegedFail(String message) {
throw new PrivilegedException(new AssertionError(message));
}
public static ThreadGroup getRootThreadGroup() {
ThreadGroup group = Thread.currentThread().getThreadGroup();
for (ThreadGroup tg = group; tg != null; tg = group.getParent()) {
group = tg;
}
return group;
}
}