Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1548 [created] 3d826a8e4


Added a short sleep to prevent traversal from finishing before it can be 
interrupted.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/3d826a8e
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3d826a8e
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3d826a8e

Branch: refs/heads/TINKERPOP-1548
Commit: 3d826a8e42c38a089bba70bf491968d2459b43a7
Parents: 7bb77c6
Author: Ted Wilmes <twil...@gmail.com>
Authored: Sat Nov 19 15:22:16 2016 -0600
Committer: Ted Wilmes <twil...@gmail.com>
Committed: Sat Nov 19 15:22:16 2016 -0600

----------------------------------------------------------------------
 .../traversal/TraversalInterruptionComputerTest.java   | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3d826a8e/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalInterruptionComputerTest.java
----------------------------------------------------------------------
diff --git 
a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalInterruptionComputerTest.java
 
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalInterruptionComputerTest.java
index c3a1042..32bbf42 100644
--- 
a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalInterruptionComputerTest.java
+++ 
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalInterruptionComputerTest.java
@@ -75,6 +75,17 @@ public class TraversalInterruptionComputerTest extends 
AbstractGremlinProcessTes
             try {
                 final Traversal traversal = 
traversalMaker.apply(g).sideEffect(traverser -> {
                     startedIterating.countDown();
+                    try {
+                        // artificially slow down the traversal execution so 
that
+                        // this test has a chance to interrupt it before it 
finishes
+                        Thread.sleep(100);
+                    } catch (InterruptedException e) {
+                        // if the traversal is interrupted while in this
+                        // sleep, reassert the interrupt so that the thread is
+                        // re-marked as interrupted and correctly handled as
+                        // an interrupted traversal
+                        Thread.currentThread().interrupt();
+                    }
                 });
                 traversal.iterate();
             } catch (Exception ex) {
@@ -86,7 +97,7 @@ public class TraversalInterruptionComputerTest extends 
AbstractGremlinProcessTes
 
         // total time for test should not exceed 5 seconds - this prevents the 
test from just hanging and allows
         // it to finish with failure
-        assertThat(startedIterating.await(5000, TimeUnit.MILLISECONDS), 
CoreMatchers.is(true));
+        assertThat(startedIterating.await(1000, TimeUnit.MILLISECONDS), 
CoreMatchers.is(true));
 
         t.interrupt();
         t.join();

Reply via email to