GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — chore: debug test by extending timeout (#5649) · mithenks/java-docs-samples@66bb5bf

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • unittests/src/test/java/com/google/appengine/samples
    • DeferredTaskTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: unittests/src/test/java/com/google/appengine/samples/DeferredTaskTest.java
+13-5Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,25 @@
3333
public class DeferredTaskTest extends BaseTestConfiguration {
3434

3535
// Unlike CountDownLatch, TaskCountDownlatch lets us reset.
36-
private final LocalTaskQueueTestConfig.TaskCountDownLatch latch =
36+
private static final LocalTaskQueueTestConfig.TaskCountDownLatch latch =
3737
new LocalTaskQueueTestConfig.TaskCountDownLatch(1);
3838

3939
private final LocalServiceTestHelper helper =
4040
new LocalServiceTestHelper(new LocalTaskQueueTestConfig()
41-
.setDisableAutoTaskExecution(false)
41+
.setDisableAutoTaskExecution(false) // Enable auto task execution
4242
.setCallbackClass(LocalTaskQueueTestConfig.DeferredTaskCallback.class)
4343
.setTaskExecutionLatch(latch));
4444

45+
private static synchronized boolean requestAwait() throws InterruptedException {
46+
return latch.await(5, TimeUnit.SECONDS);
47+
}
48+
49+
private static synchronized void requestReset() {
50+
latch.reset();
51+
}
52+
4553
private static class MyTask implements DeferredTask {
46-
private static boolean taskRan = false;
54+
private static volatile boolean taskRan = false;
4755

4856
@Override
4957
public void run() {
@@ -59,15 +67,15 @@ public void setUp() {
5967
@After
6068
public void tearDown() {
6169
MyTask.taskRan = false;
70+
requestReset();
6271
helper.tearDown();
63-
latch.reset();
6472
}
6573

6674
@Test
6775
public void testTaskGetsRun() throws InterruptedException {
6876
QueueFactory.getDefaultQueue().add(
6977
TaskOptions.Builder.withPayload(new MyTask()));
70-
assertTrue(latch.await(5, TimeUnit.SECONDS));
78+
assertTrue(requestAwait());
7179
assertTrue(MyTask.taskRan);
7280
}
7381
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.