public abstract class DistributedTestCase extends junit.framework.TestCase implements Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
DistributedTestCase.ExpectedException
A class that represents an currently logged expected exception, which
should be removed
|
static interface |
DistributedTestCase.WaitCriterion |
static interface |
DistributedTestCase.WaitCriterion2 |
| Modifier and Type | Field and Description |
|---|---|
static boolean |
logPerTest |
static boolean |
reconnect |
static com.gemstone.gemfire.distributed.internal.InternalDistributedSystem |
system
This VM's connection to the distributed system
|
static String |
testName |
| Constructor and Description |
|---|
DistributedTestCase(String name)
Creates a new
DistributedTestCase test with the
given name. |
| Modifier and Type | Method and Description |
|---|---|
static DistributedTestCase.ExpectedException |
addExpectedException(String exception)
Log in all VMs, in both the Hydra logger and the GemFire logger the
expected exception string to prevent grep logs from complaining.
|
static DistributedTestCase.ExpectedException |
addExpectedException(String exception,
VM v)
Log in all VMs, in both the Hydra logger and the GemFire logger the
expected exception string to prevent grep logs from complaining.
|
protected static void |
addHydraProperties(Properties config)
Fetches the GemFireDescription for this test and adds its
DistributedSystem properties to the provided props parameter.
|
void |
attachDebugger(VM vm,
String msg) |
static void |
checkBBFlag(String name,
int expectedValue) |
static void |
cleanupAllVms() |
static void |
clearBBFlag(String name) |
void |
crashDistributedSystem(com.gemstone.gemfire.distributed.DistributedSystem msys)
Crash the cache in the given VM in such a way that it immediately stops communicating with
peers.
|
boolean |
crashDistributedSystem(VM vm)
Crash the cache in the given VM in such a way that it immediately stops communicating with
peers.
|
protected static com.gemstone.gemfire.LogWriter |
createLogWriter(Properties config)
Creates a new LogWriter and adds it to the config properties.
|
protected static void |
disconnectAllFromDS() |
static void |
disconnectFromDS()
Disconnects this VM from the distributed system
|
static void |
dumpAllStacks()
print stack dumps for all vms
|
static void |
dumpMyThreads(com.gemstone.gemfire.LogWriter logger)
Dump all thread stacks
|
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(VM vm)
print a stack dump for the given vm
|
static void |
dumpStackTrace(Thread t,
StackTraceElement[] stack,
com.gemstone.gemfire.LogWriter logger) |
static void |
fail(String message,
Throwable ex)
Helper method that causes this test to fail because of the given
exception.
|
Properties |
getAllDistributedSystemProperties(Properties props) |
Properties |
getDistributedSystemProperties()
Returns a
Properties object used to configure a
connection to a DistributedSystem. |
static String |
getDUnitLocatorAddress()
Get the address that the standard dunit locator is listening on.
|
static int |
getDUnitLocatorPort()
Get the port that the standard dunit locator is listening on.
|
static String |
getDUnitLocatorString() |
static String |
getDUnitLogLevel()
This finds the log level configured for the test run.
|
static String |
getIPLiteral()
get the IP literal name for the current host, use this instead of
"localhost" to avoid IPv6 name resolution bugs in the JDK/machine config.
|
static com.gemstone.gemfire.LogWriter |
getLogWriter()
Returns a
LogWriter for logging information |
com.gemstone.gemfire.distributed.internal.InternalDistributedSystem |
getLonerSystem()
Returns a loner distributed system that isn't connected to other
vms
|
com.gemstone.gemfire.distributed.internal.InternalDistributedSystem |
getMcastSystem()
Returns an mcast distributed system that is connected to other
vms using a random mcast port.
|
com.gemstone.gemfire.distributed.internal.InternalDistributedSystem |
getMcastSystem(int jgroupsPort)
Returns an mcast distributed system that is connected to other
vms using the given mcast port.
|
protected long |
getRepeatTimeoutMs()
The number of milliseconds to try repeating validation code in the
event that AssertionFailedError is thrown.
|
static String |
getServerHostName(Host host)
get the host name to use for a server cache in client/server dunit
testing
|
com.gemstone.gemfire.distributed.internal.InternalDistributedSystem |
getSystem()
Returns this VM's connection to the distributed system.
|
com.gemstone.gemfire.distributed.internal.InternalDistributedSystem |
getSystem(Properties props)
Returns this VM's connection to the distributed system.
|
protected Class |
getTestClass() |
static String |
getTestName() |
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(String name) |
protected static void |
invokeInEveryVM(Class c,
String method)
Invokes a method in every remote VM that DUnit knows about.
|
protected static void |
invokeInEveryVM(Class c,
String method,
Object[] methodArgs)
Invokes a method in every remote VM that DUnit knows about.
|
protected static 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) |
protected void |
invokeRepeatingIfNecessary(VM vm,
RepeatableRunnable task) |
boolean |
isConnectedToDS()
Returns whether or this VM is connected to a
DistributedSystem. |
static void |
join(Thread t,
long ms,
com.gemstone.gemfire.LogWriter logger)
Wait for a thread to join
|
static String |
noteTiming(long operations,
String operationUnit,
long beginTime,
long endTime,
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.
|
static void |
perVMSetUp(String name,
String defaultDiskStoreName) |
protected void |
realTearDown() |
protected static void |
setDiskStoreForGateway(com.gemstone.gemfire.cache.Cache cache,
String gatewayId,
com.gemstone.gemfire.cache.util.GatewayQueueAttributes queueAttributes) |
void |
setSystem(Properties props,
com.gemstone.gemfire.distributed.DistributedSystem ds) |
static void |
setTestName(String name) |
void |
setUp()
Sets up the test (noop).
|
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.
|
static void |
unregisterAllDataSerializersFromAllVms() |
static void |
unregisterDataSerializerInThisVM() |
static void |
unregisterInstantiatorsInThisVM() |
static void |
waitForBBFlag(String name,
int expectedValue,
long timeout) |
static void |
waitForCriterion(DistributedTestCase.WaitCriterion ev,
long ms,
long interval,
boolean throwOnTimeout)
Wait until given criterion is met
|
static void |
waitMutex(DistributedTestCase.WaitCriterion ev,
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 com.gemstone.gemfire.distributed.internal.InternalDistributedSystem system
public static volatile String testName
public static boolean reconnect
public static final boolean logPerTest
public DistributedTestCase(String name)
DistributedTestCase test with the
given name.public static void invokeInEveryVM(SerializableRunnable work)
SerializableRunnable in every VM that
DUnit knows about.VM.invoke(Runnable)public static void invokeInLocator(SerializableRunnable work)
protected static Map invokeInEveryVM(SerializableCallable work)
SerializableCallable in every VM that
DUnit knows about.VM.invoke(Callable)protected static void invokeInEveryVM(Class c, String method)
VM.invoke(Class, String)protected static void invokeInEveryVM(Class c, String method, 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(VM vm)
public static void dumpStack(Host host)
public static void dumpAllStacks()
public static String noteTiming(long operations, String operationUnit, long beginTime, long endTime, String timeUnit)
protected static com.gemstone.gemfire.LogWriter createLogWriter(Properties config)
config - the DistributedSystem config properties to add LogWriter toprotected static void addHydraProperties(Properties config)
config - the properties to add hydra's test properties toprotected Class getTestClass()
public static String getDUnitLogLevel()
public final Properties getAllDistributedSystemProperties(Properties props)
public void setSystem(Properties props, com.gemstone.gemfire.distributed.DistributedSystem ds)
public com.gemstone.gemfire.distributed.internal.InternalDistributedSystem getSystem(Properties props)
Properties. Note that this method uses hydra's
configuration to determine the location of log files, etc.DistributedConnectionMgr.connect(java.lang.String)public boolean crashDistributedSystem(VM vm)
NOTE: if you use this method be sure that you clean up the VM before the end of your test with disconnectFromDS() or disconnectAllFromDS().
public void crashDistributedSystem(com.gemstone.gemfire.distributed.DistributedSystem msys)
NOTE: if you use this method be sure that you clean up the VM before the end of your test with disconnectFromDS() or disconnectAllFromDS().
public final com.gemstone.gemfire.distributed.internal.InternalDistributedSystem getSystem()
Properties returned by getDistributedSystemProperties().getSystem(Properties)public final com.gemstone.gemfire.distributed.internal.InternalDistributedSystem getLonerSystem()
public final com.gemstone.gemfire.distributed.internal.InternalDistributedSystem getMcastSystem()
public final com.gemstone.gemfire.distributed.internal.InternalDistributedSystem getMcastSystem(int jgroupsPort)
public final boolean isConnectedToDS()
DistributedSystem.public Properties getDistributedSystemProperties()
Properties object used to configure a
connection to a DistributedSystem.
Unless overridden, this method will return an empty
Properties object.public void setUp()
throws Exception
setUp in class junit.framework.TestCaseExceptionpublic static void setTestName(String name)
public static String getTestName()
public final void tearDown()
throws Exception
tearDown2() instead.tearDown in class junit.framework.TestCaseExceptionpublic void tearDown2()
throws Exception
tearDown() method, and should be over ridden in its place.Exceptionpublic static void cleanupAllVms()
public static void unregisterAllDataSerializersFromAllVms()
public static void unregisterInstantiatorsInThisVM()
public static void unregisterDataSerializerInThisVM()
protected static void disconnectAllFromDS()
public static void disconnectFromDS()
public static String getServerHostName(Host host)
host - public static String getIPLiteral()
public static int getDUnitLocatorPort()
public static String getDUnitLocatorAddress()
public static String getDUnitLocatorString()
public String getUniqueName()
public static com.gemstone.gemfire.LogWriter getLogWriter()
LogWriter for logging informationpublic static void fail(String message, 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(DistributedTestCase.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(DistributedTestCase.WaitCriterion ev, 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(Thread t, long ms, com.gemstone.gemfire.LogWriter logger)
t - thread to wait onms - maximum time to waitAssertionFailure - if the thread does not terminatepublic static void dumpStackTrace(Thread t, StackTraceElement[] stack, com.gemstone.gemfire.LogWriter logger)
public static void dumpMyThreads(com.gemstone.gemfire.LogWriter logger)
protected static void setDiskStoreForGateway(com.gemstone.gemfire.cache.Cache cache,
String gatewayId,
com.gemstone.gemfire.cache.util.GatewayQueueAttributes queueAttributes)
public static DistributedTestCase.ExpectedException addExpectedException(String exception)
exception - the exception string to expectpublic static DistributedTestCase.ExpectedException addExpectedException(String exception, VM v)
exception - the exception string to expectv - the VM on which to log the expected exception or null for all VMspublic static void incBBFlag(String name)
public static void clearBBFlag(String name)
public static void checkBBFlag(String name, int expectedValue) throws com.gemstone.gemfire.cache.CacheException
com.gemstone.gemfire.cache.CacheExceptionpublic static void waitForBBFlag(String name, int expectedValue, long timeout) throws com.gemstone.gemfire.cache.TimeoutException
com.gemstone.gemfire.cache.TimeoutExceptionCopyright © 2010-2015 Pivotal Software, Inc. All rights reserved.