1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.util;
17
18 import java.util.concurrent.Callable;
19
20 import org.junit.Rule;
21 import org.junit.rules.MethodRule;
22 import org.junit.runners.model.FrameworkMethod;
23 import org.junit.runners.model.Statement;
24
25
26
27
28
29
30
31 public class ProcessLoggingUnitTest {
32
33 @Rule
34 public MethodRule processLogRule = new MethodRule() {
35 @Override
36 public Statement apply(final Statement base,
37 final FrameworkMethod method, Object target) {
38 return new Statement() {
39 @Override
40 public void evaluate() throws Throwable {
41 try {
42 ProcessLogger.follow("test", "Test Run " + method.getName(), new Callable<Void>() {
43
44 @Override
45 public Void call() throws Exception {
46 try {
47 base.evaluate();
48 } catch (Throwable e) {
49 if (e instanceof Error)
50 throw (Error) e;
51 else
52 throw (Exception) e;
53 }
54 return null;
55 }
56
57 @Override
58 public String toString() {
59 return "Test Run " + method.getName();
60 }
61 });
62 } catch (Throwable t) {
63 System.err.println("Error running test "
64 + method.getName());
65 t.printStackTrace();
66 throw t;
67 }
68 }
69 };
70 }
71 };
72
73 }