public abstract class DistributedTestBase
extends junit.framework.TestCase
implements java.io.Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
DistributedTestBase.ExpectedException
A class that represents an currently logged expected exception, which
should be removed
|
static class |
DistributedTestBase.InitializeRun |
static interface |
DistributedTestBase.WaitCriterion |
static interface |
DistributedTestBase.WaitCriterion2 |
| Modifier and Type | Field and Description |
|---|---|
protected static boolean |
beforeClassDone
this indicates whether beforeClass has been executed for current class
|
protected static java.lang.String |
lastTest
this stores the last test method in the current class for afterClass
|
static java.lang.String |
lineSeparator
the system line separator
|
static boolean |
logPerTest |
static boolean |
reconnect |
static com.gemstone.gemfire.distributed.internal.InternalDistributedSystem |
system |
static java.lang.String |
testName |
| Constructor and Description |
|---|
DistributedTestBase(java.lang.String name)
Creates a new
DistributedTestBase test with the
given name. |
| Modifier and Type | Method and Description |
|---|---|
static DistributedTestBase.ExpectedException |
addExpectedException(java.lang.String exception)
Log in all VMs, in both the test logger and the GemFire logger the
expected exception string to prevent grep logs from complaining.
|
static DistributedTestBase.ExpectedException |
addExpectedException(java.lang.String exception,
VM v)
Log in all VMs, in both the test logger and the GemFire logger the
expected exception string to prevent grep logs from complaining.
|
void |
afterClass()
Common cleanup for all the tests in a class.
|
void |
beforeClass()
Common setup for all the tests in a class.
|
static void |
checkBBFlag(java.lang.String name,
int expectedValue) |
static void |
clearBBFlag(java.lang.String name) |
void |
deleteLocatorStateFile(int... ports)
delete locator state files.
|
static void |
disconnectFromDS() |
static void |
dumpAllStacks()
print stack dumps for all vms
|
static void |
dumpStack()
print a stack dump for this vm
|
static void |
dumpStack(Host host)
print stack dumps for all vms on the given host
|
static void |
dumpStack(org.apache.log4j.Logger logger)
print a stack dump for this vm
|
static void |
dumpStack(VM vm)
print a stack dump for the given vm
|
static void |
dumpStackTrace(java.lang.Thread t,
java.lang.StackTraceElement[] stack,
org.apache.log4j.Logger logger) |
static void |
fail(java.lang.String message,
java.lang.Throwable ex)
Helper method that causes this test to fail because of the given
exception.
|
static void |
generateThreadDump(java.lang.StringBuilder msg) |
static java.util.Properties |
getAllDistributedSystemProperties(java.util.Properties props) |
static int |
getDUnitLocatorPort()
Get the port that the standard dunit locator is listening on.
|
static org.apache.log4j.Logger |
getGlobalLogger() |
static java.lang.String |
getHostAddress(java.net.InetAddress addr)
A wrapper for
InetAddress.getHostAddress() that removes the
scope_id from all IPv4 address and all global IPv6 addresses. |
static java.lang.String |
getIPLiteral() |
java.lang.String |
getLogLevel()
This returns the log level configured for the test run.
|
org.apache.log4j.Logger |
getLogWriter() |
protected long |
getRepeatTimeoutMs()
The number of milliseconds to try repeating validation code in the
event that AssertionFailedError is thrown.
|
static java.lang.String |
getServerHostName(Host host)
get the host name to use for a server cache in client/server dunit
testing
|
static java.lang.String |
getStackTrace(java.lang.Throwable aThrowable)
Get a stack trace for the given Throwable and return it as a String.
|
com.gemstone.gemfire.distributed.internal.InternalDistributedSystem |
getSystem() |
com.gemstone.gemfire.distributed.internal.InternalDistributedSystem |
getSystem(java.util.Properties props) |
protected java.lang.Class |
getTestClass() |
static java.lang.String |
getTestName() |
java.lang.String |
getUniqueName()
Returns a unique name for this test method.
|
protected static int |
getVMCount()
Return the total number of VMs on all hosts
|
static void |
incBBFlag(java.lang.String name) |
static void |
invokeInEveryVM(java.lang.Class c,
java.lang.String method)
Invokes a method in every remote VM that DUnit knows about.
|
static void |
invokeInEveryVM(java.lang.Class c,
java.lang.String method,
java.lang.Object[] methodArgs)
Invokes a method in every remote VM that DUnit knows about.
|
static java.util.Map |
invokeInEveryVM(SerializableCallable work)
Invokes a
SerializableCallable in every VM that
DUnit knows about. |
static void |
invokeInEveryVM(SerializableRunnable work)
Invokes a
SerializableRunnable in every VM that
DUnit knows about. |
protected void |
invokeInEveryVMRepeatingIfNecessary(RepeatableRunnable work)
Invokes a
SerializableRunnable in every VM that
DUnit knows about. |
static void |
invokeInLocator(SerializableRunnable work) |
void |
invokeInVM(VM vm,
java.lang.String method,
java.lang.Object... methodArgs)
Invokes a method in every remote VM that DUnit knows about.
|
static void |
invokeInVM(VM vm,
java.lang.String className,
java.lang.String method,
java.lang.Object[] methodArgs) |
protected void |
invokeRepeatingIfNecessary(VM vm,
RepeatableRunnable task) |
static void |
join(java.lang.Thread t,
long ms,
org.apache.log4j.Logger logger)
Wait for a thread to join
|
protected void |
logTestHistory()
Write a message to the log about what tests have ran previously.
|
static java.lang.String |
noteTiming(long operations,
java.lang.String operationUnit,
long beginTime,
long endTime,
java.lang.String timeUnit) |
protected void |
pause()
pause for a default interval
|
static void |
pause(int ms)
pause for specified ms interval
Make sure system clock has advanced by the specified number of millis before
returning.
|
void |
perVMSetUp(java.lang.String name,
java.lang.String defaultDiskStoreName) |
void |
perVMTearDown(java.lang.String name) |
static void |
setTestName(java.lang.String name) |
void |
setUp()
Sets up the test (noop).
|
static void |
sleepForMs(int msToSleep)
Sleep "soundly" for msToSleep milliseconds.
|
static void |
staticLogString(java.lang.String msg) |
static void |
staticPause(int ms)
Use of this function indicates a place in the tests tree where t
he use of Thread.sleep() is
highly questionable.
|
void |
tearDown()
For logPerTest to work, we have to disconnect from the DS, but all
subclasses do not call super.tearDown().
|
void |
tearDown2()
Tears down the test.
|
protected void |
tearDownAfter()
Tears down the test.
|
static void |
waitForBBFlag(java.lang.String name,
int expectedValue,
long timeout) |
static void |
waitForCriterion(DistributedTestBase.WaitCriterion ev,
long ms,
long interval,
boolean throwOnTimeout)
Wait until given criterion is met
|
static void |
waitMutex(DistributedTestBase.WaitCriterion ev,
java.lang.Object mutex,
long ms,
long interval,
boolean throwOnTimeout)
Wait on a mutex.
|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, toStringpublic static volatile java.lang.String testName
public static boolean reconnect
public static final boolean logPerTest
public static final java.lang.String lineSeparator
public static com.gemstone.gemfire.distributed.internal.InternalDistributedSystem system
protected static boolean beforeClassDone
protected static java.lang.String lastTest
public DistributedTestBase(java.lang.String name)
DistributedTestBase test with the
given name.public static void sleepForMs(int msToSleep)
public static java.lang.String getStackTrace(java.lang.Throwable aThrowable)
aThrowable - The exception to get the stack trace for.public static java.lang.String getHostAddress(java.net.InetAddress addr)
InetAddress.getHostAddress() that removes the
scope_id from all IPv4 address and all global IPv6 addresses.addr - the InetAddress to lookuppublic static final java.util.Properties getAllDistributedSystemProperties(java.util.Properties props)
public com.gemstone.gemfire.distributed.internal.InternalDistributedSystem getSystem()
public com.gemstone.gemfire.distributed.internal.InternalDistributedSystem getSystem(java.util.Properties props)
public static void disconnectFromDS()
public static void invokeInEveryVM(SerializableRunnable work)
SerializableRunnable in every VM that
DUnit knows about.VM.invoke(Runnable)public static void invokeInLocator(SerializableRunnable work)
public static java.util.Map invokeInEveryVM(SerializableCallable work)
SerializableCallable in every VM that
DUnit knows about.public static void invokeInEveryVM(java.lang.Class c,
java.lang.String method)
VM.invoke(Class, String)public static void invokeInEveryVM(java.lang.Class c,
java.lang.String method,
java.lang.Object[] methodArgs)
VM.invoke(Class, String)public static void invokeInVM(VM vm, java.lang.String className, java.lang.String method, java.lang.Object[] methodArgs)
public void invokeInVM(VM vm, java.lang.String method, java.lang.Object... methodArgs)
VM.invoke(Class, String)protected long getRepeatTimeoutMs()
protected void invokeRepeatingIfNecessary(VM vm, RepeatableRunnable task)
protected void invokeInEveryVMRepeatingIfNecessary(RepeatableRunnable work)
SerializableRunnable in every VM that
DUnit knows about. If work.run() throws an assertion failure,
its execution is repeated, until no assertion failure occurs or
repeatTimeout milliseconds have passed.VM.invoke(Runnable)protected static int getVMCount()
public static void dumpStack()
public static void dumpStack(org.apache.log4j.Logger logger)
public static void dumpStack(VM vm)
public static void dumpStack(Host host)
public static void dumpAllStacks()
public static void generateThreadDump(java.lang.StringBuilder msg)
public static java.lang.String noteTiming(long operations,
java.lang.String operationUnit,
long beginTime,
long endTime,
java.lang.String timeUnit)
protected java.lang.Class getTestClass()
public static org.apache.log4j.Logger getGlobalLogger()
public final org.apache.log4j.Logger getLogWriter()
public java.lang.String getLogLevel()
public void beforeClass()
throws java.lang.Exception
java.lang.Exceptionpublic void afterClass()
throws java.lang.Exception
java.lang.Exceptionpublic void setUp()
throws java.lang.Exception
setUp in class junit.framework.TestCasejava.lang.Exceptionprotected void logTestHistory()
public void perVMSetUp(java.lang.String name,
java.lang.String defaultDiskStoreName)
public static void setTestName(java.lang.String name)
public static java.lang.String getTestName()
public final void tearDown()
throws java.lang.Exception
tearDown2() instead.tearDown in class junit.framework.TestCasejava.lang.Exceptionpublic void perVMTearDown(java.lang.String name)
public void tearDown2()
throws java.lang.Exception
tearDown() method and should be overridden to
perform actual test cleanup and release resources used by the test. The tasks executed by this method are
performed before the DUnit test framework using Hydra cleans up the client VMs.
java.lang.Exception - if the tear down process and test cleanup fails.tearDown(),
tearDownAfter()protected void tearDownAfter()
throws java.lang.Exception
tearDown() method and should be overridden to perform
post tear down activities.
java.lang.Exception - if the test tear down process fails.tearDown(),
tearDown2()public static java.lang.String getServerHostName(Host host)
host - public static java.lang.String getIPLiteral()
public static int getDUnitLocatorPort()
public java.lang.String getUniqueName()
public static void fail(java.lang.String message,
java.lang.Throwable ex)
protected void pause()
public static final void staticPause(int ms)
Some places in the system, especially those that test expirations and other
timeouts, have a very good reason to call Thread.sleep(long). The
other places are marked by the use of this method.
ms - public static final void pause(int ms)
public static void waitForCriterion(DistributedTestBase.WaitCriterion ev, long ms, long interval, boolean throwOnTimeout)
ev - criterion to wait onms - total time to wait, in millisecondsinterval - pause interval between waitsthrowOnTimeout - if false, don't generate an errorpublic static void waitMutex(DistributedTestBase.WaitCriterion ev, java.lang.Object mutex, long ms, long interval, boolean throwOnTimeout)
ev - condition to testmutex - object to lock and wait onms - total amount of time to waitinterval - interval to pause for the waitthrowOnTimeout - if false, no error is thrown.public static void join(java.lang.Thread t,
long ms,
org.apache.log4j.Logger logger)
t - thread to wait onms - maximum time to waitpublic static void dumpStackTrace(java.lang.Thread t,
java.lang.StackTraceElement[] stack,
org.apache.log4j.Logger logger)
public static void staticLogString(java.lang.String msg)
public static DistributedTestBase.ExpectedException addExpectedException(java.lang.String exception)
exception - the exception string to expectpublic static DistributedTestBase.ExpectedException addExpectedException(java.lang.String exception, VM v)
exception - the exception string to expectv - the VM on which to log the expected exception or null for all VMspublic void deleteLocatorStateFile(int... ports)
ports - public static void incBBFlag(java.lang.String name)
public static void clearBBFlag(java.lang.String name)
public static void checkBBFlag(java.lang.String name,
int expectedValue)
throws com.gemstone.gemfire.cache.CacheException
com.gemstone.gemfire.cache.CacheExceptionpublic static void waitForBBFlag(java.lang.String name,
int expectedValue,
long timeout)
throws com.gemstone.gemfire.cache.TimeoutException
com.gemstone.gemfire.cache.TimeoutException