@@ -36,11 +36,12 @@ public class DeferredTaskTest extends BaseTestConfiguration {
36
36
private static final LocalTaskQueueTestConfig .TaskCountDownLatch latch =
37
37
new LocalTaskQueueTestConfig .TaskCountDownLatch (1 );
38
38
39
- private final LocalServiceTestHelper helper =
40
- new LocalServiceTestHelper (new LocalTaskQueueTestConfig ()
41
- .setDisableAutoTaskExecution (false ) // Enable auto task execution
42
- .setCallbackClass (LocalTaskQueueTestConfig .DeferredTaskCallback .class )
43
- .setTaskExecutionLatch (latch ));
39
+ private static final LocalServiceTestHelper helper =
40
+ new LocalServiceTestHelper (
41
+ new LocalTaskQueueTestConfig ()
42
+ .setDisableAutoTaskExecution (false ) // Enable auto task execution
43
+ .setCallbackClass (LocalTaskQueueTestConfig .DeferredTaskCallback .class )
44
+ .setTaskExecutionLatch (latch ));
44
45
45
46
private static synchronized boolean requestAwait () throws InterruptedException {
46
47
return latch .await (5 , TimeUnit .SECONDS );
@@ -50,6 +51,14 @@ private static synchronized void requestReset() {
50
51
latch .reset ();
51
52
}
52
53
54
+ private static synchronized void helperSetUp () {
55
+ helper .setUp ();
56
+ }
57
+
58
+ private static synchronized void helperTearDown () {
59
+ helper .tearDown ();
60
+ }
61
+
53
62
private static class MyTask implements DeferredTask {
54
63
private static volatile boolean taskRan = false ;
55
64
@@ -61,20 +70,19 @@ public void run() {
61
70
62
71
@ Before
63
72
public void setUp () {
64
- helper . setUp ();
73
+ helperSetUp ();
65
74
}
66
75
67
76
@ After
68
77
public void tearDown () {
69
78
MyTask .taskRan = false ;
70
79
requestReset ();
71
- helper . tearDown ();
80
+ helperTearDown ();
72
81
}
73
82
74
83
@ Test
75
84
public void testTaskGetsRun () throws InterruptedException {
76
- QueueFactory .getDefaultQueue ().add (
77
- TaskOptions .Builder .withPayload (new MyTask ()));
85
+ QueueFactory .getDefaultQueue ().add (TaskOptions .Builder .withPayload (new MyTask ()));
78
86
assertTrue (requestAwait ());
79
87
assertTrue (MyTask .taskRan );
80
88
}
0 commit comments