@Test
  public void testReturnValue() throws Exception {
    final Host host = Host.getHost(0);
    final VM vm = host.getVM(0);
    // Assert class static invocation works
    AsyncInvocation<Integer> a1 = vm.invokeAsync(VMDistributedTest::getAndIncStaticCount);
    a1.join();
    assertEquals(0, (long) a1.getReturnValue());
    // Assert class static invocation with args works
    a1 = vm.invokeAsync(() -> incrementStaticCount(2));
    a1.join();
    assertEquals(3, (long) a1.getReturnValue());
    // Assert that previous values are not returned when invoking method w/ no return val
    a1 = vm.invokeAsync(VMDistributedTest::incStaticCount);
    a1.join();
    assertNull(a1.getReturnValue());
    // Assert that previous null returns are over-written
    a1 = vm.invokeAsync(VMDistributedTest::getAndIncStaticCount);
    a1.join();
    assertEquals(4, (long) a1.getReturnValue());

    // Assert object method invocation works with zero arg method
    final VMTestObject o = new VMTestObject(0);
    a1 = vm.invokeAsync(o, "incrementAndGet", new Object[] {});
    a1.join();
    assertEquals(1, (long) a1.getReturnValue());
    // Assert object method invocation works with no return
    a1 = vm.invokeAsync(o, "set", new Object[] {3});
    a1.join();
    assertNull(a1.getReturnValue());
  }
This class tests the functionality of the {@link VM} class.
geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/tests/VMDistributedTest.java