geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jensde...@apache.org
Subject [20/54] [abbrv] incubator-geode git commit: GEODE-1097 allow Lambda invocations to be named so that they show up in test logs
Date Mon, 21 Mar 2016 20:39:51 GMT
GEODE-1097 allow Lambda invocations to be named so that they show up in test logs

addressing issues found by Jianxia.  One of the VM methods was not invoking
the correct runnable.  Unit tests were needed for the NamedRunnable
invocation methods.  Since Runnable doesn't return a result the test
ensures that the target method has been invoked by having it throw an
exception.


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

Branch: refs/heads/feature/GEODE-17-2
Commit: c5a88171733532e76f9f6880d0a8f5ea6fe0bede
Parents: 5503de0
Author: Bruce Schuchardt <bschuchardt@pivotal.io>
Authored: Tue Mar 15 14:02:34 2016 -0700
Committer: Bruce Schuchardt <bschuchardt@pivotal.io>
Committed: Tue Mar 15 14:04:47 2016 -0700

----------------------------------------------------------------------
 .../com/gemstone/gemfire/test/dunit/VM.java     |  2 +-
 .../test/dunit/tests/BasicDUnitTest.java        | 42 ++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5a88171/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java
index 8e408dc..1c6ba6e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java
@@ -259,7 +259,7 @@ public class VM implements Serializable {
    */
   public AsyncInvocation invokeAsync(String name, SerializableRunnableIF r) {
     NamedRunnable nr = new NamedRunnable(name, r);
-    return invokeAsync(r, "run", new Object[0]);
+    return invokeAsync(nr, "run", new Object[0]);
   }
   
   /**

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5a88171/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
index 195d5f4..3a98188 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
@@ -106,6 +106,48 @@ public class BasicDUnitTest extends DistributedTestCase {
     assertEquals(0, vm0num);
     
   }
+  
+  static class BasicDUnitException extends RuntimeException {
+    public BasicDUnitException() {
+    }
+  }
+  
+  public static void throwException() throws BasicDUnitException {
+    throw new BasicDUnitException();
+  }
+
+  public void testInvokeNamedRunnableLambdaAsync() throws Throwable {
+    Host host = Host.getHost(0);
+    VM vm0 = host.getVM(0);
+    
+    AsyncInvocation<Integer> async0 = vm0.invokeAsync("throwSomething", () -> BasicDUnitTest.throwException());
+    try {
+      async0.getResult();
+      throw new Error("expected an exception to be thrown");
+    } catch (Exception e) {
+      Throwable cause = e.getCause();
+      if (cause == null) {
+        throw new Error("expected an exception with a cause to be thrown", e);
+      }
+      if ( !(cause.getCause() instanceof BasicDUnitException) ) {
+        throw new Error("expected a BasicDUnitException to be thrown", e.getCause());
+      }
+    }
+  }
+
+  public void testInvokeNamedRunnableLambda() throws Throwable {
+    Host host = Host.getHost(0);
+    VM vm0 = host.getVM(0);
+    
+    try {
+      vm0.invoke("throwSomething", () -> BasicDUnitTest.throwException());
+      throw new Error("expected an exception to be thrown");
+    } catch (Exception e) {
+      if ( !(e.getCause() instanceof BasicDUnitException) ) {
+        throw new Error("expected a BasicDUnitException to be thrown", e.getCause());
+      }
+    }
+  }
 
   static class BasicTestException extends RuntimeException {
     BasicTestException() {


Mime
View raw message