Return-Path: X-Original-To: apmail-geode-commits-archive@minotaur.apache.org Delivered-To: apmail-geode-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4EB7B1844D for ; Thu, 11 Feb 2016 00:39:04 +0000 (UTC) Received: (qmail 24095 invoked by uid 500); 11 Feb 2016 00:39:04 -0000 Delivered-To: apmail-geode-commits-archive@geode.apache.org Received: (qmail 24064 invoked by uid 500); 11 Feb 2016 00:39:04 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 24054 invoked by uid 99); 11 Feb 2016 00:39:04 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Feb 2016 00:39:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 945A0C1256 for ; Thu, 11 Feb 2016 00:39:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.462 X-Spam-Level: X-Spam-Status: No, score=-3.462 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.242] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 2VlukLdMmnPb for ; Thu, 11 Feb 2016 00:38:53 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id DBAB34415D for ; Thu, 11 Feb 2016 00:38:37 +0000 (UTC) Received: (qmail 20460 invoked by uid 99); 11 Feb 2016 00:38:36 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Feb 2016 00:38:36 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 917F4DFE2C; Thu, 11 Feb 2016 00:38:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dschneider@apache.org To: commits@geode.incubator.apache.org Date: Thu, 11 Feb 2016 00:39:09 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [35/61] [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/internal/cache/ClientServerGetAllDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerGetAllDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerGetAllDUnitTest.java index b34b115..f7f633c 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerGetAllDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerGetAllDUnitTest.java @@ -40,8 +40,12 @@ import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.internal.AvailablePort; import com.gemstone.gemfire.internal.AvailablePortHelper; import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl; +import com.gemstone.gemfire.test.dunit.Assert; import com.gemstone.gemfire.test.dunit.AsyncInvocation; +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.VM; /** @@ -57,8 +61,7 @@ import com.gemstone.gemfire.test.dunit.VM; } @Override - public void tearDown2() throws Exception { - super.tearDown2(); + protected final void postTearDownCacheTestCase() throws Exception { disconnectAllFromDS(); } @@ -69,7 +72,7 @@ import com.gemstone.gemfire.test.dunit.VM; final String regionName = getUniqueName(); final int mcastPort = 0; /* loner is ok for this test*/ //AvailablePort.getRandomAvailablePort(AvailablePort.JGROUPS); final int serverPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); - final String serverHost = getServerHostName(server.getHost()); + final String serverHost = NetworkUtils.getServerHostName(server.getHost()); createBridgeServer(server, regionName, serverPort, false, false); @@ -120,7 +123,7 @@ import com.gemstone.gemfire.test.dunit.VM; final VM client = host.getVM(1); final String regionName = getUniqueName(); final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort(); - final String serverHost = getServerHostName(server.getHost()); + final String serverHost = NetworkUtils.getServerHostName(server.getHost()); createBridgeServer(server, regionName, serverPort, false, false, true/*offheap*/); @@ -172,7 +175,7 @@ import com.gemstone.gemfire.test.dunit.VM; final VM client = host.getVM(1); final String regionName = getUniqueName(); final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort(); - final String serverHost = getServerHostName(server.getHost()); + final String serverHost = NetworkUtils.getServerHostName(server.getHost()); createBridgeServer(server, regionName, serverPort, false, false, true/*offheap*/); @@ -284,7 +287,7 @@ import com.gemstone.gemfire.test.dunit.VM; final String regionName = getUniqueName(); final int mcastPort = 0; /* loner is ok for this test*/ //AvailablePort.getRandomAvailablePort(AvailablePort.JGROUPS); final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort(); - final String serverHost = getServerHostName(server.getHost()); + final String serverHost = NetworkUtils.getServerHostName(server.getHost()); createBridgeServer(server, regionName, serverPort, false, false); @@ -395,7 +398,7 @@ import com.gemstone.gemfire.test.dunit.VM; final VM client = host.getVM(1); final String regionName = getUniqueName(); final int serverPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); - final String serverHost = getServerHostName(server.getHost()); + final String serverHost = NetworkUtils.getServerHostName(server.getHost()); createBridgeServer(server, regionName, serverPort, false, true); @@ -457,7 +460,7 @@ import com.gemstone.gemfire.test.dunit.VM; int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2); final int server1Port = ports[0]; final int server2Port = ports[1]; - final String serverHost = getServerHostName(server1.getHost()); + final String serverHost = NetworkUtils.getServerHostName(server1.getHost()); createBridgeServer(server1, regionName, server1Port, true, false); @@ -522,7 +525,7 @@ import com.gemstone.gemfire.test.dunit.VM; final VM client = host.getVM(1); final String regionName = getUniqueName(); final int serverPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); - final String serverHost = getServerHostName(server.getHost()); + final String serverHost = NetworkUtils.getServerHostName(server.getHost()); createBridgeServer(server, regionName, serverPort, false, false); @@ -575,7 +578,7 @@ import com.gemstone.gemfire.test.dunit.VM; }); // client may see "server unreachable" exceptions after this - addExpectedException("Server unreachable", client); + IgnoredException.addIgnoredException("Server unreachable", client); stopBridgeServer(server); } @@ -585,7 +588,7 @@ import com.gemstone.gemfire.test.dunit.VM; final VM client = host.getVM(1); final String regionName = getUniqueName(); final int serverPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); - final String serverHost = getServerHostName(server.getHost()); + final String serverHost = NetworkUtils.getServerHostName(server.getHost()); final int numLocalValues = 101; createBridgeServerWithoutLoader(server, regionName, serverPort, false); @@ -666,7 +669,7 @@ import com.gemstone.gemfire.test.dunit.VM; public void run2() throws CacheException { // Create DS Properties config = new Properties(); - config.setProperty("locators", "localhost["+getDUnitLocatorPort()+"]"); + config.setProperty("locators", "localhost["+DistributedTestUtils.getDUnitLocatorPort()+"]"); if (offheap) { config.setProperty(DistributionConfig.OFF_HEAP_MEMORY_SIZE_NAME, "350m"); } @@ -701,7 +704,7 @@ import com.gemstone.gemfire.test.dunit.VM; bridge.setMaxThreads(offheap ? 16 : getMaxThreads()); bridge.start(); } catch (Exception e) { - fail("While starting CacheServer", e); + Assert.fail("While starting CacheServer", e); } } }); @@ -730,7 +733,7 @@ import com.gemstone.gemfire.test.dunit.VM; public void run2() throws CacheException { // Create DS Properties config = new Properties(); - config.setProperty("locators", "localhost["+getDUnitLocatorPort()+"]"); + config.setProperty("locators", "localhost["+DistributedTestUtils.getDUnitLocatorPort()+"]"); getSystem(config); // Create Region @@ -750,7 +753,7 @@ import com.gemstone.gemfire.test.dunit.VM; startBridgeServer(serverPort); System.out.println("Started bridger server "); } catch (Exception e) { - fail("While starting CacheServer", e); + Assert.fail("While starting CacheServer", e); } } }); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerInvalidAndDestroyedEntryDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerInvalidAndDestroyedEntryDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerInvalidAndDestroyedEntryDUnitTest.java index a733753..e5ec301 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerInvalidAndDestroyedEntryDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerInvalidAndDestroyedEntryDUnitTest.java @@ -39,7 +39,9 @@ import com.gemstone.gemfire.cache30.CacheTestCase; import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.internal.AvailablePortHelper; import com.gemstone.gemfire.internal.cache.tier.InterestType; +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.SerializableCallable; import com.gemstone.gemfire.test.dunit.SerializableCallableIF; import com.gemstone.gemfire.test.dunit.SerializableRunnable; @@ -141,7 +143,7 @@ public class ClientServerInvalidAndDestroyedEntryDUnitTest extends CacheTestCase server.start(); } catch (IOException e) { - fail("Failed to start server ", e); + Assert.fail("Failed to start server ", e); } } if (usePR) { @@ -190,10 +192,10 @@ public class ClientServerInvalidAndDestroyedEntryDUnitTest extends CacheTestCase myRegion.invalidate(key2); } }); - getLogWriter().info("creating client cache"); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("creating client cache"); ClientCache c = new ClientCacheFactory() .addPoolServer("localhost", serverPort) - .set(DistributionConfig.LOG_LEVEL_NAME, getDUnitLogLevel()) + .set(DistributionConfig.LOG_LEVEL_NAME, LogWriterUtils.getDUnitLogLevel()) .create(); Region myRegion = c.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create(regionName);; if (useTX) { @@ -204,7 +206,7 @@ public class ClientServerInvalidAndDestroyedEntryDUnitTest extends CacheTestCase assertNotNull(myRegion.get(notAffectedKey)); // get of an invalid entry should return null and create the entry in an invalid state - getLogWriter().info("getting "+key1+" - should reach this cache and be INVALID"); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("getting "+key1+" - should reach this cache and be INVALID"); assertNull(myRegion.get(key1)); assertTrue(myRegion.containsKey(key1)); @@ -261,7 +263,7 @@ public class ClientServerInvalidAndDestroyedEntryDUnitTest extends CacheTestCase // test that a listener is not invoked when there is already an invalidated // entry in the client cache UpdateListener listener = new UpdateListener(); - listener.log = getLogWriter(); + listener.log = com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter(); myRegion.getAttributesMutator().addCacheListener(listener); myRegion.get(key1); assertEquals("expected no cache listener invocations", @@ -308,10 +310,10 @@ public class ClientServerInvalidAndDestroyedEntryDUnitTest extends CacheTestCase myRegion.destroy(key2); } }); - getLogWriter().info("creating client cache"); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("creating client cache"); ClientCache c = new ClientCacheFactory() .addPoolServer("localhost", serverPort) - .set(DistributionConfig.LOG_LEVEL_NAME, getDUnitLogLevel()) + .set(DistributionConfig.LOG_LEVEL_NAME, LogWriterUtils.getDUnitLogLevel()) .create(); Region myRegion = c.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create(regionName);; if (useTX) { @@ -320,7 +322,7 @@ public class ClientServerInvalidAndDestroyedEntryDUnitTest extends CacheTestCase // get of a valid entry should work assertNotNull(myRegion.get(notAffectedKey)); // get of an invalid entry should return null and create the entry in an invalid state - getLogWriter().info("getting "+key1+" - should reach this cache and be a TOMBSTONE"); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("getting "+key1+" - should reach this cache and be a TOMBSTONE"); assertNull(myRegion.get(key1)); assertFalse(myRegion.containsKey(key1)); RegionEntry entry; @@ -373,7 +375,7 @@ public class ClientServerInvalidAndDestroyedEntryDUnitTest extends CacheTestCase keys.add(notAffectedKey); keys.add(key1); keys.add(key2); Map result = myRegion.getAll(keys); - getLogWriter().info("result of getAll = " + result); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("result of getAll = " + result); assertNotNull(result.get(notAffectedKey)); assertNull(result.get(key1)); assertNull(result.get(key2)); @@ -430,10 +432,10 @@ public class ClientServerInvalidAndDestroyedEntryDUnitTest extends CacheTestCase } } }); - getLogWriter().info("creating client cache"); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("creating client cache"); ClientCache c = new ClientCacheFactory() .addPoolServer("localhost", serverPort) - .set(DistributionConfig.LOG_LEVEL_NAME, getDUnitLogLevel()) + .set(DistributionConfig.LOG_LEVEL_NAME, LogWriterUtils.getDUnitLogLevel()) .setPoolSubscriptionEnabled(true) .create(); @@ -456,7 +458,7 @@ public class ClientServerInvalidAndDestroyedEntryDUnitTest extends CacheTestCase BucketRegion bucket = ((PartitionedRegion)myRegion).getBucketRegion(key10); if (bucket != null) { event.setRegion(bucket); - getLogWriter().info("performing local destroy in " + bucket + " ccEnabled="+bucket.concurrencyChecksEnabled + " rvv="+bucket.getVersionVector()); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("performing local destroy in " + bucket + " ccEnabled="+bucket.concurrencyChecksEnabled + " rvv="+bucket.getVersionVector()); bucket.concurrencyChecksEnabled = false; // turn off cc so entry is removed bucket.mapDestroy(event, false, false, null); bucket.concurrencyChecksEnabled = true; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionCCEDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionCCEDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionCCEDUnitTest.java index 0ac6f67..6f76fc8 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionCCEDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionCCEDUnitTest.java @@ -24,6 +24,8 @@ import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.partition.PartitionRegionHelper; import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; import com.gemstone.gemfire.internal.cache.versions.VersionTag; +import com.gemstone.gemfire.test.dunit.IgnoredException; +import com.gemstone.gemfire.test.dunit.LogWriterUtils; import com.gemstone.gemfire.test.dunit.SerializableCallable; import com.gemstone.gemfire.test.dunit.VM; @@ -37,10 +39,10 @@ public class ClientServerTransactionCCEDUnitTest extends public void setUp() throws Exception { super.setUp(); - addExpectedException("Connection reset"); - addExpectedException("SocketTimeoutException"); - addExpectedException("ServerConnectivityException"); - addExpectedException("Socket Closed"); + IgnoredException.addIgnoredException("Connection reset"); + IgnoredException.addIgnoredException("SocketTimeoutException"); + IgnoredException.addIgnoredException("ServerConnectivityException"); + IgnoredException.addIgnoredException("Socket Closed"); } /** @@ -97,7 +99,7 @@ public class ClientServerTransactionCCEDUnitTest extends for (Object key : clientTags.keySet()) { VersionTag serverTag = serverTags.get(key); serverTag.setMemberID(serverId); - getLogWriter().fine("SWAP:key:"+key+" clientVersion:"+clientTags.get(key)+" serverVersion:"+serverTag); + LogWriterUtils.getLogWriter().fine("SWAP:key:"+key+" clientVersion:"+clientTags.get(key)+" serverVersion:"+serverTag); assertEquals(clientTags.get(key), serverTags.get(key)); serverTags.remove(key); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionDUnitTest.java index b5a475e..add43a0 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionDUnitTest.java @@ -16,8 +16,9 @@ */ package com.gemstone.gemfire.internal.cache; +import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*; + import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -31,16 +32,38 @@ import java.util.concurrent.TimeUnit; import javax.naming.Context; import javax.transaction.UserTransaction; -import com.gemstone.gemfire.LogWriter; -import com.gemstone.gemfire.cache.*; -import org.junit.Ignore; - +import com.gemstone.gemfire.cache.AttributesFactory; +import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.CacheFactory; +import com.gemstone.gemfire.cache.CacheListener; +import com.gemstone.gemfire.cache.CacheLoader; +import com.gemstone.gemfire.cache.CacheLoaderException; +import com.gemstone.gemfire.cache.CacheTransactionManager; +import com.gemstone.gemfire.cache.CacheWriterException; +import com.gemstone.gemfire.cache.CommitConflictException; +import com.gemstone.gemfire.cache.DataPolicy; +import com.gemstone.gemfire.cache.EntryEvent; +import com.gemstone.gemfire.cache.InterestPolicy; +import com.gemstone.gemfire.cache.LoaderHelper; +import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.Region.Entry; +import com.gemstone.gemfire.cache.RegionFactory; +import com.gemstone.gemfire.cache.RegionShortcut; +import com.gemstone.gemfire.cache.Scope; +import com.gemstone.gemfire.cache.SubscriptionAttributes; +import com.gemstone.gemfire.cache.TransactionDataNodeHasDepartedException; +import com.gemstone.gemfire.cache.TransactionDataNotColocatedException; +import com.gemstone.gemfire.cache.TransactionEvent; +import com.gemstone.gemfire.cache.TransactionException; +import com.gemstone.gemfire.cache.TransactionId; +import com.gemstone.gemfire.cache.TransactionInDoubtException; +import com.gemstone.gemfire.cache.TransactionWriter; +import com.gemstone.gemfire.cache.TransactionWriterException; +import com.gemstone.gemfire.cache.UnsupportedOperationInTransactionException; import com.gemstone.gemfire.cache.client.ClientCache; 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.Pool; import com.gemstone.gemfire.cache.client.PoolFactory; import com.gemstone.gemfire.cache.client.PoolManager; import com.gemstone.gemfire.cache.execute.Execution; @@ -65,11 +88,13 @@ import com.gemstone.gemfire.internal.cache.execute.data.OrderId; import com.gemstone.gemfire.internal.cache.execute.util.CommitFunction; import com.gemstone.gemfire.internal.cache.execute.util.RollbackFunction; import com.gemstone.gemfire.internal.cache.tx.ClientTXStateStub; -import com.gemstone.gemfire.test.dunit.DistributedTestCase; import com.gemstone.gemfire.test.dunit.Host; +import com.gemstone.gemfire.test.dunit.IgnoredException; 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 basic client-server transaction functionality @@ -88,7 +113,7 @@ public class ClientServerTransactionDUnitTest extends RemoteTransactionDUnitTest public void setUp() throws Exception { super.setUp(); - addExpectedException("java.net.SocketException"); + IgnoredException.addIgnoredException("java.net.SocketException"); } private Integer createRegionsAndStartServer(VM vm, boolean accessor) { @@ -338,10 +363,10 @@ public class ClientServerTransactionDUnitTest extends RemoteTransactionDUnitTest public Object call() throws Exception { final TXManagerImpl txmgr = getGemfireCache().getTxManager(); try { - waitForCriterion(new WaitCriterion() { + Wait.waitForCriterion(new WaitCriterion() { public boolean done() { Set states = txmgr.getTransactionsForClient((InternalDistributedMember)myId); - getLogWriter().info("found " + states.size() + " tx states for " + myId); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("found " + states.size() + " tx states for " + myId); return states.isEmpty(); } public String description() { @@ -398,17 +423,17 @@ public class ClientServerTransactionDUnitTest extends RemoteTransactionDUnitTest assertEquals(initSize, pr.size()); assertEquals(initSize, r.size()); - getLogWriter().info("Looking up transaction manager"); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Looking up transaction manager"); TXManagerImpl mgr = (TXManagerImpl) getCache().getCacheTransactionManager(); Context ctx = getCache().getJNDIContext(); UserTransaction utx = (UserTransaction)ctx.lookup("java:/UserTransaction"); - getLogWriter().info("starting transaction"); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("starting transaction"); if (useJTA) { utx.begin(); } else { mgr.begin(); } - getLogWriter().info("done starting transaction"); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("done starting transaction"); for (int i = 0; i < MAX_ENTRIES; i++) { CustId custId = new CustId(i); Customer cust = new Customer("name"+suffix+i, "address"+suffix+i); @@ -420,10 +445,10 @@ public class ClientServerTransactionDUnitTest extends RemoteTransactionDUnitTest Customer cust = new Customer("name"+suffix+i, "address"+suffix+i); assertEquals(cust, r.get(custId)); assertEquals(cust, pr.get(custId)); - getLogWriter().info("SWAP:get:"+r.get(custId)); - getLogWriter().info("SWAP:get:"+pr.get(custId)); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("SWAP:get:"+r.get(custId)); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("SWAP:get:"+pr.get(custId)); } - getLogWriter().info("suspending transaction"); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("suspending transaction"); if (!useJTA) { TXStateProxy tx = mgr.internalSuspend(); if (prePopulateData) { @@ -438,7 +463,7 @@ public class ClientServerTransactionDUnitTest extends RemoteTransactionDUnitTest assertNull(r.get(new CustId(i))); assertNull(pr.get(new CustId(i))); } - getLogWriter().info("resuming transaction"); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("resuming transaction"); mgr.resume(tx); } assertEquals( @@ -447,13 +472,13 @@ public class ClientServerTransactionDUnitTest extends RemoteTransactionDUnitTest assertEquals( "pr sized should be " + MAX_ENTRIES + " but it is:" + pr.size(), MAX_ENTRIES, pr.size()); - getLogWriter().info("committing transaction"); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("committing transaction"); if (useJTA) { utx.commit(); } else { getCache().getCacheTransactionManager().commit(); } - getLogWriter().info("done committing transaction"); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("done committing transaction"); assertEquals( "r sized should be " + MAX_ENTRIES + " but it is:" + r.size(), MAX_ENTRIES, r.size()); @@ -548,7 +573,7 @@ public class ClientServerTransactionDUnitTest extends RemoteTransactionDUnitTest return "waiting for hosted tx in progress to terminate"; } }; - waitForCriterion(w, 10000, 200, true); + Wait.waitForCriterion(w, 10000, 200, true); return null; } }); @@ -683,7 +708,7 @@ public class ClientServerTransactionDUnitTest extends RemoteTransactionDUnitTest Order order = (orderRegion.getAll(keys)).get(orderId); assertNotNull(order); mgr.rollback(); - getLogWriter().info("entry for " + orderId + " = " + orderRegion.getEntry(orderId)); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("entry for " + orderId + " = " + orderRegion.getEntry(orderId)); assertNull(orderRegion.getEntry(orderId)); return null; } @@ -970,7 +995,7 @@ public void testClientCommitAndDataStoreGetsEvent() throws Exception { // Region orderRegion = getCache().getRegion(ORDER); // Region refRegion = getCache().getRegion(D_REFERENCE); final ClientListener cl = (ClientListener) custRegion.getAttributes().getCacheListeners()[0]; - waitForCriterion(new WaitCriterion() { + Wait.waitForCriterion(new WaitCriterion() { @Override public boolean done() { @@ -1405,7 +1430,7 @@ public void testClientCommitAndDataStoreGetsEvent() throws Exception { VM server2 = host.getVM(1); VM client = host.getVM(2); - addExpectedException("java.net.SocketException"); + IgnoredException.addIgnoredException("java.net.SocketException"); final int port1 = createRegionsAndStartServer(server1, true); final int port2 = createRegionsAndStartServer(server2, false); @@ -2665,7 +2690,7 @@ public void testClientCommitAndDataStoreGetsEvent() throws Exception { final int port2 = createRegionsAndStartServer(server2, false); final int port = createRegionsAndStartServer(server1, true); - addExpectedException("ClassCastException"); + IgnoredException.addIgnoredException("ClassCastException"); SerializableRunnable suspectStrings = new SerializableRunnable("suspect string") { public void run() { InternalDistributedSystem.getLoggerI18n().convertToLogWriter().info( @@ -2699,7 +2724,7 @@ public void testClientCommitAndDataStoreGetsEvent() throws Exception { ); Region cust = getCache().getRegion(CUSTOMER); - getLogWriter().fine("SWAP:doing first get from client"); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().fine("SWAP:doing first get from client"); assertNull(cust.get(new CustId(0))); assertNull(cust.get(new CustId(1))); ArrayList args = new ArrayList(); @@ -2762,8 +2787,8 @@ public void testClientCommitAndDataStoreGetsEvent() throws Exception { doFunctionWithFailureWork(false); } private void doFunctionWithFailureWork(final boolean commit) { - addExpectedException("TransactionDataNodeHasDepartedException"); - addExpectedException("ClassCastException"); + IgnoredException.addIgnoredException("TransactionDataNodeHasDepartedException"); + IgnoredException.addIgnoredException("ClassCastException"); Host host = Host.getHost(0); VM server1 = host.getVM(0); VM server2 = host.getVM(1); @@ -2946,7 +2971,7 @@ public void testClientCommitAndDataStoreGetsEvent() throws Exception { }; // tx should timeout after 1 ms but to deal with loaded machines and thread // scheduling latency wait for 10 seconds before reporting an error. - DistributedTestCase.waitForCriterion(waitForTxTimeout, 10 * 1000, 10, true); + Wait.waitForCriterion(waitForTxTimeout, 10 * 1000, 10, true); try { mgr.resume(txId); fail("expected exception not thrown"); @@ -3353,7 +3378,7 @@ public void testClientCommitAndDataStoreGetsEvent() throws Exception { return "expected:"+keys+" found:"+clientListener.keys; } }; - DistributedTestCase.waitForCriterion(wc, 30*1000, 500, true); + Wait.waitForCriterion(wc, 30*1000, 500, true); } } assertTrue(foundListener); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentDestroySubRegionDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentDestroySubRegionDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentDestroySubRegionDUnitTest.java index 0611f63..2a7c0b5 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentDestroySubRegionDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentDestroySubRegionDUnitTest.java @@ -23,6 +23,7 @@ import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.RegionDestroyedException; import com.gemstone.gemfire.cache.Scope; import com.gemstone.gemfire.cache30.CacheTestCase; +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.SerializableRunnable; @@ -101,7 +102,7 @@ public class ConcurrentDestroySubRegionDUnitTest extends CacheTestCase { vm1.invoke(createChild); } catch(Exception e) { if(!(e.getCause() instanceof RegionDestroyedException)) { - fail("Wrong exception", e); + Assert.fail("Wrong exception", e); } RegionDestroyedException rde = (RegionDestroyedException) e.getCause(); assertEquals("Error on loop " + i, "/region", rde.getRegionFullPath()); @@ -160,7 +161,7 @@ public class ConcurrentDestroySubRegionDUnitTest extends CacheTestCase { vm1.invoke(createChild); } catch(Exception e) { if(!(e.getCause() instanceof RegionDestroyedException)) { - fail("Wrong exception", e); + Assert.fail("Wrong exception", e); } RegionDestroyedException rde = (RegionDestroyedException) e.getCause(); assertEquals("Error on loop " + i, "/region", rde.getRegionFullPath()); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentMapOpsDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentMapOpsDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentMapOpsDUnitTest.java index df0ea7f..44b89de 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentMapOpsDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentMapOpsDUnitTest.java @@ -49,11 +49,14 @@ import com.gemstone.gemfire.distributed.DistributedMember; import com.gemstone.gemfire.distributed.internal.membership.MembershipManager; import com.gemstone.gemfire.distributed.internal.membership.gms.MembershipManagerHelper; import com.gemstone.gemfire.internal.AvailablePort; -import com.gemstone.gemfire.test.dunit.DistributedTestCase; +import com.gemstone.gemfire.test.dunit.IgnoredException; +import com.gemstone.gemfire.test.dunit.LogWriterUtils; import com.gemstone.gemfire.test.dunit.Host; 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 for the concurrentMapOperations. there are more tests in ClientServerMiscDUnitTest @@ -145,7 +148,7 @@ public class ConcurrentMapOpsDUnitTest extends CacheTestCase { ccf.addPoolServer("localhost", port2); } ccf.setPoolSubscriptionEnabled(true); - ccf.set("log-level", getDUnitLogLevel()); + ccf.set("log-level", LogWriterUtils.getDUnitLogLevel()); ClientCache cCache = getClientCache(ccf); ClientRegionFactory crf = cCache .createClientRegionFactory(isEmpty ? ClientRegionShortcut.PROXY @@ -275,7 +278,7 @@ public class ConcurrentMapOpsDUnitTest extends CacheTestCase { return "Client expected to get "+MAX_ENTRIES+" creates, but got "+initialCreatesListener.numCreates.get(); } }; - DistributedTestCase.waitForCriterion(wc, 30*1000, 500, true); + Wait.waitForCriterion(wc, 30*1000, 500, true); } } if (!listenerFound) { @@ -409,7 +412,7 @@ public class ConcurrentMapOpsDUnitTest extends CacheTestCase { return "timeout "+e; } }; - DistributedTestCase.waitForCriterion(wc, 30000, 1000, true); + Wait.waitForCriterion(wc, 30000, 1000, true); return null; } }); @@ -457,7 +460,7 @@ public class ConcurrentMapOpsDUnitTest extends CacheTestCase { return "timeout "+e.getMessage(); } }; - DistributedTestCase.waitForCriterion(wc, 30000, 1000, true); + Wait.waitForCriterion(wc, 30000, 1000, true); return null; } }); @@ -957,7 +960,7 @@ public class ConcurrentMapOpsDUnitTest extends CacheTestCase { return r.containsKey(key); } }; - waitForCriterion(w, 10000, 200, true); + Wait.waitForCriterion(w, 10000, 200, true); assertTrue(r.containsKeyOnServer(key)); boolean result = r.remove(key, null); // if (!result) { @@ -1046,7 +1049,7 @@ public class ConcurrentMapOpsDUnitTest extends CacheTestCase { final int port2 = createRegionsAndStartServer(server2, true); final String regionName = usePR? PR_REG_NAME : REP_REG_NAME; - addExpectedException("java.net.SocketException"); + IgnoredException.addIgnoredException("java.net.SocketException"); createClientRegion(client, port1, false, port2); @@ -1059,11 +1062,11 @@ public class ConcurrentMapOpsDUnitTest extends CacheTestCase { final DistributedMember server1ID = (DistributedMember)server1.invoke(getID); final DistributedMember server2ID = (DistributedMember)server2.invoke(getID); - Set exceptions = new HashSet(); - exceptions.add(addExpectedException("Membership: requesting removal", server1)); - exceptions.add(addExpectedException("Membership: requesting removal", server2)); - exceptions.add(addExpectedException("ForcedDisconnect", server1)); - exceptions.add(addExpectedException("ForcedDisconnect", server2)); + Set exceptions = new HashSet(); + exceptions.add(IgnoredException.addIgnoredException("Membership: requesting removal", server1)); + exceptions.add(IgnoredException.addIgnoredException("Membership: requesting removal", server2)); + exceptions.add(IgnoredException.addIgnoredException("ForcedDisconnect", server1)); + exceptions.add(IgnoredException.addIgnoredException("ForcedDisconnect", server2)); try { @@ -1164,7 +1167,7 @@ public class ConcurrentMapOpsDUnitTest extends CacheTestCase { }); } finally { disconnectAllFromDS(); - for (ExpectedException ex: exceptions) { + for (IgnoredException ex: exceptions) { ex.remove(); } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentRegionOperationsJUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentRegionOperationsJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentRegionOperationsJUnitTest.java index 55ce901..833ef11 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentRegionOperationsJUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentRegionOperationsJUnitTest.java @@ -39,7 +39,7 @@ import org.junit.experimental.categories.Category; import com.gemstone.gemfire.cache.AttributesFactory; import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.Scope; -import com.gemstone.gemfire.test.dunit.DistributedTestCase; +import com.gemstone.gemfire.test.dunit.ThreadUtils; import com.gemstone.gemfire.test.junit.categories.IntegrationTest; /** @@ -444,8 +444,8 @@ public class ConcurrentRegionOperationsJUnitTest extends DiskRegionTestingBase }); t1.start(); t2.start(); - DistributedTestCase.join(t1, 30 * 1000, null); - DistributedTestCase.join(t2, 30 * 1000, null); + ThreadUtils.join(t1, 30 * 1000); + ThreadUtils.join(t2, 30 * 1000); assertTrue(!failure); } @@ -540,19 +540,19 @@ public class ConcurrentRegionOperationsJUnitTest extends DiskRegionTestingBase this.timeToStop.set(true); } for (int i = 0; i < numberOfPutsThreads; i++) { - DistributedTestCase.join(putThreads[i], 10*1000, null); + ThreadUtils.join(putThreads[i], 10*1000); } for (int i = 0; i < numberOfGetsThreads; i++) { - DistributedTestCase.join(getThreads[i], 10*1000, null); + ThreadUtils.join(getThreads[i], 10*1000); } for (int i = 0; i < numberOfDestroysThreads; i++) { - DistributedTestCase.join(destroyThreads[i], 10*1000, null); + ThreadUtils.join(destroyThreads[i], 10*1000); } for (int i = 0; i < numberOfClearThreads; i++) { - DistributedTestCase.join(clearThreads[i], 10*1000, null); + ThreadUtils.join(clearThreads[i], 10*1000); } for (int i = 0; i < numberOfForceRollThreads; i++) { - DistributedTestCase.join(forceRollThreads[i], 10*1000, null); + ThreadUtils.join(forceRollThreads[i], 10*1000); } if (this.validate) { @@ -824,7 +824,7 @@ public class ConcurrentRegionOperationsJUnitTest extends DiskRegionTestingBase ); region.clear(); - DistributedTestCase.join(th, 20 * 1000, null); + ThreadUtils.join(th, 20 * 1000); LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER = false; DiskStoreImpl.DEBUG_DELAY_JOINING_WITH_COMPACTOR = 500; CacheObserverHolder.setInstance(old); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentRollingAndRegionOperationsJUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentRollingAndRegionOperationsJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentRollingAndRegionOperationsJUnitTest.java index 36a0448..b95fa4e 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentRollingAndRegionOperationsJUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentRollingAndRegionOperationsJUnitTest.java @@ -41,7 +41,7 @@ import com.gemstone.gemfire.internal.cache.DiskRegionProperties; import com.gemstone.gemfire.internal.cache.DiskRegionTestingBase; import com.gemstone.gemfire.internal.cache.LocalRegion; import com.gemstone.gemfire.internal.cache.RegionEntry; -import com.gemstone.gemfire.test.dunit.DistributedTestCase; +import com.gemstone.gemfire.test.dunit.ThreadUtils; import com.gemstone.gemfire.test.junit.categories.IntegrationTest; /** @@ -866,7 +866,7 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends for (int i = 0; i < threads.size(); ++i) { Thread th = (Thread)threads.get(i); if (th != null) { - DistributedTestCase.join(th, 30 * 1000, null); + ThreadUtils.join(th, 30 * 1000); } } assertTrue( http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConnectDisconnectDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConnectDisconnectDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConnectDisconnectDUnitTest.java index f101acb..7a29e65 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConnectDisconnectDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConnectDisconnectDUnitTest.java @@ -39,10 +39,12 @@ import com.gemstone.gemfire.internal.AvailablePort; import com.gemstone.gemfire.internal.AvailablePortHelper; 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.SerializableRunnable; import com.gemstone.gemfire.test.dunit.VM; -import com.gemstone.gemfire.test.dunit.DistributedTestCase.WaitCriterion; +import com.gemstone.gemfire.test.dunit.IgnoredException; +import com.gemstone.gemfire.test.dunit.LogWriterUtils; /** A test of 46438 - missing response to an update attributes message */ public class ConnectDisconnectDUnitTest extends CacheTestCase { @@ -52,7 +54,7 @@ public class ConnectDisconnectDUnitTest extends CacheTestCase { } - private ExpectedException ex; + private IgnoredException ex; public ConnectDisconnectDUnitTest(String name) { super(name); @@ -74,7 +76,7 @@ public class ConnectDisconnectDUnitTest extends CacheTestCase { // setLocatorPorts(ports); for(int i = 0; i < 20; i++) { - getLogWriter().info("Test run: " + i); + LogWriterUtils.getLogWriter().info("Test run: " + i); runOnce(); tearDown(); setUp(); @@ -88,7 +90,7 @@ public class ConnectDisconnectDUnitTest extends CacheTestCase { static int[] locatorPorts; public void setLocatorPorts(int[] ports) { - deleteLocatorStateFile(ports); + DistributedTestUtils.deleteLocatorStateFile(ports); String locators = ""; for (int i=0; i 0) { @@ -109,13 +111,12 @@ public class ConnectDisconnectDUnitTest extends CacheTestCase { locatorPorts = ports; } - public void tearDown2() throws Exception { - super.tearDown2(); + @Override + protected final void postTearDownCacheTestCase() throws Exception { if (locatorPorts != null) { - deleteLocatorStateFile(locatorPorts); + DistributedTestUtils.deleteLocatorStateFile(locatorPorts); } } - /** * This test creates 4 vms and starts a cache in each VM. If that doesn't hang, it destroys the DS in all http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaPropagationDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaPropagationDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaPropagationDUnitTest.java index 43ed3da..9a50146 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaPropagationDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaPropagationDUnitTest.java @@ -63,6 +63,8 @@ import com.gemstone.gemfire.test.dunit.DistributedTestCase; import com.gemstone.gemfire.test.dunit.Host; 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; /** * @since 6.1 @@ -163,8 +165,8 @@ public class DeltaPropagationDUnitTest extends DistributedTestCase { DeltaPropagationDUnitTest.resetAll(); } - public void tearDown2() throws Exception { - super.tearDown2(); + @Override + protected final void preTearDown() throws Exception { DeltaPropagationDUnitTest.closeCache(); VM2.invoke(DeltaPropagationDUnitTest.class, "closeCache"); VM3.invoke(DeltaPropagationDUnitTest.class, "closeCache"); @@ -657,7 +659,7 @@ public class DeltaPropagationDUnitTest extends DistributedTestCase { primary = (((PoolImpl)pool).getPrimaryPort() == PORT1) ? VM0 : ((((PoolImpl)pool).getPrimaryPort() == PORT2) ? VM1 : VM2); - getLogWriter().info("waiting for client to receive last_key"); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("waiting for client to receive last_key"); waitForLastKey(); long fromDeltasOnClient = DeltaTestImpl.getFromDeltaInvokations() @@ -835,7 +837,7 @@ public class DeltaPropagationDUnitTest extends DistributedTestCase { } } catch (Exception e) { - fail("failed in doLocalOp()", e); + com.gemstone.gemfire.test.dunit.Assert.fail("failed in doLocalOp()", e); } } @@ -866,7 +868,7 @@ public class DeltaPropagationDUnitTest extends DistributedTestCase { } }; } - DistributedTestCase.waitForCriterion(wc, 5 * 1000, 100, true); + Wait.waitForCriterion(wc, 5 * 1000, 100, true); } public static void assertValue(String rName, String key, Object expected) { @@ -878,7 +880,7 @@ public class DeltaPropagationDUnitTest extends DistributedTestCase { + expected, expected.equals(value)); } catch (Exception e) { - fail("failed in assertValue()", e); + com.gemstone.gemfire.test.dunit.Assert.fail("failed in assertValue()", e); } } @@ -897,7 +899,7 @@ public class DeltaPropagationDUnitTest extends DistributedTestCase { return "HA Overflow did not occure."; } }; - DistributedTestCase.waitForCriterion(wc, 10 * 1000, 100, true); + Wait.waitForCriterion(wc, 10 * 1000, 100, true); } public static void waitForLastKey() { @@ -910,7 +912,7 @@ public class DeltaPropagationDUnitTest extends DistributedTestCase { return "Last key NOT received."; } }; - DistributedTestCase.waitForCriterion(wc, 10 * 1000, 100, true); + Wait.waitForCriterion(wc, 10 * 1000, 100, true); } public static void prepareDeltas() { @@ -1015,7 +1017,7 @@ public class DeltaPropagationDUnitTest extends DistributedTestCase { r.put(LAST_KEY, ""); } catch (Exception ex) { - fail("failed in createDelta()", ex); + com.gemstone.gemfire.test.dunit.Assert.fail("failed in createDelta()", ex); } } @@ -1032,7 +1034,7 @@ public class DeltaPropagationDUnitTest extends DistributedTestCase { r.create(DELTA_KEY, deltaPut[0]); } catch (Exception ex) { - fail("failed in createDelta()", ex); + com.gemstone.gemfire.test.dunit.Assert.fail("failed in createDelta()", ex); } } @@ -1054,7 +1056,7 @@ public class DeltaPropagationDUnitTest extends DistributedTestCase { r.put(LAST_KEY, ""); } catch (Exception ex) { - fail("failed in updateDelta()", ex); + com.gemstone.gemfire.test.dunit.Assert.fail("failed in updateDelta()", ex); } } @@ -1069,7 +1071,7 @@ public class DeltaPropagationDUnitTest extends DistributedTestCase { r.create(LAST_KEY, ""); } catch (Exception ex) { - fail("failed in createDeltas()", ex); + com.gemstone.gemfire.test.dunit.Assert.fail("failed in createDeltas()", ex); } } @@ -1081,7 +1083,7 @@ public class DeltaPropagationDUnitTest extends DistributedTestCase { r.create("KEY-A", "I push the delta out to disk :)"); } catch (Exception ex) { - fail("failed in createAnEntry()", ex); + com.gemstone.gemfire.test.dunit.Assert.fail("failed in createAnEntry()", ex); } } @@ -1093,7 +1095,7 @@ public class DeltaPropagationDUnitTest extends DistributedTestCase { r.invalidate(DELTA_KEY); } catch (Exception ex) { - fail("failed in invalidateDelta()", ex); + com.gemstone.gemfire.test.dunit.Assert.fail("failed in invalidateDelta()", ex); } } @@ -1476,7 +1478,7 @@ public class DeltaPropagationDUnitTest extends DistributedTestCase { r.registerInterest("ALL_KEYS"); } catch (Exception ex) { - fail("failed in registerInterestListAll", ex); + com.gemstone.gemfire.test.dunit.Assert.fail("failed in registerInterestListAll", ex); } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaPropagationStatsDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaPropagationStatsDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaPropagationStatsDUnitTest.java index d3f99bd..8c249be 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaPropagationStatsDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaPropagationStatsDUnitTest.java @@ -44,7 +44,10 @@ import com.gemstone.gemfire.internal.cache.tier.sockets.CacheClientProxy; import com.gemstone.gemfire.internal.tcp.ConnectionTable; import com.gemstone.gemfire.test.dunit.DistributedTestCase; 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.WaitCriterion; /** * @author ashetkar @@ -91,8 +94,8 @@ public class DeltaPropagationStatsDUnitTest extends DistributedTestCase { vm3 = host.getVM(3); } - public void tearDown2() throws Exception { - super.tearDown2(); + @Override + protected final void preTearDown() throws Exception { lastKeyReceived = false; vm0.invoke(DeltaPropagationStatsDUnitTest.class, "resetLastKeyReceived"); vm1.invoke(DeltaPropagationStatsDUnitTest.class, "resetLastKeyReceived"); @@ -129,7 +132,7 @@ public class DeltaPropagationStatsDUnitTest extends DistributedTestCase { int port = (Integer)vm0.invoke(DeltaPropagationStatsDUnitTest.class, "createServerCache", args); - createClientCache(getServerHostName(vm0.getHost()), port); + createClientCache(NetworkUtils.getServerHostName(vm0.getHost()), port); vm0.invoke(DeltaPropagationStatsDUnitTest.class, "putCleanDelta", new Object[] {Integer.valueOf(numOfKeys), Long.valueOf(updates)}); @@ -157,7 +160,7 @@ public class DeltaPropagationStatsDUnitTest extends DistributedTestCase { int port = (Integer)vm0.invoke(DeltaPropagationStatsDUnitTest.class, "createServerCache", args); - createClientCache(getServerHostName(vm0.getHost()), port); + createClientCache(NetworkUtils.getServerHostName(vm0.getHost()), port); vm0.invoke(DeltaPropagationStatsDUnitTest.class, "putErrorDeltaForReceiver", new Object[] {Integer.valueOf(numOfKeys), @@ -278,7 +281,7 @@ public class DeltaPropagationStatsDUnitTest extends DistributedTestCase { Scope.DISTRIBUTED_ACK, Boolean.TRUE}; Integer port = (Integer)vm0.invoke(DeltaPropagationStatsDUnitTest.class, "createServerCache", args); - createClientCache(getServerHostName(vm0.getHost()), port); + createClientCache(NetworkUtils.getServerHostName(vm0.getHost()), port); putCleanDelta(numOfKeys, updates); putLastKey(); @@ -314,7 +317,7 @@ public class DeltaPropagationStatsDUnitTest extends DistributedTestCase { Scope.DISTRIBUTED_ACK, Boolean.TRUE}; Integer port = (Integer)vm0.invoke(DeltaPropagationStatsDUnitTest.class, "createServerCache", args); - createClientCache(getServerHostName(vm0.getHost()), port); + createClientCache(NetworkUtils.getServerHostName(vm0.getHost()), port); putErrorDeltaForReceiver(numOfKeys, updates, errors); putErrorDeltaForSender(numOfKeys, updates, errors2, Boolean.FALSE); @@ -350,7 +353,7 @@ public class DeltaPropagationStatsDUnitTest extends DistributedTestCase { return "Last key NOT received."; } }; - DistributedTestCase.waitForCriterion(wc, 15 * 1000, 100, true); + Wait.waitForCriterion(wc, 15 * 1000, 100, true); } public static void putCleanDelta(Integer keys, Long updates) { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaSizingDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaSizingDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaSizingDUnitTest.java index 5da448a..4de9daf 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaSizingDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaSizingDUnitTest.java @@ -31,6 +31,7 @@ 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.Host; +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; @@ -109,8 +110,8 @@ public class DeltaSizingDUnitTest extends CacheTestCase { int port2) { AttributesFactory attr = new AttributesFactory(); PoolFactory pf = PoolManager.createFactory(); - pf.addServer(getServerHostName(host), port1); - pf.addServer(getServerHostName(host), port2); + pf.addServer(NetworkUtils.getServerHostName(host), port1); + pf.addServer(NetworkUtils.getServerHostName(host), port2); pf.create("pool"); attr.setCloningEnabled(clone); attr.setDataPolicy(DataPolicy.EMPTY); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegByteArrayDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegByteArrayDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegByteArrayDUnitTest.java index 49b47c8..f42c020 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegByteArrayDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegByteArrayDUnitTest.java @@ -31,6 +31,7 @@ import com.gemstone.gemfire.cache.Scope; import com.gemstone.gemfire.cache30.CacheTestCase; import com.gemstone.gemfire.distributed.DistributedSystem; 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; @@ -88,10 +89,10 @@ public class DiskRegByteArrayDUnitTest extends CacheTestCase { vm1.invoke(DiskRegByteArrayDUnitTest.class, "createCacheForVM1"); } - public void tearDown2() throws Exception { - super.tearDown2(); + @Override + protected final void postTearDownCacheTestCase() throws Exception { cache = null; - invokeInEveryVM(new SerializableRunnable() { public void run() { cache = null; } }); + Invoke.invokeInEveryVM(new SerializableRunnable() { public void run() { cache = null; } }); } /* public void tearDown(){ http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionClearJUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionClearJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionClearJUnitTest.java index d1e0791..7e58329 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionClearJUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionClearJUnitTest.java @@ -44,7 +44,7 @@ import com.gemstone.gemfire.cache.RegionEvent; import com.gemstone.gemfire.cache.Scope; import com.gemstone.gemfire.distributed.DistributedSystem; import com.gemstone.gemfire.internal.cache.versions.VersionStamp; -import com.gemstone.gemfire.test.dunit.DistributedTestCase; +import com.gemstone.gemfire.test.dunit.ThreadUtils; import com.gemstone.gemfire.test.junit.categories.IntegrationTest; // @TODO: use DiskRegionTestingBase and DiskRegionHelperFactory @@ -184,7 +184,7 @@ public class DiskRegionClearJUnitTest { fail("timed out counter="+counter); } } - DistributedTestCase.join(thread, 10 * 60 * 1000, null); + ThreadUtils.join(thread, 10 * 60 * 1000); Assert.assertTrue(counter == 3); if(!cleared) fail("clear not done although puts have been done"); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionJUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionJUnitTest.java index 36044f7..94e6ec6 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionJUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionJUnitTest.java @@ -47,8 +47,9 @@ import com.gemstone.gemfire.cache.util.CacheListenerAdapter; import com.gemstone.gemfire.internal.cache.lru.LRUStatistics; import com.gemstone.gemfire.internal.cache.lru.NewLRUClockHand; import com.gemstone.gemfire.internal.cache.persistence.UninterruptibleFileChannel; -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; /** @@ -411,11 +412,11 @@ public class DiskRegionJUnitTest extends DiskRegionTestingBase } long startTime = System.currentTimeMillis(); - DistributedTestCase.join(thread1, 20 * 1000, null); - DistributedTestCase.join(thread2, 20 * 1000, null); - DistributedTestCase.join(thread3, 20 * 1000, null); - DistributedTestCase.join(thread4, 20 * 1000, null); - DistributedTestCase.join(thread5, 20 * 1000, null); + ThreadUtils.join(thread1, 20 * 1000); + ThreadUtils.join(thread2, 20 * 1000); + ThreadUtils.join(thread3, 20 * 1000); + ThreadUtils.join(thread4, 20 * 1000); + ThreadUtils.join(thread5, 20 * 1000); long interval = System.currentTimeMillis() - startTime; if (interval > 100000) { @@ -521,11 +522,11 @@ public class DiskRegionJUnitTest extends DiskRegionTestingBase long startTime = System.currentTimeMillis(); finished = true; - DistributedTestCase.join(thread1, 5 * 60 * 1000, null); - DistributedTestCase.join(thread2, 5 * 60 * 1000, null); - DistributedTestCase.join(thread3, 5 * 60 * 1000, null); - DistributedTestCase.join(thread4, 5 * 60 * 1000, null); - DistributedTestCase.join(thread5, 5 * 60 * 1000, null); + ThreadUtils.join(thread1, 5 * 60 * 1000); + ThreadUtils.join(thread2, 5 * 60 * 1000); + ThreadUtils.join(thread3, 5 * 60 * 1000); + ThreadUtils.join(thread4, 5 * 60 * 1000); + ThreadUtils.join(thread5, 5 * 60 * 1000); long interval = System.currentTimeMillis() - startTime; if (interval > 100000) { fail(" Test took too long in going to join, it should have exited before 100000 ms"); @@ -720,7 +721,7 @@ public class DiskRegionJUnitTest extends DiskRegionTestingBase oplogs = dsi.testHookGetAllOverflowOplogs(); int retryCount = 20; while (oplogs.size() > 1 && retryCount > 0) { - DistributedTestCase.staticPause(100); + Wait.pause(100); oplogs = dsi.testHookGetAllOverflowOplogs(); retryCount--; } @@ -1152,7 +1153,7 @@ public class DiskRegionJUnitTest extends DiskRegionTestingBase public void beforeGoingToCompact() { try { - DistributedTestCase.join(t1, 60 * 1000, null); + ThreadUtils.join(t1, 60 * 1000); } catch (Exception ignore) { logWriter.error("Exception occured", ignore); @@ -1192,7 +1193,7 @@ public class DiskRegionJUnitTest extends DiskRegionTestingBase }); testThread.start(); // region.clear(); - DistributedTestCase.join(testThread, 40 * 1000, null); + ThreadUtils.join(testThread, 40 * 1000); assertFalse(failureCause, testFailed); assertFalse("Expected situation of max directory size violation happening and available space less than zero did not happen ", exceptionOccured); // CC jade1d failure @@ -1732,7 +1733,7 @@ public class DiskRegionJUnitTest extends DiskRegionTestingBase region.create("key1", "value1"); try { cache.getLogger().info("waiting for clear to finish"); - DistributedTestCase.join(th, 30 * 1000, null); + ThreadUtils.join(th, 30 * 1000); } catch (Exception ie) { DiskRegionJUnitTest.this.exceptionOccured = true; @@ -1782,7 +1783,7 @@ public class DiskRegionJUnitTest extends DiskRegionTestingBase public void beforeDiskClear() { th.start(); - DistributedTestCase.staticPause(7 * 1000); + Wait.pause(7 * 1000); System.out.println("FIXME: this thread does not terminate--EVER!"); // try { // DistributedTestCase.join(th, 7 * 1000, null); @@ -1795,7 +1796,7 @@ public class DiskRegionJUnitTest extends DiskRegionTestingBase }); try { region.clear(); - DistributedTestCase.join(th, 30 * 1000, null); + ThreadUtils.join(th, 30 * 1000); assertFalse(this.failureCause, this.exceptionOccured); //We expect 1 entry to exist, because the clear was triggered before //the update @@ -1842,7 +1843,7 @@ public class DiskRegionJUnitTest extends DiskRegionTestingBase LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER = false; th.start(); System.out.println("FIXME: this thread (2) does not terminate--EVER!"); - DistributedTestCase.staticPause(10 * 1000); + Wait.pause(10 * 1000); // try { // DistributedTestCase.join(th, 10 * 1000, null); // } @@ -1854,7 +1855,7 @@ public class DiskRegionJUnitTest extends DiskRegionTestingBase }); try { region.clear(); - DistributedTestCase.join(th, 30 * 1000, null); + ThreadUtils.join(th, 30 * 1000); assertFalse(this.failureCause, this.exceptionOccured); //We expect 1 entry to exist, because the clear was triggered before //the update @@ -2265,7 +2266,7 @@ public class DiskRegionJUnitTest extends DiskRegionTestingBase fail("async flusher thread did not terminate"); } - DistributedTestCase.waitForCriterion(new WaitCriterion() { + Wait.waitForCriterion(new WaitCriterion() { @Override public boolean done() { return cache.isClosed(); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DistrbutedRegionProfileOffHeapDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DistrbutedRegionProfileOffHeapDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DistrbutedRegionProfileOffHeapDUnitTest.java index 1c2f921..6ce3ffd 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DistrbutedRegionProfileOffHeapDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DistrbutedRegionProfileOffHeapDUnitTest.java @@ -28,6 +28,8 @@ import com.gemstone.gemfire.cache30.CacheSerializableRunnable; import com.gemstone.gemfire.cache30.CacheTestCase; import com.gemstone.gemfire.distributed.internal.DistributionConfig; 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.SerializableRunnable; public class DistrbutedRegionProfileOffHeapDUnitTest extends CacheTestCase { @@ -38,7 +40,7 @@ public class DistrbutedRegionProfileOffHeapDUnitTest extends CacheTestCase { } @Override - public void tearDown2() throws Exception { + protected final void preTearDownCacheTestCase() throws Exception { SerializableRunnable checkOrphans = new SerializableRunnable() { @Override @@ -48,12 +50,8 @@ public class DistrbutedRegionProfileOffHeapDUnitTest extends CacheTestCase { } } }; - invokeInEveryVM(checkOrphans); - try { - checkOrphans.run(); - } finally { - super.tearDown2(); - } + Invoke.invokeInEveryVM(checkOrphans); + checkOrphans.run(); } /** @@ -62,7 +60,7 @@ public class DistrbutedRegionProfileOffHeapDUnitTest extends CacheTestCase { * cause an exception and the region will not be created. */ public void testPartitionedRegionProfileWithConflict() throws Exception { - final String regionName = getTestName() + "Region"; + final String regionName = getTestMethodName() + "Region"; Host.getHost(0).getVM(0).invoke(new CacheSerializableRunnable("createRegionNoException") { private static final long serialVersionUID = 1L; @@ -96,7 +94,7 @@ public class DistrbutedRegionProfileOffHeapDUnitTest extends CacheTestCase { Region region = null; try { - addExpectedException("IllegalStateException"); + IgnoredException.addIgnoredException("IllegalStateException"); region = regionFactory.create(regionName); fail("Expected exception upon creation with invalid off-heap state"); } catch (IllegalStateException expected) { @@ -117,8 +115,8 @@ public class DistrbutedRegionProfileOffHeapDUnitTest extends CacheTestCase { * created. */ public void testPartitionedRegionProfileWithoutConflict() throws Exception { - final String offHeapRegionName = getTestName() + "OffHeapRegion"; - final String onHeapRegionName = getTestName() + "OnHeapRegion"; + final String offHeapRegionName = getTestMethodName() + "OffHeapRegion"; + final String onHeapRegionName = getTestMethodName() + "OnHeapRegion"; for (int vmId = 0; vmId <= 1; vmId++) { Host.getHost(0).getVM(vmId).invoke(new CacheSerializableRunnable("createRegionNoException") { @@ -155,7 +153,7 @@ public class DistrbutedRegionProfileOffHeapDUnitTest extends CacheTestCase { * exception. */ public void testPartitionedRegionProfileWithAccessor() throws Exception { - final String regionName = getTestName() + "Region"; + final String regionName = getTestMethodName() + "Region"; // Create a region using off-heap Host.getHost(0).getVM(0).invoke(new CacheSerializableRunnable("createRegionNoException") { @@ -208,7 +206,7 @@ public class DistrbutedRegionProfileOffHeapDUnitTest extends CacheTestCase { * storage and the other being a proxy will not cause an exception. */ public void testPartitionedRegionProfileWithProxy() throws Exception { - final String regionName = getTestName() + "Region"; + final String regionName = getTestMethodName() + "Region"; // Create a region using off-heap Host.getHost(0).getVM(0).invoke(new CacheSerializableRunnable("createRegionNoException") { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DistributedCacheTestCase.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DistributedCacheTestCase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DistributedCacheTestCase.java index e6057f5..4c46a55 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DistributedCacheTestCase.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DistributedCacheTestCase.java @@ -33,6 +33,7 @@ import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; import com.gemstone.gemfire.internal.Assert; 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.VM; /** @@ -104,7 +105,8 @@ public abstract class DistributedCacheTestCase /** * Closes the cache in this VM and each remote VM */ - public void tearDown2() throws Exception { + @Override + protected final void preTearDown() throws Exception { StringBuffer problems = new StringBuffer(); if (cache != null) { @@ -137,8 +139,6 @@ public abstract class DistributedCacheTestCase assertEquals("Problems while tearing down", "", problems.toString().trim()); - - super.tearDown2(); } /** @@ -229,7 +229,7 @@ public abstract class DistributedCacheTestCase Region newRegion = root.createSubregion(name, factory.create()); - getLogWriter().info( + LogWriterUtils.getLogWriter().info( "Created Region '" + newRegion.getFullPath() + "'"); } @@ -301,7 +301,7 @@ public abstract class DistributedCacheTestCase factory.create()); sub.create(entryName, null); - getLogWriter().info( + LogWriterUtils.getLogWriter().info( "Defined Entry named '" + entryName + "' in region '" + sub.getFullPath() +"'"); } @@ -328,7 +328,7 @@ public abstract class DistributedCacheTestCase sub.put(entryName, value); - getLogWriter().info( + LogWriterUtils.getLogWriter().info( "Put value " + value + " in entry " + entryName + " in region '" + region.getFullPath() +"'"); } @@ -377,7 +377,7 @@ public abstract class DistributedCacheTestCase sub.put(entryName, value); - getLogWriter().info( + LogWriterUtils.getLogWriter().info( "Replaced value " + value + "in entry " + entryName + " in region '" + region.getFullPath() +"'"); } @@ -466,7 +466,7 @@ public abstract class DistributedCacheTestCase Host host = Host.getHost(0); int vmCount = host.getVMCount(); for (int i=0; iEventTracker management. @@ -75,13 +78,9 @@ public class EventTrackerDUnitTest extends CacheTestCase { disconnectAllFromDS(); } - public void tearDown2() throws Exception { - try { - super.tearDown2(); - } - finally { - disconnectAllFromDS(); - } + @Override + protected final void postTearDownCacheTestCase() throws Exception { + disconnectAllFromDS(); } /** @@ -146,7 +145,7 @@ public class EventTrackerDUnitTest extends CacheTestCase { try { startCacheServer(); } catch (Exception ex) { - fail("While starting CacheServer", ex); + Assert.fail("While starting CacheServer", ex); } } }); @@ -162,7 +161,7 @@ public class EventTrackerDUnitTest extends CacheTestCase { // Create Create Region in the client final int port = serverVM.invokeInt(EventTrackerDUnitTest.class, "getCacheServerPort"); - final String hostName = getServerHostName(host); + final String hostName = NetworkUtils.getServerHostName(host); clientVM.invoke(new CacheSerializableRunnable("Create client") { public void run2() throws CacheException { getCache(); @@ -219,7 +218,7 @@ public class EventTrackerDUnitTest extends CacheTestCase { try { startCacheServer(); } catch (Exception ex) { - fail("While starting CacheServer", ex); + Assert.fail("While starting CacheServer", ex); } } }); @@ -235,7 +234,7 @@ public class EventTrackerDUnitTest extends CacheTestCase { // Create Create Region in the client final int port = serverVM.invokeInt(EventTrackerDUnitTest.class, "getCacheServerPort"); - final String hostName = getServerHostName(host); + final String hostName = NetworkUtils.getServerHostName(host); clientVM.invoke(new CacheSerializableRunnable("Create client") { public void run2() throws CacheException { getCache(); @@ -266,7 +265,7 @@ public class EventTrackerDUnitTest extends CacheTestCase { // Pause for the message tracking timeout int waitTime = Integer.parseInt(MESSAGE_TRACKING_TIMEOUT) * 3; - pause(waitTime); + Wait.pause(waitTime); // Verify the server no longer contains an entry eventState = region.getEventState(); @@ -303,7 +302,7 @@ public class EventTrackerDUnitTest extends CacheTestCase { try { startCacheServer(); } catch (Exception ex) { - fail("While starting CacheServer", ex); + Assert.fail("While starting CacheServer", ex); } } }; @@ -313,7 +312,7 @@ public class EventTrackerDUnitTest extends CacheTestCase { // Create Create Region in the client final int port = vm0.invokeInt(EventTrackerDUnitTest.class, "getCacheServerPort"); - final String hostName = getServerHostName(host); + final String hostName = NetworkUtils.getServerHostName(host); vm2.invoke(new CacheSerializableRunnable("Create client") { public void run2() throws CacheException { getCache(); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/EvictionDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/EvictionDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/EvictionDUnitTest.java index 33807b7..2d19ba5 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/EvictionDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/EvictionDUnitTest.java @@ -26,6 +26,7 @@ import org.junit.experimental.categories.Category; import com.gemstone.gemfire.cache.EvictionAlgorithm; import com.gemstone.gemfire.internal.cache.lru.HeapEvictor; import com.gemstone.gemfire.internal.cache.lru.MemLRUCapacityController; +import com.gemstone.gemfire.test.dunit.LogWriterUtils; import com.gemstone.gemfire.test.junit.categories.DistributedTest; @Category(DistributedTest.class) @@ -94,7 +95,7 @@ public class EvictionDUnitTest extends EvictionTestBase { createPartitionedRegion(true, EvictionAlgorithm.LRU_ENTRY, "PR1", 4, 1, 1000,maxEnteries); final PartitionedRegion pr = (PartitionedRegion)cache.getRegion("PR1"); - getLogWriter().info( + LogWriterUtils.getLogWriter().info( "PR- " +pr.getEvictionAttributes().getMaximum()); for (int counter = 1; counter <= maxEnteries+extraEntries; counter++) { @@ -111,7 +112,7 @@ public class EvictionDUnitTest extends EvictionTestBase { createPartitionedRegion(true, EvictionAlgorithm.LRU_ENTRY, "PR1", 4, 1, 1000,maxEnteries); final PartitionedRegion pr = (PartitionedRegion)cache.getRegion("PR1"); - getLogWriter().info( + LogWriterUtils.getLogWriter().info( "PR- " +pr.getEvictionAttributes().getMaximum()); for (int i = 0; i < 3; i++) { // assume mod-based hashing for bucket creation @@ -138,7 +139,7 @@ public class EvictionDUnitTest extends EvictionTestBase { createPartitionedRegion(true, EvictionAlgorithm.LRU_ENTRY, "PR1", 5, 1, 1000,maxEnteries); final PartitionedRegion pr = (PartitionedRegion)cache.getRegion("PR1"); - getLogWriter().info( + LogWriterUtils.getLogWriter().info( "PR- " +pr.getEvictionAttributes().getMaximum()); for (int counter = 1; counter <= maxEnteries+extraEntries; counter++) { @@ -154,7 +155,7 @@ public class EvictionDUnitTest extends EvictionTestBase { if (bucketRegion == null) { continue; } - getLogWriter().info( + LogWriterUtils.getLogWriter().info( "FINAL bucket= " + bucketRegion.getFullPath() + "size= " + bucketRegion.size() + " count= "+bucketRegion.entryCount()); assertEquals(4,bucketRegion.size()); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/EvictionObjectSizerDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/EvictionObjectSizerDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/EvictionObjectSizerDUnitTest.java index dbc1f3f..18346b7 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/EvictionObjectSizerDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/EvictionObjectSizerDUnitTest.java @@ -37,6 +37,8 @@ import com.gemstone.gemfire.internal.SharedLibrary; import com.gemstone.gemfire.internal.cache.lru.HeapLRUCapacityController; import com.gemstone.gemfire.internal.cache.lru.Sizeable; import com.gemstone.gemfire.internal.size.ReflectionSingleObjectSizer; +import com.gemstone.gemfire.test.dunit.Assert; +import com.gemstone.gemfire.test.dunit.LogWriterUtils; public class EvictionObjectSizerDUnitTest extends CacheTestCase { @@ -61,11 +63,6 @@ public class EvictionObjectSizerDUnitTest extends CacheTestCase { super.setUp(); } - @Override - public void tearDown2() throws Exception { - super.tearDown2(); - } - /** * Without object sizer */ @@ -139,7 +136,7 @@ public class EvictionObjectSizerDUnitTest extends CacheTestCase { int valueSize = SharedLibrary.getObjectHeaderSize() + 4 /* array length */ + 0 /* bytes */; valueSize = (int) ReflectionSingleObjectSizer.roundUpSize(valueSize); int entrySize = keySize + valueSize + ((HeapLRUCapacityController)((PartitionedRegion)region).getEvictionController()).getPerEntryOverhead(); - getLogWriter().info("testObjectSizerForHeapLRU_CustomizedNonSizerObject expected= " + entrySize); + LogWriterUtils.getLogWriter().info("testObjectSizerForHeapLRU_CustomizedNonSizerObject expected= " + entrySize); assertEquals(entrySize, getSizeOfCustomizedData(1)); } @@ -153,7 +150,7 @@ public class EvictionObjectSizerDUnitTest extends CacheTestCase { int valueSize = SharedLibrary.getObjectHeaderSize() + 4 /* array length */ + 4 /* bytes */; valueSize = (int) ReflectionSingleObjectSizer.roundUpSize(valueSize); int entrySize = keySize + valueSize + ((HeapLRUCapacityController)((PartitionedRegion)region).getEvictionController()).getPerEntryOverhead(); - getLogWriter().info("testObjectSizerForHeapLRU_CustomizedNonSizerObject expected= " + entrySize); + LogWriterUtils.getLogWriter().info("testObjectSizerForHeapLRU_CustomizedNonSizerObject expected= " + entrySize); assertEquals(entrySize, getSizeOfCustomizedData(2)); } } @@ -171,7 +168,7 @@ public class EvictionObjectSizerDUnitTest extends CacheTestCase { // Total Size of entry should be= 71 putCustomizedData(1, new TestObjectSizerImpl()); int expected = (0+160+(Sizeable.PER_OBJECT_OVERHEAD*2)+((HeapLRUCapacityController)((PartitionedRegion)region).getEvictionController()).getPerEntryOverhead()); - getLogWriter().info("testObjectSizerForHeapLRU_CustomizedSizerObject expected= " + expected); + LogWriterUtils.getLogWriter().info("testObjectSizerForHeapLRU_CustomizedSizerObject expected= " + expected); assertEquals(expected, getSizeOfCustomizedData(1)); assertEquals(expected, ((PartitionedRegion)region).getEvictionController() .getLRUHelper().getStats().getCounter()); @@ -189,7 +186,7 @@ public class EvictionObjectSizerDUnitTest extends CacheTestCase { // Total Size of entry should be= 72 putCustomizedObjects(new TestNonSizerObject("1"), new TestObjectSizerImpl()); int expected = (1+160+(Sizeable.PER_OBJECT_OVERHEAD*2)+((HeapLRUCapacityController)((PartitionedRegion)region).getEvictionController()).getPerEntryOverhead()); - getLogWriter().info("testObjectSizerForHeapLRU_CustomizedSizerObjects expected= " + expected); + LogWriterUtils.getLogWriter().info("testObjectSizerForHeapLRU_CustomizedSizerObjects expected= " + expected); assertEquals(expected, getSizeOfCustomizedObject(new TestNonSizerObject("1"))); assertEquals(expected, ((PartitionedRegion)region).getEvictionController() .getLRUHelper().getStats().getCounter()); @@ -210,12 +207,12 @@ public class EvictionObjectSizerDUnitTest extends CacheTestCase { ds = getSystem(props); cache = CacheFactory.create(ds); assertNotNull(cache); - getLogWriter().info("cache= " + cache); - getLogWriter().info("cache closed= " + cache.isClosed()); + LogWriterUtils.getLogWriter().info("cache= " + cache); + LogWriterUtils.getLogWriter().info("cache closed= " + cache.isClosed()); cache.getResourceManager().setEvictionHeapPercentage(50); } catch (Exception e) { - fail("Failed while creating the cache", e); + Assert.fail("Failed while creating the cache", e); } } @@ -264,7 +261,7 @@ public class EvictionObjectSizerDUnitTest extends CacheTestCase { region = cache.createRegion(regionName, factory.create()); assertNotNull(region); - getLogWriter().info("Partitioned Region created Successfully :" + region); + LogWriterUtils.getLogWriter().info("Partitioned Region created Successfully :" + region); } /** @@ -298,7 +295,7 @@ public class EvictionObjectSizerDUnitTest extends CacheTestCase { if (map == null || map.size() == 0) { continue; } - getLogWriter().info( + LogWriterUtils.getLogWriter().info( "Checking for entry in bucket region: " + bucketRegion); for (int counter = 1; counter <= noOfElememts; counter++) { assertEquals(entrySize, ((AbstractLRURegionEntry)map