You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2015/05/12 04:14:27 UTC

[09/12] incubator-tinkerpop git commit: take expected exceptions into account

take expected exceptions into account


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

Branch: refs/heads/TINKERPOP3-666
Commit: 47dbd5d0e084c44eac0028c94d81140b62902103
Parents: ce85971
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Tue May 12 02:12:14 2015 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Tue May 12 02:12:14 2015 +0200

----------------------------------------------------------------------
 .../gremlin/process/GremlinProcessRunner.java     | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/47dbd5d0/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/GremlinProcessRunner.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/GremlinProcessRunner.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/GremlinProcessRunner.java
index eaf2acc..1d10114 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/GremlinProcessRunner.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/GremlinProcessRunner.java
@@ -36,29 +36,43 @@ public class GremlinProcessRunner extends BlockJUnit4ClassRunner {
 
     @Override
     protected Statement possiblyExpectingExceptions(final FrameworkMethod method, final Object test, final Statement next) {
-        return new ExpectComputerVerificationException(next, (AbstractGremlinTest) test);
+        org.junit.Test annotation = method.getAnnotation(org.junit.Test.class);
+        return new ExpectComputerVerificationException(next, (AbstractGremlinTest) test,
+                annotation != null ? annotation.expected() : org.junit.Test.None.class);
     }
 
     class ExpectComputerVerificationException extends Statement {
 
         private Statement next;
         private AbstractGremlinTest test;
+        private final Class<? extends Throwable> expected;
 
-        public ExpectComputerVerificationException(final Statement next, final AbstractGremlinTest test) {
+        public ExpectComputerVerificationException(final Statement next, final AbstractGremlinTest test,
+                                                   final Class<? extends Throwable> expected) {
             this.next = next;
             this.test = test;
+            this.expected = expected;
         }
 
         @Override
         public void evaluate() throws Throwable {
+            boolean complete = false;
             try {
                 next.evaluate();
+                complete = true;
             } catch (ComputerVerificationException e) {
                 if (!test.isComputerTest()) throw e;
                 final boolean muted = Boolean.parseBoolean(System.getProperty("muteTestLogs", "false"));
                 if (!muted) System.out.println(String.format(
                         "The following traversal is not valid for computer execution: %s",
                         e.getTraversal()));
+            } catch (Throwable e) {
+                if (!expected.isAssignableFrom(e.getClass())) {
+                    throw e;
+                }
+            }
+            if (complete && !expected.equals(org.junit.Test.None.class)) {
+                throw new AssertionError("Expected exception: " + expected.getName());
             }
         }
     }