Skip to content

Commit 5f0ff70

Browse files
authored
fix: extend timeout (GoogleCloudPlatform#5697)
* fix: extend timeout * synchronize * lint
1 parent f4af3eb commit 5f0ff70

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

unittests/src/test/java/com/google/appengine/samples/DeferredTaskTest.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ public class DeferredTaskTest extends BaseTestConfiguration {
3636
private static final LocalTaskQueueTestConfig.TaskCountDownLatch latch =
3737
new LocalTaskQueueTestConfig.TaskCountDownLatch(1);
3838

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));
4445

4546
private static synchronized boolean requestAwait() throws InterruptedException {
4647
return latch.await(5, TimeUnit.SECONDS);
@@ -50,6 +51,14 @@ private static synchronized void requestReset() {
5051
latch.reset();
5152
}
5253

54+
private static synchronized void helperSetUp() {
55+
helper.setUp();
56+
}
57+
58+
private static synchronized void helperTearDown() {
59+
helper.tearDown();
60+
}
61+
5362
private static class MyTask implements DeferredTask {
5463
private static volatile boolean taskRan = false;
5564

@@ -61,20 +70,19 @@ public void run() {
6170

6271
@Before
6372
public void setUp() {
64-
helper.setUp();
73+
helperSetUp();
6574
}
6675

6776
@After
6877
public void tearDown() {
6978
MyTask.taskRan = false;
7079
requestReset();
71-
helper.tearDown();
80+
helperTearDown();
7281
}
7382

7483
@Test
7584
public void testTaskGetsRun() throws InterruptedException {
76-
QueueFactory.getDefaultQueue().add(
77-
TaskOptions.Builder.withPayload(new MyTask()));
85+
QueueFactory.getDefaultQueue().add(TaskOptions.Builder.withPayload(new MyTask()));
7886
assertTrue(requestAwait());
7987
assertTrue(MyTask.taskRan);
8088
}

0 commit comments

Comments
 (0)