You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2016/02/11 16:27:14 UTC
[50/62] [abbrv] [partial] incubator-geode git commit: GEODE-773:
Extract static methods from DistributedTestCase
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/LocatorLoadBalancingDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/LocatorLoadBalancingDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/LocatorLoadBalancingDUnitTest.java
index 1c8e9eb..3c6a980 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/LocatorLoadBalancingDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/LocatorLoadBalancingDUnitTest.java
@@ -47,11 +47,14 @@ import com.gemstone.gemfire.internal.cache.CacheServerImpl;
import com.gemstone.gemfire.internal.cache.PoolFactoryImpl;
import com.gemstone.gemfire.internal.logging.InternalLogWriter;
import com.gemstone.gemfire.internal.logging.LocalLogWriter;
-import com.gemstone.gemfire.test.dunit.DistributedTestCase;
import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
import com.gemstone.gemfire.test.dunit.SerializableRunnableIF;
import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
/**
* @author dsmith
@@ -98,7 +101,7 @@ public class LocatorLoadBalancingDUnitTest extends LocatorTestBase {
int serverPort = startBridgeServerInVM(vm1, new String[] {"a", "b"}, locators);
ServerLoad expectedLoad = new ServerLoad(0f, 1 / 800.0f, 0f, 1f);
- ServerLocation expectedLocation = new ServerLocation(getServerHostName(vm0
+ ServerLocation expectedLocation = new ServerLocation(NetworkUtils.getServerHostName(vm0
.getHost()), serverPort);
Map expected = new HashMap();
expected.put(expectedLocation, expectedLoad);
@@ -107,7 +110,7 @@ public class LocatorLoadBalancingDUnitTest extends LocatorTestBase {
int serverPort2 = startBridgeServerInVM(vm2, new String[] {"a", "b"}, locators);
- ServerLocation expectedLocation2 = new ServerLocation(getServerHostName(vm0
+ ServerLocation expectedLocation2 = new ServerLocation(NetworkUtils.getServerHostName(vm0
.getHost()), serverPort2);
expected.put(expectedLocation2, expectedLoad);
@@ -130,18 +133,18 @@ public class LocatorLoadBalancingDUnitTest extends LocatorTestBase {
int serverPort = startBridgeServerInVM(vm1, new String[] {"a", "b"}, locators);
ServerLoad expectedLoad = new ServerLoad(2/800f, 1 / 800.0f, 0f, 1f);
- ServerLocation expectedLocation = new ServerLocation(getServerHostName(host), serverPort);
+ ServerLocation expectedLocation = new ServerLocation(NetworkUtils.getServerHostName(host), serverPort);
Map expected = new HashMap();
expected.put(expectedLocation, expectedLoad);
ClientConnectionResponse response;
response = (ClientConnectionResponse) TcpClient.requestToServer(InetAddress
- .getByName(getServerHostName(host)), locatorPort,
+ .getByName(NetworkUtils.getServerHostName(host)), locatorPort,
new ClientConnectionRequest(Collections.EMPTY_SET, null), 10000);
Assert.assertEquals(expectedLocation, response.getServer());
response = (ClientConnectionResponse) TcpClient.requestToServer(InetAddress
- .getByName(getServerHostName(host)), locatorPort,
+ .getByName(NetworkUtils.getServerHostName(host)), locatorPort,
new ClientConnectionRequest(Collections.EMPTY_SET, null), 10000, true);
Assert.assertEquals(expectedLocation, response.getServer());
@@ -150,13 +153,13 @@ public class LocatorLoadBalancingDUnitTest extends LocatorTestBase {
QueueConnectionResponse response2;
response2 = (QueueConnectionResponse) TcpClient.requestToServer(InetAddress
- .getByName(getServerHostName(host)), locatorPort,
+ .getByName(NetworkUtils.getServerHostName(host)), locatorPort,
new QueueConnectionRequest(null, 2,
Collections.EMPTY_SET, null, false), 10000, true);
Assert.assertEquals(Collections.singletonList(expectedLocation), response2.getServers());
response2 = (QueueConnectionResponse) TcpClient
- .requestToServer(InetAddress.getByName(getServerHostName(host)),
+ .requestToServer(InetAddress.getByName(NetworkUtils.getServerHostName(host)),
locatorPort, new QueueConnectionRequest(null, 5, Collections.EMPTY_SET, null,
false), 10000, true);
@@ -186,13 +189,13 @@ public class LocatorLoadBalancingDUnitTest extends LocatorTestBase {
//We expect 0 load
Map expected = new HashMap();
- ServerLocation expectedLocation = new ServerLocation(getServerHostName(host), serverPort);
+ ServerLocation expectedLocation = new ServerLocation(NetworkUtils.getServerHostName(host), serverPort);
ServerLoad expectedLoad = new ServerLoad(0f, 1 / 800.0f, 0f, 1f);
expected.put(expectedLocation, expectedLoad);
checkLocatorLoad(vm0, expected);
PoolFactoryImpl pf = new PoolFactoryImpl(null);
- pf.addServer(getServerHostName(host), serverPort);
+ pf.addServer(NetworkUtils.getServerHostName(host), serverPort);
pf.setMinConnections(8);
pf.setMaxConnections(8);
pf.setSubscriptionEnabled(true);
@@ -233,7 +236,7 @@ public class LocatorLoadBalancingDUnitTest extends LocatorTestBase {
startBridgeServerInVM(vm2, new String[] {"a", "b"}, locators);
PoolFactoryImpl pf = new PoolFactoryImpl(null);
- pf.addLocator(getServerHostName(host), locatorPort);
+ pf.addLocator(NetworkUtils.getServerHostName(host), locatorPort);
pf.setMinConnections(80);
pf.setMaxConnections(80);
pf.setSubscriptionEnabled(false);
@@ -267,7 +270,7 @@ public class LocatorLoadBalancingDUnitTest extends LocatorTestBase {
return excuse;
}
};
- DistributedTestCase.waitForCriterion(wc, 5 * 60 * 1000, 1000, true);
+ Wait.waitForCriterion(wc, 5 * 60 * 1000, 1000, true);
}
};
@@ -290,7 +293,7 @@ public class LocatorLoadBalancingDUnitTest extends LocatorTestBase {
return "connection count never reached " + count;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_WAIT, 200, true);
+ Wait.waitForCriterion(ev, MAX_WAIT, 200, true);
}
};
if(vm == null) {
@@ -321,7 +324,7 @@ public class LocatorLoadBalancingDUnitTest extends LocatorTestBase {
startBridgeServerInVM(vm3, new String[] {"b"}, locators);
PoolFactoryImpl pf = new PoolFactoryImpl(null);
- pf.addLocator(getServerHostName(host), locatorPort);
+ pf.addLocator(NetworkUtils.getServerHostName(host), locatorPort);
pf.setMinConnections(12);
pf.setSubscriptionEnabled(false);
pf.setServerGroup("a");
@@ -333,7 +336,7 @@ public class LocatorLoadBalancingDUnitTest extends LocatorTestBase {
checkConnectionCount(vm2, 6);
checkConnectionCount(vm3, 0);
- getLogWriter().info("pool1 prefilled");
+ LogWriterUtils.getLogWriter().info("pool1 prefilled");
PoolFactoryImpl pf2 = (PoolFactoryImpl) PoolManager.createFactory();
pf2.init(pf.getPoolAttributes());
@@ -347,9 +350,9 @@ public class LocatorLoadBalancingDUnitTest extends LocatorTestBase {
checkConnectionCount(vm2, 9);
checkConnectionCount(vm3, 9);
- getLogWriter().info("pool2 prefilled");
+ LogWriterUtils.getLogWriter().info("pool2 prefilled");
- ServerLocation location1 = new ServerLocation(getServerHostName(host), serverPort1);
+ ServerLocation location1 = new ServerLocation(NetworkUtils.getServerHostName(host), serverPort1);
PoolImpl pool1 = (PoolImpl) PoolManager.getAll().get(POOL_NAME);
Assert.assertEquals("a", pool1.getServerGroup());
@@ -358,7 +361,7 @@ public class LocatorLoadBalancingDUnitTest extends LocatorTestBase {
pool1.acquireConnection();
}
- getLogWriter().info("aquired 15 connections in pool1");
+ LogWriterUtils.getLogWriter().info("aquired 15 connections in pool1");
//now the load should be equal
checkConnectionCount(vm1, 9);
@@ -370,7 +373,7 @@ public class LocatorLoadBalancingDUnitTest extends LocatorTestBase {
pool2.acquireConnection();
}
- getLogWriter().info("aquired 12 connections in pool2");
+ LogWriterUtils.getLogWriter().info("aquired 12 connections in pool2");
//interleave creating connections in both pools
for(int i = 0; i < 6; i++) {
@@ -378,7 +381,7 @@ public class LocatorLoadBalancingDUnitTest extends LocatorTestBase {
pool2.acquireConnection();
}
- getLogWriter().info("interleaved 6 connections from pool1 with 6 connections from pool2");
+ LogWriterUtils.getLogWriter().info("interleaved 6 connections from pool1 with 6 connections from pool2");
//The load should still be balanced
checkConnectionCount(vm1, 13);
@@ -404,8 +407,8 @@ public class LocatorLoadBalancingDUnitTest extends LocatorTestBase {
int serverPort2 = startBridgeServerInVM(vm2, null, locators, new String[] {REGION_NAME}, new MyLoadProbe(load2 ));
HashMap expected = new HashMap();
- ServerLocation l1 = new ServerLocation(getServerHostName(host), serverPort1);
- ServerLocation l2 = new ServerLocation(getServerHostName(host), serverPort2);
+ ServerLocation l1 = new ServerLocation(NetworkUtils.getServerHostName(host), serverPort1);
+ ServerLocation l2 = new ServerLocation(NetworkUtils.getServerHostName(host), serverPort2);
expected.put(l1, load1);
expected.put(l2, load2);
checkLocatorLoad(vm0, expected);
@@ -425,7 +428,7 @@ public class LocatorLoadBalancingDUnitTest extends LocatorTestBase {
checkLocatorLoad(vm0, expected);
PoolFactoryImpl pf = new PoolFactoryImpl(null);
- pf.addLocator(getServerHostName(host), locatorPort);
+ pf.addLocator(NetworkUtils.getServerHostName(host), locatorPort);
pf.setMinConnections(20);
pf.setSubscriptionEnabled(true);
pf.setIdleTimeout(-1);
@@ -455,7 +458,7 @@ public class LocatorLoadBalancingDUnitTest extends LocatorTestBase {
return "load map never became equal to " + expected;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_WAIT, 200, true);
+ Wait.waitForCriterion(ev, MAX_WAIT, 200, true);
}
});
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/LocatorTestBase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/LocatorTestBase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/LocatorTestBase.java
index 72f1a5c..f35e2fa 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/LocatorTestBase.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/LocatorTestBase.java
@@ -42,8 +42,12 @@ import com.gemstone.gemfire.distributed.Locator;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.internal.AvailablePortHelper;
import com.gemstone.gemfire.internal.cache.PoolFactoryImpl;
+import com.gemstone.gemfire.test.dunit.Assert;
import com.gemstone.gemfire.test.dunit.DistributedTestCase;
import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.Invoke;
+import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
import com.gemstone.gemfire.test.dunit.SerializableCallable;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
import com.gemstone.gemfire.test.dunit.VM;
@@ -67,7 +71,8 @@ public abstract class LocatorTestBase extends DistributedTestCase {
super(name);
}
- public void tearDown2() throws Exception {
+ @Override
+ protected final void preTearDown() throws Exception {
SerializableRunnable tearDown = new SerializableRunnable("tearDown") {
public void run() {
@@ -94,9 +99,13 @@ public abstract class LocatorTestBase extends DistributedTestCase {
};
//We seem to like leaving the DS open if we can for
//speed, but lets at least destroy our cache and locator.
- invokeInEveryVM(tearDown);
+ Invoke.invokeInEveryVM(tearDown);
tearDown.run();
- super.tearDown2();
+
+ postTearDownLocatorTestBase();
+ }
+
+ protected void postTearDownLocatorTestBase() throws Exception {
}
protected void startLocatorInVM(final VM vm, final int locatorPort, final String otherLocators) {
@@ -108,21 +117,21 @@ public abstract class LocatorTestBase extends DistributedTestCase {
Properties props = new Properties();
props.setProperty(DistributionConfig.MCAST_PORT_NAME, String.valueOf(0));
props.setProperty(DistributionConfig.LOCATORS_NAME, otherLocators);
- props.setProperty(DistributionConfig.LOG_LEVEL_NAME, getDUnitLogLevel());
+ props.setProperty(DistributionConfig.LOG_LEVEL_NAME, LogWriterUtils.getDUnitLogLevel());
props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
try {
File logFile = new File(testName + "-locator" + locatorPort
+ ".log");
InetAddress bindAddr = null;
try {
- bindAddr = InetAddress.getByName(getServerHostName(vm.getHost()));
+ bindAddr = InetAddress.getByName(NetworkUtils.getServerHostName(vm.getHost()));
} catch (UnknownHostException uhe) {
- fail("While resolving bind address ", uhe);
+ Assert.fail("While resolving bind address ", uhe);
}
Locator locator = Locator.startLocatorAndDS(locatorPort, logFile, bindAddr, props);
remoteObjects.put(LOCATOR_KEY, locator);
} catch (IOException ex) {
- fail("While starting locator on port " + locatorPort, ex);
+ Assert.fail("While starting locator on port " + locatorPort, ex);
}
}
});
@@ -302,7 +311,7 @@ public abstract class LocatorTestBase extends DistributedTestCase {
public String getLocatorString(Host host, int[] locatorPorts) {
StringBuffer str = new StringBuffer();
for(int i = 0; i < locatorPorts.length; i++) {
- str.append(getServerHostName(host))
+ str.append(NetworkUtils.getServerHostName(host))
.append("[")
.append(locatorPorts[i])
.append("]");
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/SSLNoClientAuthDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/SSLNoClientAuthDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/SSLNoClientAuthDUnitTest.java
index 1c79129..bb1cc09 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/SSLNoClientAuthDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/SSLNoClientAuthDUnitTest.java
@@ -266,14 +266,12 @@ public class SSLNoClientAuthDUnitTest extends DistributedTestCase {
}
}
- public void tearDown2() throws Exception
- {
+ @Override
+ protected final void preTearDown() throws Exception {
final Host host = Host.getHost(0);
VM serverVM = host.getVM(1);
VM clientVM = host.getVM(2);
clientVM.invoke(SSLNoClientAuthDUnitTest.class, "closeClientCacheTask");
serverVM.invoke(SSLNoClientAuthDUnitTest.class, "closeCacheTask");
- super.tearDown2();
}
-
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/pooling/ConnectionManagerJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/pooling/ConnectionManagerJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/pooling/ConnectionManagerJUnitTest.java
index a398975..d0b2991 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/pooling/ConnectionManagerJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/client/internal/pooling/ConnectionManagerJUnitTest.java
@@ -59,8 +59,9 @@ import com.gemstone.gemfire.internal.cache.PoolStats;
import com.gemstone.gemfire.internal.cache.tier.sockets.ServerQueueStatus;
import com.gemstone.gemfire.internal.logging.InternalLogWriter;
import com.gemstone.gemfire.internal.logging.LocalLogWriter;
-import com.gemstone.gemfire.test.dunit.DistributedTestCase;
-import com.gemstone.gemfire.test.dunit.DistributedTestCase.WaitCriterion;
+import com.gemstone.gemfire.test.dunit.ThreadUtils;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
/**
@@ -159,7 +160,7 @@ public class ConnectionManagerJUnitTest {
return "waiting for manager " + descrip;
}
};
- DistributedTestCase.waitForCriterion(ev, 200, 200, true);
+ Wait.waitForCriterion(ev, 200, 200, true);
}
@Test
@@ -426,7 +427,7 @@ public class ConnectionManagerJUnitTest {
}
for(int i = 0; i < updaterCount; i++) {
- DistributedTestCase.join(updaters[i], 30 * 1000, null);
+ ThreadUtils.join(updaters[i], 30 * 1000);
}
if(exception.get() !=null) {
@@ -490,7 +491,7 @@ public class ConnectionManagerJUnitTest {
}
for(int i = 0; i < updaterCount; i++) {
- DistributedTestCase.join(updaters[i], 30 * 1000, null);
+ ThreadUtils.join(updaters[i], 30 * 1000);
}
if(exception.get() !=null) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java
index b9e213a..4e4b10f 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java
@@ -79,12 +79,20 @@ import com.gemstone.gemfire.internal.cache.control.ResourceAdvisor;
import com.gemstone.gemfire.internal.cache.control.ResourceListener;
import com.gemstone.gemfire.internal.cache.control.TestMemoryThresholdListener;
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import com.gemstone.gemfire.test.dunit.Assert;
import com.gemstone.gemfire.test.dunit.AsyncInvocation;
import com.gemstone.gemfire.test.dunit.DistributedTestCase;
+import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.IgnoredException;
+import com.gemstone.gemfire.test.dunit.Invoke;
+import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
import com.gemstone.gemfire.test.dunit.SerializableCallable;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
/**
* Tests the Heap Memory thresholds of {@link ResourceManager}
@@ -129,15 +137,14 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
@Override
public void setUp() throws Exception {
super.setUp();
- invokeInEveryVM(this.setHeapMemoryMonitorTestMode);
- addExpectedException(expectedEx);
- addExpectedException(expectedBelow);
+ Invoke.invokeInEveryVM(this.setHeapMemoryMonitorTestMode);
+ IgnoredException.addIgnoredException(expectedEx);
+ IgnoredException.addIgnoredException(expectedBelow);
}
@Override
- public void tearDown2() throws Exception {
- invokeInEveryVM(resetResourceManager);
- super.tearDown2();
+ protected void preTearDownClientServerTestCase() throws Exception {
+ Invoke.invokeInEveryVM(resetResourceManager);
}
public void testPRClientPutRejection() throws Exception {
@@ -263,7 +270,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
return dr.getMemoryThresholdReachedMembers().size() == 0;
}
};
- waitForCriterion(wc, 30000, 10, true);
+ Wait.waitForCriterion(wc, 30000, 10, true);
return null;
}
});
@@ -474,7 +481,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
verifyListenerValue(server1, MemoryState.EVICTION, 2, true);
verifyListenerValue(server1, MemoryState.NORMAL, 1, true);
- this.getLogWriter().info("before NORMAL->CRITICAL->NORMAL");
+ LogWriterUtils.getLogWriter().info("before NORMAL->CRITICAL->NORMAL");
//NORMAL -> EVICTION -> NORMAL
server2.invoke(new SerializableCallable("NORMAL->CRITICAL->NORMAL") {
public Object call() throws Exception {
@@ -484,7 +491,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
return null;
}
});
- this.getLogWriter().info("after NORMAL->CRITICAL->NORMAL");
+ LogWriterUtils.getLogWriter().info("after NORMAL->CRITICAL->NORMAL");
verifyListenerValue(server2, MemoryState.CRITICAL, 2, true);
verifyListenerValue(server2, MemoryState.EVICTION, 3, true);
@@ -646,7 +653,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
return keyFoundOnSickMember && caughtException;
}
};
- waitForCriterion(wc, 30000, 10, true);
+ Wait.waitForCriterion(wc, 30000, 10, true);
return null;
}
});
@@ -661,7 +668,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
server1.invoke(new SerializableCallable("local destroy sick member") {
public Object call() throws Exception {
Region r = getRootRegion().getSubregion(regionName);
- getLogWriter().info("PRLocalDestroy");
+ LogWriterUtils.getLogWriter().info("PRLocalDestroy");
r.localDestroyRegion();
return null;
}
@@ -699,7 +706,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
return done;
}
};
- waitForCriterion(wc, 30000, 10, true);
+ Wait.waitForCriterion(wc, 30000, 10, true);
return null;
}
});
@@ -814,7 +821,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
}
public void testDRFunctionExecutionRejection() throws Exception {
- addExpectedException("LowMemoryException");
+ IgnoredException.addIgnoredException("LowMemoryException");
final Host host = Host.getHost(0);
final VM server1 = host.getVM(0);
final VM server2 = host.getVM(1);
@@ -832,7 +839,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
final RejectFunction function = new RejectFunction();
final RejectFunction function2 = new RejectFunction("noRejFunc", false);
- invokeInEveryVM(new SerializableCallable("register function") {
+ Invoke.invokeInEveryVM(new SerializableCallable("register function") {
public Object call() throws Exception {
FunctionService.registerFunction(function);
FunctionService.registerFunction(function2);
@@ -915,7 +922,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
fail("expected low memory exception was not thrown");
} catch (FunctionException e) {
if (!(e.getCause().getCause() instanceof LowMemoryException)) {
- fail("unexpected exception ", e);
+ Assert.fail("unexpected exception ", e);
}
//expected
}
@@ -928,7 +935,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
// this test is DISABLED due to intermittent failures. See bug #52222
public void disabledtestPRFunctionExecutionRejection() throws Exception {
- addExpectedException("LowMemoryException");
+ IgnoredException.addIgnoredException("LowMemoryException");
final Host host = Host.getHost(0);
final VM accessor = host.getVM(0);
final VM server1 = host.getVM(1);
@@ -961,7 +968,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
final RejectFunction function = new RejectFunction();
final RejectFunction function2 = new RejectFunction("noRejFunc", false);
- invokeInEveryVM(new SerializableCallable("register function") {
+ Invoke.invokeInEveryVM(new SerializableCallable("register function") {
public Object call() throws Exception {
FunctionService.registerFunction(function);
FunctionService.registerFunction(function2);
@@ -1046,7 +1053,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
fail("expected low memory exception was not thrown");
} catch (FunctionException e) {
if (!(e.getCause().getCause() instanceof LowMemoryException)) {
- fail("unexpected exception", e);
+ Assert.fail("unexpected exception", e);
}
//expected
}
@@ -1141,7 +1148,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
final RejectFunction function = new RejectFunction();
final RejectFunction function2 = new RejectFunction("noRejFunc", false);
- invokeInEveryVM(new SerializableCallable("register function") {
+ Invoke.invokeInEveryVM(new SerializableCallable("register function") {
public Object call() throws Exception {
FunctionService.registerFunction(function);
FunctionService.registerFunction(function2);
@@ -1187,7 +1194,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
fail("expected LowMemoryExcception was not thrown");
} catch (ServerOperationException e) {
if (!(e.getCause().getMessage().matches(".*low.*memory.*"))) {
- fail("unexpected exception", e);
+ Assert.fail("unexpected exception", e);
}
//expected
}
@@ -1280,7 +1287,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
getCache();
PoolFactory pf = PoolManager.createFactory();
- pf.addServer(getServerHostName(server.getHost()), serverPort);
+ pf.addServer(NetworkUtils.getServerHostName(server.getHost()), serverPort);
pf.create("pool1");
AttributesFactory af = new AttributesFactory();
@@ -1305,14 +1312,14 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
}
} catch (ServerOperationException ex) {
if (!catchServerException) {
- fail("Unexpected exception: ", ex);
+ Assert.fail("Unexpected exception: ", ex);
}
if (!(ex.getCause() instanceof LowMemoryException)) {
- fail("Unexpected exception: ", ex);
+ Assert.fail("Unexpected exception: ", ex);
}
} catch (LowMemoryException low) {
if (!catchLowMemoryException) {
- fail("Unexpected exception: ", low);
+ Assert.fail("Unexpected exception: ", low);
}
}
return null;
@@ -1342,18 +1349,18 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
}
} catch (ServerOperationException ex) {
if (!catchServerException) {
- fail("Unexpected exception: ", ex);
+ Assert.fail("Unexpected exception: ", ex);
}
if (!(ex.getCause() instanceof LowMemoryException)) {
- fail("Unexpected exception: ", ex);
+ Assert.fail("Unexpected exception: ", ex);
}
for(Integer me: temp.keySet()) {
assertFalse("Key " + me + " should not exist", r.containsKey(me));
}
} catch (LowMemoryException low) {
- getLogWriter().info("Caught LowMemoryException", low);
+ LogWriterUtils.getLogWriter().info("Caught LowMemoryException", low);
if (!catchLowMemoryException) {
- fail("Unexpected exception: ", low);
+ Assert.fail("Unexpected exception: ", low);
}
for(Integer me: temp.keySet()) {
assertFalse("Key " + me + " should not exist", r.containsKey(me));
@@ -1535,7 +1542,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
throw new IllegalStateException("Unknown memory state");
}
if (useWaitCriterion) {
- waitForCriterion(wc, 30000, 10, true);
+ Wait.waitForCriterion(wc, 30000, 10, true);
}
return null;
}
@@ -1555,7 +1562,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
return numberOfProfiles == ra.adviseGeneric().size();
}
};
- waitForCriterion(wc, 30000, 10, true);
+ Wait.waitForCriterion(wc, 30000, 10, true);
return null;
}
});
@@ -1570,7 +1577,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
protected Properties getServerProperties() {
Properties p = new Properties();
- p.setProperty(DistributionConfig.LOCATORS_NAME, "localhost["+getDUnitLocatorPort()+"]");
+ p.setProperty(DistributionConfig.LOCATORS_NAME, "localhost["+DistributedTestUtils.getDUnitLocatorPort()+"]");
return p;
}
@@ -1657,7 +1664,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
}
};
final String tenuredPoolName = HeapMemoryMonitor.getTenuredMemoryPoolMXBean().getName();
- getLogWriter().info("TenuredPoolName:"+tenuredPoolName);
+ LogWriterUtils.getLogWriter().info("TenuredPoolName:"+tenuredPoolName);
final List list = internalSystem.getStatsList();
assertFalse(list.isEmpty());
@@ -1667,10 +1674,10 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
int i=0;
synchronized (list) {
for (Object o : list) {
- getLogWriter().info("List:"+(++i)+":"+o);
+ LogWriterUtils.getLogWriter().info("List:"+(++i)+":"+o);
if (o instanceof StatisticsImpl) {
StatisticsImpl si = (StatisticsImpl)o;
- getLogWriter().info("stat:"+si.getTextId());
+ LogWriterUtils.getLogWriter().info("stat:"+si.getTextId());
if (si.getTextId().contains(tenuredPoolName)) {
sampler.addLocalStatListener(l, si, "currentUsedMemory");
return true;
@@ -1684,7 +1691,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
return "Waiting for " + tenuredPoolName + " statistics to be added to create listener for";
}
};
- DistributedTestCase.waitForCriterion(wc, 5000, 10, true);
+ Wait.waitForCriterion(wc, 5000, 10, true);
assertTrue("expected at least one stat listener, found " +
sampler.getLocalListeners().size(),
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsOffHeapDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsOffHeapDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsOffHeapDUnitTest.java
index 43b53a3..4a205f3 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsOffHeapDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsOffHeapDUnitTest.java
@@ -68,12 +68,20 @@ import com.gemstone.gemfire.internal.cache.control.ResourceListener;
import com.gemstone.gemfire.internal.cache.control.TestMemoryThresholdListener;
import com.gemstone.gemfire.internal.cache.partitioned.RegionAdvisor;
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import com.gemstone.gemfire.test.dunit.Assert;
import com.gemstone.gemfire.test.dunit.AsyncInvocation;
import com.gemstone.gemfire.test.dunit.DistributedTestCase;
+import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.IgnoredException;
+import com.gemstone.gemfire.test.dunit.Invoke;
+import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
import com.gemstone.gemfire.test.dunit.SerializableCallable;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
/**
* Tests the Off-Heap Memory thresholds of {@link ResourceManager}
@@ -101,16 +109,15 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
@Override
public void setUp() throws Exception {
- addExpectedException(expectedEx);
- addExpectedException(expectedBelow);
+ IgnoredException.addIgnoredException(expectedEx);
+ IgnoredException.addIgnoredException(expectedBelow);
}
@Override
- public void tearDown2() throws Exception {
- invokeInEveryVM(this.resetResourceManager);
- super.tearDown2();
+ protected void preTearDownClientServerTestCase() throws Exception {
+ Invoke.invokeInEveryVM(this.resetResourceManager);
}
private SerializableCallable resetResourceManager = new SerializableCallable() {
@@ -495,7 +502,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
return dr.getMemoryThresholdReachedMembers().size() == 0;
}
};
- waitForCriterion(wc, 10000, 10, true);
+ Wait.waitForCriterion(wc, 10000, 10, true);
return null;
}
});
@@ -596,7 +603,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
return r.memoryThresholdReached.get();
}
};
- waitForCriterion(wc, 30*1000, 10, true);
+ Wait.waitForCriterion(wc, 30*1000, 10, true);
{
Integer k = new Integer(2);
assertEquals(k.toString(), r.get(k, new Integer(expectedInvocations++)));
@@ -611,7 +618,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
return !r.memoryThresholdReached.get();
}
};
- waitForCriterion(wc, 30*1000, 10, true);
+ Wait.waitForCriterion(wc, 30*1000, 10, true);
{
Integer k = new Integer(3);
assertEquals(k.toString(), r.get(k, new Integer(expectedInvocations++)));
@@ -660,7 +667,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
return r.memoryThresholdReached.get();
}
};
- waitForCriterion(wc, 30*1000, 10, true);
+ Wait.waitForCriterion(wc, 30*1000, 10, true);
{
Integer k = new Integer(5);
assertEquals(k.toString(), r.get(k, new Integer(expectedInvocations++)));
@@ -675,7 +682,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
return !r.memoryThresholdReached.get();
}
};
- waitForCriterion(wc, 30*1000, 10, true);
+ Wait.waitForCriterion(wc, 30*1000, 10, true);
{
Integer k = new Integer(6);
assertEquals(k.toString(), r.get(k, new Integer(expectedInvocations++)));
@@ -832,7 +839,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
return keyFoundOnSickMember && caughtException;
}
};
- waitForCriterion(wc, 10000, 10, true);
+ Wait.waitForCriterion(wc, 10000, 10, true);
return null;
}
});
@@ -862,7 +869,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
vm.invoke(new SerializableCallable("local destroy sick member") {
public Object call() throws Exception {
Region r = getRootRegion().getSubregion(regionName);
- getLogWriter().info("PRLocalDestroy");
+ LogWriterUtils.getLogWriter().info("PRLocalDestroy");
r.localDestroyRegion();
return null;
}
@@ -906,7 +913,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
return done;
}
};
- waitForCriterion(wc, 10000, 10, true);
+ Wait.waitForCriterion(wc, 10000, 10, true);
return null;
}
});
@@ -1001,7 +1008,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
return false;
}
};
- waitForCriterion(wc, 30*1000, 10, true);
+ Wait.waitForCriterion(wc, 30*1000, 10, true);
final Integer k = new Integer(2); // reload with same key again and again
final Integer expectedInvocations3 = new Integer(expectedInvocations.getAndIncrement());
@@ -1046,7 +1053,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
return !r.memoryThresholdReached.get();
}
};
- waitForCriterion(wc, 30*1000, 10, true);
+ Wait.waitForCriterion(wc, 30*1000, 10, true);
Integer k = new Integer(3); // same key as previously used, this time is should stick
Integer expectedInvocations8 = new Integer(expectedInvocations.incrementAndGet());
@@ -1196,7 +1203,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
return r.memoryThresholdReached.get();
}
};
- waitForCriterion(wc, 30*1000, 10, true);
+ Wait.waitForCriterion(wc, 30*1000, 10, true);
{
Integer k = new Integer(2);
assertEquals(k.toString(), r.get(k));
@@ -1217,7 +1224,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
return !r.memoryThresholdReached.get();
}
};
- waitForCriterion(wc, 30*1000, 10, true);
+ Wait.waitForCriterion(wc, 30*1000, 10, true);
{
Integer k = new Integer(3);
@@ -1318,14 +1325,14 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
}
} catch (ServerOperationException ex) {
if (!catchServerException) {
- fail("Unexpected exception: ", ex);
+ Assert.fail("Unexpected exception: ", ex);
}
if (!(ex.getCause() instanceof LowMemoryException)) {
- fail("Unexpected exception: ", ex);
+ Assert.fail("Unexpected exception: ", ex);
}
} catch (LowMemoryException low) {
if (!catchLowMemoryException) {
- fail("Unexpected exception: ", low);
+ Assert.fail("Unexpected exception: ", low);
}
}
return null;
@@ -1355,18 +1362,18 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
}
} catch (ServerOperationException ex) {
if (!catchServerException) {
- fail("Unexpected exception: ", ex);
+ Assert.fail("Unexpected exception: ", ex);
}
if (!(ex.getCause() instanceof LowMemoryException)) {
- fail("Unexpected exception: ", ex);
+ Assert.fail("Unexpected exception: ", ex);
}
for(Integer me: temp.keySet()) {
assertFalse("Key " + me + " should not exist", r.containsKey(me));
}
} catch (LowMemoryException low) {
- getLogWriter().info("Caught LowMemoryException", low);
+ LogWriterUtils.getLogWriter().info("Caught LowMemoryException", low);
if (!catchLowMemoryException) {
- fail("Unexpected exception: ", low);
+ Assert.fail("Unexpected exception: ", low);
}
for(Integer me: temp.keySet()) {
assertFalse("Key " + me + " should not exist", r.containsKey(me));
@@ -1431,7 +1438,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
return null;
}
};
- waitForCriterion(waitForCritical, 30*1000, 9, false);
+ Wait.waitForCriterion(waitForCritical, 30*1000, 9, false);
th.validateUpdateStateAndSendEventBeforeProcess(bytesUsedAfterSmallKey + 943720 + 8, MemoryState.EVICTION_DISABLED_CRITICAL);
} finally {
ohm.testHook = null;
@@ -1472,7 +1479,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
}
};
}
- waitForCriterion(wc, 30000, 9, true);
+ Wait.waitForCriterion(wc, 30000, 9, true);
getCache().getLoggerI18n().fine(removeExpectedExString);
return bytesUsedAfterSmallKey;
}
@@ -1510,7 +1517,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
return ohm.getState().isNormal();
}
};
- waitForCriterion(wc, 30000, 9, true);
+ Wait.waitForCriterion(wc, 30000, 9, true);
getCache().getLogger().fine(MemoryThresholdsOffHeapDUnitTest.this.removeExpectedBelow);
return;
}
@@ -1648,7 +1655,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
getCache();
PoolFactory pf = PoolManager.createFactory();
- pf.addServer(getServerHostName(server.getHost()), serverPort);
+ pf.addServer(NetworkUtils.getServerHostName(server.getHost()), serverPort);
pf.create("pool1");
AttributesFactory af = new AttributesFactory();
@@ -1781,7 +1788,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
throw new IllegalStateException("Unknown memory state");
}
if (useWaitCriterion) {
- waitForCriterion(wc, 5000, 10, true);
+ Wait.waitForCriterion(wc, 5000, 10, true);
}
return null;
}
@@ -1801,7 +1808,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
return numberOfProfiles == ra.adviseGeneric().size();
}
};
- waitForCriterion(wc, 10000, 10, true);
+ Wait.waitForCriterion(wc, 10000, 10, true);
return null;
}
});
@@ -1809,7 +1816,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends ClientServerTestCase {
private Properties getOffHeapProperties() {
Properties p = new Properties();
- p.setProperty(DistributionConfig.LOCATORS_NAME, "localhost["+getDUnitLocatorPort()+"]");
+ p.setProperty(DistributionConfig.LOCATORS_NAME, "localhost["+DistributedTestUtils.getDUnitLocatorPort()+"]");
p.setProperty(DistributionConfig.OFF_HEAP_MEMORY_SIZE_NAME, "1m");
return p;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/ResourceManagerDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/ResourceManagerDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/ResourceManagerDUnitTest.java
index 19f0612..0595948 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/ResourceManagerDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/ResourceManagerDUnitTest.java
@@ -61,6 +61,7 @@ import com.gemstone.gemfire.internal.cache.partitioned.RemoveBucketMessage;
import com.gemstone.gemfire.internal.cache.partitioned.RemoveBucketMessage.RemoveBucketResponse;
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.test.dunit.Assert;
import com.gemstone.gemfire.test.dunit.Host;
import com.gemstone.gemfire.test.dunit.SerializableCallable;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
@@ -1022,9 +1023,9 @@ public class ResourceManagerDUnitTest extends CacheTestCase {
assertEquals(1, sr.size());
assertEquals(value, sr.iterator().next());
} catch (QueryException ex) {
- fail("didn't expect a QueryException", ex);
+ Assert.fail("didn't expect a QueryException", ex);
} catch (QueryInvalidException ex2) {
- fail("didn't expect QueryInvalidException", ex2);
+ Assert.fail("didn't expect QueryInvalidException", ex2);
}
}
});
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/cache/mapInterface/PutAllGlobalLockJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/mapInterface/PutAllGlobalLockJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/mapInterface/PutAllGlobalLockJUnitTest.java
index 48f1c56..2f9be54 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/mapInterface/PutAllGlobalLockJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/mapInterface/PutAllGlobalLockJUnitTest.java
@@ -36,7 +36,7 @@ import com.gemstone.gemfire.cache.RegionAttributes;
import com.gemstone.gemfire.cache.Scope;
import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
import com.gemstone.gemfire.distributed.DistributedSystem;
-import com.gemstone.gemfire.test.dunit.DistributedTestCase;
+import com.gemstone.gemfire.test.dunit.ThreadUtils;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
@Category(IntegrationTest.class)
@@ -79,7 +79,7 @@ public class PutAllGlobalLockJUnitTest {
}
try {
testRegion.putAll(trialMap);
- DistributedTestCase.join(this.thread, 30 * 1000, null);
+ ThreadUtils.join(this.thread, 30 * 1000);
assertTrue(this.testOK);
} catch (Exception e) {
fail("Test has failed due to "+e);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/cache/partition/PartitionRegionHelperDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/partition/PartitionRegionHelperDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/partition/PartitionRegionHelperDUnitTest.java
index f70e7a2..d09c6e0 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/partition/PartitionRegionHelperDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/partition/PartitionRegionHelperDUnitTest.java
@@ -43,10 +43,11 @@ import com.gemstone.gemfire.internal.cache.BucketRegion;
import com.gemstone.gemfire.internal.cache.ForceReattemptException;
import com.gemstone.gemfire.internal.cache.PartitionedRegion;
import com.gemstone.gemfire.internal.cache.PartitionedRegionHelper;
-import com.gemstone.gemfire.internal.cache.partitioned.fixed.FixedPartitioningTestBase;
import com.gemstone.gemfire.internal.cache.partitioned.fixed.FixedPartitioningTestBase.Months_Accessor;
+import com.gemstone.gemfire.test.dunit.Assert;
import com.gemstone.gemfire.test.dunit.AsyncInvocation;
import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.LogWriterUtils;
import com.gemstone.gemfire.test.dunit.SerializableCallable;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
import com.gemstone.gemfire.test.dunit.VM;
@@ -249,7 +250,7 @@ public class PartitionRegionHelperDUnitTest extends CacheTestCase {
date = sdf.parse(dateString);
}
catch (ParseException e) {
- FixedPartitioningTestBase.fail("Exception Occured while parseing date", e);
+ Assert.fail("Exception Occured while parseing date", e);
}
String value = month.toString() + 10;
region.put(date, value);
@@ -272,7 +273,7 @@ public class PartitionRegionHelperDUnitTest extends CacheTestCase {
date = sdf.parse(dateString);
}
catch (ParseException e) {
- FixedPartitioningTestBase.fail("Exception Occured while parseing date", e);
+ Assert.fail("Exception Occured while parseing date", e);
}
DistributedMember key1Pri = PartitionRegionHelper.getPrimaryMemberForKey(region, date);
assertNotNull(key1Pri);
@@ -468,7 +469,7 @@ public class PartitionRegionHelperDUnitTest extends CacheTestCase {
assertTrue(buk0.getBucketAdvisor().isPrimary());
}
catch (ForceReattemptException e) {
- getLogWriter().severe(e);
+ LogWriterUtils.getLogWriter().severe(e);
fail();
}
}
@@ -485,14 +486,14 @@ public class PartitionRegionHelperDUnitTest extends CacheTestCase {
assertNotNull(k1e);
}
catch (ForceReattemptException e) {
- getLogWriter().severe(e);
+ LogWriterUtils.getLogWriter().severe(e);
fail();
}
}
};
for (DistributedMember bom: buk0AllMems) {
VM v = d2v.get(bom);
- getLogWriter().info("Visiting bucket owner member " + bom + " for key " + buk0Key1);
+ LogWriterUtils.getLogWriter().info("Visiting bucket owner member " + bom + " for key " + buk0Key1);
v.invoke(assertHasBucket);
}
@@ -507,14 +508,14 @@ public class PartitionRegionHelperDUnitTest extends CacheTestCase {
assertFalse(buk0.getBucketAdvisor().isPrimary());
}
catch (ForceReattemptException e) {
- getLogWriter().severe(e);
+ LogWriterUtils.getLogWriter().severe(e);
fail();
}
}
};
for (DistributedMember redm: buk0Redundants) {
VM v = d2v.get(redm);
- getLogWriter().info("Visiting redundant member " + redm + " for key " + buk0Key1);
+ LogWriterUtils.getLogWriter().info("Visiting redundant member " + redm + " for key " + buk0Key1);
v.invoke(assertRed);
}
}
@@ -588,7 +589,7 @@ public class PartitionRegionHelperDUnitTest extends CacheTestCase {
} catch(IllegalStateException expected) {
System.err.println(expected);
} catch (UnknownHostException e) {
- fail("Unknown host", e);
+ Assert.fail("Unknown host", e);
}
assertHasMembers(PartitionRegionHelper.getAllMembersForKey(region, 1), member0, member1);
@@ -668,7 +669,7 @@ public class PartitionRegionHelperDUnitTest extends CacheTestCase {
} catch(IllegalStateException expected) {
System.err.println(expected);
} catch (UnknownHostException e) {
- fail("Unknown host", e);
+ Assert.fail("Unknown host", e);
}
assertHasMembers(PartitionRegionHelper.getAllMembersForKey(region, 1), member0, member1);
@@ -679,7 +680,7 @@ public class PartitionRegionHelperDUnitTest extends CacheTestCase {
} catch(IllegalStateException expected) {
System.err.println(expected);
} catch (UnknownHostException e) {
- fail("Unknown host", e);
+ Assert.fail("Unknown host", e);
}
assertHasMembers(PartitionRegionHelper.getAllMembersForKey(region, 1), member0, member1);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqQueryTestListener.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqQueryTestListener.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqQueryTestListener.java
index 8c43e47..e402671 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqQueryTestListener.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqQueryTestListener.java
@@ -30,8 +30,8 @@ import com.gemstone.gemfire.cache.client.Pool;
import com.gemstone.gemfire.cache.query.CqEvent;
import com.gemstone.gemfire.cache.query.CqStatusListener;
import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
-import com.gemstone.gemfire.test.dunit.DistributedTestCase;
-import com.gemstone.gemfire.test.dunit.DistributedTestCase.WaitCriterion;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
/**
* @author rmadduri
@@ -238,7 +238,7 @@ public class CqQueryTestListener implements CqStatusListener {
return "never got create event for CQ " + CqQueryTestListener.this.cqName + " key " + key;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_TIME, 200, true);
+ Wait.waitForCriterion(ev, MAX_TIME, 200, true);
return true;
}
@@ -253,7 +253,7 @@ public class CqQueryTestListener implements CqStatusListener {
" expected: " + total + " receieved: " + CqQueryTestListener.this.totalEventCount;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_TIME, 200, true);
+ Wait.waitForCriterion(ev, MAX_TIME, 200, true);
return true;
}
@@ -266,7 +266,7 @@ public class CqQueryTestListener implements CqStatusListener {
return "never got destroy event for key " + key + " in CQ " + CqQueryTestListener.this.cqName;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_TIME, 200, true);
+ Wait.waitForCriterion(ev, MAX_TIME, 200, true);
return true;
}
@@ -279,7 +279,7 @@ public class CqQueryTestListener implements CqStatusListener {
return "never got invalidate event for CQ " + CqQueryTestListener.this.cqName;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_TIME, 200, true);
+ Wait.waitForCriterion(ev, MAX_TIME, 200, true);
return true;
}
@@ -292,7 +292,7 @@ public class CqQueryTestListener implements CqStatusListener {
return "never got update event for CQ " + CqQueryTestListener.this.cqName;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_TIME, 200, true);
+ Wait.waitForCriterion(ev, MAX_TIME, 200, true);
return true;
}
@@ -305,7 +305,7 @@ public class CqQueryTestListener implements CqStatusListener {
return "never got close event for CQ " + CqQueryTestListener.this.cqName;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_TIME, 200, true);
+ Wait.waitForCriterion(ev, MAX_TIME, 200, true);
return true;
}
@@ -318,7 +318,7 @@ public class CqQueryTestListener implements CqStatusListener {
return "never got region clear event for CQ " + CqQueryTestListener.this.cqName;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_TIME, 200, true);
+ Wait.waitForCriterion(ev, MAX_TIME, 200, true);
return true;
}
@@ -331,7 +331,7 @@ public class CqQueryTestListener implements CqStatusListener {
return "never got region invalidate event for CQ " + CqQueryTestListener.this.cqName;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_TIME, 200, true);
+ Wait.waitForCriterion(ev, MAX_TIME, 200, true);
return true;
}
@@ -354,7 +354,7 @@ public class CqQueryTestListener implements CqStatusListener {
return "never got create error for CQ " + CqQueryTestListener.this.cqName + " messaged " + expectedMessage;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_TIME, 200, true);
+ Wait.waitForCriterion(ev, MAX_TIME, 200, true);
return true;
}
@@ -368,7 +368,7 @@ public class CqQueryTestListener implements CqStatusListener {
" expected: " + total + " received: " + CqQueryTestListener.this.cqsDisconnectedCount;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_TIME, 200, true);
+ Wait.waitForCriterion(ev, MAX_TIME, 200, true);
return true;
}
@@ -382,7 +382,7 @@ public class CqQueryTestListener implements CqStatusListener {
" expected: " + total + " receieved: " + CqQueryTestListener.this.cqsConnectedCount;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_TIME, 200, true);
+ Wait.waitForCriterion(ev, MAX_TIME, 200, true);
return true;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/CompactRangeIndexDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/CompactRangeIndexDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/CompactRangeIndexDUnitTest.java
index f579e58..81b545f 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/CompactRangeIndexDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/CompactRangeIndexDUnitTest.java
@@ -25,11 +25,15 @@ import com.gemstone.gemfire.cache.query.internal.index.IndexManager;
import com.gemstone.gemfire.cache.query.internal.index.IndexManager.TestHook;
import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
import com.gemstone.gemfire.cache30.CacheSerializableRunnable.CacheSerializableRunnableException;
+import com.gemstone.gemfire.test.dunit.Assert;
import com.gemstone.gemfire.test.dunit.AsyncInvocation;
import com.gemstone.gemfire.test.dunit.DistributedTestCase;
+import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.Invoke;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.Wait;
public class CompactRangeIndexDUnitTest extends DistributedTestCase{
@@ -43,7 +47,7 @@ public class CompactRangeIndexDUnitTest extends DistributedTestCase{
public void setUp() throws Exception {
super.setUp();
getSystem();
- invokeInEveryVM(new SerializableRunnable("getSystem") {
+ Invoke.invokeInEveryVM(new SerializableRunnable("getSystem") {
public void run() {
getSystem();
}
@@ -51,7 +55,7 @@ public class CompactRangeIndexDUnitTest extends DistributedTestCase{
Host host = Host.getHost(0);
vm0 = host.getVM(0);
utils = new QueryTestUtils();
- utils.createServer(vm0, getAllDistributedSystemProperties(new Properties()));
+ utils.createServer(vm0, DistributedTestUtils.getAllDistributedSystemProperties(new Properties()));
utils.createReplicateRegion("exampleRegion", vm0);
utils.createIndex(vm0,"type", "\"type\"", "/exampleRegion");
}
@@ -145,7 +149,7 @@ public class CompactRangeIndexDUnitTest extends DistributedTestCase{
});
as0.join();
if(as0.exceptionOccurred()){
- fail("Query execution failed.", as0.getException());
+ Assert.fail("Query execution failed.", as0.getException());
}
}
@@ -164,7 +168,8 @@ public class CompactRangeIndexDUnitTest extends DistributedTestCase{
}
- public void tearDown2() throws Exception{
+ @Override
+ protected final void preTearDown() throws Exception {
Thread.sleep(5000);
removeHook();
utils.closeServer(vm0);
@@ -191,7 +196,7 @@ public class CompactRangeIndexDUnitTest extends DistributedTestCase{
@Override
public void hook(int spot) throws RuntimeException {
if(spot == 11){
- pause(10);
+ Wait.pause(10);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/CqTimeTestListener.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/CqTimeTestListener.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/CqTimeTestListener.java
index 5f3d45d..3d3a2e4 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/CqTimeTestListener.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/CqTimeTestListener.java
@@ -25,8 +25,8 @@ import com.gemstone.gemfire.cache.Operation;
import com.gemstone.gemfire.cache.query.CqEvent;
import com.gemstone.gemfire.cache.query.CqListener;
import com.gemstone.gemfire.cache.query.data.Portfolio;
-import com.gemstone.gemfire.test.dunit.DistributedTestCase;
-import com.gemstone.gemfire.test.dunit.DistributedTestCase.WaitCriterion;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
/**
* @author anil.
@@ -198,7 +198,7 @@ public class CqTimeTestListener implements CqListener {
return "never got create event for CQ " + CqTimeTestListener.this.cqName;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_TIME, 200, true);
+ Wait.waitForCriterion(ev, MAX_TIME, 200, true);
return true;
}
@@ -211,7 +211,7 @@ public class CqTimeTestListener implements CqListener {
return "never got destroy event for CQ " + CqTimeTestListener.this.cqName;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_TIME, 200, true);
+ Wait.waitForCriterion(ev, MAX_TIME, 200, true);
return true;
}
@@ -224,7 +224,7 @@ public class CqTimeTestListener implements CqListener {
return "never got invalidate event for CQ " + CqTimeTestListener.this.cqName;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_TIME, 200, true);
+ Wait.waitForCriterion(ev, MAX_TIME, 200, true);
return true;
}
@@ -237,7 +237,7 @@ public class CqTimeTestListener implements CqListener {
return "never got update event for CQ " + CqTimeTestListener.this.cqName;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_TIME, 200, true);
+ Wait.waitForCriterion(ev, MAX_TIME, 200, true);
return true;
}
@@ -250,7 +250,7 @@ public class CqTimeTestListener implements CqListener {
return "never got close event for CQ " + CqTimeTestListener.this.cqName;
}
};
- DistributedTestCase.waitForCriterion(ev, MAX_TIME, 200, true);
+ Wait.waitForCriterion(ev, MAX_TIME, 200, true);
return true;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/HashIndexDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/HashIndexDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/HashIndexDUnitTest.java
index afd2119..38721be 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/HashIndexDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/HashIndexDUnitTest.java
@@ -22,7 +22,9 @@ import com.gemstone.gemfire.cache.CacheException;
import com.gemstone.gemfire.cache.query.QueryTestUtils;
import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
import com.gemstone.gemfire.test.dunit.DistributedTestCase;
+import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.Invoke;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
import com.gemstone.gemfire.test.dunit.VM;
@@ -38,7 +40,7 @@ public class HashIndexDUnitTest extends DistributedTestCase{
public void setUp() throws Exception {
super.setUp();
getSystem();
- invokeInEveryVM(new SerializableRunnable("getSystem") {
+ Invoke.invokeInEveryVM(new SerializableRunnable("getSystem") {
public void run() {
getSystem();
}
@@ -46,7 +48,7 @@ public class HashIndexDUnitTest extends DistributedTestCase{
Host host = Host.getHost(0);
vm0 = host.getVM(0);
utils = new QueryTestUtils();
- utils.createServer(vm0, getAllDistributedSystemProperties(new Properties()));
+ utils.createServer(vm0, DistributedTestUtils.getAllDistributedSystemProperties(new Properties()));
utils.createReplicateRegion("exampleRegion", vm0);
utils.createHashIndex(vm0,"ID", "r.ID", "/exampleRegion r");
}
@@ -122,9 +124,9 @@ public class HashIndexDUnitTest extends DistributedTestCase{
});
}
- public void tearDown2() throws Exception{
+ @Override
+ protected final void preTearDown() throws Exception {
Thread.sleep(5000);
utils.closeServer(vm0);
}
-
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/HelperTestCase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/HelperTestCase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/HelperTestCase.java
index 08a4882..f4132da 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/HelperTestCase.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/HelperTestCase.java
@@ -46,6 +46,7 @@ import com.gemstone.gemfire.cache30.CacheTestCase;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
import com.gemstone.gemfire.test.dunit.AsyncInvocation;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
import com.gemstone.gemfire.test.dunit.SerializableCallable;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
import com.gemstone.gemfire.test.dunit.VM;
@@ -239,7 +240,7 @@ public class HelperTestCase extends CacheTestCase {
final ClientCacheFactory ccf = new ClientCacheFactory(properties);
for (int i = 0; i < servers.length; i++) {
- ccf.addPoolServer(getServerHostName(servers[i].getHost()), ports[i]);
+ ccf.addPoolServer(NetworkUtils.getServerHostName(servers[i].getHost()), ports[i]);
}
ccf.setPoolSubscriptionEnabled(true);
ccf.setPoolSubscriptionRedundancy(redundancyLevel);