geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [geode] 03/13: GEODE-5058: Delete redundant DUnit tests with JUnit4 prefix
Date Mon, 23 Apr 2018 05:46:41 GMT
This is an automated email from the ASF dual-hosted git repository.

klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 83dd8fc2a0996ee04d89dfa5fb2c69ea9c3ef42e
Author: Kirk Lund <klund@apache.org>
AuthorDate: Thu Apr 12 12:00:32 2018 -0700

    GEODE-5058: Delete redundant DUnit tests with JUnit4 prefix
---
 .../test/dunit/tests/JUnit4BasicDUnitTest.java     | 243 ---------------------
 .../JUnit4GetDefaultDiskStoreNameDUnitTest.java    |  67 ------
 .../tests/JUnit4GetTestMethodNameDUnitTest.java    |  53 -----
 ...ridingGetPropertiesDisconnectsAllDUnitTest.java |  60 -----
 .../geode/test/dunit/tests/JUnit4VMDUnitTest.java  | 205 -----------------
 5 files changed, 628 deletions(-)

diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4BasicDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4BasicDUnitTest.java
deleted file mode 100644
index d5edae7..0000000
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4BasicDUnitTest.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * 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.geode.test.dunit.tests;
-
-import static com.googlecode.catchexception.CatchException.*;
-import static com.googlecode.catchexception.throwable.CatchThrowable.*;
-import static org.apache.geode.test.dunit.Assert.*;
-import static org.apache.geode.test.dunit.Invoke.*;
-import static org.hamcrest.Matchers.*;
-
-import java.util.Properties;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.test.dunit.AsyncInvocation;
-import org.apache.geode.test.dunit.DUnitEnv;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.RMIException;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.junit.categories.DistributedTest;
-
-/**
- * This class tests the basic functionality of the distributed unit test framework.
- */
-@Category(DistributedTest.class)
-@SuppressWarnings({"serial", "unused"})
-public class JUnit4BasicDUnitTest extends JUnit4DistributedTestCase {
-
-  private static final String MESSAGE_FOR_remoteThrowException = "Test exception.  Please
ignore.";
-
-  private static Properties bindings;
-
-  private VM vm0;
-  private VM vm1;
-
-  @BeforeClass
-  public static void setUpJUnit4BasicDUnitTest() throws Exception {
-    invokeInEveryVM(() -> bindings = new Properties());
-  }
-
-  @Override
-  public final void postSetUp() throws Exception {
-    this.vm0 = Host.getHost(0).getVM(0);
-    this.vm1 = Host.getHost(0).getVM(1);
-  }
-
-  @AfterClass
-  public static void tearDownJUnit4BasicDUnitTest() {
-    invokeInEveryVM(() -> bindings = null);
-  }
-
-  @Test
-  public void testPreconditions() {
-    invokeInEveryVM(
-        () -> assertThat("getUniqueName() must not return null", getUniqueName(), notNullValue()));
-    invokeInEveryVM(() -> assertThat("bindings must not be null", bindings, notNullValue()));
-  }
-
-  @Test
-  public void testInvokeOnClassTargetWithEmptyArgs() throws Exception {
-    assertThat(this.vm0.invoke(JUnit4BasicDUnitTest.class, "booleanValue", new Object[] {}),
-        is(true));
-  }
-
-  @Test
-  public void testInvokeOnObjectTargetWithEmptyArgs() throws Exception {
-    assertThat(this.vm0.invoke(new JUnit4BasicDUnitTest(), "booleanValue", new Object[] {}),
-        is(true));
-  }
-
-  @Test
-  public void testInvokeAsyncOnClassTargetWithEmptyArgs() throws Exception {
-    AsyncInvocation<?> async =
-        this.vm0.invokeAsync(JUnit4BasicDUnitTest.class, "booleanValue", new Object[] {}).join();
-    assertThat(async.getResult(), is(true));
-  }
-
-  @Test
-  public void testInvokeAsyncOnObjectTargetWithEmptyArgs() throws Exception {
-    AsyncInvocation<?> async =
-        this.vm0.invokeAsync(new JUnit4BasicDUnitTest(), "booleanValue", new Object[] {}).join();
-    assertThat(async.getResult(), is(true));
-  }
-
-  @Test
-  public void testInvokeOnClassTargetWithNullArgs() throws Exception {
-    assertThat(this.vm0.invoke(JUnit4BasicDUnitTest.class, "booleanValue", null), is(true));
-  }
-
-  @Test
-  public void testInvokeOnObjectTargetWithNullArgs() throws Exception {
-    assertThat(this.vm0.invoke(new JUnit4BasicDUnitTest(), "booleanValue", null), is(true));
-  }
-
-  @Test
-  public void testInvokeAsyncOnClassTargetWithNullArgs() throws Exception {
-    AsyncInvocation<?> async =
-        this.vm0.invokeAsync(JUnit4BasicDUnitTest.class, "booleanValue", null).join();
-    assertThat(async.getResult(), is(true));
-  }
-
-  @Test
-  public void testInvokeAsyncOnObjectTargetWithNullArgs() throws Exception {
-    AsyncInvocation<?> async =
-        this.vm0.invokeAsync(new JUnit4BasicDUnitTest(), "booleanValue", null).join();
-    assertThat(async.getResult(), is(true));
-  }
-
-  @Test
-  public void testRemoteInvocationWithException() throws Exception {
-    catchException(this.vm0).invoke(() -> remoteThrowException());
-
-    assertThat(caughtException(), instanceOf(RMIException.class));
-    assertThat(caughtException().getCause(), notNullValue());
-    assertThat(caughtException().getCause(), instanceOf(BasicTestException.class));
-    assertThat(caughtException().getCause().getMessage(), is(MESSAGE_FOR_remoteThrowException));
-  }
-
-  @Test
-  public void testInvokeWithLambda() throws Exception {
-    assertThat(this.vm0.invoke(() -> DUnitEnv.get().getVMID()), is(0));
-    assertThat(this.vm1.invoke(() -> DUnitEnv.get().getVMID()), is(1));
-  }
-
-  @Test
-  public void testInvokeLambdaAsync() throws Throwable {
-    assertThat(this.vm0.invokeAsync(() -> DUnitEnv.get().getVMID()).getResult(), is(0));
-  }
-
-  @Test
-  public void testInvokeWithNamedLambda() {
-    assertThat(this.vm0.invoke("getVMID", () -> DUnitEnv.get().getVMID()), is(0));
-    assertThat(this.vm1.invoke("getVMID", () -> DUnitEnv.get().getVMID()), is(1));
-  }
-
-  @Test
-  public void testInvokeNamedLambdaAsync() throws Throwable {
-    assertThat(this.vm0.invokeAsync("getVMID", () -> DUnitEnv.get().getVMID()).getResult(),
is(0));
-  }
-
-  @Test
-  public void testRemoteInvokeAsync() throws Exception {
-    String name = getUniqueName();
-    String value = "Hello";
-
-    this.vm0.invokeAsync(() -> remoteBind(name, value)).join().checkException();
-    this.vm0.invokeAsync(() -> remoteValidateBind(name, value)).join().checkException();
-  }
-
-  @Test
-  public void testRemoteInvokeAsyncWithException() throws Exception {
-    AsyncInvocation<?> async = this.vm0.invokeAsync(() -> remoteThrowException()).join();
-
-    assertThat(async.exceptionOccurred(), is(true));
-    assertThat(async.getException(), instanceOf(BasicTestException.class));
-
-    catchThrowable(async).checkException();
-
-    assertThat(caughtThrowable(), instanceOf(AssertionError.class));
-    assertThat(caughtThrowable().getCause(), notNullValue());
-    assertThat(caughtThrowable().getCause(), instanceOf(BasicTestException.class));
-    assertThat(caughtThrowable().getCause().getMessage(), is(MESSAGE_FOR_remoteThrowException));
-  }
-
-  @Test
-  public void testInvokeNamedRunnableLambdaAsync() throws Exception {
-    catchThrowable(this.vm0.invokeAsync("throwSomething", () -> throwException()).join())
-        .checkException();
-
-    assertThat(caughtThrowable(), notNullValue());
-    assertThat(caughtThrowable().getCause(), notNullValue());
-    assertThat(caughtThrowable().getCause(), instanceOf(BasicDUnitException.class));
-  }
-
-  @Test
-  public void testInvokeNamedRunnableLambda() throws Exception {
-    catchException(this.vm0).invoke("throwSomething", () -> throwException());
-
-    assertThat(caughtException(), notNullValue());
-    assertThat(caughtException().getCause(), notNullValue());
-    assertThat(caughtException().getCause(), instanceOf(BasicDUnitException.class));
-    assertThat(caughtException().getCause().getMessage(), nullValue());
-  }
-
-  private static boolean booleanValue() { // invoked by reflection
-    return true;
-  }
-
-  private static boolean booleanValue(final boolean value) { // invoked by reflection
-    return value;
-  }
-
-  private static void remoteThrowException() {
-    throw new BasicTestException(MESSAGE_FOR_remoteThrowException);
-  }
-
-  private static void throwException() throws BasicDUnitException {
-    throw new BasicDUnitException();
-  }
-
-  private static void remoteBind(String name, String value) {
-    assertNotNull("name must not be null", name);
-    assertNotNull("value must not be null", value);
-    assertNotNull("bindings must not be null", bindings);
-
-    new JUnit4BasicDUnitTest().getSystem(); // forces connection
-    bindings.setProperty(name, value);
-  }
-
-  private static void remoteValidateBind(String name, String expected) {
-    assertEquals(expected, bindings.getProperty(name));
-  }
-
-  private static class BasicTestException extends RuntimeException {
-    BasicTestException() {
-      this("Test exception.  Please ignore.");
-    }
-
-    BasicTestException(String s) {
-      super(s);
-    }
-  }
-
-  private static class BasicDUnitException extends RuntimeException {
-    public BasicDUnitException() {}
-  }
-}
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4GetDefaultDiskStoreNameDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4GetDefaultDiskStoreNameDUnitTest.java
deleted file mode 100644
index c8cd900..0000000
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4GetDefaultDiskStoreNameDUnitTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.geode.test.dunit.tests;
-
-import static org.assertj.core.api.Assertions.*;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.junit.categories.DistributedTest;
-
-@Category(DistributedTest.class)
-@SuppressWarnings("serial")
-public class JUnit4GetDefaultDiskStoreNameDUnitTest extends JUnit4DistributedTestCase {
-
-  @Test
-  public void testGetTestMethodName() {
-    String expected = createDefaultDiskStoreName(0, -1, "testGetTestMethodName");
-    assertGetDefaultDiskStoreName(expected);
-  }
-
-  @Test
-  public void testGetTestMethodNameChanges() {
-    String expected = createDefaultDiskStoreName(0, -1, "testGetTestMethodNameChanges");
-    assertGetDefaultDiskStoreName(expected);
-  }
-
-  @Test
-  public void testGetTestMethodNameInAllVMs() {
-    String expected = createDefaultDiskStoreName(0, -1, "testGetTestMethodNameInAllVMs");
-    assertGetDefaultDiskStoreName(expected);
-
-    for (int vmIndex = 0; vmIndex < Host.getHost(0).getVMCount(); vmIndex++) {
-      String expectedInVM = createDefaultDiskStoreName(0, vmIndex, "testGetTestMethodNameInAllVMs");
-      Host.getHost(0).getVM(vmIndex).invoke(() -> assertGetDefaultDiskStoreName(expectedInVM));
-    }
-  }
-
-  private void assertGetDefaultDiskStoreName(final String expected) {
-    assertThat(getDefaultDiskStoreName()).isEqualTo(expected);
-  }
-
-  private String createDefaultDiskStoreName(final int hostIndex, final int vmIndex,
-      final String methodName) {
-    return "DiskStore-" + hostIndex + "-" + vmIndex + "-" + getClass().getCanonicalName()
+ "."
-        + methodName;
-  }
-
-  private String getDefaultDiskStoreName() {
-    return GemFireCacheImpl.getDefaultDiskStoreName(); // TODO: not thread safe
-  }
-}
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4GetTestMethodNameDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4GetTestMethodNameDUnitTest.java
deleted file mode 100644
index e88ec6f..0000000
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4GetTestMethodNameDUnitTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.geode.test.dunit.tests;
-
-import static org.assertj.core.api.Assertions.*;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.junit.categories.DistributedTest;
-
-@Category(DistributedTest.class)
-@SuppressWarnings("serial")
-public class JUnit4GetTestMethodNameDUnitTest extends JUnit4DistributedTestCase {
-
-  @Test
-  public void testGetTestMethodName() {
-    assertGetTestMethodName("testGetTestMethodName");
-  }
-
-  @Test
-  public void testGetTestMethodNameChanges() {
-    assertGetTestMethodName("testGetTestMethodNameChanges");
-  }
-
-  @Test
-  public void testGetTestMethodNameInAllVMs() {
-    assertGetTestMethodName("testGetTestMethodNameInAllVMs");
-
-    for (int vmIndex = 0; vmIndex < Host.getHost(0).getVMCount(); vmIndex++) {
-      Host.getHost(0).getVM(vmIndex)
-          .invoke(() -> assertGetTestMethodName("testGetTestMethodNameInAllVMs"));
-    }
-  }
-
-  private void assertGetTestMethodName(final String expected) {
-    assertThat(getTestMethodName()).isEqualTo(expected);
-  }
-}
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4OverridingGetPropertiesDisconnectsAllDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4OverridingGetPropertiesDisconnectsAllDUnitTest.java
deleted file mode 100644
index df6c35d..0000000
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4OverridingGetPropertiesDisconnectsAllDUnitTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.geode.test.dunit.tests;
-
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
-import static org.apache.geode.test.dunit.Assert.*;
-import static org.apache.geode.test.dunit.Invoke.invokeInEveryVM;
-
-import java.util.Properties;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.junit.categories.DistributedTest;
-
-/**
- * Verifies that overriding {@code getDistributedSystemProperties} results in
- * {@code disconnectAllFromDS} during tear down.
- */
-@Category(DistributedTest.class)
-@SuppressWarnings("serial")
-public class JUnit4OverridingGetPropertiesDisconnectsAllDUnitTest
-    extends JUnit4DistributedTestCase {
-
-  @Override
-  public final void preTearDownAssertions() throws Exception {
-    invokeInEveryVM(() -> assertNotNull(basicGetSystem()));
-  }
-
-  @Override
-  public final void postTearDownAssertions() throws Exception {
-    invokeInEveryVM(() -> assertNull(basicGetSystem()));
-  }
-
-  @Override
-  public final Properties getDistributedSystemProperties() {
-    Properties props = new Properties();
-    props.setProperty(MCAST_PORT, "0");
-    return props;
-  }
-
-  @Test
-  public void testDisconnects() throws Exception {
-    invokeInEveryVM(() -> assertFalse(getDistributedSystemProperties().isEmpty()));
-    invokeInEveryVM(() -> assertNotNull(getSystem()));
-  }
-}
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4VMDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4VMDUnitTest.java
deleted file mode 100644
index 1538355..0000000
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4VMDUnitTest.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * 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.geode.test.dunit.tests;
-
-import static org.apache.geode.test.dunit.Assert.*;
-
-import java.io.Serializable;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.test.dunit.AsyncInvocation;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.RMIException;
-import org.apache.geode.test.dunit.SerializableRunnableIF;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.junit.categories.DistributedTest;
-
-/**
- * This class tests the functionality of the {@link VM} class.
- */
-@Category(DistributedTest.class)
-@SuppressWarnings("serial")
-public class JUnit4VMDUnitTest extends JUnit4DistributedTestCase {
-
-  private static final AtomicInteger COUNTER = new AtomicInteger();
-  private static final boolean BOOLEAN_VALUE = true;
-  private static final byte BYTE_VALUE = (byte) 40;
-  private static final long LONG_VALUE = 42L;
-  private static final String STRING_VALUE = "BLAH BLAH BLAH";
-
-  @Test
-  public void testInvokeStaticBoolean() {
-    Host host = Host.getHost(0);
-    VM vm = host.getVM(0);
-    assertEquals(BOOLEAN_VALUE, (boolean) vm.invoke(() -> remoteBooleanMethod()));
-  }
-
-  @Test
-  public void testInvokeStaticByte() {
-    Host host = Host.getHost(0);
-    VM vm = host.getVM(0);
-    assertEquals(BYTE_VALUE, (byte) vm.invoke(() -> remoteByteMethod()));
-  }
-
-  @Test
-  public void testInvokeStaticLong() {
-    Host host = Host.getHost(0);
-    VM vm = host.getVM(0);
-    assertEquals(LONG_VALUE, (long) vm.invoke(() -> remoteLongMethod()));
-  }
-
-  @Test
-  public void testInvokeInstance() {
-    Host host = Host.getHost(0);
-    VM vm = host.getVM(0);
-    assertEquals(STRING_VALUE, vm.invoke(new ClassWithString(), "getString"));
-  }
-
-  @Test
-  public void testInvokeRunnableWithException() {
-    Host host = Host.getHost(0);
-    VM vm = host.getVM(0);
-    try {
-      vm.invoke(new InvokeRunnable());
-      fail("Should have thrown a BasicTestException");
-    } catch (RMIException ex) {
-      assertTrue(ex.getCause() instanceof BasicTestException);
-    }
-  }
-
-  @Test
-  public void testReturnValue() throws Exception {
-    final Host host = Host.getHost(0);
-    final VM vm = host.getVM(0);
-    // Assert class static invocation works
-    AsyncInvocation a1 = vm.invokeAsync(() -> getAndIncStaticCount());
-    a1.join();
-    assertEquals(new Integer(0), a1.getReturnValue());
-    // Assert class static invocation with args works
-    a1 = vm.invokeAsync(() -> incrementStaticCount(new Integer(2)));
-    a1.join();
-    assertEquals(new Integer(3), a1.getReturnValue());
-    // Assert that previous values are not returned when invoking method w/ no return val
-    a1 = vm.invokeAsync(() -> incStaticCount());
-    a1.join();
-    assertNull(a1.getReturnValue());
-    // Assert that previous null returns are over-written
-    a1 = vm.invokeAsync(() -> getAndIncStaticCount());
-    a1.join();
-    assertEquals(new Integer(4), 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(new Integer(1), a1.getReturnValue());
-    // Assert object method invocation works with no return
-    a1 = vm.invokeAsync(o, "set", new Object[] {new Integer(3)});
-    a1.join();
-    assertNull(a1.getReturnValue());
-  }
-
-  private static Integer getAndIncStaticCount() {
-    return new Integer(COUNTER.getAndIncrement());
-  }
-
-  private static Integer incrementStaticCount(Integer inc) {
-    return new Integer(COUNTER.addAndGet(inc.intValue()));
-  }
-
-  private static void incStaticCount() {
-    COUNTER.incrementAndGet();
-  }
-
-  /**
-   * Accessed via reflection. DO NOT REMOVE
-   */
-  private static byte remoteByteMethod() {
-    return BYTE_VALUE;
-  }
-
-  /**
-   * Accessed via reflection. DO NOT REMOVE
-   */
-  private static boolean remoteBooleanMethod() {
-    return BOOLEAN_VALUE;
-  }
-
-  /**
-   * Accessed via reflection. DO NOT REMOVE
-   */
-  private static long remoteLongMethod() {
-    return LONG_VALUE;
-  }
-
-  private static class ClassWithLong implements Serializable {
-    public long getLong() {
-      return LONG_VALUE;
-    }
-  }
-
-  private static class ClassWithByte implements Serializable {
-    public byte getByte() {
-      return BYTE_VALUE;
-    }
-  }
-
-  private static class InvokeRunnable implements SerializableRunnableIF {
-    public void run() {
-      throw new BasicTestException();
-    }
-  }
-
-  private static class ClassWithString implements Serializable {
-    public String getString() {
-      return STRING_VALUE;
-    }
-  }
-
-  private static class BasicTestException extends RuntimeException {
-    BasicTestException() {
-      this("Test exception.  Please ignore.");
-    }
-
-    BasicTestException(String s) {
-      super(s);
-    }
-  }
-
-  private static class VMTestObject implements Serializable {
-    private static final long serialVersionUID = 1L;
-    private final AtomicInteger val;
-
-    public VMTestObject(int init) {
-      this.val = new AtomicInteger(init);
-    }
-
-    public Integer get() {
-      return new Integer(this.val.get());
-    }
-
-    public Integer incrementAndGet() {
-      return new Integer(this.val.incrementAndGet());
-    }
-
-    public void set(Integer newVal) {
-      this.val.set(newVal.intValue());
-    }
-  }
-}

-- 
To stop receiving notification emails like this one, please contact
klund@apache.org.

Mime
View raw message