You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ji...@apache.org on 2016/04/12 23:16:29 UTC
[04/18] incubator-geode git commit: Add SecurityTest and FlakyTest.
Convert CLI tests to JUnit 4.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/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 962978f..b559a6e 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
@@ -21,19 +21,24 @@ import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.rmi.RemoteException;
+import java.util.concurrent.Callable;
+import com.jayway.awaitility.Awaitility;
+import hydra.MethExecutorResult;
+
+import com.gemstone.gemfire.internal.process.ProcessUtils;
import com.gemstone.gemfire.test.dunit.standalone.BounceResult;
import com.gemstone.gemfire.test.dunit.standalone.RemoteDUnitVMIF;
-
-import hydra.MethExecutorResult;
+import com.gemstone.gemfire.test.dunit.standalone.StandAloneDUnitEnv;
/**
* This class represents a Java Virtual Machine that runs on a host.
- *
*/
@SuppressWarnings("serial")
public class VM implements Serializable {
+ private static final int MAX_RETRY_COUNT = 0; // was 120 for JDK 1.3 or 1.4 on Windows
+
/** The host on which this VM runs */
private Host host;
@@ -46,11 +51,33 @@ public class VM implements Serializable {
/** The state of this VM */
private volatile boolean available;
- //////////////////// Constructors ////////////////////
+ /**
+ * Returns the {@code VM} identity. For {@link StandAloneDUnitEnv} the number
+ * returned is a zero-based sequence representing the order in with
+ * the DUnit {@code VM}s were launched.
+ */
+ public static int getCurrentVMNum() {
+ return DUnitEnv.get().getVMID();
+ }
/**
- * Creates a new <code>VM</code> that runs on a given host with a
- * given process id.
+ * Returns the total number of {@code VM}s on all {@code Host}s (note that
+ * DUnit currently only supports one {@code Host}).
+ */
+ public static int getVMCount() {
+ int count = 0;
+ for (int h = 0; h < Host.getHostCount(); h++) {
+ Host host = Host.getHost(h);
+ count += host.getVMCount();
+ }
+ return count;
+ }
+
+ /**
+ * Creates a new {@code VM} that runs on a given host with a given process
+ * id.
+ *
+ * TODO: change pid to reflect value from {@link ProcessUtils#identifyPid()}
*/
public VM(final Host host, final int pid, final RemoteDUnitVMIF client) {
this.host = host;
@@ -59,452 +86,415 @@ public class VM implements Serializable {
this.available = true;
}
- ////////////////////// Accessors //////////////////////
-
/**
- * Returns the host on which this <code>VM</code> runs
+ * Returns the {@code Host} on which this {@code VM} is running.
*/
public Host getHost() {
return this.host;
}
/**
- * Returns the process id of this <code>VM</code>
+ * Returns the process id of this {@code VM}.
*/
public int getPid() {
return this.pid;
}
- ///////////////// Remote Method Invocation ///////////////
-
/**
- * Invokes a static zero-arg method with an {@link Object} or
- * <code>void</code> return type in this VM. If the return type of
- * the method is <code>void</code>, <code>null</code> is returned.
- *
- * @param targetClass
- * The class on which to invoke the method
- * @param methodName
- * The name of the method to invoke
+ * Invokes a static zero-arg method with an {@link Object} or {@code void}
+ * return type in this {@code VM}. If the return type of the method is
+ * {@code void}, {@code null} is returned.
*
+ * @param targetClass
+ * The class on which to invoke the method
+ * @param methodName
+ * The name of the method to invoke
+ *
* @throws RMIException
- * An exception occurred on while invoking the method in
+ * Wraps any underlying exception thrown while invoking the method in
* this VM
- * @deprecated Use {@link #invoke(SerializableCallableIF)} instead
+ *
+ * @deprecated Please use {@link #invoke(SerializableCallableIF)} instead
*/
public Object invoke(final Class targetClass, final String methodName) {
return invoke(targetClass, methodName, new Object[0]);
}
/**
- * Asynchronously invokes a static zero-arg method with an {@link
- * Object} or <code>void</code> return type in this VM. If the
- * return type of the method is <code>void</code>, <code>null</code>
- * is returned.
+ * Asynchronously invokes a static zero-arg method with an {@code Object} or
+ * {@code void} return type in this VM. If the return type of the method is
+ * {@code void}, {@code null} is returned.
*
- * @param targetClass
- * The class on which to invoke the method
- * @param methodName
- * The name of the method to invoke
- * @deprecated Use {@link #invoke(SerializableCallableIF)} instead
+ * @param targetClass
+ * The class on which to invoke the method
+ * @param methodName
+ * The name of the method to invoke
+ *
+ * @deprecated Please use {@link #invoke(SerializableCallableIF)} instead
*/
public AsyncInvocation invokeAsync(final Class targetClass, final String methodName) {
return invokeAsync(targetClass, methodName, null);
}
/**
- * Invokes a static method with an {@link Object} or
- * <code>void</code> return type in this VM. If the return type of
- * the method is <code>void</code>, <code>null</code> is returned.
- *
- * @param targetClass
- * The class on which to invoke the method
- * @param methodName
- * The name of the method to invoke
- * @param args
- * Arguments passed to the method call (must be {@link
- * java.io.Serializable}).
+ * Invokes a static method with an {@link Object} or {@code void} return type
+ * in this VM. If the return type of the method is {@code void},
+ * {@code null} is returned.
*
+ * @param targetClass
+ * The class on which to invoke the method
+ * @param methodName
+ * The name of the method to invoke
+ * @param args
+ * Arguments passed to the method call (must be
+ * {@link java.io.Serializable}).
+ *
* @throws RMIException
- * An exception occurred on while invoking the method in
- * this VM
- * @deprecated Use {@link #invoke(SerializableCallableIF)} instead
+ * Wraps any underlying exception thrown while invoking the method in
+ * this {@code VM}
+ *
+ * @deprecated Please use {@link #invoke(SerializableCallableIF)} instead
*/
- public Object invoke(Class targetClass, String methodName, Object[] args) {
+ public Object invoke(final Class targetClass, final String methodName, final Object[] args) {
if (!this.available) {
- String s = "VM not available: " + this;
- throw new RMIException(this, targetClass.getName(), methodName,
- new IllegalStateException(s));
+ throw new RMIException(this, targetClass.getName(), methodName, new IllegalStateException("VM not available: " + this));
}
- MethExecutorResult result = null;
- int retryCount = 120;
- do {
- try {
- result = this.client.executeMethodOnClass(targetClass.getName(), methodName, args);
- break; // out of while loop
- } catch( RemoteException e ) {
- boolean isWindows = false;
- String os = System.getProperty("os.name");
- if (os != null) {
- if (os.indexOf("Windows") != -1) {
- isWindows = true;
- }
- }
- if (isWindows && retryCount-- > 0) {
- boolean interrupted = Thread.interrupted();
- try { Thread.sleep(1000); } catch (InterruptedException ignore) {interrupted = true;}
- finally {
- if (interrupted) {
- Thread.currentThread().interrupt();
- }
- }
- } else {
- throw new RMIException(this, targetClass.getName(), methodName, e );
- }
- }
- } while (true);
+
+ MethExecutorResult result = execute(targetClass, methodName, args, MAX_RETRY_COUNT);
if (!result.exceptionOccurred()) {
return result.getResult();
} else {
- Throwable thr = result.getException();
- throw new RMIException(this, targetClass.getName(), methodName, thr,
- result.getStackTrace());
+ throw new RMIException(this, targetClass.getName(), methodName, result.getException(), result.getStackTrace());
}
}
/**
- * Asynchronously invokes a static method with an {@link Object} or
- * <code>void</code> return type in this VM. If the return type of
- * the method is <code>void</code>, <code>null</code> is returned.
+ * Asynchronously invokes an instance method with an {@link Object} or
+ * {@code void} return type in this {@code VM}. If the return type of the
+ * method is {@code void}, {@code null} is returned.
*
- * @param targetClass
- * The class on which to invoke the method
- * @param methodName
- * The name of the method to invoke
- * @param args
- * Arguments passed to the method call (must be {@link
- * java.io.Serializable}).
- * @deprecated Use {@link #invoke(SerializableCallableIF)} instead
+ * @param targetObject
+ * The object on which to invoke the method
+ * @param methodName
+ * The name of the method to invoke
+ * @param args
+ * Arguments passed to the method call (must be {@link
+ * java.io.Serializable}).
+ *
+ * @deprecated Please use {@link #invoke(SerializableCallableIF)} instead
*/
- public AsyncInvocation invokeAsync(final Class targetClass,
- final String methodName,
- final Object[] args) {
- AsyncInvocation ai =
- new AsyncInvocation(targetClass, methodName, new Runnable() {
- public void run() {
- final Object o = invoke(targetClass, methodName, args);
- AsyncInvocation.setReturnValue(o);
- }
- });
- ai.start();
- return ai;
+ public AsyncInvocation invokeAsync(final Object targetObject, final String methodName, final Object[] args) {
+ return new AsyncInvocation(targetObject, methodName, () -> invoke(targetObject, methodName, args)).start();
}
/**
* Asynchronously invokes an instance method with an {@link Object} or
- * <code>void</code> return type in this VM. If the return type of
- * the method is <code>void</code>, <code>null</code> is returned.
+ * {@code void} return type in this {@code VM}. If the return type of the
+ * method is {@code void}, {@code null} is returned.
+ *
+ * @param targetClass
+ * The class on which to invoke the method
+ * @param methodName
+ * The name of the method to invoke
+ * @param args
+ * Arguments passed to the method call (must be {@link
+ * java.io.Serializable}).
*
- * @param o
- * The object on which to invoke the method
- * @param methodName
- * The name of the method to invoke
- * @param args
- * Arguments passed to the method call (must be {@link
- * java.io.Serializable}).
- * @deprecated Use {@link #invoke(SerializableCallableIF)} instead
+ * @deprecated Please use {@link #invoke(SerializableCallableIF)} instead
*/
- public AsyncInvocation invokeAsync(final Object o,
- final String methodName,
- final Object[] args) {
- AsyncInvocation ai =
- new AsyncInvocation(o, methodName, new Runnable() {
- public void run() {
- final Object ret = invoke(o, methodName, args);
- AsyncInvocation.setReturnValue(ret);
- }
- });
- ai.start();
- return ai;
+ public AsyncInvocation invokeAsync(final Class<?> targetClass, final String methodName, final Object[] args) {
+ return new AsyncInvocation(targetClass, methodName, () -> invoke(targetClass, methodName, args)).start();
}
/**
- * Invokes the <code>run</code> method of a {@link Runnable} in this
- * VM. Recall that <code>run</code> takes no arguments and has no
- * return value.
- *
- * @param r
- * The <code>Runnable</code> to be run
+ * Invokes the {@code run} method of a {@link Runnable} in this VM. Recall
+ * that {@code run} takes no arguments and has no return value.
*
+ * @param runnable
+ * The {@code Runnable} to be run
+ *
* @see SerializableRunnable
*/
- public AsyncInvocation invokeAsync(SerializableRunnableIF r) {
- return invokeAsync(r, "run", new Object[0]);
+ public AsyncInvocation invokeAsync(final SerializableRunnableIF runnable) {
+ return invokeAsync(runnable, "run", new Object[0]);
}
/**
- * Invokes the <code>run</code> method of a {@link Runnable} in this
- * VM. Recall that <code>run</code> takes no arguments and has no
- * return value. The Runnable is wrapped in a NamedRunnable having
- * the given name so it shows up in dunit logs.
+ * Invokes the {@code run} method of a {@link Runnable} in this VM. Recall
+ * that {@code run} takes no arguments and has no return value. The
+ * {@code Runnable} is wrapped in a {@link NamedRunnable} having the given
+ * name so it shows up in DUnit logs.
*
- * @param r
- * The <code>Runnable</code> to be run
- * @param name the name of the runnable, which will be logged in dunit output
+ * @param runnable
+ * The {@code Runnable} to be run
+ * @param name
+ * The name of the {@code Runnable}, which will be logged in DUnit
+ * output
*
* @see SerializableRunnable
*/
- public AsyncInvocation invokeAsync(String name, SerializableRunnableIF r) {
- NamedRunnable nr = new NamedRunnable(name, r);
- return invokeAsync(nr, "run", new Object[0]);
+ public AsyncInvocation invokeAsync(final String name, final SerializableRunnableIF runnable) {
+ return invokeAsync(new NamedRunnable(name, runnable), "run", new Object[0]);
}
/**
- * Invokes the <code>call</code> method of a {@link Runnable} in this
- * VM.
+ * Invokes the {@code call} method of a {@link Callable} in this {@code VM}.
*
- * @param c
- * The <code>Callable</code> to be run
- * @param name the name of the callable, which will be logged in dunit output
+ * @param callable
+ * The {@code Callable} to be run
+ * @param name
+ * The name of the {@code Callable}, which will be logged in dunit
+ * output
*
* @see SerializableCallable
*/
- public <T> AsyncInvocation<T> invokeAsync(String name, SerializableCallableIF<T> c) {
- return invokeAsync(new NamedCallable(name, c), "call", new Object[0]);
+ public <T> AsyncInvocation<T> invokeAsync(final String name, final SerializableCallableIF<T> callable) {
+ return invokeAsync(new NamedCallable(name, callable), "call", new Object[0]);
}
/**
- * Invokes the <code>call</code> method of a {@link Runnable} in this
- * VM.
+ * Invokes the {@code call} method of a {@link Callable} in this {@code VM}.
*
- * @param c
- * The <code>Callable</code> to be run
+ * @param callable
+ * The {@code Callable} to be run
*
* @see SerializableCallable
*/
- public <T> AsyncInvocation<T> invokeAsync(SerializableCallableIF<T> c) {
- return invokeAsync(c, "call", new Object[0]);
+ public <T> AsyncInvocation<T> invokeAsync(final SerializableCallableIF<T> callable) {
+ return invokeAsync(callable, "call", new Object[0]);
}
/**
- * Invokes the <code>run</code> method of a {@link Runnable} in this
- * VM. Recall that <code>run</code> takes no arguments and has no
- * return value.
+ * Invokes the {@code run} method of a {@link Runnable} in this {@code VM}.
+ * Recall that {@code run} takes no arguments and has no return value.
*
- * @param r
- * The <code>Runnable</code> to be run
- * @param name the name of the runnable, which will be logged in dunit output
+ * @param runnable
+ * The {@code Runnable} to be run
+ * @param name
+ * The name of the {@code Runnable}, which will be logged in DUnit
+ * output
*
* @see SerializableRunnable
*/
- public void invoke(String name, SerializableRunnableIF r) {
- invoke(new NamedRunnable(name, r), "run");
+ public void invoke(final String name, final SerializableRunnableIF runnable) {
+ invoke(new NamedRunnable(name, runnable), "run");
}
/**
- * Invokes the <code>run</code> method of a {@link Runnable} in this
- * VM. Recall that <code>run</code> takes no arguments and has no
- * return value.
+ * Invokes the {@code run} method of a {@link Runnable} in this {@code VM}.
+ * Recall that {@code run} takes no arguments and has no return value.
*
- * @param r
- * The <code>Runnable</code> to be run
+ * @param runnable
+ * The {@code Runnable} to be run
*
* @see SerializableRunnable
*/
- public void invoke(SerializableRunnableIF r) {
- invoke(r, "run");
+ public void invoke(final SerializableRunnableIF runnable) {
+ invoke(runnable, "run");
}
/**
- * Invokes the <code>run</code> method of a {@link Runnable} in this
- * VM. Recall that <code>run</code> takes no arguments and has no
- * return value.
+ * Invokes the {@code call} method of a {@link Callable} in this {@code VM}.
*
- * @param c
- * The <code>Callable</code> to be run
- * @param name the name of the callable, which will be logged in dunit output
+ * @param callable
+ * The {@code Callable} to be run
+ * @param name
+ * The name of the {@code Callable}, which will be logged in DUnit
+ * output
*
* @see SerializableCallable
*/
- public <T> T invoke(String name, SerializableCallableIF<T> c) {
- return (T) invoke(new NamedCallable(name, c), "call");
+ public <T> T invoke(final String name, final SerializableCallableIF<T> callable) {
+ return (T) invoke(new NamedCallable(name, callable), "call");
}
/**
- * Invokes the <code>run</code> method of a {@link Runnable} in this
- * VM. Recall that <code>run</code> takes no arguments and has no
- * return value.
+ * Invokes the {@code call} method of a {@link Callable} in this {@code VM}.
*
- * @param c
- * The <code>Callable</code> to be run
+ * @param callable
+ * The {@code Callable} to be run
*
* @see SerializableCallable
*/
- public <T> T invoke(SerializableCallableIF<T> c) {
- return (T) invoke(c, "call");
+ public <T> T invoke(final SerializableCallableIF<T> callable) {
+ return (T) invoke(callable, "call");
}
/**
- * Invokes the <code>run</code> method of a {@link Runnable} in this
- * VM. If the invocation throws AssertionFailedError, and repeatTimeoutMs
- * is >0, the <code>run</code> method is invoked repeatedly until it
+ * Invokes the {@code run} method of a {@link Runnable} in this {@code VM}.
+ * If the invocation throws AssertionFailedError, and repeatTimeoutMs
+ * is >0, the {@code run} method is invoked repeatedly until it
* either succeeds, or repeatTimeoutMs has passed. The AssertionFailedError
- * is thrown back to the sender of this method if <code>run</code> has not
+ * is thrown back to the sender of this method if {@code run} has not
* completed successfully before repeatTimeoutMs has passed.
*
- * @deprecated Please use {@link com.jayway.awaitility.Awaitility} with {@link #invoke(SerializableCallableIF)} instead.
+ * @deprecated Please use {@link Awaitility} to await condition and then {@link #invoke(SerializableCallableIF)} instead.
*/
- public void invokeRepeatingIfNecessary(RepeatableRunnable o, long repeatTimeoutMs) {
- invoke(o, "runRepeatingIfNecessary", new Object[] {new Long(repeatTimeoutMs)});
+ public void invokeRepeatingIfNecessary(final RepeatableRunnable runnable, final long repeatTimeoutMs) {
+ invoke(runnable, "runRepeatingIfNecessary", new Object[] { repeatTimeoutMs });
}
/**
- * Invokes an instance method with no arguments on an object that is
- * serialized into this VM. The return type of the method can be
- * either {@link Object} or <code>void</code>. If the return type
- * of the method is <code>void</code>, <code>null</code> is
- * returned.
+ * Invokes an instance method with no arguments on an object that is
+ * serialized into this {@code VM}. The return type of the method can be
+ * either {@link Object} or {@code void}. If the return type of the method
+ * is {@code void}, {@code null} is returned.
*
- * @param o
- * The receiver of the method invocation
- * @param methodName
- * The name of the method to invoke
+ * @param targetObject
+ * The receiver of the method invocation
+ * @param methodName
+ * The name of the method to invoke
*
* @throws RMIException
- * An exception occurred on while invoking the method in
- * this VM
- * @deprecated Use {@link #invoke(SerializableCallableIF)} instead
+ * Wraps any underlying exception thrown while invoking the method in
+ * this {@code VM}
+ *
+ * @deprecated Please use {@link #invoke(SerializableCallableIF)} instead.
*/
- public Object invoke(Object o, String methodName) {
- return invoke(o, methodName, new Object[0]);
+ public Object invoke(final Object targetObject, final String methodName) {
+ return invoke(targetObject, methodName, new Object[0]);
}
/**
- * Invokes an instance method on an object that is serialized into
- * this VM. The return type of the method can be either {@link
- * Object} or <code>void</code>. If the return type of the method
- * is <code>void</code>, <code>null</code> is returned.
+ * Invokes an instance method on an object that is serialized into this
+ * {@code VM}. The return type of the method can be either {@link Object} or
+ * {@code void}. If the return type of the method is {@code void},
+ * {@code null} is returned.
*
- * @param o
- * The receiver of the method invocation
- * @param methodName
- * The name of the method to invoke
- * @param args
- * Arguments passed to the method call (must be {@link
- * java.io.Serializable}).
+ * @param targetObject
+ * The receiver of the method invocation
+ * @param methodName
+ * The name of the method to invoke
+ * @param args
+ * Arguments passed to the method call (must be {@link
+ * java.io.Serializable}).
*
* @throws RMIException
- * An exception occurred on while invoking the method in
- * this VM
- * @deprecated Use {@link #invoke(SerializableCallableIF)} instead
+ * Wraps any underlying exception thrown while invoking the method in
+ * this {@code VM}
+ *
+ * @deprecated Please use {@link #invoke(SerializableCallableIF)} instead.
*/
- public Object invoke(Object o, String methodName, Object[] args) {
+ public Object invoke(final Object targetObject, final String methodName, final Object[] args) {
if (!this.available) {
- String s = "VM not available: " + this;
- throw new RMIException(this, o.getClass().getName(), methodName,
- new IllegalStateException(s));
- }
- MethExecutorResult result = null;
- int retryCount = 120;
- do {
- try {
- if ( args == null )
- result = this.client.executeMethodOnObject(o, methodName);
- else
- result = this.client.executeMethodOnObject(o, methodName, args);
- break; // out of while loop
- } catch( RemoteException e ) {
- if (retryCount-- > 0) {
- boolean interrupted = Thread.interrupted();
- try { Thread.sleep(1000); } catch (InterruptedException ignore) {interrupted = true;}
- finally {
- if (interrupted) {
- Thread.currentThread().interrupt();
- }
- }
- } else {
- throw new RMIException(this, o.getClass().getName(), methodName, e );
- }
+ throw new RMIException(this, targetObject.getClass().getName(), methodName, new IllegalStateException("VM not available: " + this));
}
- } while (true);
+
+ MethExecutorResult result = execute(targetObject, methodName, args, MAX_RETRY_COUNT);
if (!result.exceptionOccurred()) {
return result.getResult();
} else {
- Throwable thr = result.getException();
- throw new RMIException(this, o.getClass().getName(), methodName, thr,
- result.getStackTrace());
+ throw new RMIException(this, targetObject.getClass().getName(), methodName, result.getException(), result.getStackTrace());
}
}
-
-
-
/**
- * Synchronously bounces (mean kills and restarts) this <code>VM</code>.
- * Concurrent bounce attempts are synchronized but attempts to invoke
- * methods on a bouncing VM will cause test failure. Tests using bounce
- * should be placed at the end of the dunit test suite, since an exception
- * here will cause all tests using the unsuccessfully bounced VM to fail.
+ * Synchronously bounces (mean kills and restarts) this {@code VM}.
+ * Concurrent bounce attempts are synchronized but attempts to invoke methods
+ * on a bouncing {@code VM} will cause test failure. Tests using bounce
+ * should be placed at the end of the DUnit test suite, since an exception
+ * here will cause all tests using the unsuccessfully bounced {@code VM} to
+ * fail.
*
- * This method is currently not supported by the standalone dunit
- * runner.
+ * This method is currently not supported by the standalone DUnit runner.
*
- * @throws RMIException if an exception occurs while bouncing this VM, for
- * example a HydraTimeoutException if the VM fails to stop within
- * hydra.Prms#maxClientShutdownWaitSec or restart within
- * hydra.Prms#maxClientStartupWaitSec.
+ * @throws RMIException if an exception occurs while bouncing this
+ * {@code VM}, for example a {@code HydraTimeoutException} if the
+ * {@code VM} fails to stop within
+ * {@code hydra.Prms#maxClientShutdownWaitSec} or restart within
+ * {@code hydra.Prms#maxClientStartupWaitSec}.
*/
public synchronized void bounce() {
if (!this.available) {
- String s = "VM not available: " + this;
- throw new RMIException(this, this.getClass().getName(), "bounceVM",
- new IllegalStateException(s));
+ throw new RMIException(this, getClass().getName(), "bounceVM", new IllegalStateException("VM not available: " + this));
}
+
this.available = false;
+
try {
BounceResult result = DUnitEnv.get().bounce(this.pid);
-
this.pid = result.getNewPid();
this.client = result.getNewClient();
this.available = true;
+
} catch (UnsupportedOperationException e) {
this.available = true;
throw e;
+
} catch (RemoteException e) {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw, true));
- RMIException rmie = new RMIException(this, this.getClass().getName(),
- "bounceVM", e, sw.toString());
+ RMIException rmie = new RMIException(this, getClass().getName(), "bounceVM", e, sw.toString());
throw rmie;
}
}
- ///////////////////// Utility Methods ////////////////////
-
public String toString() {
- return "VM " + this.getPid() + " running on " + this.getHost();
+ return "VM " + getPid() + " running on " + getHost();
}
- public static int getCurrentVMNum() {
- return DUnitEnv.get().getVMID();
- }
-
public File getWorkingDirectory() {
- return DUnitEnv.get().getWorkingDirectory(this.getPid());
+ return DUnitEnv.get().getWorkingDirectory(getPid());
}
- /** Return the total number of VMs on all hosts */
- public static int getVMCount() {
- int count = 0;
- for (int h = 0; h < Host.getHostCount(); h++) {
- Host host = Host.getHost(h);
- count += host.getVMCount();
- }
- return count;
+ private MethExecutorResult execute(final Class targetClass, final String methodName, final Object[] args, int retryCount) {
+// do {
+//
+ try {
+ return this.client.executeMethodOnClass(targetClass.getName(), methodName, args);
+
+ } catch (RemoteException e) {
+// boolean isWindows = false;
+// String os = System.getProperty("os.name");
+// if (os != null) {
+// if (os.indexOf("Windows") != -1) {
+// isWindows = true;
+// }
+// }
+// if (isWindows && retryCount-- > 0) {
+// boolean interrupted = Thread.interrupted();
+// try { Thread.sleep(1000); } catch (InterruptedException ignore) {interrupted = true;}
+// finally {
+// if (interrupted) {
+// Thread.currentThread().interrupt();
+// }
+// }
+// } else {
+ throw new RMIException(this, targetClass.getName(), methodName, e );
+// }
+ }
+//
+// } while (true);
}
+ private MethExecutorResult execute(final Object targetObject, final String methodName, final Object[] args, int retryCount) {
+// do {
+
+ try {
+ if (args == null) {
+ return this.client.executeMethodOnObject(targetObject, methodName);
+ } else {
+ return this.client.executeMethodOnObject(targetObject, methodName, args);
+ }
+
+ } catch (RemoteException e) {
+// if (retryCount-- > 0) {
+// boolean interrupted = Thread.interrupted();
+// try { Thread.sleep(1000); } catch (InterruptedException ignore) {interrupted = true;}
+// finally {
+// if (interrupted) {
+// Thread.currentThread().interrupt();
+// }
+// }
+// } else {
+ throw new RMIException(this, targetObject.getClass().getName(), methodName, e );
+// }
+ }
+
+// } while (true);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java
index b73a25c..564fb91 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java
@@ -16,8 +16,8 @@
*/
package com.gemstone.gemfire.test.dunit;
-import static org.junit.Assert.fail;
import static com.gemstone.gemfire.test.dunit.Jitter.*;
+import static org.junit.Assert.*;
import org.apache.logging.log4j.Logger;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit4CacheTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit4CacheTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit4CacheTestCase.java
index b5bd5f7..6a719ab 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit4CacheTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit4CacheTestCase.java
@@ -18,13 +18,14 @@ package com.gemstone.gemfire.test.dunit.cache.internal;
import java.io.File;
import java.io.FileWriter;
-import java.io.FilenameFilter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Map;
import java.util.Properties;
+import org.apache.logging.log4j.Logger;
+
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheException;
@@ -56,7 +57,6 @@ import com.gemstone.gemfire.test.dunit.VM;
import com.gemstone.gemfire.test.dunit.Wait;
import com.gemstone.gemfire.test.dunit.WaitCriterion;
import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.logging.log4j.Logger;
/**
* This class is the base class for all distributed tests using JUnit 4 that
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit3DistributedTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit3DistributedTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit3DistributedTestCase.java
index f453e7e..71dee9b 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit3DistributedTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit3DistributedTestCase.java
@@ -19,14 +19,15 @@ package com.gemstone.gemfire.test.dunit.internal;
import java.io.Serializable;
import java.util.Properties;
+import junit.framework.TestCase;
+import org.apache.logging.log4j.Logger;
+import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
import com.gemstone.gemfire.internal.logging.LogService;
import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import junit.framework.TestCase;
-import org.apache.logging.log4j.Logger;
-import org.junit.experimental.categories.Category;
/**
* This class is the superclass of all distributed tests using JUnit 3.
@@ -36,7 +37,7 @@ public abstract class JUnit3DistributedTestCase extends TestCase implements Dist
private static final Logger logger = LogService.getLogger();
- private final JUnit4DistributedTestCase delegate = new JUnit4DistributedTestCase(this);
+ private final JUnit4DistributedTestCase delegate = new JUnit4DistributedTestCase(this) {};
/**
* Constructs a new distributed test. All JUnit 3 test classes need to have a
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit4DistributedTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit4DistributedTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit4DistributedTestCase.java
index d5b5b6f..30940b7 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit4DistributedTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit4DistributedTestCase.java
@@ -26,6 +26,12 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import org.apache.logging.log4j.Logger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+
import com.gemstone.gemfire.admin.internal.AdminDistributedSystemImpl;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.Region;
@@ -61,18 +67,13 @@ import com.gemstone.gemfire.test.dunit.Invoke;
import com.gemstone.gemfire.test.dunit.LogWriterUtils;
import com.gemstone.gemfire.test.dunit.standalone.DUnitLauncher;
import com.gemstone.gemfire.test.junit.rules.serializable.SerializableTestName;
-import org.apache.logging.log4j.Logger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
/**
* This class is the base class for all distributed tests using JUnit 4.
*
* TODO: make this class abstract when JUnit3DistributedTestCase is deleted
*/
-public class JUnit4DistributedTestCase implements DistributedTestFixture, Serializable {
+public abstract class JUnit4DistributedTestCase implements DistributedTestFixture, Serializable {
private static final Logger logger = LogService.getLogger();
@@ -98,7 +99,7 @@ public class JUnit4DistributedTestCase implements DistributedTestFixture, Serial
* no-arg constructor.
*/
public JUnit4DistributedTestCase() {
- this((DistributedTestFixture)null);
+ this(null);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit3BasicDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit3BasicDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit3BasicDUnitTest.java
deleted file mode 100644
index 5130b5c..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit3BasicDUnitTest.java
+++ /dev/null
@@ -1,189 +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 com.gemstone.gemfire.test.dunit.internal.tests;
-
-import static com.gemstone.gemfire.test.dunit.Invoke.*;
-
-import java.util.Properties;
-
-import com.gemstone.gemfire.test.dunit.Assert;
-import com.gemstone.gemfire.test.dunit.AsyncInvocation;
-import com.gemstone.gemfire.test.dunit.DUnitEnv;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.RMIException;
-import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.internal.JUnit3DistributedTestCase;
-
-/**
- * This class tests the basic functionality of the distributed unit
- * test framework.
- */
-public class JUnit3BasicDUnitTest extends JUnit3DistributedTestCase {
-
- private static Properties bindings;
-
- public JUnit3BasicDUnitTest(String name) {
- super(name);
- }
-
- @Override
- public void postSetUp() throws Exception {
- bindings = new Properties();
- invokeInEveryVM(() -> bindings = new Properties());
- }
-
- @Override
- public void postTearDown() throws Exception {
- bindings = null;
- invokeInEveryVM(() -> bindings = null);
- }
-
- public void testPreconditions() {
- invokeInEveryVM(() -> assertNotNull("getUniqueName() must not return null", getUniqueName()));
- invokeInEveryVM(() -> assertNotNull("bindings must not be null", bindings));
- }
-
- /**
- * Tests how the Hydra framework handles an error
- */
- public void ignore_testDontCatchRemoteException() throws Exception {
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
- vm.invoke(() -> remoteThrowException());
- }
-
- public void testRemoteInvocationWithException() throws Exception {
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
- try {
- vm.invoke(() -> remoteThrowException());
- fail("Should have thrown a BasicTestException");
-
- } catch (RMIException ex) {
- assertTrue(ex.getCause() instanceof BasicTestException);
- }
- }
-
- public void testInvokeWithLambda() throws Exception {
- Host host = Host.getHost(0);
- VM vm0 = host.getVM(0);
- VM vm1 = host.getVM(1);
-
- int vm0Num = vm0.invoke(() -> DUnitEnv.get().getVMID());
- int vm1Num = vm1.invoke(() -> DUnitEnv.get().getVMID());
-
- assertEquals(0, vm0Num);
- assertEquals(1, vm1Num);
- }
-
- public void testInvokeLambdaAsync() throws Throwable {
- Host host = Host.getHost(0);
- VM vm0 = host.getVM(0);
-
- AsyncInvocation<Integer> async0 = vm0.invokeAsync(() -> DUnitEnv.get().getVMID());
- int vm0num = async0.getResult();
-
- assertEquals(0, vm0num);
- }
-
- public void testInvokeWithNamedLambda() {
- Host host = Host.getHost(0);
- VM vm0 = host.getVM(0);
- VM vm1 = host.getVM(1);
-
- int vm0Num = vm0.invoke("getVMID", () -> DUnitEnv.get().getVMID());
- int vm1Num = vm1.invoke("getVMID", () -> DUnitEnv.get().getVMID());
-
- assertEquals(0, vm0Num);
- assertEquals(1, vm1Num);
- }
-
- public void testInvokeNamedLambdaAsync() throws Throwable {
- Host host = Host.getHost(0);
- VM vm0 = host.getVM(0);
-
- AsyncInvocation<Integer> async0 = vm0.invokeAsync("getVMID", () -> DUnitEnv.get().getVMID());
- int vm0num = async0.getResult();
-
- assertEquals(0, vm0num);
- }
-
- // Test was never implemented
- public void ignore_testRemoteInvocationBoolean() {
- }
-
- public void testRemoteInvokeAsync() throws Exception {
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
- String name = getUniqueName();
- String value = "Hello";
-
- AsyncInvocation ai = vm.invokeAsync(() -> remoteBind(name, value));
- ai.join();
- // TODO shouldn't we call fail() here?
- if (ai.exceptionOccurred()) {
- Assert.fail("remoteBind failed", ai.getException());
- }
-
- ai = vm.invokeAsync(() -> remoteValidateBind(name, value ));
- ai.join();
- if (ai.exceptionOccurred()) {
- Assert.fail("remoteValidateBind failed", ai.getException());
- }
- }
-
- public void testRemoteInvokeAsyncWithException() throws Exception {
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
-
- AsyncInvocation ai = vm.invokeAsync(() -> remoteThrowException());
- ai.join();
- assertTrue(ai.exceptionOccurred());
- Throwable ex = ai.getException();
- assertTrue(ex instanceof BasicTestException);
- }
-
- /**
- * Accessed via reflection. DO NOT REMOVE
- */
- private static void remoteThrowException() {
- String s = "Test exception. Please ignore.";
- throw new BasicTestException(s);
- }
-
- 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 JUnit3BasicDUnitTest("").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);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit3GetDefaultDiskStoreNameDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit3GetDefaultDiskStoreNameDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit3GetDefaultDiskStoreNameDUnitTest.java
deleted file mode 100644
index e89f66b..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit3GetDefaultDiskStoreNameDUnitTest.java
+++ /dev/null
@@ -1,66 +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 com.gemstone.gemfire.test.dunit.internal.tests;
-
-import static org.assertj.core.api.Assertions.*;
-
-import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.internal.JUnit3DistributedTestCase;
-import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import org.junit.experimental.categories.Category;
-
-@SuppressWarnings("serial")
-@Category(DistributedTest.class)
-public class JUnit3GetDefaultDiskStoreNameDUnitTest extends JUnit3DistributedTestCase {
-
- public JUnit3GetDefaultDiskStoreNameDUnitTest(final String name) {
- super(name);
- }
-
- public void testGetTestMethodName() {
- String expected = createDefaultDiskStoreName(0, -1, "testGetTestMethodName");
- assertGetDefaultDiskStoreName(expected);
- }
-
- public void testGetTestMethodNameChanges() {
- String expected = createDefaultDiskStoreName(0, -1, "testGetTestMethodNameChanges");
- assertGetDefaultDiskStoreName(expected);
- }
-
- 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.DEFAULT_DS_NAME; // TODO: not thread safe
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit3GetTestMethodNameDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit3GetTestMethodNameDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit3GetTestMethodNameDUnitTest.java
deleted file mode 100644
index c77843d..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit3GetTestMethodNameDUnitTest.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 com.gemstone.gemfire.test.dunit.internal.tests;
-
-import static org.assertj.core.api.Assertions.*;
-
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.internal.JUnit3DistributedTestCase;
-import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import org.junit.experimental.categories.Category;
-
-@SuppressWarnings("serial")
-@Category(DistributedTest.class)
-public class JUnit3GetTestMethodNameDUnitTest extends JUnit3DistributedTestCase {
-
- public JUnit3GetTestMethodNameDUnitTest(final String name) {
- super(name);
- }
-
- public void testGetTestMethodName() {
- assertGetTestMethodName("testGetTestMethodName");
- }
-
- public void testGetTestMethodNameChanges() {
- assertGetTestMethodName("testGetTestMethodNameChanges");
- }
-
- 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);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit3VMDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit3VMDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit3VMDUnitTest.java
deleted file mode 100644
index ac2ed7e..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit3VMDUnitTest.java
+++ /dev/null
@@ -1,192 +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 com.gemstone.gemfire.test.dunit.internal.tests;
-
-import java.io.Serializable;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import com.gemstone.gemfire.test.dunit.AsyncInvocation;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.RMIException;
-import com.gemstone.gemfire.test.dunit.SerializableRunnableIF;
-import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.internal.JUnit3DistributedTestCase;
-
-/**
- * This class tests the functionality of the {@link VM} class.
- */
-public class JUnit3VMDUnitTest extends JUnit3DistributedTestCase {
-
- 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";
-
- public JUnit3VMDUnitTest(String name) {
- super(name);
- }
-
- public void testInvokeStaticBoolean() {
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
- assertEquals(BOOLEAN_VALUE, (boolean) vm.invoke(() -> remoteBooleanMethod()));
- }
-
- public void testInvokeStaticByte() {
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
- assertEquals(BYTE_VALUE, (byte) vm.invoke(() -> remoteByteMethod()));
- }
-
- public void testInvokeStaticLong() {
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
- assertEquals(LONG_VALUE, (long) vm.invoke(() -> remoteLongMethod()));
- }
-
- public void testInvokeInstance() {
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
- assertEquals(STRING_VALUE, vm.invoke(new ClassWithString(), "getString"));
- }
-
- 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);
- }
- }
-
- 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());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit4BasicDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit4BasicDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit4BasicDUnitTest.java
deleted file mode 100644
index 5cac3ba..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit4BasicDUnitTest.java
+++ /dev/null
@@ -1,202 +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 com.gemstone.gemfire.test.dunit.internal.tests;
-
-import static com.gemstone.gemfire.test.dunit.Assert.*;
-import static com.gemstone.gemfire.test.dunit.Invoke.*;
-
-import java.util.Properties;
-
-import com.gemstone.gemfire.test.dunit.AsyncInvocation;
-import com.gemstone.gemfire.test.dunit.DUnitEnv;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.RMIException;
-import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
-import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-/**
- * This class tests the basic functionality of the distributed unit
- * test framework.
- */
-@Category(DistributedTest.class)
-public class JUnit4BasicDUnitTest extends JUnit4DistributedTestCase {
-
- private static Properties bindings;
-
- @BeforeClass
- public static void setUpJUnit4BasicDUnitTest() throws Exception {
- invokeInEveryVM(() -> bindings = new Properties());
- }
-
- @AfterClass
- public static void tearDownJUnit4BasicDUnitTest() {
- invokeInEveryVM(() -> bindings = null);
- }
-
- @Test
- public void testPreconditions() {
- invokeInEveryVM(() -> assertNotNull("getUniqueName() must not return null", getUniqueName()));
- invokeInEveryVM(() -> assertNotNull("bindings must not be null", bindings));
- }
-
- /**
- * Tests how the Hydra framework handles an error
- */
- @Ignore
- @Test
- public void testDontCatchRemoteException() throws Exception {
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
- vm.invoke(() -> remoteThrowException());
- }
-
- @Test
- public void testRemoteInvocationWithException() throws Exception {
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
- try {
- vm.invoke(() -> remoteThrowException());
- fail("Should have thrown a BasicTestException");
-
- } catch (RMIException ex) {
- assertTrue(ex.getCause() instanceof BasicTestException);
- }
- }
-
- @Test
- public void testInvokeWithLambda() throws Exception {
- Host host = Host.getHost(0);
- VM vm0 = host.getVM(0);
- VM vm1 = host.getVM(1);
-
- int vm0Num = vm0.invoke(() -> DUnitEnv.get().getVMID());
- int vm1Num = vm1.invoke(() -> DUnitEnv.get().getVMID());
-
- assertEquals(0, vm0Num);
- assertEquals(1, vm1Num);
- }
-
- @Test
- public void testInvokeLambdaAsync() throws Throwable {
- Host host = Host.getHost(0);
- VM vm0 = host.getVM(0);
-
- AsyncInvocation<Integer> async0 = vm0.invokeAsync(() -> DUnitEnv.get().getVMID());
- int vm0num = async0.getResult();
-
- assertEquals(0, vm0num);
- }
-
- @Test
- public void testInvokeWithNamedLambda() {
- Host host = Host.getHost(0);
- VM vm0 = host.getVM(0);
- VM vm1 = host.getVM(1);
-
- int vm0Num = vm0.invoke("getVMID", () -> DUnitEnv.get().getVMID());
- int vm1Num = vm1.invoke("getVMID", () -> DUnitEnv.get().getVMID());
-
- assertEquals(0, vm0Num);
- assertEquals(1, vm1Num);
- }
-
- @Test
- public void testInvokeNamedLambdaAsync() throws Throwable {
- Host host = Host.getHost(0);
- VM vm0 = host.getVM(0);
-
- AsyncInvocation<Integer> async0 = vm0.invokeAsync("getVMID", () -> DUnitEnv.get().getVMID());
- int vm0num = async0.getResult();
-
- assertEquals(0, vm0num);
- }
-
- @Ignore("Test was never implemented")
- @Test
- public void testRemoteInvocationBoolean() {
- }
-
- @Test
- public void testRemoteInvokeAsync() throws Exception {
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
- String name = this.getUniqueName();
- String value = "Hello";
-
- AsyncInvocation ai =
- vm.invokeAsync(() -> this.remoteBind( name, value ));
- ai.join();
- // TODO shouldn't we call fail() here?
- if (ai.exceptionOccurred()) {
- fail("remoteBind failed", ai.getException());
- }
-
- ai = vm.invokeAsync(() -> this.remoteValidateBind(name, value ));
- ai.join();
- if (ai.exceptionOccurred()) {
- fail("remoteValidateBind failed", ai.getException());
- }
- }
-
- @Test
- public void testRemoteInvokeAsyncWithException() throws Exception {
- Host host = Host.getHost(0);
- VM vm = host.getVM(0);
-
- AsyncInvocation ai = vm.invokeAsync(() -> this.remoteThrowException());
- ai.join();
- assertTrue(ai.exceptionOccurred());
- Throwable ex = ai.getException();
- assertTrue(ex instanceof BasicTestException);
- }
-
- /**
- * Accessed via reflection. DO NOT REMOVE
- */
- private static void remoteThrowException() {
- String s = "Test exception. Please ignore.";
- throw new BasicTestException(s);
- }
-
- 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);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit4GetDefaultDiskStoreNameDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit4GetDefaultDiskStoreNameDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit4GetDefaultDiskStoreNameDUnitTest.java
deleted file mode 100644
index 7f99bc1..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit4GetDefaultDiskStoreNameDUnitTest.java
+++ /dev/null
@@ -1,65 +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 com.gemstone.gemfire.test.dunit.internal.tests;
-
-import static org.assertj.core.api.Assertions.*;
-
-import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
-import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-@Category(DistributedTest.class)
-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.DEFAULT_DS_NAME; // TODO: not thread safe
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit4GetTestMethodNameDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit4GetTestMethodNameDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit4GetTestMethodNameDUnitTest.java
deleted file mode 100644
index 93b2e86..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit4GetTestMethodNameDUnitTest.java
+++ /dev/null
@@ -1,52 +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 com.gemstone.gemfire.test.dunit.internal.tests;
-
-import static org.assertj.core.api.Assertions.*;
-
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
-import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-@Category(DistributedTest.class)
-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);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit4VMDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit4VMDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit4VMDUnitTest.java
deleted file mode 100644
index c9d9d3c..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/tests/JUnit4VMDUnitTest.java
+++ /dev/null
@@ -1,200 +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 com.gemstone.gemfire.test.dunit.internal.tests;
-
-import static com.gemstone.gemfire.test.dunit.Assert.*;
-
-import java.io.Serializable;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import com.gemstone.gemfire.test.dunit.AsyncInvocation;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.RMIException;
-import com.gemstone.gemfire.test.dunit.SerializableRunnableIF;
-import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
-import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-/**
- * This class tests the functionality of the {@link VM} class.
- */
-@Category(DistributedTest.class)
-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());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedRestoreSystemProperties.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedRestoreSystemProperties.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedRestoreSystemProperties.java
index 7f95fad..73e813d 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedRestoreSystemProperties.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedRestoreSystemProperties.java
@@ -16,8 +16,7 @@
*/
package com.gemstone.gemfire.test.dunit.rules;
-import static java.lang.System.getProperties;
-import static java.lang.System.setProperties;
+import static java.lang.System.*;
import java.util.Properties;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/RemoteInvoker.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/RemoteInvoker.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/RemoteInvoker.java
index 98dbc2f..789af38 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/RemoteInvoker.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/RemoteInvoker.java
@@ -16,8 +16,7 @@
*/
package com.gemstone.gemfire.test.dunit.rules;
-import static com.gemstone.gemfire.test.dunit.Invoke.invokeInEveryVM;
-import static com.gemstone.gemfire.test.dunit.Invoke.invokeInLocator;
+import static com.gemstone.gemfire.test.dunit.Invoke.*;
import java.io.Serializable;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ChildVM.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ChildVM.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ChildVM.java
index 06c3196..5301ffe 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ChildVM.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ChildVM.java
@@ -16,11 +16,10 @@
*/
package com.gemstone.gemfire.test.dunit.standalone;
-import hydra.HydraRuntimeException;
-import hydra.Log;
-
import java.rmi.Naming;
+import hydra.HydraRuntimeException;
+import hydra.Log;
import org.apache.logging.log4j.Logger;
import com.gemstone.gemfire.internal.OSProcess;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java
index 216971a..be459b9 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java
@@ -16,9 +16,6 @@
*/
package com.gemstone.gemfire.test.dunit.standalone;
-import hydra.Log;
-import hydra.MethExecutorResult;
-
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
@@ -41,6 +38,10 @@ import java.rmi.server.UnicastRemoteObject;
import java.util.List;
import java.util.Properties;
+import batterytest.greplogs.ExpectedStrings;
+import batterytest.greplogs.LogConsumer;
+import hydra.Log;
+import hydra.MethExecutorResult;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
@@ -49,9 +50,6 @@ import org.apache.logging.log4j.core.config.LoggerConfig;
import org.apache.logging.log4j.core.layout.PatternLayout;
import org.junit.Assert;
-import batterytest.greplogs.ExpectedStrings;
-import batterytest.greplogs.LogConsumer;
-
import com.gemstone.gemfire.distributed.Locator;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.distributed.internal.membership.gms.membership.GMSJoinLeave;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/RemoteDUnitVM.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/RemoteDUnitVM.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/RemoteDUnitVM.java
index 81c895e..21f35ac 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/RemoteDUnitVM.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/RemoteDUnitVM.java
@@ -20,13 +20,12 @@ import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.concurrent.TimeUnit;
+import hydra.MethExecutor;
+import hydra.MethExecutorResult;
import org.apache.logging.log4j.Logger;
import com.gemstone.gemfire.internal.logging.LogService;
-import hydra.MethExecutor;
-import hydra.MethExecutorResult;
-
/**
*
*/
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69fd61f0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/RemoteDUnitVMIF.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/RemoteDUnitVMIF.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/RemoteDUnitVMIF.java
index 849e2f2..57bbee2 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/RemoteDUnitVMIF.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/RemoteDUnitVMIF.java
@@ -16,11 +16,11 @@
*/
package com.gemstone.gemfire.test.dunit.standalone;
-import hydra.MethExecutorResult;
-
import java.rmi.Remote;
import java.rmi.RemoteException;
+import hydra.MethExecutorResult;
+
public interface RemoteDUnitVMIF extends Remote {
MethExecutorResult executeMethodOnObject(Object o, String methodName) throws RemoteException;