You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/07/15 23:00:30 UTC

[15/31] incubator-tinkerpop git commit: Pull ThreadInterrupt compiler provider tests to their own case.

Pull ThreadInterrupt compiler provider tests to their own case.


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

Branch: refs/heads/tp30
Commit: 6b8628be701558ba1bf91f8713639f6d9fe33694
Parents: 44d8f37
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jul 9 08:29:07 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 9 08:29:07 2015 -0400

----------------------------------------------------------------------
 .../jsr223/GremlinGroovyScriptEngineTest.java   | 45 -----------
 ...inGroovyScriptEngineThreadInterruptTest.java | 78 ++++++++++++++++++++
 2 files changed, 78 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6b8628be/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
index 19f56d8..15c4cb4 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
@@ -23,7 +23,6 @@ import groovy.lang.Script;
 import org.apache.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider;
 import org.apache.tinkerpop.gremlin.groovy.NoImportCustomizerProvider;
 import org.apache.tinkerpop.gremlin.groovy.SecurityCustomizerProvider;
-import org.apache.tinkerpop.gremlin.groovy.ThreadInterruptCustomizerProvider;
 import org.apache.tinkerpop.gremlin.groovy.TimedInterruptCustomizerProvider;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
@@ -359,50 +358,6 @@ public class GremlinGroovyScriptEngineTest {
     }
 
     @Test
-    public void shouldInterruptWhile() throws Exception {
-        final ScriptEngine engine = new GremlinGroovyScriptEngine(new ThreadInterruptCustomizerProvider());
-        final AtomicBoolean asserted = new AtomicBoolean(false);
-
-        final Thread t = new Thread(() -> {
-            try {
-                engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 10000) {}");
-            } catch (ScriptException se) {
-                asserted.set(se.getCause().getCause() instanceof InterruptedException);
-            }
-        });
-
-        t.start();
-        Thread.sleep(100);
-        t.interrupt();
-        while(t.isAlive()) {}
-
-        assertTrue(asserted.get());
-    }
-
-    @Test
-    public void shouldNotInterruptWhile() throws Exception {
-        // companion to shouldInterruptWhile                                 t
-        final ScriptEngine engine = new GremlinGroovyScriptEngine();
-        final AtomicBoolean exceptionFired = new AtomicBoolean(true);
-
-        final Thread t = new Thread(() -> {
-            try {
-                engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 2000) {};'test'");
-                exceptionFired.set(false);
-            } catch (ScriptException se) {
-                se.printStackTrace();
-            }
-        });
-
-        t.start();
-        Thread.sleep(100);
-        t.interrupt();
-        while(t.isAlive()) {}
-
-        assertFalse(exceptionFired.get());
-    }
-
-    @Test
     public void shouldNotTimeoutStandaloneFunction() throws Exception {
         // use a super fast timeout which should not prevent the call of a cached function
         final ScriptEngine engine = new GremlinGroovyScriptEngine(

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6b8628be/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java
new file mode 100644
index 0000000..939453f
--- /dev/null
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223;
+
+import org.apache.tinkerpop.gremlin.groovy.ThreadInterruptCustomizerProvider;
+import org.junit.Test;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class GremlinGroovyScriptEngineThreadInterruptTest {
+    @Test
+    public void shouldInterruptWhile() throws Exception {
+        final ScriptEngine engine = new GremlinGroovyScriptEngine(new ThreadInterruptCustomizerProvider());
+        final AtomicBoolean asserted = new AtomicBoolean(false);
+
+        final Thread t = new Thread(() -> {
+            try {
+                engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 10000) {}");
+            } catch (ScriptException se) {
+                asserted.set(se.getCause().getCause() instanceof InterruptedException);
+            }
+        });
+
+        t.start();
+        Thread.sleep(100);
+        t.interrupt();
+        while(t.isAlive()) {}
+
+        assertTrue(asserted.get());
+    }
+
+    @Test
+    public void shouldNotInterruptWhile() throws Exception {
+        // companion to shouldInterruptWhile                                 t
+        final ScriptEngine engine = new GremlinGroovyScriptEngine();
+        final AtomicBoolean exceptionFired = new AtomicBoolean(true);
+
+        final Thread t = new Thread(() -> {
+            try {
+                engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 2000) {};'test'");
+                exceptionFired.set(false);
+            } catch (ScriptException se) {
+                se.printStackTrace();
+            }
+        });
+
+        t.start();
+        Thread.sleep(100);
+        t.interrupt();
+        while(t.isAlive()) {}
+
+        assertFalse(exceptionFired.get());
+    }
+}