You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/06/09 18:49:44 UTC
[16/54] [abbrv] [partial] incubator-geode git commit: GEODE-837:
update tests from JUnit3 to JUnit4
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientServerMiscDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientServerMiscDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientServerMiscDUnitTest.java
index d91e3f5..3d5bdf7 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientServerMiscDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientServerMiscDUnitTest.java
@@ -16,8 +16,25 @@
*/
package com.gemstone.gemfire.internal.cache.tier.sockets;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static org.junit.Assert.*;
+
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.GemFireIOException;
-import com.gemstone.gemfire.cache.*;
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheException;
+import com.gemstone.gemfire.cache.CacheWriterException;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.Scope;
import com.gemstone.gemfire.cache.client.NoAvailableServersException;
import com.gemstone.gemfire.cache.client.Pool;
import com.gemstone.gemfire.cache.client.PoolManager;
@@ -27,30 +44,28 @@ import com.gemstone.gemfire.cache.client.internal.PoolImpl;
import com.gemstone.gemfire.cache.client.internal.RegisterInterestTracker;
import com.gemstone.gemfire.cache.server.CacheServer;
import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
-import com.gemstone.gemfire.cache30.CacheTestCase;
import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.distributed.DistributedSystemDisconnectedException;
import com.gemstone.gemfire.internal.AvailablePort;
import com.gemstone.gemfire.internal.cache.CacheServerImpl;
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
import com.gemstone.gemfire.internal.cache.LocalRegion;
-import com.gemstone.gemfire.test.dunit.*;
-
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Set;
-
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.LOCATORS;
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT;
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.IgnoredException;
+import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
+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.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
/**
* Tests client server corner cases between Region and Pool
- *
- *
*/
-public class ClientServerMiscDUnitTest extends CacheTestCase
-{
-// private static Cache cache = null;
+@Category(DistributedTest.class)
+public class ClientServerMiscDUnitTest extends JUnit4CacheTestCase {
protected static PoolImpl pool = null;
@@ -82,7 +97,6 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
private static RegionAttributes attrs;
-
// variables for concurrent map API test
Properties props = new Properties();
final int putRange_1Start = 1;
@@ -98,13 +112,6 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
final int removeRange_2Start = 7;
final int removeRange_2End = 9;
-
-
- /** constructor */
- public ClientServerMiscDUnitTest(String name) {
- super(name);
- }
-
@Override
public final void postSetUp() throws Exception {
host = Host.getHost(0);
@@ -127,6 +134,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
}
+ @Test
public void testConcurrentOperationsWithDRandPR() throws Exception {
int port1 = initServerCache(true); // vm0
int port2 = initServerCache2(true); // vm1
@@ -141,6 +149,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
// TODO add verification in vm3
}
+ @Test
public void testConcurrentOperationsWithDRandPRandEmptyClient() throws Exception {
int port1 = initServerCache(true); // vm0
int port2 = initServerCache2(true); // vm1
@@ -357,6 +366,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
* If an update/create is made on region1 , the client should not receive any.
* If the create/update is on region2 , the client should receive the update.
*/
+ @Test
public void testForTwoRegionHavingDifferentInterestList()
throws Exception
{
@@ -390,6 +400,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
* ( which is diferent from not receiving a callbak on the client).
* If an update on region2 is made on the server , then client should receive the calback
*/
+ @Test
public void testForTwoRegionHavingALLKEYSInterest()
throws Exception
{
@@ -413,6 +424,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
* close all the server connection threads on the server &
* remove the CacheClientProxy from the CacheClient notifier
*/
+ @Test
public void testRegionClose() throws Exception
{
// start server first
@@ -440,6 +452,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
* to the clients. Then create third region and verify that no
* CacheClientProxy is created on server
*/
+ @Test
public void testCCPDestroyOnLastDestroyRegion() throws Exception
{
PORT1 = initServerCache(true);
@@ -473,6 +486,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
* updates on server in their respective regions
*
*/
+ @Test
public void testInvalidatesPropagateOnTwoRegions()
throws Exception
{
@@ -494,6 +508,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
* client's cache. This turned out to be expected behavior, but we
* now have this test to guarantee that the product behaves as expected.
*/
+ @Test
public void testGetInClientCreatesEntry() throws Exception {
// start server first
PORT1 = initServerCache(false);
@@ -527,6 +542,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
/**
* GEODE-478 - large payloads are rejected by client->server
*/
+ @Test
public void testLargeMessageIsRejected() throws Exception {
PORT1 = initServerCache(false);
createClientCache(NetworkUtils.getServerHostName(Host.getHost(0)), PORT1);
@@ -557,9 +573,8 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
* populate some entries on region both on client and server.
* Update the entries on server the client.
* The client should not have entry invalidate.
- *
- * @throws Exception
*/
+ @Test
public void testInvalidatesPropagateOnRegionHavingNoPool()
throws Exception
{
@@ -568,7 +583,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
- new ClientServerMiscDUnitTest("temp").createCache(props);
+ new ClientServerMiscDUnitTest().createCache(props);
String host = NetworkUtils.getServerHostName(server1.getHost());
PoolImpl p = (PoolImpl)PoolManager.createFactory()
.addServer(host, PORT1)
@@ -662,6 +677,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
* @throws Exception
*/
+ @Test
public void testProxyCreationBeforeCacheCreation() throws Exception
{
Properties props = new Properties();
@@ -712,6 +728,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
*
* @throws Exception
*/
+ @Test
public void testSystemCanBeCycledWithAnInitializedPool() throws Exception
{
//work around GEODE-477
@@ -805,7 +822,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
- Cache cache = new ClientServerMiscDUnitTest("temp").createCacheV(props);
+ Cache cache = new ClientServerMiscDUnitTest().createCacheV(props);
ClientServerMiscDUnitTest.static_cache = cache;
PoolImpl p = (PoolImpl)PoolManager.createFactory()
.addServer(h, port)
@@ -864,7 +881,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static Integer createServerCache(Boolean notifyBySubscription, Integer maxThreads)
throws Exception {
- Cache cache = new ClientServerMiscDUnitTest("temp").createCacheV(new Properties());
+ Cache cache = new ClientServerMiscDUnitTest().createCacheV(new Properties());
unsetSlowDispatcherFlag();
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
@@ -900,7 +917,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void registerInterest()
{
try {
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME2);
assertNotNull(r);
//r.registerInterestRegex(CacheClientProxy.ALL_KEYS);
@@ -915,7 +932,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void registerInterestForInvalidatesInBothTheRegions()
{
try {
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME1);
assertNotNull(r1);
Region r2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2);
@@ -934,7 +951,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void registerInterestInBothTheRegions()
{
try {
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME1);
assertNotNull(r1);
Region r2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2);
@@ -953,7 +970,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void closeRegion1()
{
try {
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME1);
assertNotNull(r1);
r1.close();
@@ -967,7 +984,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void closeBothRegions()
{
try {
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME1);
Region r2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2);
Region pr = cache.getRegion(Region.SEPARATOR + PR_REGION_NAME);
@@ -987,7 +1004,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void destroyRegion1()
{
try {
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME1);
assertNotNull(r1);
r1.destroyRegion();
@@ -1001,7 +1018,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void destroyRegion2()
{
try {
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
Region r2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2);
assertNotNull(r2);
r2.destroyRegion();
@@ -1014,7 +1031,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void destroyPRRegion() {
try {
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
Region r2 = cache.getRegion(Region.SEPARATOR + PR_REGION_NAME);
assertNotNull(r2);
r2.destroyRegion();
@@ -1027,7 +1044,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void verifyInterestListOnServer()
{
try {
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
assertEquals("More than one BridgeServer", 1, cache.getCacheServers()
.size());
CacheServerImpl bs = (CacheServerImpl)cache.getCacheServers()
@@ -1057,7 +1074,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void verifyNoCacheClientProxyOnServer()
{
try {
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
assertEquals("More than one BridgeServer", 1, cache.getCacheServers()
.size());
CacheServerImpl bs = (CacheServerImpl)cache.getCacheServers()
@@ -1087,7 +1104,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void verifyCacheClientProxyOnServer(String regionName)
{
try {
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
assertNull(cache.getRegion(Region.SEPARATOR + regionName));
verifyCacheClientProxyOnServer();
@@ -1102,7 +1119,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void verifyCacheClientProxyOnServer()
{
try {
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
assertEquals("More than one BridgeServer", 1, cache.getCacheServers()
.size());
CacheServerImpl bs = (CacheServerImpl)cache.getCacheServers()
@@ -1132,7 +1149,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void populateCache()
{
try {
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME1);
Region r2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2);
assertNotNull(r1);
@@ -1160,7 +1177,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void put()
{
try {
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME1);
Region r2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2);
assertNotNull(r1);
@@ -1185,7 +1202,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void verifyUpdates()
{
try {
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
final Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME1);
final Region r2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2);
assertNotNull(r1);
@@ -1252,7 +1269,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void verifyInvalidatesOnBothRegions()
{
try {
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
final Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME1);
final Region r2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2);
assertNotNull(r1);
@@ -1331,7 +1348,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void verifyUpdatesOnRegion2()
{
try {
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
final Region r2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2);
assertNotNull(r2);
WaitCriterion wc = new WaitCriterion() {
@@ -1376,7 +1393,7 @@ public class ClientServerMiscDUnitTest extends CacheTestCase
public static void closeCacheAndDisconnect()
{
- Cache cache = new ClientServerMiscDUnitTest("temp").getCache();
+ Cache cache = new ClientServerMiscDUnitTest().getCache();
if (cache != null && !cache.isClosed()) {
cache.close();
cache.getDistributedSystem().disconnect();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientServerMiscSelectorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientServerMiscSelectorDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientServerMiscSelectorDUnitTest.java
index bc02159..d25e3a7 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientServerMiscSelectorDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientServerMiscSelectorDUnitTest.java
@@ -16,6 +16,15 @@
*/
package com.gemstone.gemfire.internal.cache.tier.sockets;
+import org.junit.experimental.categories.Category;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+
/**
* Just like parent but enables server thread pool
@@ -23,10 +32,11 @@ package com.gemstone.gemfire.internal.cache.tier.sockets;
*
*
*/
+@Category(DistributedTest.class)
public class ClientServerMiscSelectorDUnitTest extends ClientServerMiscDUnitTest
{
- public ClientServerMiscSelectorDUnitTest(String name) {
- super(name);
+ public ClientServerMiscSelectorDUnitTest() {
+ super();
}
protected int getMaxThreads() {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/ConflationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/ConflationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/ConflationDUnitTest.java
index 0ab0116..e0d672f 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/ConflationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/ConflationDUnitTest.java
@@ -16,7 +16,24 @@
*/
package com.gemstone.gemfire.internal.cache.tier.sockets;
-import com.gemstone.gemfire.cache.*;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static org.junit.Assert.*;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.CacheWriterException;
+import com.gemstone.gemfire.cache.EntryEvent;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.Scope;
import com.gemstone.gemfire.cache.client.Pool;
import com.gemstone.gemfire.cache.client.PoolManager;
import com.gemstone.gemfire.cache.client.internal.PoolImpl;
@@ -24,17 +41,22 @@ import com.gemstone.gemfire.cache.server.CacheServer;
import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.internal.cache.*;
+import com.gemstone.gemfire.internal.cache.CacheServerImpl;
+import com.gemstone.gemfire.internal.cache.ClientServerObserverAdapter;
+import com.gemstone.gemfire.internal.cache.ClientServerObserverHolder;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.internal.cache.HARegion;
import com.gemstone.gemfire.internal.cache.ha.HAHelper;
import com.gemstone.gemfire.internal.cache.ha.HARegionQueue;
-import com.gemstone.gemfire.test.dunit.*;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Properties;
-
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.LOCATORS;
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT;
+import com.gemstone.gemfire.test.dunit.Assert;
+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.VM;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
/**
* This test verifies the conflation functionality of the
@@ -47,25 +69,20 @@ import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties
* The test has two regions. In one scenario
* they share a common bridgewriter and in the second
* scenario, each has a unique bridgewriter.
- *
*/
-public class ConflationDUnitTest extends DistributedTestCase
-{
+@Category(DistributedTest.class)
+public class ConflationDUnitTest extends JUnit4DistributedTestCase {
+
VM vm0 = null;
VM vm2 = null;
private static Cache cache = null;
private int PORT ;
private static final String REGION_NAME1 = "ConflationDUnitTest_region1" ;
private static final String REGION_NAME2 = "ConflationDUnitTest_region2" ;
- final static String MARKER = "markerKey";
+ static final String MARKER = "markerKey";
private static HashMap statMap = new HashMap();
- /** constructor */
- public ConflationDUnitTest(String name) {
- super(name);
- }
-
@Override
public final void postSetUp() throws Exception {
disconnectAllFromDS();
@@ -120,6 +137,7 @@ public class ConflationDUnitTest extends DistributedTestCase
* two regions, with two writers (each region will have a unique bridgwriter).
*
*/
+ @Test
public void testTwoRegionsTwoWriters()
{
try {
@@ -151,6 +169,7 @@ public class ConflationDUnitTest extends DistributedTestCase
* two regions with a common bridgewriter
*
*/
+ @Test
public void testTwoRegionsOneWriter() throws Exception
{
vm0.invoke(() -> ConflationDUnitTest.setIsSlowStart());
@@ -178,6 +197,7 @@ public class ConflationDUnitTest extends DistributedTestCase
* test more messages are not sent to client from server
*
*/
+ @Test
public void testNotMoreMessagesSent() throws Exception
{
vm0.invoke(() -> ConflationDUnitTest.setIsSlowStart());
@@ -237,7 +257,7 @@ public class ConflationDUnitTest extends DistributedTestCase
public static void createClientCache1CommonWriter(String host, Integer port) throws Exception
{
- ConflationDUnitTest test = new ConflationDUnitTest("temp");
+ ConflationDUnitTest test = new ConflationDUnitTest();
cache = test.createCache(createProperties1());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
@@ -255,7 +275,7 @@ public class ConflationDUnitTest extends DistributedTestCase
public static void createClientCache1CommonWriterTest3(String host, Integer port) throws Exception
{
- ConflationDUnitTest test = new ConflationDUnitTest("temp");
+ ConflationDUnitTest test = new ConflationDUnitTest();
cache = test.createCache(createProperties1());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
@@ -272,7 +292,7 @@ public class ConflationDUnitTest extends DistributedTestCase
*/
public static void createClientCache2CommonWriter(String host, Integer port) throws Exception
{
- ConflationDUnitTest test = new ConflationDUnitTest("temp");
+ ConflationDUnitTest test = new ConflationDUnitTest();
cache = test.createCache(createProperties1());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
@@ -319,7 +339,7 @@ public class ConflationDUnitTest extends DistributedTestCase
public static void createClientCache2CommonWriterTest3(String host, Integer port)
throws Exception
{
- ConflationDUnitTest test = new ConflationDUnitTest("temp");
+ ConflationDUnitTest test = new ConflationDUnitTest();
cache = test.createCache(createProperties1());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
@@ -371,7 +391,7 @@ public class ConflationDUnitTest extends DistributedTestCase
public static void createClientCache1UniqueWriter(String host, Integer port) throws Exception
{
- ConflationDUnitTest test = new ConflationDUnitTest("temp");
+ ConflationDUnitTest test = new ConflationDUnitTest();
cache = test.createCache(createProperties1());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
@@ -390,7 +410,7 @@ public class ConflationDUnitTest extends DistributedTestCase
*/
public static void createClientCache2UniqueWriter(String host, Integer port) throws Exception
{
- ConflationDUnitTest test = new ConflationDUnitTest("temp");
+ ConflationDUnitTest test = new ConflationDUnitTest();
cache = test.createCache(createProperties1());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
@@ -626,7 +646,7 @@ public class ConflationDUnitTest extends DistributedTestCase
*/
public static Integer createServerCache() throws Exception
{
- ConflationDUnitTest test = new ConflationDUnitTest("temp");
+ ConflationDUnitTest test = new ConflationDUnitTest();
cache = test.createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DataSerializerPropogationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DataSerializerPropogationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DataSerializerPropogationDUnitTest.java
index ba08e33..74987f0 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DataSerializerPropogationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DataSerializerPropogationDUnitTest.java
@@ -16,9 +16,27 @@
*/
package com.gemstone.gemfire.internal.cache.tier.sockets;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static org.junit.Assert.*;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.DataSerializer;
import com.gemstone.gemfire.TestDataSerializer;
-import com.gemstone.gemfire.cache.*;
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheException;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.MirrorType;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.Scope;
import com.gemstone.gemfire.cache.client.Pool;
import com.gemstone.gemfire.cache.client.PoolManager;
import com.gemstone.gemfire.cache.client.internal.PoolImpl;
@@ -31,19 +49,20 @@ import com.gemstone.gemfire.internal.cache.CacheServerImpl;
import com.gemstone.gemfire.internal.cache.ClientServerObserverAdapter;
import com.gemstone.gemfire.internal.cache.ClientServerObserverHolder;
import com.gemstone.gemfire.internal.cache.EventID;
-import com.gemstone.gemfire.test.dunit.*;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.Properties;
-
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.LOCATORS;
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT;
-
-public class DataSerializerPropogationDUnitTest extends DistributedTestCase {
-
- private static final long serialVersionUID = 0L;
+import com.gemstone.gemfire.test.dunit.Assert;
+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.NetworkUtils;
+import com.gemstone.gemfire.test.dunit.StoppableWaitCriterion;
+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 com.gemstone.gemfire.test.junit.categories.DistributedTest;
+
+@Category(DistributedTest.class)
+public class DataSerializerPropogationDUnitTest extends JUnit4DistributedTestCase {
private static Cache cache = null;
@@ -71,11 +90,6 @@ public class DataSerializerPropogationDUnitTest extends DistributedTestCase {
public static boolean successfullyLoadedTestDataSerializer = false;
- public DataSerializerPropogationDUnitTest(String name) {
- super(name);
- // TODO Auto-generated constructor stub
- }
-
@Override
public final void postSetUp() throws Exception {
final Host host = Host.getHost(0);
@@ -99,7 +113,7 @@ public class DataSerializerPropogationDUnitTest extends DistributedTestCase {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
- new DataSerializerPropogationDUnitTest("temp").createCache(props);
+ new DataSerializerPropogationDUnitTest().createCache(props);
Pool p = PoolManager.createFactory().addServer(host, port1.intValue())
.setMinConnections(1).setSubscriptionEnabled(true).setPingInterval(200)
.create("ClientServerDataSerializersRegistrationDUnitTestPool");
@@ -121,7 +135,7 @@ public class DataSerializerPropogationDUnitTest extends DistributedTestCase {
}
public static Integer createServerCache(Integer maxThreads) throws Exception {
- new DataSerializerPropogationDUnitTest("temp")
+ new DataSerializerPropogationDUnitTest()
.createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
@@ -381,6 +395,7 @@ public class DataSerializerPropogationDUnitTest extends DistributedTestCase {
* Verified if the 2 DataSerializers get propogated to client when client gets
* connected.
*/
+ @Test
public void testServerUpFirstClientLater() throws Exception {
PORT1 = initServerCache(server1);
@@ -443,6 +458,7 @@ public class DataSerializerPropogationDUnitTest extends DistributedTestCase {
});
}
+ @Test
public void testDataSerializersWith2ClientsN2Servers() throws Exception {
PORT1 = initServerCache(server1);
PORT2 = initServerCache(server2);
@@ -468,6 +484,7 @@ public class DataSerializerPropogationDUnitTest extends DistributedTestCase {
}
// this test is for bug 44112
+ @Test
public void testLocalOnlyDS() throws Exception {
PORT1 = initServerCache(server1);
PORT2 = initServerCache(server2);
@@ -493,6 +510,7 @@ public class DataSerializerPropogationDUnitTest extends DistributedTestCase {
client2.invoke(() -> DataSerializerPropogationDUnitTest.verifyDataSerializers( new Integer(0) ));
}
+ @Test
public void testDataSerializersWithServerKill() throws Exception {
PORT1 = initServerCache(server1);
PORT2 = initServerCache(server2);
@@ -538,6 +556,7 @@ public class DataSerializerPropogationDUnitTest extends DistributedTestCase {
expectedEx.remove();
}
+ @Test
public void testDataSerializers() throws Exception {
PORT1 = initServerCache(server1);
PORT2 = initServerCache(server2);
@@ -564,6 +583,7 @@ public class DataSerializerPropogationDUnitTest extends DistributedTestCase {
client2.invoke(() -> DataSerializerPropogationDUnitTest.verifyDataSerializers( new Integer(2) ));
}
+ @Test
public void testDataSerializersWithServerKillAndReInvoked() throws Exception {
PORT1 = initServerCache(server1);
PORT2 = initServerCache(server2);
@@ -620,6 +640,7 @@ public class DataSerializerPropogationDUnitTest extends DistributedTestCase {
expectedEx.remove();
}
+ @Test
public void testDataSerializerCount() throws Exception {
PORT1 = initServerCache(server1);
PORT2 = initServerCache(server2);
@@ -652,6 +673,7 @@ public class DataSerializerPropogationDUnitTest extends DistributedTestCase {
* servers
*
*/
+ @Test
public void testDataSerializersEventIdVerificationClientsAndServers()
throws Exception {
PORT1 = initServerCache(server1, 1);
@@ -677,6 +699,7 @@ public class DataSerializerPropogationDUnitTest extends DistributedTestCase {
}
+ @Test
public void testLazyLoadingOfDataSerializersWith2ClientsN2Servers() throws Exception {
PORT1 = initServerCache(server1);
PORT2 = initServerCache(server2);
@@ -792,7 +815,7 @@ public class DataSerializerPropogationDUnitTest extends DistributedTestCase {
*/
public static Integer createServerCacheTwo(Integer maxThreads)
throws Exception {
- new DataSerializerPropogationDUnitTest("temp")
+ new DataSerializerPropogationDUnitTest()
.createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
@@ -818,7 +841,7 @@ public class DataSerializerPropogationDUnitTest extends DistributedTestCase {
*/
public static Integer createServerCacheOne(Integer maxThreads)
throws Exception {
- new DataSerializerPropogationDUnitTest("temp").createCache(new Properties());
+ new DataSerializerPropogationDUnitTest().createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setMirrorType(MirrorType.KEYS_VALUES);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java
index 592b179..99f4a80 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java
@@ -16,7 +16,27 @@
*/
package com.gemstone.gemfire.internal.cache.tier.sockets;
-import com.gemstone.gemfire.cache.*;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheException;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.CacheWriterException;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.Operation;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.Scope;
import com.gemstone.gemfire.cache.client.Pool;
import com.gemstone.gemfire.cache.client.PoolManager;
import com.gemstone.gemfire.cache.client.internal.Connection;
@@ -29,42 +49,36 @@ import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.internal.AvailablePort;
import com.gemstone.gemfire.internal.cache.EventID;
import com.gemstone.gemfire.internal.cache.EventIDHolder;
-import com.gemstone.gemfire.test.dunit.*;
+import com.gemstone.gemfire.test.dunit.Assert;
+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.VM;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.FlakyTest;
-import org.junit.experimental.categories.Category;
-import util.TestException;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.LOCATORS;
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT;
/**
* Tests propagation of destroy entry operation across the vms
*/
-public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
+@Category(DistributedTest.class)
+public class DestroyEntryPropagationDUnitTest extends JUnit4DistributedTestCase {
- VM vm0 = null;
+ private static final String REGION_NAME = DestroyEntryPropagationDUnitTest.class.getSimpleName() + "_region";
+ private static final String WAIT_PROPERTY = DestroyEntryPropagationDUnitTest.class.getSimpleName() + ".maxWaitTime";
+ private static final int WAIT_DEFAULT = 120000;
- VM vm1 = null;
+ private static Cache cache;
- VM vm2 = null;
-
- VM vm3 = null;
+ private VM vm0;
+ private VM vm1;
+ private VM vm2;
+ private VM vm3;
private int PORT1 ;
private int PORT2;
- protected static Cache cache = null;
-
- private static final String REGION_NAME = "DestroyEntryPropagationDUnitTest_region";
-
- /** constructor */
- public DestroyEntryPropagationDUnitTest(String name) {
- super(name);
- }
@Override
public final void postSetUp() throws Exception {
@@ -90,8 +104,22 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
vm3.invoke(() -> DestroyEntryPropagationDUnitTest.createClientCache( NetworkUtils.getServerHostName(host), new Integer(PORT1),new Integer(PORT2)));
}
- private void createCache(Properties props) throws Exception
- {
+ @Override
+ public final void preTearDown() throws Exception {
+ //close client
+ vm2.invoke(() -> DestroyEntryPropagationDUnitTest.closeCache());
+ vm3.invoke(() -> DestroyEntryPropagationDUnitTest.closeCache());
+ //close server
+ vm0.invoke(() -> DestroyEntryPropagationDUnitTest.closeCache());
+ vm1.invoke(() -> DestroyEntryPropagationDUnitTest.closeCache());
+ }
+
+ @Override
+ public final void postTearDown() throws Exception {
+ cache = null;
+ }
+
+ private void createCache(Properties props) throws Exception {
DistributedSystem ds = getSystem(props);
cache = CacheFactory.create(ds);
assertNotNull(cache);
@@ -99,10 +127,9 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
/**
* This tests whether the destroy are propagted or not according to interest registration.
- *
*/
- public void testDestroyPropagation()
- {
+ @Test
+ public void testDestroyPropagation() {
//First create entries on both servers via the two clients
vm2.invoke(() -> DestroyEntryPropagationDUnitTest.createEntriesK1andK2());
vm3.invoke(() -> DestroyEntryPropagationDUnitTest.createEntriesK1andK2());
@@ -122,16 +149,14 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
vm2.invoke(() -> DestroyEntryPropagationDUnitTest.verifyEntriesAreDestroyed());
// verify only key-1 is destroyed
vm3.invoke(() -> DestroyEntryPropagationDUnitTest.verifyOnlyRegisteredEntriesAreDestroyed());
-
}
/**
* This tests whether the destroy happened directly on server are propagted or
* not.
- *
*/
- public void testDestroyOnServerPropagation()
- {
+ @Test
+ public void testDestroyOnServerPropagation() {
//First create entries on both servers via the two client
vm2.invoke(() -> DestroyEntryPropagationDUnitTest.createEntriesK1andK2());
vm3.invoke(() -> DestroyEntryPropagationDUnitTest.createEntriesK1andK2());
@@ -149,19 +174,14 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
vm2.invoke(() -> DestroyEntryPropagationDUnitTest.verifyOnlyRegisteredEntriesAreDestroyed());
// verify destroy entry only for registered keys in client 2
vm3.invoke(() -> DestroyEntryPropagationDUnitTest.verifyOnlyRegisteredEntriesAreDestroyed());
-
}
- static private final String WAIT_PROPERTY =
- "DestroyEntryPropagationDUnitTest.maxWaitTime";
- static private final int WAIT_DEFAULT = 120000;
-
/**
* This tests whether the destroy are received by the sender or not if there
* are situation of Interest List fail over
- *
*/
@Category(FlakyTest.class) // GEODE-897: random port, time sensitive, waitForCriterion, 2 minute timeouts, eats exception (1 fixed)
+ @Test
public void testVerifyDestroyNotReceivedBySender() {
final int maxWaitTime = Integer.getInteger(WAIT_PROPERTY, WAIT_DEFAULT).intValue();
//First create entries on both servers via the two client
@@ -234,11 +254,9 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
vm1.invoke(() -> DestroyEntryPropagationDUnitTest.verifyEntriesAreDestroyed());
vm2.invoke(() -> DestroyEntryPropagationDUnitTest.verifyNoDestroyEntryInSender());
-
}
- public void acquireConnectionsAndDestroyEntriesK1andK2()
- {
+ private void acquireConnectionsAndDestroyEntriesK1andK2() {
try {
Region r1 = cache.getRegion(Region.SEPARATOR+REGION_NAME);
assertNotNull(r1);
@@ -260,12 +278,11 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
srp.destroyOnForTestsOnly(conn1, "key2", null, Operation.DESTROY, new EventIDHolder(new EventID(new byte[] {1},100000,2)), null);
}
catch (Exception ex) {
- throw new TestException("Failed while setting acquireConnectionsAndDestroyEntry ", ex);
+ throw new AssertionError("Failed while setting acquireConnectionsAndDestroyEntry ", ex);
}
}
- public static void killServer(Integer port)
- {
+ private static void killServer(Integer port) {
try {
Iterator iter = cache.getCacheServers().iterator();
LogWriterUtils.getLogWriter().fine ("Asif: servers running = "+cache.getCacheServers().size());
@@ -282,8 +299,7 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
}
}
- public static void startServer(Integer port)
- {
+ private static void startServer(Integer port) {
try {
CacheServer server1 = cache.addCacheServer();
server1.setPort(port.intValue());
@@ -297,10 +313,8 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
/**
* Creates entries on the server
- *
*/
- public static void createEntriesK1andK2()
- {
+ private static void createEntriesK1andK2() {
try {
Region r1 = cache.getRegion(Region.SEPARATOR+REGION_NAME);
assertNotNull(r1);
@@ -320,10 +334,8 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
/**
* destroy entry
- *
*/
- public static void destroyEntriesK1andK2()
- {
+ private static void destroyEntriesK1andK2() {
try {
Region r = cache.getRegion(Region.SEPARATOR+ REGION_NAME);
assertNotNull(r);
@@ -335,8 +347,7 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
}
}
- public static void verifyNoDestroyEntryInSender()
- {
+ private static void verifyNoDestroyEntryInSender() {
try {
Region r = cache.getRegion(Region.SEPARATOR+ REGION_NAME);
assertNotNull(r);
@@ -348,8 +359,7 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
}
}
- public static void verifyEntriesAreDestroyed()
- {
+ private static void verifyEntriesAreDestroyed() {
try {
Region r = cache.getRegion(Region.SEPARATOR+ REGION_NAME);
assertNotNull(r);
@@ -362,8 +372,7 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
}
}
- public static void verifyOnlyRegisteredEntriesAreDestroyed()
- {
+ private static void verifyOnlyRegisteredEntriesAreDestroyed() {
try {
Region r = cache.getRegion(Region.SEPARATOR+ REGION_NAME);
assertNotNull(r);
@@ -376,7 +385,7 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
}
}
- public static void waitForDestroyEvent(Region r, final Object key) {
+ private static void waitForDestroyEvent(Region r, final Object key) {
final CertifiableTestCacheListener ccl = (CertifiableTestCacheListener) r.getAttributes().getCacheListener();
WaitCriterion ev = new WaitCriterion() {
public boolean done() {
@@ -390,14 +399,13 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
ccl.destroys.remove(key);
}
- public static void createClientCache(String host, Integer port1, Integer port2) throws Exception
- {
+ private static void createClientCache(String host, Integer port1, Integer port2) throws Exception {
int PORT1 = port1.intValue();
int PORT2 = port2.intValue();
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
- new DestroyEntryPropagationDUnitTest("temp").createCache(props);
+ new DestroyEntryPropagationDUnitTest().createCache(props);
CacheServerTestUtil.disableShufflingOfEndpoints();
Pool p;
try {
@@ -425,9 +433,8 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
}
- public static Integer createServerCache() throws Exception
- {
- new DestroyEntryPropagationDUnitTest("temp").createCache(new Properties());
+ private static Integer createServerCache() throws Exception {
+ new DestroyEntryPropagationDUnitTest().createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
@@ -443,8 +450,7 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
return new Integer(server.getPort());
}
- public static void registerKey1()
- {
+ private static void registerKey1() {
try {
Region r = cache.getRegion(Region.SEPARATOR+REGION_NAME);
assertNotNull(r);
@@ -458,21 +464,10 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
}
}
- public static void closeCache()
- {
+ private static void closeCache() {
if (cache != null && !cache.isClosed()) {
cache.close();
cache.getDistributedSystem().disconnect();
}
}
-
- @Override
- public final void preTearDown() throws Exception {
- //close client
- vm2.invoke(() -> DestroyEntryPropagationDUnitTest.closeCache());
- vm3.invoke(() -> DestroyEntryPropagationDUnitTest.closeCache());
- //close server
- vm0.invoke(() -> DestroyEntryPropagationDUnitTest.closeCache());
- vm1.invoke(() -> DestroyEntryPropagationDUnitTest.closeCache());
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientBug39997DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientBug39997DUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientBug39997DUnitTest.java
index fb5a60d..0821592 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientBug39997DUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientBug39997DUnitTest.java
@@ -16,31 +16,42 @@
*/
package com.gemstone.gemfire.internal.cache.tier.sockets;
-import com.gemstone.gemfire.cache.*;
-import com.gemstone.gemfire.cache.client.PoolManager;
-import com.gemstone.gemfire.cache.client.internal.PoolImpl;
-import com.gemstone.gemfire.cache.server.CacheServer;
-import com.gemstone.gemfire.cache30.CacheTestCase;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.test.dunit.*;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static org.junit.Assert.*;
import java.io.IOException;
import java.util.Properties;
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
-
-public class DurableClientBug39997DUnitTest extends CacheTestCase {
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
- private static final long serialVersionUID = -2712855295338732543L;
-
- public DurableClientBug39997DUnitTest(String name) {
- super(name);
- }
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.NoSubscriptionServersAvailableException;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.Scope;
+import com.gemstone.gemfire.cache.client.PoolManager;
+import com.gemstone.gemfire.cache.client.internal.PoolImpl;
+import com.gemstone.gemfire.cache.server.CacheServer;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
+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;
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+
+@Category(DistributedTest.class)
+public class DurableClientBug39997DUnitTest extends JUnit4CacheTestCase {
public final void postTearDownCacheTestCase() {
Host.getHost(0) .getVM(0).invoke(() -> disconnectFromDS());
}
+ @Test
public void testNoServerAvailableOnStartup() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientQueueSizeDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientQueueSizeDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientQueueSizeDUnitTest.java
index 11a3e45..9ccc3c9 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientQueueSizeDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientQueueSizeDUnitTest.java
@@ -16,29 +16,41 @@
*/
package com.gemstone.gemfire.internal.cache.tier.sockets;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static org.junit.Assert.*;
+
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionFactory;
import com.gemstone.gemfire.cache.RegionShortcut;
-import com.gemstone.gemfire.cache.client.*;
+import com.gemstone.gemfire.cache.client.ClientCacheFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
+import com.gemstone.gemfire.cache.client.PoolFactory;
+import com.gemstone.gemfire.cache.client.PoolManager;
import com.gemstone.gemfire.cache.client.internal.PoolImpl;
import com.gemstone.gemfire.cache.server.CacheServer;
import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.internal.AvailablePort;
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-import com.gemstone.gemfire.test.dunit.*;
-
-import java.util.Iterator;
-import java.util.Properties;
-
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
-
-/**
- *
- */
+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.VM;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+
+@Category(DistributedTest.class)
@SuppressWarnings("serial")
-public class DurableClientQueueSizeDUnitTest extends DistributedTestCase {
+public class DurableClientQueueSizeDUnitTest extends JUnit4DistributedTestCase {
private static VM vm0 = null;
private static VM vm1 = null;
@@ -53,21 +65,14 @@ public class DurableClientQueueSizeDUnitTest extends DistributedTestCase {
private static final int EXCEPTION = -5;
- public static final String REGION_NAME = "DurableClientQueueSizeDunitTest_region";
+ public static final String REGION_NAME = DurableClientQueueSizeDUnitTest.class.getSimpleName() + "_region";
- public static final String NEW_REGION = "DurableClientQueueSizeDunitTest_region_2";
+ public static final String NEW_REGION = DurableClientQueueSizeDUnitTest.class.getSimpleName() + "_region_2";
public static final String POOL_NAME = "my-pool";
public static final String DEFAULT_POOL_NAME = "DEFAULT";
- /**
- * @param name
- */
- public DurableClientQueueSizeDUnitTest(String name) {
- super(name);
- }
-
@Override
public final void postSetUp() throws Exception {
vm0 = Host.getHost(0).getVM(0);
@@ -92,8 +97,9 @@ public class DurableClientQueueSizeDUnitTest extends DistributedTestCase {
vm1.invoke(() -> DurableClientQueueSizeDUnitTest.closeCache());
}
+ @Test
public void testNonDurableClientFails() throws Exception {
- vm2.invoke(DurableClientQueueSizeDUnitTest.class, "createClientCache",
+ vm2.invoke(DurableClientQueueSizeDUnitTest.class, "createClientCache", // TODO: change to lambda
new Object[] { vm2.getHost(), new Integer[] { port0, port1 }, false });
vm2.invoke(() -> DurableClientQueueSizeDUnitTest.verifyQueueSize( EXCEPTION ));
@@ -102,7 +108,9 @@ public class DurableClientQueueSizeDUnitTest extends DistributedTestCase {
// this test is disabled due to a high rate of failure. It fails with
// the queue size being 11 instead of 10 in the first verifyQueueSize check.
// See internal ticket #52227.
- public void disabledtestSinglePoolClientReconnectsBeforeTimeOut() throws Exception {
+ @Ignore("TODO: test is disabled due to #52227")
+ @Test
+ public void testSinglePoolClientReconnectsBeforeTimeOut() throws Exception {
int num = 10;
vm2.invoke(DurableClientQueueSizeDUnitTest.class, "createClientCache",
new Object[] { vm2.getHost(), new Integer[] { port0, port1 }});
@@ -123,6 +131,7 @@ public class DurableClientQueueSizeDUnitTest extends DistributedTestCase {
}
+ @Test
public void testSinglePoolClientReconnectsAfterTimeOut() throws Exception {
int num = 10;
long timeoutSeconds = 10;
@@ -145,6 +154,7 @@ public class DurableClientQueueSizeDUnitTest extends DistributedTestCase {
vm2.invoke(() -> DurableClientQueueSizeDUnitTest.verifyQueueSize( PoolImpl.PRIMARY_QUEUE_TIMED_OUT ));
}
+ @Test
public void testPrimaryServerRebootReturnsCorrectResponse() throws Exception {
int num = 10;
vm2.invoke(DurableClientQueueSizeDUnitTest.class, "createClientCache",
@@ -175,7 +185,9 @@ public class DurableClientQueueSizeDUnitTest extends DistributedTestCase {
vm2.invoke(() -> DurableClientQueueSizeDUnitTest.verifyQueueSize( PoolImpl.PRIMARY_QUEUE_NOT_AVAILABLE ));
}
- public void bug51854_testMultiPoolClientReconnectsBeforeTimeOut() throws Exception {
+ @Ignore("TODO: test is disabled due to #51854")
+ @Test
+ public void testMultiPoolClientReconnectsBeforeTimeOut() throws Exception {
int num = 10;
vm2.invoke(DurableClientQueueSizeDUnitTest.class, "createClientCache",
new Object[] { vm2.getHost(), new Integer[] { port0, port1 }, "300",
@@ -197,7 +209,9 @@ public class DurableClientQueueSizeDUnitTest extends DistributedTestCase {
vm2.invoke(() -> DurableClientQueueSizeDUnitTest.verifyQueueSize( EXCEPTION, EXCEPTION ));
}
- public void bug51854_testMultiPoolClientReconnectsAfterTimeOut() throws Exception {
+ @Ignore("TODO: test is disabled due to #51854")
+ @Test
+ public void testMultiPoolClientReconnectsAfterTimeOut() throws Exception {
int num = 10;
long timeout = 10;
vm2.invoke(
@@ -225,7 +239,9 @@ public class DurableClientQueueSizeDUnitTest extends DistributedTestCase {
vm2.invoke(() -> DurableClientQueueSizeDUnitTest.verifyQueueSize( PoolImpl.PRIMARY_QUEUE_TIMED_OUT, PoolImpl.PRIMARY_QUEUE_TIMED_OUT));
}
- public void _testMultiPoolClientFailsOver() throws Exception {
+ @Ignore("TODO: test is not implemented")
+ @Test
+ public void testMultiPoolClientFailsOver() throws Exception {
}
public static void closeCache() throws Exception {
@@ -253,12 +269,10 @@ public class DurableClientQueueSizeDUnitTest extends DistributedTestCase {
throws Exception {
Properties props = new Properties();
props.setProperty(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
- DurableClientQueueSizeDUnitTest test = new DurableClientQueueSizeDUnitTest(
- "DurableClientQueueSizeDUnitTest");
+ DurableClientQueueSizeDUnitTest test = new DurableClientQueueSizeDUnitTest();
DistributedSystem ds = test.getSystem(props);
ds.disconnect();
cache = (GemFireCacheImpl)CacheFactory.create(test.getSystem());
-// cache = (GemFireCacheImpl) new CacheFactory(props).create();
RegionFactory<String, String> rf = cache
.createRegionFactory(RegionShortcut.REPLICATE);
@@ -305,8 +319,7 @@ public class DurableClientQueueSizeDUnitTest extends DistributedTestCase {
timeoutSeconds);
}
- DistributedSystem ds = new DurableClientQueueSizeDUnitTest(
- "DurableClientQueueSizeDUnitTest").getSystem(props);
+ DistributedSystem ds = new DurableClientQueueSizeDUnitTest().getSystem(props);
ds.disconnect();
ClientCacheFactory ccf = new ClientCacheFactory(props);
ccf.setPoolSubscriptionEnabled(true);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientReconnectAutoDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientReconnectAutoDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientReconnectAutoDUnitTest.java
index 4936053..e706290 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientReconnectAutoDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientReconnectAutoDUnitTest.java
@@ -16,34 +16,42 @@
*/
package com.gemstone.gemfire.internal.cache.tier.sockets;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.cache.client.PoolFactory;
import com.gemstone.gemfire.cache.client.PoolManager;
-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.NetworkUtils;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
/**
- * @since GemFire 5.7
- *
* Test reconnecting a durable client that is using
* the locator to discover its servers
+ *
+ * @since GemFire 5.7
*/
-public class DurableClientReconnectAutoDUnitTest extends
- DurableClientReconnectDUnitTest {
+@Category(DistributedTest.class)
+public class DurableClientReconnectAutoDUnitTest extends DurableClientReconnectDUnitTest {
+ @BeforeClass
public static void caseSetUp() throws Exception {
- DistributedTestCase.disconnectAllFromDS();
+ disconnectAllFromDS();
}
- public DurableClientReconnectAutoDUnitTest(String name) {
- super(name);
- }
-
+ @Ignore("do nothing, this test doesn't make sense with the locator")
+ @Override
+ @Test
public void testDurableReconnectSingleServerWithZeroConnPerServer() {
//do nothing, this test doesn't make sense with the locator
}
+ @Ignore("do nothing, this test doesn't make sense with the locator")
+ @Override
+ @Test
public void testDurableReconnectSingleServer() throws Exception {
//do nothing, this test doesn't make sense with the locator
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientReconnectDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientReconnectDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientReconnectDUnitTest.java
index e8b24cf..b2b1b5c 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientReconnectDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientReconnectDUnitTest.java
@@ -16,7 +16,30 @@
*/
package com.gemstone.gemfire.internal.cache.tier.sockets;
-import com.gemstone.gemfire.cache.*;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static org.junit.Assert.*;
+
+import java.net.SocketException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.Scope;
import com.gemstone.gemfire.cache.client.PoolFactory;
import com.gemstone.gemfire.cache.client.PoolManager;
import com.gemstone.gemfire.cache.client.internal.Connection;
@@ -27,22 +50,25 @@ import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.distributed.internal.ServerLocation;
import com.gemstone.gemfire.internal.AvailablePort;
import com.gemstone.gemfire.internal.cache.CacheServerImpl;
-import com.gemstone.gemfire.test.dunit.*;
-
-import java.net.SocketException;
-import java.util.*;
-
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
-
-
-/**
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.IgnoredException;
+import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
+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 com.gemstone.gemfire.test.junit.categories.DistributedTest;
+
+/**
* Tests for durable reconnect issue
*
* @since GemFire 5.2
*/
+@Category(DistributedTest.class)
+public class DurableClientReconnectDUnitTest extends JUnit4DistributedTestCase {
-public class DurableClientReconnectDUnitTest extends DistributedTestCase
-{
private static Cache cache = null;
private static VM server1 = null;
@@ -62,17 +88,13 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
private static String SERVER3;
private static String SERVER4;
- private static final String REGION_NAME = "DurableClientReconnectDUnitTest_region";
+ private static final String REGION_NAME = DurableClientReconnectDUnitTest.class.getSimpleName() + "_region";
private DurableClientReconnectDUnitTest instance = null ;
- /** constructor */
- public DurableClientReconnectDUnitTest(String name) {
- super(name);
- }
-
+ @BeforeClass
public static void caseSetUp() throws Exception {
- DistributedTestCase.disconnectAllFromDS();
+ disconnectAllFromDS();
}
@Override
@@ -97,8 +119,8 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "bridge.disableShufflingOfEndpoints", "false");
}
- public void testDurableReconnectSingleServer() throws Exception
- {
+ @Test
+ public void testDurableReconnectSingleServer() throws Exception {
createCacheClientAndConnectToSingleServer(NetworkUtils.getServerHostName(Host.getHost(0)), 0);
List redundantServers = pool.getRedundantNames();
String primaryName = pool.getPrimaryName();
@@ -115,8 +137,9 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
assertTrue(redundantServers2.isEmpty());
assertTrue(primaryName2.equals(primaryName));
}
- public void testDurableReconnectSingleServerWithZeroConnPerServer() throws Exception
- {
+
+ @Test
+ public void testDurableReconnectSingleServerWithZeroConnPerServer() throws Exception {
createCacheClientAndConnectToSingleServerWithZeroConnPerServer(NetworkUtils.getServerHostName(Host.getHost(0)), 0);
List redundantServers = pool.getRedundantNames();
String primaryName = pool.getPrimaryName();
@@ -129,8 +152,9 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
assertTrue(redundantServers2.isEmpty());
assertTrue(primaryName2.equals(primaryName));
}
- public void testDurableReconnectNonHA() throws Exception
- {
+
+ @Test
+ public void testDurableReconnectNonHA() throws Exception {
createCacheClient(0);
List redundantServers = pool.getRedundantNames();
String primaryName = pool.getPrimaryName();
@@ -147,12 +171,12 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
assertTrue(redundantServers2.isEmpty());
assertTrue(primaryName2.equals(primaryName));
}
+
/**
* (R = 1 ) , four servers , all Servers are up, Check client reconnect to either of server having queue.
- * @throws Exception
- */
- public void testDurableReconnect() throws Exception
- {
+ */
+ @Test
+ public void testDurableReconnect() throws Exception {
//create client cache and Send clientReady message
createCacheClient();
HashSet redundantServers = new HashSet(pool.getRedundantNames());
@@ -178,10 +202,9 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
assertTrue(redundantServers.equals(redundantServersAfterReconnect));
}
-
-
- public void testDurableReconnect_DifferentPrimary() throws Exception
- {
+
+ @Test
+ public void testDurableReconnect_DifferentPrimary() throws Exception {
//create client cache and Send clientReady message
createCacheClient();
HashSet redundantServers = new HashSet(pool.getRedundantNames());
@@ -207,10 +230,10 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
assertTrue(redundantServers.equals(redundantServersAfterReconnect));
assertFalse(primaryBefore.equals(primaryAfter));
-
}
- public void testDurableReconnectWithOneRedundantServerDown() throws Exception
- {
+
+ @Test
+ public void testDurableReconnectWithOneRedundantServerDown() throws Exception {
//create client cache and Send clientReady message
createCacheClient();
List redundantServers = pool.getRedundantNames();
@@ -247,8 +270,8 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
assertTrue(redundantServersAfterReconnect.contains(rServer2));
}
- public void testDurableReconnectWithBothRedundantServersDown() throws Exception
- {
+ @Test
+ public void testDurableReconnectWithBothRedundantServersDown() throws Exception {
//create client cache and Send clientReady message
createCacheClient();
List redundantServers = pool.getRedundantNames();
@@ -290,9 +313,8 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
assertFalse(redundantServersAfterReconnect.contains(rServer2));
}
-
- public void testDurableReconnectWithBothNonRedundantServersDown() throws Exception
- {
+ @Test
+ public void testDurableReconnectWithBothNonRedundantServersDown() throws Exception {
//create client cache and Send clientReady message
createCacheClient();
HashSet redundantServers = new HashSet(pool.getRedundantNames());
@@ -343,7 +365,8 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
assertFalse("redundantServersAfterReconnect contains " + rServer2, redundantServersAfterReconnect.contains(rServer2));
}
- /** This test checks a problem found in bug 39332
+ /**
+ * This test checks a problem found in bug 39332
* 1. Durable client disconnects
* 2. Durable client comes back, creates a create to server connection but not a queue connection
* 3. Durable client disconnects again
@@ -351,6 +374,7 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
* 5. Eventually, all of the durable clients connections are closed because the durable expiration timer task created
* in step 1 is never cancelled.
*/
+ @Test
public void testBug39332() {
//create client cache and Send clientReady message
createCacheClient(2, 20);
@@ -424,8 +448,7 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
assertEquals(redundantServers, redundantServersAfterReconnect);
}
-
-
+
private static void verifyRedundantServers(Set redundantServers , Set redundantServersAfterReconnect) {
try{
Iterator iter = redundantServers.iterator();
@@ -445,11 +468,10 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
Assert.fail("test failed due to" , e);
}
}
-
- public static Integer createServerCache() throws Exception
- {
+
+ private static Integer createServerCache() throws Exception {
Properties props = new Properties();
- new DurableClientReconnectDUnitTest("temp").createCache(props);
+ new DurableClientReconnectDUnitTest().createCache(props);
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
@@ -509,16 +531,15 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
}
}
-
private static void verifyDurableClientOnServer() {
- try{
- checkNumberOfClientProxies(1);
- CacheClientProxy proxy = getClientProxy();
- assertNotNull(proxy);
- // Verify that it is durable and its properties are correct
- assertTrue(proxy.isDurable());
- assertEquals("DurableClientReconnectDUnitTest_client", proxy.getDurableId());
-// assertIndexDetailsEquals(60, proxy.getDurableTimeout());
+ try {
+ checkNumberOfClientProxies(1);
+ CacheClientProxy proxy = getClientProxy();
+ assertNotNull(proxy);
+ // Verify that it is durable and its properties are correct
+ assertTrue(proxy.isDurable());
+ assertEquals("DurableClientReconnectDUnitTest_client", proxy.getDurableId());
+ // assertIndexDetailsEquals(60, proxy.getDurableTimeout());
}catch (Exception e){
Assert.fail("test failed due to" , e);
}
@@ -540,17 +561,19 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
private static void checkNumberOfClientProxies(final int expected) {
WaitCriterion ev = new WaitCriterion() {
+ @Override
public boolean done() {
return expected == getNumberOfClientProxies();
}
+ @Override
public String description() {
return null;
}
};
Wait.waitForCriterion(ev, 15 * 1000, 200, true);
}
-
- protected static int getNumberOfClientProxies() {
+
+ private static int getNumberOfClientProxies() {
return getBridgeServer().getAcceptor().getCacheClientNotifier()
.getClientProxies().size();
}
@@ -560,25 +583,25 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
assertNotNull(bridgeServer);
return bridgeServer;
}
- private void createCache(Properties props)
- {try{
- DistributedSystem ds = getSystem(props);
- assertNotNull(ds);
- ds.disconnect();
- ds = getSystem(props);
- cache = CacheFactory.create(ds);
- assertNotNull(cache);
- } catch(Exception e){
- Assert.fail("test failed due to " , e );
- }
+
+ private void createCache(Properties props) {
+ try{
+ DistributedSystem ds = getSystem(props);
+ assertNotNull(ds);
+ ds.disconnect();
+ ds = getSystem(props);
+ cache = CacheFactory.create(ds);
+ assertNotNull(cache);
+ } catch(Exception e){
+ Assert.fail("test failed due to ", e);
+ }
}
- private void createCacheClient()
- {
+ private void createCacheClient() {
createCacheClient(1);
}
-
- protected PoolFactory getPoolFactory() {
+
+ private PoolFactory getPoolFactory() {
Host host = Host.getHost(0);
PoolFactory factory = PoolManager.createFactory()
.addServer(NetworkUtils.getServerHostName(host), PORT1.intValue())
@@ -592,84 +615,83 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
createCacheClient(redundancyLevel, 60);
}
- private void createCacheClient(int redundancyLevel, final int durableClientTimeout){
+ private void createCacheClient(int redundancyLevel, final int durableClientTimeout) {
createCacheClient(redundancyLevel, durableClientTimeout, true);
}
- private void createCacheClient(int redundancyLevel, final int durableClientTimeout, boolean queueEnabled){
- try{
- final String durableClientId = "DurableClientReconnectDUnitTest_client";
- Properties props = getClientDistributedSystemProperties(durableClientId,durableClientTimeout );
- instance = new DurableClientReconnectDUnitTest("temp");
- instance.createCache(props);
-// Host host = Host.getHost(0);
- PoolImpl p = (PoolImpl) getPoolFactory()
- .setSubscriptionEnabled(queueEnabled)
- .setReadTimeout(10000)
- // .setRetryInterval(2000)
- .setSubscriptionRedundancy(redundancyLevel)
- .create("DurableClientReconnectDUnitTestPool");
+ private void createCacheClient(int redundancyLevel, final int durableClientTimeout, boolean queueEnabled) {
+ try {
+ final String durableClientId = "DurableClientReconnectDUnitTest_client";
+ Properties props = getClientDistributedSystemProperties(durableClientId,durableClientTimeout );
+ instance = new DurableClientReconnectDUnitTest();
+ instance.createCache(props);
+ // Host host = Host.getHost(0);
+ PoolImpl p = (PoolImpl) getPoolFactory()
+ .setSubscriptionEnabled(queueEnabled)
+ .setReadTimeout(10000)
+ // .setRetryInterval(2000)
+ .setSubscriptionRedundancy(redundancyLevel)
+ .create("DurableClientReconnectDUnitTestPool");
- AttributesFactory factory = new AttributesFactory();
- factory.setScope(Scope.LOCAL);
- factory.setPoolName(p.getName());
+ AttributesFactory factory = new AttributesFactory();
+ factory.setScope(Scope.LOCAL);
+ factory.setPoolName(p.getName());
- RegionAttributes attrs = factory.create();
- Region r = cache.createRegion(REGION_NAME, attrs);
- assertNotNull(r);
+ RegionAttributes attrs = factory.create();
+ Region r = cache.createRegion(REGION_NAME, attrs);
+ assertNotNull(r);
- pool = p;
- conn = pool.acquireConnection();
- assertNotNull(conn);
-
- cache.readyForEvents();
+ pool = p;
+ conn = pool.acquireConnection();
+ assertNotNull(conn);
+
+ cache.readyForEvents();
}catch(Exception e){
Assert.fail("test failed due to " , e );
}
-
}
- private void createCacheClientAndConnectToSingleServer(String host, int redundancyLevel){
- try{
- final String durableClientId = "DurableClientReconnectDUnitTest_client";
- final int durableClientTimeout = 60; // keep the client alive for 60 seconds
- Properties props = getClientDistributedSystemProperties(durableClientId,durableClientTimeout );
- instance = new DurableClientReconnectDUnitTest("temp");
- instance.createCache(props);
- PoolImpl p = (PoolImpl)PoolManager.createFactory()
- .addServer(host, PORT1.intValue())
- .setSubscriptionEnabled(true)
- .setReadTimeout(10000)
- // .setRetryInterval(2000)
- .setSubscriptionRedundancy(redundancyLevel)
- .create("DurableClientReconnectDUnitTestPool");
-
- AttributesFactory factory = new AttributesFactory();
- factory.setScope(Scope.LOCAL);
- factory.setPoolName(p.getName());
+ private void createCacheClientAndConnectToSingleServer(String host, int redundancyLevel) {
+ try {
+ final String durableClientId = "DurableClientReconnectDUnitTest_client";
+ final int durableClientTimeout = 60; // keep the client alive for 60 seconds
+ Properties props = getClientDistributedSystemProperties(durableClientId,durableClientTimeout );
+ instance = new DurableClientReconnectDUnitTest();
+ instance.createCache(props);
+ PoolImpl p = (PoolImpl)PoolManager.createFactory()
+ .addServer(host, PORT1.intValue())
+ .setSubscriptionEnabled(true)
+ .setReadTimeout(10000)
+ // .setRetryInterval(2000)
+ .setSubscriptionRedundancy(redundancyLevel)
+ .create("DurableClientReconnectDUnitTestPool");
- RegionAttributes attrs = factory.create();
- Region r = cache.createRegion(REGION_NAME, attrs);
- assertNotNull(r);
+ AttributesFactory factory = new AttributesFactory();
+ factory.setScope(Scope.LOCAL);
+ factory.setPoolName(p.getName());
- pool = p;
- conn = pool.acquireConnection();
- assertNotNull(conn);
-
- cache.readyForEvents();
+ RegionAttributes attrs = factory.create();
+ Region r = cache.createRegion(REGION_NAME, attrs);
+ assertNotNull(r);
+
+ pool = p;
+ conn = pool.acquireConnection();
+ assertNotNull(conn);
+
+ cache.readyForEvents();
}catch(Exception e){
Assert.fail("test failed due to " , e );
}
}
- private void createCacheClientAndConnectToSingleServerWithZeroConnPerServer(String host, int redundancyLevel){
- try{
+ private void createCacheClientAndConnectToSingleServerWithZeroConnPerServer(String host, int redundancyLevel) {
+ try {
final String durableClientId = "DurableClientReconnectDUnitTest_client";
final int durableClientTimeout = 60; // keep the client alive for 60 seconds
Properties props = getClientDistributedSystemProperties(durableClientId,durableClientTimeout );
- instance = new DurableClientReconnectDUnitTest("temp");
+ instance = new DurableClientReconnectDUnitTest();
instance.createCache(props);
PoolImpl p = (PoolImpl)PoolManager.createFactory()
.addServer(host, PORT1.intValue())
@@ -694,13 +716,12 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
cache.readyForEvents();
- }catch(Exception e){
- Assert.fail("test failed due to " , e );
- }
+ }catch(Exception e){
+ Assert.fail("test failed due to " , e );
+ }
}
- private Properties getClientDistributedSystemProperties(
- String durableClientId, int durableClientTimeout) {
+ private Properties getClientDistributedSystemProperties( String durableClientId, int durableClientTimeout) {
Properties properties = new Properties();
properties.setProperty(MCAST_PORT, "0");
properties.setProperty(LOCATORS, "");
@@ -721,17 +742,14 @@ public class DurableClientReconnectDUnitTest extends DistributedTestCase
server4.invoke(() -> DurableClientReconnectDUnitTest.closeCache());
}
- public void closeCache(boolean keepAlive)
- {
- if (cache != null && !cache.isClosed()) {
- cache.close(keepAlive);
- cache.getDistributedSystem().disconnect();
- }
- }
-
+ private void closeCache(boolean keepAlive) {
+ if (cache != null && !cache.isClosed()) {
+ cache.close(keepAlive);
+ cache.getDistributedSystem().disconnect();
+ }
+ }
- public static void closeCache()
- {
+ private static void closeCache() {
if (cache != null && !cache.isClosed()) {
cache.close();
cache.getDistributedSystem().disconnect();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientStatsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientStatsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientStatsDUnitTest.java
index c2145b3..b1f0095 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientStatsDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableClientStatsDUnitTest.java
@@ -16,6 +16,16 @@
*/
package com.gemstone.gemfire.internal.cache.tier.sockets;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Properties;
+import java.util.concurrent.RejectedExecutionException;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheException;
import com.gemstone.gemfire.cache.InterestResultPolicy;
@@ -26,17 +36,15 @@ import com.gemstone.gemfire.cache.client.PoolManager;
import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
import com.gemstone.gemfire.internal.cache.CacheServerImpl;
import com.gemstone.gemfire.internal.cache.PoolFactoryImpl;
-import com.gemstone.gemfire.test.dunit.*;
-
-import java.util.ArrayList;
-import java.util.Properties;
-import java.util.concurrent.RejectedExecutionException;
-
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
/**
- *
- *
* The DUnitTest checks whether the following Three counts are incremented
* correctly or not:
* 1) DurableReconnectionCount -> Incremented Each time
@@ -49,7 +57,8 @@ import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties
* In the given test DurableClient comes up and goes down discreetly with
* different DurableClientTimeouts so as to increment the counts
*/
-public class DurableClientStatsDUnitTest extends DistributedTestCase {
+@Category(DistributedTest.class)
+public class DurableClientStatsDUnitTest extends JUnit4DistributedTestCase {
private VM server1VM;
@@ -61,10 +70,6 @@ public class DurableClientStatsDUnitTest extends DistributedTestCase {
private final String K1 = "Key1";
- public DurableClientStatsDUnitTest(String name) {
- super(name);
- }
-
@Override
public final void postSetUp() throws Exception {
Host host = Host.getHost(0);
@@ -81,9 +86,8 @@ public class DurableClientStatsDUnitTest extends DistributedTestCase {
CacheServerTestUtil.resetDisableShufflingOfEndpointsFlag();
}
+ @Test
public void testNonDurableClientStatistics() {
-
-
// Step 1: Starting the servers
PORT1 = ((Integer)this.server1VM.invoke(() -> CacheServerTestUtil.createCacheServer( regionName, new Boolean(true)
))).intValue();
@@ -119,9 +123,9 @@ public class DurableClientStatsDUnitTest extends DistributedTestCase {
this.server1VM.invoke(() -> DurableClientStatsDUnitTest.checkStatisticsWithExpectedValues( new Integer(0),
new Integer(0), new Integer(0) ));
-
-
}
+
+ @Test
public void testDurableClientStatistics() {
// Step 1: Starting the servers
@@ -160,9 +164,7 @@ public class DurableClientStatsDUnitTest extends DistributedTestCase {
this.server1VM.invoke(() -> DurableClientStatsDUnitTest.checkStatisticsWithExpectedValues( new Integer(3),
new Integer(4), new Integer(2) ));
}
-
-
-
+
public void startRegisterAndCloseDurableClientCache(int durableClientTimeout) {
final String durableClientId = getName() + "_client";
@@ -269,7 +271,7 @@ public class DurableClientStatsDUnitTest extends DistributedTestCase {
+ stats.get_eventEnqueuedWhileClientAwayCount());
}
catch (Exception e) {
- fail("Exception thrown while executing checkStatistics()");
+ fail("Exception thrown while executing checkStatistics()", e);
}
}
@@ -293,7 +295,7 @@ public class DurableClientStatsDUnitTest extends DistributedTestCase {
assertEquals(enqueueCount, stats.get_eventEnqueuedWhileClientAwayCount());
}
catch (Exception e) {
- fail("Exception thrown while executing checkStatisticsWithExpectedValues()");
+ fail("Exception thrown while executing checkStatisticsWithExpectedValues()", e);
}
}
@@ -339,9 +341,7 @@ public class DurableClientStatsDUnitTest extends DistributedTestCase {
assertEquals(value, r.getEntry(key).getValue());
}
catch (Exception e) {
-
- fail("Put in Server has some fight");
-
+ fail("Put in Server has some fight", e);
}
}