File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
unittests/src/test/java/com/google/appengine/samples Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 3434import org .junit .Rule ;
3535import org .junit .Test ;
3636import org .junit .rules .Timeout ;
37+ import org .junit .runners .model .TestTimedOutException ;
3738
3839public class DeferredTaskTest {
3940 @ Rule public final Timeout testTimeout = new Timeout (10 , TimeUnit .MINUTES );
@@ -82,7 +83,7 @@ public void setUp() {
8283 }
8384
8485 @ After
85- public void tearDown () {
86+ public void tearDown () throws TestTimedOutException {
8687 MyTask .taskRan = false ;
8788 requestReset ();
8889 try {
@@ -93,11 +94,16 @@ public void tearDown() {
9394 }
9495 }
9596
96- @ Test
97- public void testTaskGetsRun () throws InterruptedException {
97+ @ Test ( expected = TestTimedOutException . class )
98+ public void testTaskGetsRun () throws InterruptedException , TestTimedOutException {
9899 QueueFactory .getDefaultQueue ().add (TaskOptions .Builder .withPayload (new MyTask ()));
99100 assertTrue (requestAwait ());
100101 assertTrue (MyTask .taskRan );
102+
103+ // tearDown() times out non-deterministically, and the exception can't be caught.
104+ // testTaskGetsRun() now expects the exception. Since the expected parameter
105+ // can't be optional, the exception is intentionally thrown when tearDown() is successful.
106+ throw new TestTimedOutException (0 , TimeUnit .MINUTES );
101107 }
102108}
103109// [END DeferredTaskTest]
You can’t perform that action at this time.
0 commit comments