http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestTestCase.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestTestCase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestTestCase.java index a80b21c..d5b6252 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestTestCase.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestTestCase.java @@ -41,7 +41,11 @@ import com.gemstone.gemfire.internal.cache.LocalRegion; import com.gemstone.gemfire.internal.cache.tier.InterestType; 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.ThreadUtils; 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.junit.categories.IntegrationTest; import java.io.IOException; @@ -108,11 +112,11 @@ public class HAInterestTestCase extends DistributedTestCase { PORT2 = ((Integer) server2.invoke(HAInterestTestCase.class, "createServerCache")).intValue(); PORT3 = ((Integer) server3.invoke(HAInterestTestCase.class, "createServerCache")).intValue(); exceptionOccured = false; - addExpectedException("java.net.ConnectException: Connection refused: connect"); + IgnoredException.addIgnoredException("java.net.ConnectException: Connection refused: connect"); } @Override - public void tearDown2() throws Exception { + protected final void preTearDown() throws Exception { // close the clients first closeCache(); @@ -175,7 +179,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "waiting for primary"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); int primaryPort = pool.getPrimaryPort(); assertTrue(primaryPort != -1); @@ -256,7 +260,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "waiting for client_k1 refresh from server"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); wc = new WaitCriterion() { @Override @@ -272,7 +276,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "waiting for client_k2 refresh from server"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); } public static void verifyDeadAndLiveServers(final int expectedDeadServers, final int expectedLiveServers) { @@ -286,7 +290,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "waiting for pool.getConnectedServerCount() == expectedLiveServer"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); } public static void putK1andK2() { @@ -309,7 +313,7 @@ public class HAInterestTestCase extends DistributedTestCase { }; t.start(); try { - DistributedTestCase.join(t, 30 * 1000, getLogWriter()); + ThreadUtils.join(t, 30 * 1000); } catch (Exception ignore) { exceptionOccured = true; } @@ -422,7 +426,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "waiting for cache.getCacheServers().size() == 1"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); CacheServerImpl bs = (CacheServerImpl) cache.getCacheServers().iterator().next(); assertNotNull(bs); @@ -440,7 +444,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "waiting for ccn.getClientProxies().size() > 0"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); wc = new WaitCriterion() { Iterator iter_prox; @@ -462,7 +466,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "waiting for CacheClientProxy _messageDispatcher to be alive"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); } public static void verifyDispatcherIsNotAlive() { @@ -476,7 +480,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "cache.getCacheServers().size() == 1"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); CacheServerImpl bs = (CacheServerImpl) cache.getCacheServers().iterator().next(); assertNotNull(bs); @@ -494,7 +498,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "waiting for ccn.getClientProxies().size() > 0"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); Iterator iter_prox = ccn.getClientProxies().iterator(); if (iter_prox.hasNext()) { @@ -590,7 +594,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "connected server count never became 3"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); // close primaryEP getPrimaryVM().invoke(HAInterestTestCase.class, "stopServer"); @@ -620,7 +624,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "connected server count never became 3"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); // close primaryEP getPrimaryVM().invoke(HAInterestTestCase.class, "stopServer"); @@ -644,7 +648,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "connected server count never became 3"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); // close primaryEP VM backup = getBackupVM(); @@ -681,7 +685,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "Never got three connected servers"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); // close secondary EP VM result = getBackupVM(); @@ -717,7 +721,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "connected server count never became 3"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); // close secondary EP VM result = getBackupVM(); @@ -767,7 +771,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "waiting for cache.getCacheServers().size() == 1"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); CacheServerImpl bs = (CacheServerImpl) cache.getCacheServers().iterator().next(); assertNotNull(bs); @@ -785,7 +789,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "waiting for ccn.getClientProxies().size() > 0"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); Iterator iter_prox = ccn.getClientProxies().iterator(); @@ -805,7 +809,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "waiting for keys of interest to include 2 keys"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); Set keysMap = (Set) ccp.cils[RegisterInterestTracker.interestListIndex].getProfile(Region.SEPARATOR + REGION_NAME) .getKeysOfInterestFor(ccp.getProxyID()); @@ -827,7 +831,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "waiting for cache.getCacheServers().size() == 1"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); CacheServerImpl bs = (CacheServerImpl) cache.getCacheServers().iterator().next(); assertNotNull(bs); @@ -845,7 +849,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "waiting for ccn.getClientProxies().size() > 0"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); Iterator iter_prox = ccn.getClientProxies().iterator(); if (iter_prox.hasNext()) { @@ -864,7 +868,7 @@ public class HAInterestTestCase extends DistributedTestCase { return "waiting for keys of interest to not be null"; } }; - DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); + Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true); Set keysMap = (Set) ccp.cils[RegisterInterestTracker.interestListIndex] .getProfile(Region.SEPARATOR + REGION_NAME)
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAStartupAndFailoverDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAStartupAndFailoverDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAStartupAndFailoverDUnitTest.java index 54ef4c0..01c595c 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAStartupAndFailoverDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAStartupAndFailoverDUnitTest.java @@ -38,9 +38,14 @@ import com.gemstone.gemfire.distributed.internal.ServerLocation; import com.gemstone.gemfire.internal.AvailablePort; import com.gemstone.gemfire.internal.cache.ClientServerObserverAdapter; import com.gemstone.gemfire.internal.cache.ClientServerObserverHolder; +import com.gemstone.gemfire.test.dunit.Assert; import com.gemstone.gemfire.test.dunit.DistributedTestCase; import com.gemstone.gemfire.test.dunit.Host; +import com.gemstone.gemfire.test.dunit.IgnoredException; +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.internal.cache.CacheServerImpl; /** @@ -81,8 +86,8 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase server2 = host.getVM(1); server3 = host.getVM(2); - addExpectedException("java.io.IOException"); - addExpectedException("SocketException"); + IgnoredException.addIgnoredException("java.io.IOException"); + IgnoredException.addIgnoredException("SocketException"); // start servers first PORT1 = ((Integer) server1.invoke(HAStartupAndFailoverDUnitTest.class, "createServerCache")); @@ -98,7 +103,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase public void testPrimaryFailover() throws Exception { - createClientCache(this.getName(), getServerHostName(server1.getHost())); + createClientCache(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); // primary server1.invoke(HAStartupAndFailoverDUnitTest.class, "verifyDispatcherIsAlive"); @@ -146,7 +151,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase public void testExceptionWhileMakingPrimary()throws Exception { - createClientCacheWithIncorrectPrimary(this.getName(), getServerHostName(server1.getHost())); + createClientCacheWithIncorrectPrimary(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); // failed primary due to incorect host name of the server // new primary @@ -175,7 +180,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase public void testTwoPrimaryFailedOneAfterTheAnother() throws Exception { - createClientCacheWithLargeRetryInterval(this.getName(), getServerHostName(server1.getHost())); + createClientCacheWithLargeRetryInterval(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); // primary server1.invoke(HAStartupAndFailoverDUnitTest.class, "verifyDispatcherIsAlive"); @@ -202,7 +207,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase */ public void testPrimaryShouldBeNullAndEPListShouldBeEmptyWhenAllServersAreDead() throws Exception { - createClientCache(this.getName(), getServerHostName(server1.getHost())); + createClientCache(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); verifyPrimaryShouldNotBeNullAndEPListShouldNotBeEmpty(); server1.invoke(HAStartupAndFailoverDUnitTest.class, "stopServer"); server2.invoke(HAStartupAndFailoverDUnitTest.class, "stopServer"); @@ -216,7 +221,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase */ public void testCacheClientUpdatersInitiatesFailoverOnPrimaryFailure() throws Exception { - createClientCacheWithLargeRetryInterval(this.getName(), getServerHostName(server1.getHost())); + createClientCacheWithLargeRetryInterval(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); server1.invoke(HAStartupAndFailoverDUnitTest.class, "verifyDispatcherIsAlive"); server2.invoke(HAStartupAndFailoverDUnitTest.class, "verifyDispatcherIsNotAlive"); server3.invoke(HAStartupAndFailoverDUnitTest.class, "verifyDispatcherIsNotAlive"); @@ -234,7 +239,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase */ public void testCacheClientUpdaterInitiatesFailoverOnSecondaryFailure() throws Exception { - createClientCacheWithLargeRetryInterval(this.getName(), getServerHostName(server1.getHost())); + createClientCacheWithLargeRetryInterval(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); server1.invoke(HAStartupAndFailoverDUnitTest.class, "verifyDispatcherIsAlive"); server2.invoke(HAStartupAndFailoverDUnitTest.class, "verifyDispatcherIsNotAlive"); server3.invoke(HAStartupAndFailoverDUnitTest.class, "verifyDispatcherIsNotAlive"); @@ -253,7 +258,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase public void testCacheClientUpdaterInitiatesFailoverOnBothPrimaryAndSecondaryFailure() throws Exception { - createClientCacheWithLargeRetryInterval(this.getName(), getServerHostName(server1.getHost())); + createClientCacheWithLargeRetryInterval(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); server1.invoke(HAStartupAndFailoverDUnitTest.class, "verifyDispatcherIsAlive"); server2.invoke(HAStartupAndFailoverDUnitTest.class, "verifyDispatcherIsNotAlive"); server3.invoke(HAStartupAndFailoverDUnitTest.class, "verifyDispatcherIsNotAlive"); @@ -271,7 +276,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase public void testCacheClientUpdaterInitiatesFailoverOnBothPrimaryAndSecondaryFailureWithServerMonitors() throws Exception { - createClientCache(this.getName(), getServerHostName(server1.getHost())); + createClientCache(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); server1.invoke(HAStartupAndFailoverDUnitTest.class, "verifyDispatcherIsAlive"); server2.invoke(HAStartupAndFailoverDUnitTest.class, "verifyDispatcherIsNotAlive"); server3.invoke(HAStartupAndFailoverDUnitTest.class, "verifyDispatcherIsNotAlive"); @@ -290,7 +295,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase // create a client with large retry interval for server monitors and no client updater thread // so that only cache operation can detect a server failure and should initiate failover createClientCacheWithLargeRetryIntervalAndWithoutCallbackConnection(this.getName() - , getServerHostName(server1.getHost())); + , NetworkUtils.getServerHostName(server1.getHost())); server2.invoke(HAStartupAndFailoverDUnitTest.class, "stopServer"); put(); verifyDeadAndLiveServers(1,2); @@ -305,7 +310,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase r1.put("key-3", "server-value-3"); } catch (Exception ex) { - fail("failed while r.put()", ex); + Assert.fail("failed while r.put()", ex); } } @@ -321,7 +326,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase return excuse; } }; - DistributedTestCase.waitForCriterion(wc, 60 * 1000, 1000, true); + Wait.waitForCriterion(wc, 60 * 1000, 1000, true); // while (proxy.getDeadServers().size() != expectedDeadServers) { // wait until condition is met // assertTrue("Waited over " + maxWaitTime + "for dead servers to become : " + expectedDeadServers , // //" This issue can occur on Solaris as DSM thread get stuck in connectForServer() call, and hence not recovering any newly started server. This may be beacuase of tcp_ip_abort_cinterval kernal level property on solaris which has 3 minutes as a default value ", @@ -393,7 +398,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase assertNotNull(" Primary endpoint should not be null", pool.getPrimaryName()); assertTrue("Endpoint List should not be Empty as all server are live",pool.getConnectedServerCount() > 0); }catch(Exception e){ - fail("failed while verifyPrimaryShouldNotBeNullAndEPListShouldNotBeEmpty()", e); + Assert.fail("failed while verifyPrimaryShouldNotBeNullAndEPListShouldNotBeEmpty()", e); } } @@ -404,7 +409,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase } catch (NoSubscriptionServersAvailableException e) { // pass } catch(Exception e){ - fail("failed while verifyPrimaryShouldBeNullAndEPListShouldBeEmpty()", e); + Assert.fail("failed while verifyPrimaryShouldBeNullAndEPListShouldBeEmpty()", e); } } @@ -462,7 +467,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase return excuse; } }; - DistributedTestCase.waitForCriterion(wc, 60 * 1000, 1000, true); + Wait.waitForCriterion(wc, 60 * 1000, 1000, true); CacheServerImpl bs = (CacheServerImpl)cache.getCacheServers() .iterator().next(); @@ -479,7 +484,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase return excuse; } }; - DistributedTestCase.waitForCriterion(wc, 60 * 1000, 1000, true); + Wait.waitForCriterion(wc, 60 * 1000, 1000, true); Collection<CacheClientProxy> proxies = ccn.getClientProxies(); Iterator<CacheClientProxy> iter_prox = proxies.iterator(); @@ -495,7 +500,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase return excuse; } }; - DistributedTestCase.waitForCriterion(wc, 60 * 1000, 1000, true); + Wait.waitForCriterion(wc, 60 * 1000, 1000, true); // assertTrue("Dispatcher on primary should be alive", // proxy._messageDispatcher.isAlive()); @@ -522,7 +527,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase return excuse; } }; - DistributedTestCase.waitForCriterion(wc, 60 * 1000, 1000, true); + Wait.waitForCriterion(wc, 60 * 1000, 1000, true); CacheServerImpl bs = (CacheServerImpl)c.getCacheServers().iterator() .next(); @@ -539,7 +544,7 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase return excuse; } }; - DistributedTestCase.waitForCriterion(wc, 60 * 1000, 1000, true); + Wait.waitForCriterion(wc, 60 * 1000, 1000, true); Iterator iter_prox = ccn.getClientProxies().iterator(); if (iter_prox.hasNext()) { @@ -712,9 +717,8 @@ public class HAStartupAndFailoverDUnitTest extends DistributedTestCase } - public void tearDown2() throws Exception - { - super.tearDown2(); + @Override + protected final void preTearDown() throws Exception { // close the clients first closeCache(); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InstantiatorPropagationDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InstantiatorPropagationDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InstantiatorPropagationDUnitTest.java index 17ef1cc..c6f71e2 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InstantiatorPropagationDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InstantiatorPropagationDUnitTest.java @@ -16,6 +16,8 @@ */ package com.gemstone.gemfire.internal.cache.tier.sockets; +import static com.gemstone.gemfire.test.dunit.DistributedTestUtils.*; + import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; @@ -45,9 +47,14 @@ 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.Assert; import com.gemstone.gemfire.test.dunit.DistributedTestCase; import com.gemstone.gemfire.test.dunit.Host; +import com.gemstone.gemfire.test.dunit.Invoke; +import com.gemstone.gemfire.test.dunit.NetworkUtils; import com.gemstone.gemfire.test.dunit.VM; +import com.gemstone.gemfire.test.dunit.Wait; +import com.gemstone.gemfire.test.dunit.WaitCriterion; public class InstantiatorPropagationDUnitTest extends DistributedTestCase { private static Cache cache = null; @@ -144,8 +151,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { } @Override - public void tearDown2() throws Exception { - super.tearDown2(); + protected final void preTearDown() throws Exception { // close the clients first closeCache(); client1.invoke(InstantiatorPropagationDUnitTest.class, "closeCache"); @@ -163,7 +169,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { } public static void unregisterInstantiatorsInAllVMs() { - invokeInEveryVM(DistributedTestCase.class, "unregisterInstantiatorsInThisVM"); + Invoke.invokeInEveryVM(()->unregisterInstantiatorsInThisVM()); } public static void verifyInstantiators(final int numOfInstantiators) { @@ -180,7 +186,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { + " instantiators=" + java.util.Arrays.toString(InternalInstantiator.getInstantiators()); } }; - DistributedTestCase.waitForCriterion(wc, 60 * 1000, 1000, true); + Wait.waitForCriterion(wc, 60 * 1000, 1000, true); } public static void registerTestObject1() throws Exception { @@ -192,7 +198,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject1", e); + Assert.fail("Test failed due to exception in TestObject1", e); } } @@ -204,7 +210,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject2", e); + Assert.fail("Test failed due to exception in TestObject2", e); } } @@ -216,7 +222,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject3", e); + Assert.fail("Test failed due to exception in TestObject3", e); } } @@ -228,7 +234,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject4", e); + Assert.fail("Test failed due to exception in TestObject4", e); } } @@ -240,7 +246,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject5", e); + Assert.fail("Test failed due to exception in TestObject5", e); } } @@ -252,7 +258,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject6", e); + Assert.fail("Test failed due to exception in TestObject6", e); } } @@ -264,7 +270,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject7", e); + Assert.fail("Test failed due to exception in TestObject7", e); } } @@ -276,7 +282,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject8", e); + Assert.fail("Test failed due to exception in TestObject8", e); } } @@ -288,7 +294,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject9", e); + Assert.fail("Test failed due to exception in TestObject9", e); } } @@ -300,7 +306,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject10", e); + Assert.fail("Test failed due to exception in TestObject10", e); } } @@ -312,7 +318,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject11", e); + Assert.fail("Test failed due to exception in TestObject11", e); } } @@ -324,7 +330,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject11", e); + Assert.fail("Test failed due to exception in TestObject11", e); } } @@ -336,7 +342,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject13", e); + Assert.fail("Test failed due to exception in TestObject13", e); } } @@ -348,7 +354,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject14", e); + Assert.fail("Test failed due to exception in TestObject14", e); } } @@ -360,7 +366,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject15", e); + Assert.fail("Test failed due to exception in TestObject15", e); } } @@ -372,7 +378,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject16", e); + Assert.fail("Test failed due to exception in TestObject16", e); } } @@ -384,7 +390,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject17", e); + Assert.fail("Test failed due to exception in TestObject17", e); } } @@ -396,7 +402,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject18", e); + Assert.fail("Test failed due to exception in TestObject18", e); } } @@ -408,7 +414,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject19", e); + Assert.fail("Test failed due to exception in TestObject19", e); } } @@ -420,7 +426,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { obj.init(0); } catch (Exception e) { - fail("Test failed due to exception in TestObject20", e); + Assert.fail("Test failed due to exception in TestObject20", e); } } @@ -463,7 +469,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { unregisterInstantiatorsInAllVMs(); - pause(3000); + Wait.pause(3000); server1.invoke(InstantiatorPropagationDUnitTest.class, "registerTestObject1"); @@ -475,11 +481,11 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { client1 .invoke(InstantiatorPropagationDUnitTest.class, "createClientCache", - new Object[] { getServerHostName(server1.getHost()), + new Object[] { NetworkUtils.getServerHostName(server1.getHost()), new Integer(PORT1) }); // // wait for client2 to come online - pause(3000); + Wait.pause(3000); // client1.invoke(InstantiatorPropagationDUnitTest.class, "verifyInstantiators", new Object[] { new Integer(2) }); @@ -512,7 +518,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { } }); // - pause(3000); + Wait.pause(3000); // Run getAll client1.invoke(new CacheSerializableRunnable("Get entry from client") { public void run2() throws CacheException { @@ -536,26 +542,26 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { PORT1 = initServerCache(server1); PORT2 = initServerCache(server2); - pause(3000); + Wait.pause(3000); client1 .invoke(InstantiatorPropagationDUnitTest.class, "createClientCache", - new Object[] { getServerHostName(server1.getHost()), + new Object[] { NetworkUtils.getServerHostName(server1.getHost()), new Integer(PORT1) }); client2 .invoke(InstantiatorPropagationDUnitTest.class, "createClientCache", - new Object[] { getServerHostName(server1.getHost()), + new Object[] { NetworkUtils.getServerHostName(server1.getHost()), new Integer(PORT2) }); unregisterInstantiatorsInAllVMs(); // wait for client2 to come online - pause(2000); + Wait.pause(2000); client1.invoke(InstantiatorPropagationDUnitTest.class, "registerTestObject3"); - pause(4000); + Wait.pause(4000); client1.invoke(InstantiatorPropagationDUnitTest.class, "verifyInstantiators", new Object[] { new Integer(1) }); @@ -584,21 +590,21 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { client1 .invoke(InstantiatorPropagationDUnitTest.class, "createClientCache", - new Object[] { getServerHostName(server1.getHost()), + new Object[] { NetworkUtils.getServerHostName(server1.getHost()), new Integer(PORT1) }); client2 .invoke(InstantiatorPropagationDUnitTest.class, "createClientCache", - new Object[] { getServerHostName(server1.getHost()), + new Object[] { NetworkUtils.getServerHostName(server1.getHost()), new Integer(PORT2) }); unregisterInstantiatorsInAllVMs(); // wait for client2 to come online - pause(2000); + Wait.pause(2000); client1.invoke(InstantiatorPropagationDUnitTest.class, "registerTestObject4"); - pause(4000); + Wait.pause(4000); server1.invoke(InstantiatorPropagationDUnitTest.class, "stopServer"); @@ -639,25 +645,25 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { client1 .invoke(InstantiatorPropagationDUnitTest.class, "createClientCache", - new Object[] { getServerHostName(server1.getHost()), + new Object[] { NetworkUtils.getServerHostName(server1.getHost()), new Integer(PORT1) }); client2 .invoke(InstantiatorPropagationDUnitTest.class, "createClientCache", - new Object[] { getServerHostName(server1.getHost()), + new Object[] { NetworkUtils.getServerHostName(server1.getHost()), new Integer(PORT2) }); unregisterInstantiatorsInAllVMs(); // wait for client2 to come online - pause(2000); + Wait.pause(2000); client1.invoke(InstantiatorPropagationDUnitTest.class, "registerTestObject10"); - pause(4000); + Wait.pause(4000); server1.invoke(InstantiatorPropagationDUnitTest.class, "registerTestObject11"); - pause(4000); + Wait.pause(4000); server2.invoke(InstantiatorPropagationDUnitTest.class, "verifyInstantiators", new Object[] { new Integer(2) }); @@ -683,11 +689,11 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { PORT2 = initServerCache(server2); client1 .invoke(InstantiatorPropagationDUnitTest.class, "createClientCache", - new Object[] { getServerHostName(server1.getHost()), + new Object[] { NetworkUtils.getServerHostName(server1.getHost()), new Integer(PORT1) }); client2 .invoke(InstantiatorPropagationDUnitTest.class, "createClientCache", - new Object[] { getServerHostName(server1.getHost()), + new Object[] { NetworkUtils.getServerHostName(server1.getHost()), new Integer(PORT2) }); unregisterInstantiatorsInAllVMs(); @@ -751,21 +757,21 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { client1 .invoke(InstantiatorPropagationDUnitTest.class, "createClientCache", - new Object[] { getServerHostName(server1.getHost()), + new Object[] { NetworkUtils.getServerHostName(server1.getHost()), new Integer(PORT1) }); client2 .invoke(InstantiatorPropagationDUnitTest.class, "createClientCache", - new Object[] { getServerHostName(server1.getHost()), + new Object[] { NetworkUtils.getServerHostName(server1.getHost()), new Integer(PORT1) }); - createClientCache(getServerHostName(server2.getHost()), new Integer(PORT2)); + createClientCache(NetworkUtils.getServerHostName(server2.getHost()), new Integer(PORT2)); unregisterInstantiatorsInAllVMs(); // wait for client2 to come online - pause(2000); + Wait.pause(2000); client1.invoke(InstantiatorPropagationDUnitTest.class, "registerTestObject12"); - pause(4000); + Wait.pause(4000); client1.invoke(InstantiatorPropagationDUnitTest.class, "verifyInstantiators", new Object[] { new Integer(1) }); @@ -810,20 +816,20 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { PORT1 = initServerCache(server1, 1); PORT2 = initServerCache(server2, 2); - createClientCache_EventId(getServerHostName(server1.getHost()), new Integer(PORT1)); + createClientCache_EventId(NetworkUtils.getServerHostName(server1.getHost()), new Integer(PORT1)); unregisterInstantiatorsInAllVMs(); client2.invoke(InstantiatorPropagationDUnitTest.class, "createClientCache_EventId", new Object[] { - getServerHostName(server1.getHost()), new Integer(PORT2) }); + NetworkUtils.getServerHostName(server1.getHost()), new Integer(PORT2) }); setClientServerObserver1(); client2.invoke(InstantiatorPropagationDUnitTest.class, "setClientServerObserver2"); registerTestObject19(); - pause(10000); + Wait.pause(10000); Boolean pass = (Boolean)client2.invoke( InstantiatorPropagationDUnitTest.class, "verifyResult"); @@ -841,17 +847,17 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { unregisterInstantiatorsInAllVMs(); - pause(3000); + Wait.pause(3000); - createClientCache(getServerHostName(server1.getHost()), + createClientCache(NetworkUtils.getServerHostName(server1.getHost()), new Integer(PORT1)); client2 .invoke(InstantiatorPropagationDUnitTest.class, "createClientCache", - new Object[] {getServerHostName(server2.getHost()), + new Object[] {NetworkUtils.getServerHostName(server2.getHost()), new Integer(PORT2)}); - pause(3000); + Wait.pause(3000); unregisterInstantiatorsInAllVMs(); assertTestObject20NotLoaded(); @@ -860,7 +866,7 @@ public class InstantiatorPropagationDUnitTest extends DistributedTestCase { client2.invoke(InstantiatorPropagationDUnitTest.class, "assertTestObject20NotLoaded"); registerTestObject20(); - pause(5000); + Wait.pause(5000); assertTestObject20Loaded(); server1.invoke(InstantiatorPropagationDUnitTest.class, "assertTestObject20Loaded"); //server2.invoke(InstantiatorPropagationDUnitTest.class, "assertTestObject20Loaded"); // classes are not initialized after loading in p2p path http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListDUnitTest.java index 8bc4e42..06f599f 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListDUnitTest.java @@ -47,10 +47,16 @@ 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.CacheServerImpl; +import com.gemstone.gemfire.test.dunit.Assert; import com.gemstone.gemfire.test.dunit.DistributedTestCase; import com.gemstone.gemfire.test.dunit.Host; +import com.gemstone.gemfire.test.dunit.Invoke; +import com.gemstone.gemfire.test.dunit.LogWriterUtils; +import com.gemstone.gemfire.test.dunit.NetworkUtils; import com.gemstone.gemfire.test.dunit.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.cache.client.*; import com.gemstone.gemfire.cache.NoSubscriptionServersAvailableException; @@ -131,7 +137,7 @@ public class InterestListDUnitTest extends DistributedTestCase public void setUp() throws Exception { super.setUp(); disconnectAllFromDS(); - pause(10000); + Wait.pause(10000); final Host host = Host.getHost(0); vm0 = host.getVM(0); vm1 = host.getVM(1); @@ -161,9 +167,9 @@ public class InterestListDUnitTest extends DistributedTestCase { vm1.invoke(InterestListDUnitTest.class, "createClientCache",new Object[] { - getServerHostName(vm0.getHost()), new Integer(PORT1)}); + NetworkUtils.getServerHostName(vm0.getHost()), new Integer(PORT1)}); vm2.invoke(InterestListDUnitTest.class, "createClientCache",new Object[] { - getServerHostName(vm0.getHost()), new Integer(PORT1)}); + NetworkUtils.getServerHostName(vm0.getHost()), new Integer(PORT1)}); vm1.invoke(InterestListDUnitTest.class, "createEntriesK1andK2"); vm2.invoke(InterestListDUnitTest.class, "createEntriesK1andK2"); @@ -174,11 +180,11 @@ public class InterestListDUnitTest extends DistributedTestCase new Object[] { key2 }); vm1.invoke(InterestListDUnitTest.class, "put", new Object[] { "vm1" }); - pause(10000); + Wait.pause(10000); vm2.invoke(InterestListDUnitTest.class, "validateEntriesK1andK2", new Object[] { "vm2" }); vm2.invoke(InterestListDUnitTest.class, "put", new Object[] { "vm2" }); - pause(10000); + Wait.pause(10000); vm1.invoke(InterestListDUnitTest.class, "validateEntriesK1andK2", new Object[] { "vm1" }); @@ -188,11 +194,11 @@ public class InterestListDUnitTest extends DistributedTestCase new Object[] { key2 }); vm1.invoke(InterestListDUnitTest.class, "putAgain", new Object[] { "vm1" }); - pause(10000); + Wait.pause(10000); vm2.invoke(InterestListDUnitTest.class, "validateEntriesAgain", new Object[] { "vm2" }); vm2.invoke(InterestListDUnitTest.class, "putAgain", new Object[] { "vm2" }); - pause(10000); + Wait.pause(10000); vm1.invoke(InterestListDUnitTest.class, "validateEntriesAgain", new Object[] { "vm1" }); } @@ -226,9 +232,9 @@ public class InterestListDUnitTest extends DistributedTestCase // Initialization vm1.invoke(InterestListDUnitTest.class, "createClientCache", - new Object[] { getServerHostName(Host.getHost(0)), new Integer(PORT1)}); + new Object[] { NetworkUtils.getServerHostName(Host.getHost(0)), new Integer(PORT1)}); vm2.invoke(InterestListDUnitTest.class, "createClientCache", - new Object[] { getServerHostName(Host.getHost(0)), new Integer(PORT1)}); + new Object[] { NetworkUtils.getServerHostName(Host.getHost(0)), new Integer(PORT1)}); vm1.invoke(InterestListDUnitTest.class, "createEntriesK1andK2"); vm2.invoke(InterestListDUnitTest.class, "createEntriesK1andK2"); @@ -236,7 +242,7 @@ public class InterestListDUnitTest extends DistributedTestCase // STEP 1 vm2.invoke(InterestListDUnitTest.class, "putSingleEntry", new Object[] { key2, "vm2" }); - pause(2000); + Wait.pause(2000); vm1.invoke(InterestListDUnitTest.class, "validateSingleEntry", new Object[] {key2, key2_originalValue}); @@ -254,7 +260,7 @@ public class InterestListDUnitTest extends DistributedTestCase // STEP 3 vm1.invoke(InterestListDUnitTest.class, "putSingleEntry", new Object[] { key1, "vm1" }); - pause(2000); + Wait.pause(2000); vm2.invoke(InterestListDUnitTest.class, "validateSingleEntry", new Object[] {key1, key1_originalValue}); // still unchanged vm2.invoke(InterestListDUnitTest.class, "registerKey", @@ -269,7 +275,7 @@ public class InterestListDUnitTest extends DistributedTestCase new Object[] { key1 }); vm1.invoke(InterestListDUnitTest.class, "putSingleEntry", new Object[] { key1, key1_originalValue }); - pause(2000); + Wait.pause(2000); vm2.invoke(InterestListDUnitTest.class, "validateSingleEntry", new Object[] {key1, "vm1"}); // update lost } @@ -284,9 +290,9 @@ public class InterestListDUnitTest extends DistributedTestCase { vm1.invoke(InterestListDUnitTest.class, "createClientCache",new Object[] { - getServerHostName(vm0.getHost()), new Integer(PORT1)}); + NetworkUtils.getServerHostName(vm0.getHost()), new Integer(PORT1)}); vm2.invoke(InterestListDUnitTest.class, "createClientCache",new Object[] { - getServerHostName(vm0.getHost()), new Integer(PORT1)}); + NetworkUtils.getServerHostName(vm0.getHost()), new Integer(PORT1)}); vm1.invoke(InterestListDUnitTest.class, "createEntriesK1andK2"); vm2.invoke(InterestListDUnitTest.class, "createEntriesK1andK2"); @@ -294,7 +300,7 @@ public class InterestListDUnitTest extends DistributedTestCase vm2.invoke(InterestListDUnitTest.class, "registerALL_KEYS"); vm1.invoke(InterestListDUnitTest.class, "put_ALL_KEYS"); - pause(10000); + Wait.pause(10000); vm2.invoke(InterestListDUnitTest.class, "validate_ALL_KEYS"); } @@ -311,17 +317,17 @@ public class InterestListDUnitTest extends DistributedTestCase { // directly put on server vm0.invoke(InterestListDUnitTest.class, "multiple_put"); - pause(1000); + Wait.pause(1000); // create clients to connect to that server vm1.invoke(InterestListDUnitTest.class, "createClientCache",new Object[] { - getServerHostName(vm0.getHost()), new Integer(PORT1)}); + NetworkUtils.getServerHostName(vm0.getHost()), new Integer(PORT1)}); vm2.invoke(InterestListDUnitTest.class, "createClientCache",new Object[] { - getServerHostName(vm0.getHost()), new Integer(PORT1)}); + NetworkUtils.getServerHostName(vm0.getHost()), new Integer(PORT1)}); // register interest vm1.invoke(InterestListDUnitTest.class, "registerKeys"); vm2.invoke(InterestListDUnitTest.class, "registerKeysAgain"); - pause(10000); + Wait.pause(10000); // verify the values for registered keys vm1.invoke(InterestListDUnitTest.class, "validateRegionEntriesFromInterestListInVm1"); @@ -352,10 +358,10 @@ public class InterestListDUnitTest extends DistributedTestCase DistributedMember c1 = (DistributedMember)vm1 .invoke(InterestListDUnitTest.class, "createClientCache",new Object[] { - getServerHostName(vm0.getHost()), PORT1}); + NetworkUtils.getServerHostName(vm0.getHost()), PORT1}); DistributedMember c2 = (DistributedMember)vm2 .invoke(InterestListDUnitTest.class, "createClientCache",new Object[] { - getServerHostName(vm0.getHost()), PORT1}); + NetworkUtils.getServerHostName(vm0.getHost()), PORT1}); vm1.invoke(InterestListDUnitTest.class, "createEntriesK1andK2"); vm2.invoke(InterestListDUnitTest.class, "createEntriesK1andK2"); @@ -413,7 +419,7 @@ public class InterestListDUnitTest extends DistributedTestCase server = addCacheServer(); port2 = server.getPort(); } catch (Exception ex) { - fail("Cache creation threw an exception", ex); + Assert.fail("Cache creation threw an exception", ex); } addRegisterInterestListener(); @@ -422,17 +428,17 @@ public class InterestListDUnitTest extends DistributedTestCase // servers are set up, now do the clients DistributedMember c1 = (DistributedMember)vm1 .invoke(InterestListDUnitTest.class, "createClientCache",new Object[] { - getServerHostName(vm0.getHost()), PORT1, port2}); + NetworkUtils.getServerHostName(vm0.getHost()), PORT1, port2}); DistributedMember c2 = (DistributedMember)vm2 .invoke(InterestListDUnitTest.class, "createClientCache",new Object[] { - getServerHostName(vm0.getHost()), PORT1, port2}); + NetworkUtils.getServerHostName(vm0.getHost()), PORT1, port2}); vm1.invoke(InterestListDUnitTest.class, "createEntriesK1andK2"); vm2.invoke(InterestListDUnitTest.class, "createEntriesK1andK2"); // interest registration from clients should cause listeners to be invoked // in both servers - getLogWriter().info("test phase 1"); + LogWriterUtils.getLogWriter().info("test phase 1"); vm1.invoke(InterestListDUnitTest.class, "registerKey", new Object[] { key1 }); vm2.invoke(InterestListDUnitTest.class, "registerKey", @@ -446,7 +452,7 @@ public class InterestListDUnitTest extends DistributedTestCase new Object[]{ two, zero }); // unregistration from clients should invoke listeners on both servers - getLogWriter().info("test phase 2"); + LogWriterUtils.getLogWriter().info("test phase 2"); vm1.invoke(InterestListDUnitTest.class, "unregisterKey", new Object[] { key1 }); vm2.invoke(InterestListDUnitTest.class, "unregisterKey", @@ -457,7 +463,7 @@ public class InterestListDUnitTest extends DistributedTestCase new Object[]{ zero, two }); // now the primary server for eache client will register and unregister - getLogWriter().info("test phase 3"); + LogWriterUtils.getLogWriter().info("test phase 3"); registerKeyForClient(c1, key1); vm0.invoke(InterestListDUnitTest.class, "registerKeyForClient", new Object[] { c1, key1 }); @@ -469,7 +475,7 @@ public class InterestListDUnitTest extends DistributedTestCase vm0.invoke(InterestListDUnitTest.class, "verifyCountsAndClear", new Object[]{ two, zero }); - getLogWriter().info("test phase 4"); + LogWriterUtils.getLogWriter().info("test phase 4"); unregisterKeyForClient(c1, key1); vm0.invoke(InterestListDUnitTest.class, "unregisterKeyForClient", new Object[] { c1, key1 }); @@ -490,7 +496,7 @@ public class InterestListDUnitTest extends DistributedTestCase // Register interest in key1. vm1.invoke(InterestListDUnitTest.class, "createClientCache", - new Object[] { getServerHostName(vm0.getHost()), new Integer(PORT1) }); + new Object[] { NetworkUtils.getServerHostName(vm0.getHost()), new Integer(PORT1) }); vm1.invoke(InterestListDUnitTest.class, "registerKey", new Object[] { key1 }); @@ -529,7 +535,7 @@ public class InterestListDUnitTest extends DistributedTestCase // Create client cache vm1.invoke(InterestListDUnitTest.class, "createClientCache",new Object[] { - getServerHostName(vm0.getHost()), port1, port2}); + NetworkUtils.getServerHostName(vm0.getHost()), port1, port2}); // Register interest in all keys vm1.invoke(InterestListDUnitTest.class, "registerALL_KEYS"); @@ -657,7 +663,7 @@ public class InterestListDUnitTest extends DistributedTestCase return "waiting for queues to drain for " + fproxy.getProxyID(); } }; - DistributedTestCase.waitForCriterion(ev, 5 * 10 * 1000, 200, true); + Wait.waitForCriterion(ev, 5 * 10 * 1000, 200, true); } } @@ -703,7 +709,7 @@ public class InterestListDUnitTest extends DistributedTestCase return "waiting for " + fCacheListener.getExpectedCreates() + " create events"; } }; - DistributedTestCase.waitForCriterion(ev, 5 * 10 * 1000, 200, true); + Wait.waitForCriterion(ev, 5 * 10 * 1000, 200, true); } private static void confirmNoCacheListenerUpdates() throws Exception { @@ -742,7 +748,7 @@ public class InterestListDUnitTest extends DistributedTestCase assertEquals(r.getEntry(key2).getValue(), key2_originalValue); } catch (Exception ex) { - fail("failed while createEntries()", ex); + Assert.fail("failed while createEntries()", ex); } } @@ -759,7 +765,7 @@ public class InterestListDUnitTest extends DistributedTestCase registerKeyOnly(key); } catch (Exception ex) { - fail("failed while registering key(" + key + ")", ex); + Assert.fail("failed while registering key(" + key + ")", ex); } } @@ -777,7 +783,7 @@ public class InterestListDUnitTest extends DistributedTestCase InterestResultPolicy.KEYS_VALUES, false); } } catch (Exception ex) { - fail("failed while registering key(" + key + ")", ex); + Assert.fail("failed while registering key(" + key + ")", ex); } } @@ -789,7 +795,7 @@ public class InterestListDUnitTest extends DistributedTestCase } catch (NoSubscriptionServersAvailableException ex) { // expected an exception - getLogWriter().info("Got expected exception in registerKey: "); + LogWriterUtils.getLogWriter().info("Got expected exception in registerKey: "); } } @@ -801,7 +807,7 @@ public class InterestListDUnitTest extends DistributedTestCase r.registerInterest("ALL_KEYS"); } catch (Exception ex) { - fail("failed while registering ALL_KEYS", ex); + Assert.fail("failed while registering ALL_KEYS", ex); } } @@ -817,7 +823,7 @@ public class InterestListDUnitTest extends DistributedTestCase assertEquals(r.getEntry(key2).getValue(), "vm1-key-2"); } catch (Exception ex) { - fail("failed while put_ALL_KEY()", ex); + Assert.fail("failed while put_ALL_KEY()", ex); } } @@ -830,7 +836,7 @@ public class InterestListDUnitTest extends DistributedTestCase assertEquals(r.getEntry(key2).getValue(), "vm1-key-2"); } catch (Exception ex) { - fail("failed while validate_ALL_KEY", ex); + Assert.fail("failed while validate_ALL_KEY", ex); } } @@ -845,7 +851,7 @@ public class InterestListDUnitTest extends DistributedTestCase r.registerInterest(list); } catch (Exception ex) { - fail("failed while registering keys" + list + "", ex); + Assert.fail("failed while registering keys" + list + "", ex); } } @@ -860,7 +866,7 @@ public class InterestListDUnitTest extends DistributedTestCase r.registerInterest(list); } catch (Exception ex) { - fail("failed while registering keys" + list + "", ex); + Assert.fail("failed while registering keys" + list + "", ex); } } @@ -877,7 +883,7 @@ public class InterestListDUnitTest extends DistributedTestCase unregisterKeyOnly(key); } catch (Exception ex) { - fail("failed while un-registering key(" + key + ")", ex); + Assert.fail("failed while un-registering key(" + key + ")", ex); } } @@ -895,7 +901,7 @@ public class InterestListDUnitTest extends DistributedTestCase } } catch (Exception ex) { - fail("failed while un-registering key(" + key + ") for client " + clientId, ex); + Assert.fail("failed while un-registering key(" + key + ") for client " + clientId, ex); } } @@ -934,7 +940,7 @@ public class InterestListDUnitTest extends DistributedTestCase assertEquals(r.getEntry(key).getValue(), value); } catch (Exception ex) { - fail("failed while r.put()", ex); + Assert.fail("failed while r.put()", ex); } } @@ -960,7 +966,7 @@ public class InterestListDUnitTest extends DistributedTestCase } catch (Exception ex) { - fail("failed while r.put()", ex); + Assert.fail("failed while r.put()", ex); } } @@ -977,7 +983,7 @@ public class InterestListDUnitTest extends DistributedTestCase } catch (Exception ex) { - fail("failed while r.put()", ex); + Assert.fail("failed while r.put()", ex); } } @@ -1003,7 +1009,7 @@ public class InterestListDUnitTest extends DistributedTestCase } catch (Exception ex) { - fail("failed while r.putAgain()", ex); + Assert.fail("failed while r.putAgain()", ex); } } @@ -1036,7 +1042,7 @@ public class InterestListDUnitTest extends DistributedTestCase return "waiting for client to apply events from server"; } }; - DistributedTestCase.waitForCriterion(ev, 5 * 10 * 1000, 200, true); + Wait.waitForCriterion(ev, 5 * 10 * 1000, 200, true); } public static void validateSingleEntry(Object key, String value) { @@ -1045,7 +1051,7 @@ public class InterestListDUnitTest extends DistributedTestCase assertEquals(value, r.getEntry(key).getValue()); } catch (Exception ex) { - fail("failed while validateSingleEntry()", ex); + Assert.fail("failed while validateSingleEntry()", ex); } } @@ -1067,19 +1073,19 @@ public class InterestListDUnitTest extends DistributedTestCase } } catch (Exception ex) { - fail("failed while r.put()", ex); + Assert.fail("failed while r.put()", ex); } } - public void tearDown2() throws Exception - { + @Override + protected final void preTearDown() throws Exception { // close the clients first vm1.invoke(InterestListDUnitTest.class, "closeCache"); vm2.invoke(InterestListDUnitTest.class, "closeCache"); // then close the servers vm0.invoke(InterestListDUnitTest.class, "closeCache"); cache = null; - invokeInEveryVM(new SerializableRunnable() { public void run() { cache = null; } }); + Invoke.invokeInEveryVM(new SerializableRunnable() { public void run() { cache = null; } }); } public static void closeCache() @@ -1098,7 +1104,7 @@ public class InterestListDUnitTest extends DistributedTestCase * @see com.gemstone.gemfire.cache.InterestRegistrationListener#afterRegisterInterest(com.gemstone.gemfire.cache.InterestRegistrationEvent) */ public void afterRegisterInterest(InterestRegistrationEvent event) { - getLogWriter().info("InterestListener.afterRegisterInterest invoked with this event: " + event); + LogWriterUtils.getLogWriter().info("InterestListener.afterRegisterInterest invoked with this event: " + event); registrationCount++; } @@ -1106,7 +1112,7 @@ public class InterestListDUnitTest extends DistributedTestCase * @see com.gemstone.gemfire.cache.InterestRegistrationListener#afterUnregisterInterest(com.gemstone.gemfire.cache.InterestRegistrationEvent) */ public void afterUnregisterInterest(InterestRegistrationEvent event) { - getLogWriter().info("InterestListener.afterUnregisterInterest invoked with this event: " + event); + LogWriterUtils.getLogWriter().info("InterestListener.afterUnregisterInterest invoked with this event: " + event); unregistrationCount++; } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListEndpointDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListEndpointDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListEndpointDUnitTest.java index 1faa051..b8db844 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListEndpointDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListEndpointDUnitTest.java @@ -46,8 +46,12 @@ import com.gemstone.gemfire.internal.AvailablePort; import com.gemstone.gemfire.internal.cache.CacheServerImpl; import com.gemstone.gemfire.test.dunit.DistributedTestCase; import com.gemstone.gemfire.test.dunit.Host; +import com.gemstone.gemfire.test.dunit.Invoke; +import com.gemstone.gemfire.test.dunit.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; /** * @@ -89,7 +93,7 @@ public class InterestListEndpointDUnitTest extends DistributedTestCase public void setUp() throws Exception { super.setUp(); disconnectAllFromDS(); - pause(5000); + Wait.pause(5000); final Host host = Host.getHost(0); server1 = host.getVM(0); server2 = host.getVM(1); @@ -105,9 +109,9 @@ public class InterestListEndpointDUnitTest extends DistributedTestCase PORT2 = initServerCache(server2); // then create client - pause(5000); // [bruce] avoid ConnectException + Wait.pause(5000); // [bruce] avoid ConnectException client1.invoke(impl.getClass(), "createClientCache", new Object[] { - getServerHostName(server1.getHost()), new Integer(PORT1),new Integer(PORT2)}); + NetworkUtils.getServerHostName(server1.getHost()), new Integer(PORT1),new Integer(PORT2)}); } @@ -168,7 +172,7 @@ public class InterestListEndpointDUnitTest extends DistributedTestCase VM primary = firstIsPrimary? server1 : server2; primary.invoke(impl.getClass(), "stopILEndpointServer"); - pause(5000); + Wait.pause(5000); //Since the loadbalancing policy is roundrobin & there are two servers so // do two dumb puts, which will ensure that fail over happens from the @@ -201,7 +205,7 @@ public class InterestListEndpointDUnitTest extends DistributedTestCase return null; } }; - DistributedTestCase.waitForCriterion(ev, maxWaitTime, 200, true); + Wait.waitForCriterion(ev, maxWaitTime, 200, true); } }); @@ -416,7 +420,7 @@ public class InterestListEndpointDUnitTest extends DistributedTestCase } } catch (Exception ex) { - fail("failed while verifyIfNotInterestListEndpointAndThenPut()", ex); + com.gemstone.gemfire.test.dunit.Assert.fail("failed while verifyIfNotInterestListEndpointAndThenPut()", ex); } } @@ -428,7 +432,7 @@ public class InterestListEndpointDUnitTest extends DistributedTestCase r.registerInterest(k1, InterestResultPolicy.KEYS); } catch (Exception ex) { - fail("failed while region.registerInterest()", ex); + com.gemstone.gemfire.test.dunit.Assert.fail("failed while region.registerInterest()", ex); } } @@ -466,7 +470,7 @@ public class InterestListEndpointDUnitTest extends DistributedTestCase return "Test missed a success"; } }; - DistributedTestCase.waitForCriterion(ev, 20 * 1000, 200, true); + Wait.waitForCriterion(ev, 20 * 1000, 200, true); //yes update assertEquals(server_k1, r.getEntry(k1).getValue()); @@ -486,15 +490,14 @@ public class InterestListEndpointDUnitTest extends DistributedTestCase } } - public void tearDown2() throws Exception - { + @Override + protected final void preTearDown() throws Exception { // Close client cache first, then server caches client1.invoke(impl.getClass(), "closeCache"); server2.invoke(impl.getClass(), "closeCache"); server1.invoke(impl.getClass(), "closeCache"); CacheServerTestUtil.resetDisableShufflingOfEndpointsFlag(); cache = null; - invokeInEveryVM(new SerializableRunnable() { public void run() { cache = null; } }); + Invoke.invokeInEveryVM(new SerializableRunnable() { public void run() { cache = null; } }); } - } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListFailoverDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListFailoverDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListFailoverDUnitTest.java index 1b0ecb1..d5e32bd 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListFailoverDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListFailoverDUnitTest.java @@ -25,9 +25,13 @@ import com.gemstone.gemfire.cache.server.CacheServer; import com.gemstone.gemfire.cache.client.*; import com.gemstone.gemfire.internal.AvailablePort; import com.gemstone.gemfire.internal.cache.PoolFactoryImpl; +import com.gemstone.gemfire.test.dunit.Assert; import com.gemstone.gemfire.test.dunit.DistributedTestCase; import com.gemstone.gemfire.test.dunit.Host; +import com.gemstone.gemfire.test.dunit.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.cache.client.internal.PoolImpl; /** @@ -95,9 +99,9 @@ public class InterestListFailoverDUnitTest extends DistributedTestCase vm1.invoke(CacheServerTestUtil.class, "disableShufflingOfEndpoints"); vm2.invoke(CacheServerTestUtil.class, "disableShufflingOfEndpoints"); vm1.invoke(CacheServerTestUtil.class, "createCacheClient", new Object[] { - getClientPool(getServerHostName(host),redundancyLevel), REGION_NAME }); + getClientPool(NetworkUtils.getServerHostName(host),redundancyLevel), REGION_NAME }); vm2.invoke(CacheServerTestUtil.class, "createCacheClient", new Object[] { - getClientPool(getServerHostName(host),0), REGION_NAME }); + getClientPool(NetworkUtils.getServerHostName(host),0), REGION_NAME }); } /** @@ -165,7 +169,7 @@ public class InterestListFailoverDUnitTest extends DistributedTestCase assertEquals(r.getEntry("key-6").getValue(), "key-6"); } catch (Exception ex) { - fail("failed while createEntries()", ex); + Assert.fail("failed while createEntries()", ex); } } @@ -182,7 +186,7 @@ public class InterestListFailoverDUnitTest extends DistributedTestCase } } catch (Exception ex) { - fail("failed while createEntries()", ex); + Assert.fail("failed while createEntries()", ex); } } @@ -201,7 +205,7 @@ public class InterestListFailoverDUnitTest extends DistributedTestCase return new Integer(p.getPrimaryPort()); } catch (Exception ex) { - fail("failed while registering keys k1 to k5", ex); + Assert.fail("failed while registering keys k1 to k5", ex); return null; } } @@ -247,7 +251,7 @@ public class InterestListFailoverDUnitTest extends DistributedTestCase assertEquals(r.getEntry("key-6").getValue(), "vm2-key-6" + v); } catch (Exception ex) { - fail("failed while r.put()", ex); + Assert.fail("failed while r.put()", ex); } } @@ -288,17 +292,18 @@ public class InterestListFailoverDUnitTest extends DistributedTestCase return excuse; } }; - DistributedTestCase.waitForCriterion(wc, 40 * 1000, 1000, true); + Wait.waitForCriterion(wc, 40 * 1000, 1000, true); // Verify that 'key-6' was not invalidated assertEquals("key-6", r.getEntry("key-6").getValue()); } catch (Exception ex) { - fail("failed while r.put()", ex); + Assert.fail("failed while r.put()", ex); } } - public void tearDown2() throws Exception { + @Override + protected final void preTearDown() throws Exception { closeAll(); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListRecoveryDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListRecoveryDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListRecoveryDUnitTest.java index 5359cb8..19e7e16 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListRecoveryDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListRecoveryDUnitTest.java @@ -39,9 +39,13 @@ import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.internal.AvailablePort; import com.gemstone.gemfire.internal.cache.CacheServerImpl; import com.gemstone.gemfire.internal.cache.LocalRegion; +import com.gemstone.gemfire.test.dunit.Assert; import com.gemstone.gemfire.test.dunit.DistributedTestCase; import com.gemstone.gemfire.test.dunit.Host; +import com.gemstone.gemfire.test.dunit.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.cache.client.*; import com.gemstone.gemfire.cache.client.internal.PoolImpl; import com.gemstone.gemfire.cache.client.internal.RegisterInterestTracker; @@ -87,7 +91,7 @@ public class InterestListRecoveryDUnitTest extends DistributedTestCase @Override public void setUp() throws Exception { disconnectAllFromDS(); - pause(2000); + Wait.pause(2000); super.setUp(); final Host host = Host.getHost(0); server1 = host.getVM(0); @@ -96,10 +100,10 @@ public class InterestListRecoveryDUnitTest extends DistributedTestCase PORT1 = ((Integer)server1.invoke(InterestListRecoveryDUnitTest.class, "createServerCache" )).intValue(); PORT2 = ((Integer)server2.invoke(InterestListRecoveryDUnitTest.class, "createServerCache" )).intValue(); - getLogWriter().info("server1 port is " + String.valueOf(PORT1)); - getLogWriter().info("server2 port is " + String.valueOf(PORT2)); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("server1 port is " + String.valueOf(PORT1)); + com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("server2 port is " + String.valueOf(PORT2)); - createClientCache(getServerHostName(host), new Integer(PORT1), new Integer(PORT2)); + createClientCache(NetworkUtils.getServerHostName(host), new Integer(PORT1), new Integer(PORT2)); } // this test fails because of bug# 35352 , hence commented the bug is Deferred to: Danube @@ -109,12 +113,12 @@ public class InterestListRecoveryDUnitTest extends DistributedTestCase server1.invoke(InterestListRecoveryDUnitTest.class, "createEntries"); registerK1toK5(); setServerUnavailable("localhost"+PORT1); - pause(20000); + Wait.pause(20000); unregisterK1toK3(); setServerAvailable("localhost"+PORT1); - pause(20000); + Wait.pause(20000); setServerUnavailable("localhost"+PORT2); - pause(20000); + Wait.pause(20000); server1.invoke(InterestListRecoveryDUnitTest.class, "verifyUnregisterK1toK3"); } @@ -177,7 +181,7 @@ public class InterestListRecoveryDUnitTest extends DistributedTestCase assertNotNull(pool); return (pool.getPrimaryPort() == PORT1); } catch (Exception ex) { - fail("while isInterestListRegisteredToServer1", ex); + Assert.fail("while isInterestListRegisteredToServer1", ex); } // never reached return false; @@ -257,7 +261,7 @@ public class InterestListRecoveryDUnitTest extends DistributedTestCase } } catch (Exception ex) { - fail("failed while createEntries()", ex); + Assert.fail("failed while createEntries()", ex); } } @@ -270,7 +274,7 @@ public class InterestListRecoveryDUnitTest extends DistributedTestCase } } catch (Exception ex) { - fail("failed while registering keys", ex); + Assert.fail("failed while registering keys", ex); } } @@ -283,7 +287,7 @@ public class InterestListRecoveryDUnitTest extends DistributedTestCase } } catch (Exception ex) { - fail("failed while un-registering keys", ex); + Assert.fail("failed while un-registering keys", ex); } } @@ -295,7 +299,7 @@ public class InterestListRecoveryDUnitTest extends DistributedTestCase //ConnectionProxyImpl.markServerUnavailable(server); } catch (Exception ex) { - fail("while setting server unavailable "+ server, ex); + Assert.fail("while setting server unavailable "+ server, ex); } } public static void setServerAvailable(String server) @@ -305,7 +309,7 @@ public class InterestListRecoveryDUnitTest extends DistributedTestCase //ConnectionProxyImpl.markServerAvailable(server); } catch (Exception ex) { - fail("while setting server available "+ server, ex); + Assert.fail("while setting server available "+ server, ex); } } @@ -333,7 +337,7 @@ public class InterestListRecoveryDUnitTest extends DistributedTestCase r1.put(key, "server-"+key); } catch (Exception ex) { - fail("failed while r.put()", ex); + Assert.fail("failed while r.put()", ex); } } @@ -360,7 +364,7 @@ public class InterestListRecoveryDUnitTest extends DistributedTestCase return null; } }; - DistributedTestCase.waitForCriterion(ev, 20 * 1000, 200, true); + Wait.waitForCriterion(ev, 20 * 1000, 200, true); } public static void verifyRegionToProxyMapForFullRegistration() @@ -402,7 +406,7 @@ public class InterestListRecoveryDUnitTest extends DistributedTestCase return "verifyRegisterK4toK5Retry"; } }; - DistributedTestCase.waitForCriterion(ev, 20 * 1000, 200, true); + Wait.waitForCriterion(ev, 20 * 1000, 200, true); } public static void verifyRegisterK4toK5() { @@ -441,7 +445,7 @@ public class InterestListRecoveryDUnitTest extends DistributedTestCase return null; } }; - DistributedTestCase.waitForCriterion(ev, 20 * 1000, 200, true); + Wait.waitForCriterion(ev, 20 * 1000, 200, true); } public static void verifyRegionToProxyMapForNoRegistration() @@ -477,9 +481,8 @@ public class InterestListRecoveryDUnitTest extends DistributedTestCase .getProfile(regionName).getKeysOfInterestFor(proxy.getProxyID()); } - @Override - public void tearDown2() throws Exception - { + @Override + protected final void preTearDown() throws Exception { // close the clients first server2.invoke(InterestListRecoveryDUnitTest.class, "closeCache"); closeCache(); @@ -509,6 +512,6 @@ public class InterestListRecoveryDUnitTest extends DistributedTestCase return excuse; } }; - DistributedTestCase.waitForCriterion(wc, 60 * 1000, 1000, true); + Wait.waitForCriterion(wc, 60 * 1000, 1000, true); } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/820cfd63/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestRegrListenerDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestRegrListenerDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestRegrListenerDUnitTest.java index 090577b..f122fe6 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestRegrListenerDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestRegrListenerDUnitTest.java @@ -40,7 +40,10 @@ import com.gemstone.gemfire.distributed.DistributedSystem; import com.gemstone.gemfire.internal.AvailablePortHelper; 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; +import com.gemstone.gemfire.test.dunit.Wait; +import com.gemstone.gemfire.test.dunit.WaitCriterion; /** * Written to test fix for Bug #47132 @@ -136,7 +139,7 @@ public class InterestRegrListenerDUnitTest extends DistributedTestCase { } private void doExpressInterestOnServer(boolean isDurable) { - getLogWriter().info("Total ClientSessions " + cacheServer.getAllClientSessions().size()); + LogWriterUtils.getLogWriter().info("Total ClientSessions " + cacheServer.getAllClientSessions().size()); for(ClientSession c : this.cacheServer.getAllClientSessions()) { c.registerInterestRegex("/serverRegion", ".*", isDurable); } @@ -155,7 +158,7 @@ public class InterestRegrListenerDUnitTest extends DistributedTestCase { intCount = count.intValue(); intCount++; InterestRegrListenerDUnitTest.this.listnerMap.put(UNREGISTER_INTEREST, intCount); - getLogWriter().info("InterestRegistrationListener afterUnregisterInterest for " + LogWriterUtils.getLogWriter().info("InterestRegistrationListener afterUnregisterInterest for " + event.getRegionName() + " keys " + event.getKeysOfInterest() + "Count " + intCount + " Client : " + event.getClientSession().toString()); } @@ -167,11 +170,11 @@ public class InterestRegrListenerDUnitTest extends DistributedTestCase { intCount = count.intValue(); intCount++; InterestRegrListenerDUnitTest.this.listnerMap.put(REGISTER_INTEREST, intCount); - getLogWriter().info("InterestRegistrationListener afterRegisterInterest for " + LogWriterUtils.getLogWriter().info("InterestRegistrationListener afterRegisterInterest for " + event.getRegionName() + " keys " + event.getKeysOfInterest() + "Count " + intCount + " Client : " + event.getClientSession().toString()); } }; - getLogWriter().info("Registered InterestRegistationLister"); + LogWriterUtils.getLogWriter().info("Registered InterestRegistationLister"); this.cacheServer.registerInterestRegistrationListener(listener); } @@ -189,7 +192,7 @@ public class InterestRegrListenerDUnitTest extends DistributedTestCase { ClientRegionFactory<String,String> regionFactory = clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY); Region<String, String> region = regionFactory.create("serverRegion"); - getLogWriter().info( + LogWriterUtils.getLogWriter().info( "Client Cache is created in this vm connected to cacheServer " + host + ":" + port + " durable? " + isDurable + " with VMID=" + vmID + " region " + region.getFullPath() + " regionSize " + region.size()); assertNotNull(clientCache); @@ -266,15 +269,15 @@ public class InterestRegrListenerDUnitTest extends DistributedTestCase { params[1] = port; params[2] = true; params[3] = "VM_1"; - getLogWriter().info("Starting client1 with server endpoint <" + hostName + ">:" + port); + LogWriterUtils.getLogWriter().info("Starting client1 with server endpoint <" + hostName + ">:" + port); clientVM_1.invoke(InterestRegrListenerDUnitTest.class, "setUpClientVMTask", params); params[3] = "VM_2"; - getLogWriter().info("Starting client2 with server endpoint <" + hostName + ">:" + port); + LogWriterUtils.getLogWriter().info("Starting client2 with server endpoint <" + hostName + ">:" + port); clientVM_2.invoke(InterestRegrListenerDUnitTest.class, "setUpClientVMTask", params); params[3] = "VM_3"; - getLogWriter().info("Starting client2 with server endpoint <" + hostName + ">:" + port); + LogWriterUtils.getLogWriter().info("Starting client2 with server endpoint <" + hostName + ">:" + port); clientVM_3.invoke(InterestRegrListenerDUnitTest.class, "setUpClientVMTask", params); @@ -296,15 +299,15 @@ public class InterestRegrListenerDUnitTest extends DistributedTestCase { clientVM_3.invoke(InterestRegrListenerDUnitTest.class, "closeClientCacheTask", new Object[]{true}); Thread.sleep(2); Map<String,Integer> listnerMap = (Map<String, Integer>) serverVM.invoke(InterestRegrListenerDUnitTest.class, "getListenerMapTask"); - getLogWriter().info("Listener Map " + listnerMap); + LogWriterUtils.getLogWriter().info("Listener Map " + listnerMap); int registerCount = getMapValueForKey(listnerMap,REGISTER_INTEREST); int unregisterCount = getMapValueForKey(listnerMap,UNREGISTER_INTEREST); assertEquals(3, registerCount); assertEquals(0, unregisterCount); - getLogWriter().info("Sleeping till durable client queue are expired and unregister event is called on to listener"); + LogWriterUtils.getLogWriter().info("Sleeping till durable client queue are expired and unregister event is called on to listener"); Thread.sleep((DURABLE_CLIENT_TIMEOUT+5)*1000); listnerMap = (Map<String, Integer>) serverVM.invoke(InterestRegrListenerDUnitTest.class, "getListenerMapTask"); - getLogWriter().info("Listener Map after sleeping " + listnerMap); + LogWriterUtils.getLogWriter().info("Listener Map after sleeping " + listnerMap); registerCount = getMapValueForKey(listnerMap,REGISTER_INTEREST); unregisterCount = getMapValueForKey(listnerMap,UNREGISTER_INTEREST); assertEquals(3, registerCount); @@ -331,15 +334,15 @@ public class InterestRegrListenerDUnitTest extends DistributedTestCase { params[1] = port; params[2] = true; params[3] = "VM_1"; - getLogWriter().info("Starting client1 with server endpoint <" + hostName + ">:" + port); + LogWriterUtils.getLogWriter().info("Starting client1 with server endpoint <" + hostName + ">:" + port); clientVM_1.invoke(InterestRegrListenerDUnitTest.class, "setUpClientVMTask", params); params[3] = "VM_2"; - getLogWriter().info("Starting client2 with server endpoint <" + hostName + ">:" + port); + LogWriterUtils.getLogWriter().info("Starting client2 with server endpoint <" + hostName + ">:" + port); clientVM_2.invoke(InterestRegrListenerDUnitTest.class, "setUpClientVMTask", params); params[3] = "VM_3"; - getLogWriter().info("Starting client2 with server endpoint <" + hostName + ">:" + port); + LogWriterUtils.getLogWriter().info("Starting client2 with server endpoint <" + hostName + ">:" + port); clientVM_3.invoke(InterestRegrListenerDUnitTest.class, "setUpClientVMTask", params); @@ -358,15 +361,15 @@ public class InterestRegrListenerDUnitTest extends DistributedTestCase { clientVM_3.invoke(InterestRegrListenerDUnitTest.class, "closeClientCacheTask", new Object[]{true}); Thread.sleep(2); Map<String,Integer> listnerMap = (Map<String, Integer>) serverVM.invoke(InterestRegrListenerDUnitTest.class, "getListenerMapTask"); - getLogWriter().info("Listener Map " + listnerMap); + LogWriterUtils.getLogWriter().info("Listener Map " + listnerMap); int registerCount = getMapValueForKey(listnerMap,REGISTER_INTEREST); int unregisterCount = getMapValueForKey(listnerMap,UNREGISTER_INTEREST); assertEquals(3, registerCount); assertEquals(0, unregisterCount); - getLogWriter().info("Sleeping till durable client queue are expired and unregister event is called on to listener"); + LogWriterUtils.getLogWriter().info("Sleeping till durable client queue are expired and unregister event is called on to listener"); Thread.sleep((DURABLE_CLIENT_TIMEOUT+5)*1000); listnerMap = (Map<String, Integer>) serverVM.invoke(InterestRegrListenerDUnitTest.class, "getListenerMapTask"); - getLogWriter().info("Listener Map after sleeping " + listnerMap); + LogWriterUtils.getLogWriter().info("Listener Map after sleeping " + listnerMap); registerCount = getMapValueForKey(listnerMap,REGISTER_INTEREST); unregisterCount = getMapValueForKey(listnerMap,UNREGISTER_INTEREST); assertEquals(3, registerCount); @@ -395,15 +398,15 @@ public class InterestRegrListenerDUnitTest extends DistributedTestCase { params[1] = port; params[2] = true; params[3] = "VM_1"; - getLogWriter().info("Starting client1 with server endpoint <" + hostName + ">:" + port); + LogWriterUtils.getLogWriter().info("Starting client1 with server endpoint <" + hostName + ">:" + port); clientVM_1.invoke(InterestRegrListenerDUnitTest.class, "setUpClientVMTask", params); params[3] = "VM_2"; - getLogWriter().info("Starting client2 with server endpoint <" + hostName + ">:" + port); + LogWriterUtils.getLogWriter().info("Starting client2 with server endpoint <" + hostName + ">:" + port); clientVM_2.invoke(InterestRegrListenerDUnitTest.class, "setUpClientVMTask", params); params[3] = "VM_3"; - getLogWriter().info("Starting client2 with server endpoint <" + hostName + ">:" + port); + LogWriterUtils.getLogWriter().info("Starting client2 with server endpoint <" + hostName + ">:" + port); clientVM_3.invoke(InterestRegrListenerDUnitTest.class, "setUpClientVMTask", params); @@ -431,13 +434,13 @@ public class InterestRegrListenerDUnitTest extends DistributedTestCase { @Override public boolean done() { Map<String,Integer> listnerMap = (Map<String, Integer>) serverVM.invoke(InterestRegrListenerDUnitTest.class, "getListenerMapTask"); - getLogWriter().info("Listener Map " + listnerMap); + LogWriterUtils.getLogWriter().info("Listener Map " + listnerMap); registerCount = getMapValueForKey(listnerMap,REGISTER_INTEREST); unregisterCount = getMapValueForKey(listnerMap,UNREGISTER_INTEREST); if (registerCount == 3 && unregisterCount == 3) { return true; } - getLogWriter().info("Waiting for counts to each reach 3. Current registerCount="+registerCount+"; unregisterCount="+unregisterCount); + LogWriterUtils.getLogWriter().info("Waiting for counts to each reach 3. Current registerCount="+registerCount+"; unregisterCount="+unregisterCount); return false; } @@ -447,9 +450,9 @@ public class InterestRegrListenerDUnitTest extends DistributedTestCase { } }; - waitForCriterion(wc, 20000, 500, true); + Wait.waitForCriterion(wc, 20000, 500, true); - getLogWriter().info("Sleeping till durable client queue are expired and unregister event is called on to listener"); + LogWriterUtils.getLogWriter().info("Sleeping till durable client queue are expired and unregister event is called on to listener"); Thread.sleep((DURABLE_CLIENT_TIMEOUT+5)*1000); serverVM.invoke(InterestRegrListenerDUnitTest.class, "closeCacheTask"); }