You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2018/08/24 22:47:23 UTC
[geode] 02/03: GEODE-5614: rename distributedTestRule field to
distributedRule
This is an automated email from the ASF dual-hosted git repository.
klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
commit 16d0f6962a1c11d5f09e21ab67e23e1686d14934
Author: Kirk Lund <kl...@apache.org>
AuthorDate: Thu Aug 23 15:25:24 2018 -0700
GEODE-5614: rename distributedTestRule field to distributedRule
* Cleanup warnings in these tests
---
.../CreateAndLocalDestroyInTXRegressionTest.java | 5 +-
.../PRCreationTotalNumBucketsDistributedTest.java | 6 +-
.../cache/RegionClearStatsDistributedTest.java | 6 +-
.../cache/RegionExpirationDistributedTest.java | 6 +-
.../dunit/QueryDataInconsistencyDUnitTest.java | 32 ++++----
.../geode/cache30/DiskRegionDistributedTest.java | 9 +--
...okenSerializationConsistencyRegressionTest.java | 6 +-
.../cache/BucketCreationCrashRegressionTest.java | 9 +--
...ntServerTransactionFailoverDistributedTest.java | 33 +++++----
...overWithMixedVersionServersDistributedTest.java | 42 ++++++-----
.../EntriesDoNotExpireDuringGiiRegressionTest.java | 10 +--
...zedDiskRegionWithIoExceptionRegressionTest.java | 16 ++--
.../cache/PRCustomPartitioningDistributedTest.java | 8 +-
.../PREntryIdleExpirationDistributedTest.java | 29 +++++---
.../internal/cache/PRQueryDistributedTest.java | 6 +-
.../PRQueryWithIndexAndPdxDistributedTest.java | 7 +-
.../cache/PRQueryWithIndexDistributedTest.java | 7 +-
.../cache/PRQueryWithOrderByDistributedTest.java | 7 +-
...RQueryWithPdxDuringRebalanceRegressionTest.java | 7 +-
.../PRWithIndexAfterRebalanceRegressionTest.java | 7 +-
.../PartitionedRegionCloseDistributedTest.java | 17 +++--
.../cache/PersistentRegionRecoveryDUnitTest.java | 17 ++---
.../cache/RegionListenerDistributedTest.java | 15 ++--
...eplicateEntryIdleExpirationDistributedTest.java | 34 +++++----
.../cache/backup/BackupDistributedTest.java | 9 +--
.../backup/IncrementalBackupDistributedTest.java | 10 +--
.../PrepareAndFinishBackupDistributedTest.java | 4 +-
.../ClientFunctionTimeoutRegressionTest.java | 24 +++---
...ctionExecutionWithExceptionDistributedTest.java | 7 +-
...ctionOnBehalfOfClientMemberDistributedTest.java | 12 +--
.../cache/ha/HARegionQueueSizeRegressionTest.java | 7 +-
.../HARegionQueueThreadIdExpiryRegressionTest.java | 9 +--
...BucketCreationCrashCompletesRegressionTest.java | 49 ++++++-------
.../BucketRebalanceStatRegressionTest.java | 2 +-
...RDiskConflictWithColocationDistributedTest.java | 3 +-
...PersistentPartitionedRegionDistributedTest.java | 19 ++---
.../PersistentPartitionedRegionRegressionTest.java | 5 +-
...eueRemovalMessageProcessingDistributedTest.java | 85 +++++++++++-----------
.../RegisterInterestKeysValuesDistributedTest.java | 48 ++++++------
.../DeltaPropagationFailureRegressionTest.java | 31 ++++----
.../AcceptorImplClientQueueDistributedTest.java | 40 +++++-----
...entDestroyRegionNotificationRegressionTest.java | 29 ++++----
...troyRegionUnregisterInterestRegressionTest.java | 29 ++++----
.../ClientProxyWithDeltaDistributedTest.java | 32 ++++----
.../ClientWithInterestFailoverDistributedTest.java | 30 ++++----
.../GetConnectedServerCountRegressionTest.java | 6 +-
.../HARegionQueueStatsCloseRegressionTest.java | 22 +++---
.../MessageTrackingTimeoutRegressionTest.java | 16 +---
...nterestOnServerWithoutRegionRegressionTest.java | 13 ++--
...isterInterestServerMetaDataDistributedTest.java | 42 +++++------
...RootRegionsExcludesHARegionsRegressionTest.java | 22 +++---
.../AsyncEventListenerDistributedTest.java | 2 +-
...ventListenerWithCacheLoaderDistributedTest.java | 4 +-
...syncEventListenerWithFilterDistributedTest.java | 4 +-
...oncurrentAsyncEventListenerDistributedTest.java | 2 +-
.../ParallelAsyncEventListenerDistributedTest.java | 2 +-
.../SerialEventListenerDistributedTest.java | 2 +-
.../ClientServerJTAFailoverDistributedTest.java | 39 +++++-----
.../apache/geode/management/JMXMBeanDUnitTest.java | 57 +++++++--------
.../tests/GetCurrentVmNumDistributedTest.java | 3 +-
.../GetPidAndIdAfterBounceDistributedTest.java | 9 +--
.../dunit/tests/GetPidAndIdDistributedTest.java | 7 +-
.../examples/AsyncInvokeCallableExampleTest.java | 24 ++----
.../examples/AsyncInvokeRunnableExampleTest.java | 10 +--
.../CatchingUnexpectedExceptionExampleTest.java | 11 ++-
.../dunit/examples/InvokeRunnableExampleTest.java | 11 ++-
.../examples/LocatorPortClusterExampleTest.java | 5 +-
.../examples/ReplaceTryFinallyExampleTest.java | 12 ++-
.../tests/CacheRuleBuilderDistributedTest.java | 7 +-
.../rules/tests/CacheRuleDistributedTest.java | 2 +-
...utedRestoreSystemPropertiesDistributedTest.java | 12 +--
.../apache/geode/test/dunit/rules/CacheRule.java | 17 ++++-
.../geode/test/dunit/rules/ClientCacheRule.java | 16 +++-
.../GatewayLegacyAuthenticationRegressionTest.java | 20 +----
74 files changed, 589 insertions(+), 635 deletions(-)
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache/CreateAndLocalDestroyInTXRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache/CreateAndLocalDestroyInTXRegressionTest.java
index 8580b02..64055d2 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/cache/CreateAndLocalDestroyInTXRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/cache/CreateAndLocalDestroyInTXRegressionTest.java
@@ -32,7 +32,6 @@ import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import junitparams.naming.TestCaseName;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -66,8 +65,8 @@ public class CreateAndLocalDestroyInTXRegressionTest implements Serializable {
private VM otherVM;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache/PRCreationTotalNumBucketsDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache/PRCreationTotalNumBucketsDistributedTest.java
index 777576c..50a6901 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/cache/PRCreationTotalNumBucketsDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/cache/PRCreationTotalNumBucketsDistributedTest.java
@@ -26,7 +26,6 @@ import java.io.Serializable;
import java.util.Properties;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
@@ -36,7 +35,6 @@ import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.CacheRule;
import org.apache.geode.test.dunit.rules.DistributedRule;
-
@SuppressWarnings("serial")
public class PRCreationTotalNumBucketsDistributedTest implements Serializable {
@@ -44,8 +42,8 @@ public class PRCreationTotalNumBucketsDistributedTest implements Serializable {
private VM vm1;
private int totalNumBuckets;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache/RegionClearStatsDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache/RegionClearStatsDistributedTest.java
index 1b62369..e3e5753 100755
--- a/geode-core/src/distributedTest/java/org/apache/geode/cache/RegionClearStatsDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/cache/RegionClearStatsDistributedTest.java
@@ -25,7 +25,6 @@ import java.io.Serializable;
import java.util.Properties;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
@@ -39,7 +38,6 @@ import org.apache.geode.test.dunit.rules.DistributedRule;
/**
* verifies the count of clear operation
*/
-
@SuppressWarnings("serial")
public class RegionClearStatsDistributedTest implements Serializable {
@@ -53,8 +51,8 @@ public class RegionClearStatsDistributedTest implements Serializable {
private VM server1;
private VM client1;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache/RegionExpirationDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache/RegionExpirationDistributedTest.java
index 9402428..81bf86b 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/cache/RegionExpirationDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/cache/RegionExpirationDistributedTest.java
@@ -30,7 +30,6 @@ import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import junitparams.naming.TestCaseName;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -52,7 +51,6 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
*
* @since GemFire 3.0
*/
-
@RunWith(JUnitParamsRunner.class)
@SuppressWarnings("serial")
public class RegionExpirationDistributedTest implements Serializable {
@@ -67,8 +65,8 @@ public class RegionExpirationDistributedTest implements Serializable {
private VM withExpirationVM0;
private VM withoutExpirationVM1;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = CacheRule.builder().createCacheInAll().build();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/QueryDataInconsistencyDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/QueryDataInconsistencyDUnitTest.java
index 60452e9..2524081 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/QueryDataInconsistencyDUnitTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/QueryDataInconsistencyDUnitTest.java
@@ -14,6 +14,7 @@
*/
package org.apache.geode.cache.query.dunit;
+import static org.apache.geode.test.dunit.VM.getVM;
import static org.assertj.core.api.Assertions.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -28,7 +29,6 @@ import org.awaitility.Awaitility;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -49,7 +49,6 @@ import org.apache.geode.cache.query.internal.QueryObserverHolder;
import org.apache.geode.cache.query.internal.index.IndexManager;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.test.dunit.AsyncInvocation;
-import org.apache.geode.test.dunit.Host;
import org.apache.geode.test.dunit.Invoke;
import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.CacheRule;
@@ -62,6 +61,8 @@ import org.apache.geode.test.junit.categories.OQLIndexTest;
@Category({OQLIndexTest.class})
public class QueryDataInconsistencyDUnitTest implements Serializable {
+ private static final Logger logger = LogService.getLogger();
+
private static final int cnt = 0;
private static final int cntDest = 10;
private static VM server = null;
@@ -69,30 +70,29 @@ public class QueryDataInconsistencyDUnitTest implements Serializable {
private static String repRegionName = "TestRepRegion"; // default name
private static volatile boolean hooked = false;
- private Logger logger = LogService.getLogger(QueryDataInconsistencyDUnitTest.class.getName());
-
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule(1);
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule(1);
@Rule
- public CacheRule cacheRule = CacheRule.builder().createCacheInAll().disconnectAfter().build();
+ public CacheRule cacheRule = new CacheRule(1);
+
+ @BeforeClass
+ public static void setUpClass() {
+ Awaitility.setDefaultPollInterval(200, TimeUnit.MILLISECONDS);
+ Awaitility.waitAtMost(30, TimeUnit.SECONDS);
+ }
@Before
- public void initialize() {
- server = Host.getHost(0).getVM(0);
+ public void setUp() {
+ server = getVM(0);
+ server.invoke(() -> cacheRule.createCache());
}
@After
- public final void postTearDownCacheTestCase() {
+ public void tearDown() {
Invoke.invokeInEveryVM(QueryObserverHolder::reset);
}
- @BeforeClass
- public static final void postSetUp() {
- Awaitility.setDefaultPollInterval(200, TimeUnit.MILLISECONDS);
- Awaitility.waitAtMost(30, TimeUnit.SECONDS);
- }
-
@Test
public void testCompactRangeIndex() {
// Create caches
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache30/DiskRegionDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache30/DiskRegionDistributedTest.java
index 35b6132..33188be 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/cache30/DiskRegionDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/cache30/DiskRegionDistributedTest.java
@@ -49,7 +49,6 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
*
* @since GemFire 3.2
*/
-
public class DiskRegionDistributedTest implements Serializable {
private String uniqueName;
@@ -61,16 +60,16 @@ public class DiskRegionDistributedTest implements Serializable {
private VM vm3;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
- /** DistributedDiskDirRule invokes before and after for SerializableTestName */
- private SerializableTestName testName = new SerializableTestName();
+ @Rule
+ public DistributedDiskDirRule diskDirsRule = new DistributedDiskDirRule();
@Rule
- public DistributedDiskDirRule diskDirsRule = new DistributedDiskDirRule(testName);
+ public SerializableTestName testName = new SerializableTestName();
@Before
public void setUp() {
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/BrokenSerializationConsistencyRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/BrokenSerializationConsistencyRegressionTest.java
index 96b75cf..da6365b 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/BrokenSerializationConsistencyRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/BrokenSerializationConsistencyRegressionTest.java
@@ -29,7 +29,6 @@ import java.io.Serializable;
import java.io.UncheckedIOException;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
@@ -44,7 +43,6 @@ import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.CacheRule;
import org.apache.geode.test.dunit.rules.DistributedRule;
-
@SuppressWarnings("serial")
public class BrokenSerializationConsistencyRegressionTest implements Serializable {
@@ -60,8 +58,8 @@ public class BrokenSerializationConsistencyRegressionTest implements Serializabl
private transient PdxValue pdxValue;
private transient byte[] bytesValue;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/BucketCreationCrashRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/BucketCreationCrashRegressionTest.java
index 9daa000..9f3316a 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/BucketCreationCrashRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/BucketCreationCrashRegressionTest.java
@@ -66,7 +66,6 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
* <p>
* TRAC #41733: Hang in BucketAdvisor.waitForPrimaryMember
*/
-
@SuppressWarnings("serial")
public class BucketCreationCrashRegressionTest implements Serializable {
@@ -80,7 +79,7 @@ public class BucketCreationCrashRegressionTest implements Serializable {
private VM locator;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -118,7 +117,7 @@ public class BucketCreationCrashRegressionTest implements Serializable {
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
DistributionMessageObserver.setInstance(null);
invokeInEveryVM(() -> {
DistributionMessageObserver.setInstance(null);
@@ -130,7 +129,7 @@ public class BucketCreationCrashRegressionTest implements Serializable {
* we choose a primary
*/
@Test
- public void putShouldNotHangAfterBucketCrashesBeforePrimarySelection() throws Exception {
+ public void putShouldNotHangAfterBucketCrashesBeforePrimarySelection() {
server1.invoke(
() -> handleBeforeProcessMessage(ManageBucketReplyMessage.class, () -> crashServer()));
server1.invoke(() -> createPartitionedRegion());
@@ -157,7 +156,7 @@ public class BucketCreationCrashRegressionTest implements Serializable {
* the remote node.
*/
@Test
- public void putShouldNotHangAfterServerWithBucketCrashes() throws Exception {
+ public void putShouldNotHangAfterServerWithBucketCrashes() {
server2.invoke(() -> handleBeforeProcessMessage(ManageBucketMessage.class,
() -> server1.invoke(() -> crashServer())));
server1.invoke(() -> createPartitionedRegion());
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClientServerTransactionFailoverDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClientServerTransactionFailoverDistributedTest.java
index 1ae8413..9f411f4 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClientServerTransactionFailoverDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClientServerTransactionFailoverDistributedTest.java
@@ -19,6 +19,7 @@ import static org.apache.geode.test.dunit.VM.getVM;
import static org.junit.Assert.assertEquals;
import java.io.Serializable;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import org.junit.Before;
@@ -48,7 +49,13 @@ import org.apache.geode.test.dunit.rules.ClientCacheRule;
import org.apache.geode.test.dunit.rules.DistributedRule;
import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
+@SuppressWarnings("serial")
public class ClientServerTransactionFailoverDistributedTest implements Serializable {
+
+ private final int numOfOperationsInTransaction = 10;
+ private final int key1 = 1;
+ private final String originalValue = "originalValue";
+
private String hostName;
private String uniqueName;
private String regionName;
@@ -58,15 +65,9 @@ public class ClientServerTransactionFailoverDistributedTest implements Serializa
private VM server4;
private int port1;
private int port2;
- private int port3;
- private int port4;
-
- private final int numOfOperationsInTransaction = 10;
- private final int key1 = 1;
- private final String originalValue = "originalValue";
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -136,7 +137,7 @@ public class ClientServerTransactionFailoverDistributedTest implements Serializa
CacheServerTestUtil.disableShufflingOfEndpoints();
PoolImpl pool;
try {
- pool = getPool(connectToFirstPort, ports);
+ pool = getPool(ports);
} finally {
CacheServerTestUtil.enableShufflingOfEndpoints();
}
@@ -152,7 +153,7 @@ public class ClientServerTransactionFailoverDistributedTest implements Serializa
}
}
- private PoolImpl getPool(boolean connectToFirstPort, int... ports) {
+ private PoolImpl getPool(int... ports) {
PoolFactory factory = PoolManager.createFactory();
for (int port : ports) {
factory.addServer(hostName, port);
@@ -177,7 +178,8 @@ public class ClientServerTransactionFailoverDistributedTest implements Serializa
return txManager.suspend();
}
- private void resumeTransaction(TransactionId txId, int numOfOperations) throws Exception {
+ private void resumeTransaction(TransactionId txId, int numOfOperations)
+ throws InterruptedException {
Region region = clientCacheRule.getClientCache().getRegion(regionName);
TXManagerImpl txManager =
(TXManagerImpl) clientCacheRule.getClientCache().getCacheTransactionManager();
@@ -288,7 +290,7 @@ public class ClientServerTransactionFailoverDistributedTest implements Serializa
private void beginAndSuspendTransactions(int numOfTransactions, int numOfOperations,
Thread[] threads,
FutureTask<TransactionId>[] futureTasks, TransactionId[] txIds)
- throws InterruptedException, java.util.concurrent.ExecutionException {
+ throws InterruptedException, ExecutionException {
for (int i = 0; i < numOfTransactions; i++) {
FutureTask<TransactionId> futureTask =
new FutureTask<>(() -> beginAndSuspendTransaction(numOfOperations));
@@ -304,17 +306,16 @@ public class ClientServerTransactionFailoverDistributedTest implements Serializa
}
private void setupClientAndServerForMultipleTransactions() {
- port4 = server4.invoke(() -> createServerRegion(1, false));
+ int port4 = server4.invoke(() -> createServerRegion(1, false));
server4.invoke(() -> doPut(key1, originalValue));
port1 = server1.invoke(() -> createServerRegion(1, true));
port2 = server2.invoke(() -> createServerRegion(1, true));
- port3 = server3.invoke(() -> createServerRegion(1, true));
+ int port3 = server3.invoke(() -> createServerRegion(1, true));
createClientRegion(false, port1, port2, port3, port4);
}
private void resumeTransactions(int numOfTransactions, int numOfOperations, Thread[] threads,
- TransactionId[] txIds)
- throws InterruptedException {
+ TransactionId[] txIds) {
for (int i = 0; i < numOfTransactions; i++) {
TransactionId txId = txIds[i];
Thread thread = new Thread(() -> {
@@ -330,7 +331,7 @@ public class ClientServerTransactionFailoverDistributedTest implements Serializa
}
private void unregisterClientMultipleTimes(ClientProxyMembershipID clientProxyMembershipID)
- throws Exception {
+ throws InterruptedException {
int numOfUnregisterClients = 4;
for (int i = 0; i < numOfUnregisterClients; i++) {
getVM(i).invoke(() -> unregisterClient(clientProxyMembershipID));
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClientServerTransactionFailoverWithMixedVersionServersDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClientServerTransactionFailoverWithMixedVersionServersDistributedTest.java
index c29e6d3..b08c3a0 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClientServerTransactionFailoverWithMixedVersionServersDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClientServerTransactionFailoverWithMixedVersionServersDistributedTest.java
@@ -28,12 +28,12 @@ import java.io.IOException;
import java.io.Serializable;
import java.net.InetAddress;
import java.util.Properties;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import org.awaitility.Awaitility;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
@@ -61,8 +61,13 @@ import org.apache.geode.test.dunit.standalone.VersionManager;
import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
+@SuppressWarnings("serial")
public class ClientServerTransactionFailoverWithMixedVersionServersDistributedTest
implements Serializable {
+
+ private static final int TRANSACTION_TIMEOUT_SECOND = 2;
+ private static final int VM_COUNT = 6;
+
private String hostName;
private String uniqueName;
private String regionName;
@@ -75,16 +80,15 @@ public class ClientServerTransactionFailoverWithMixedVersionServersDistributedTe
private int locatorPort;
private File locatorLog;
private Host host;
- private final int transactionTimeoutSecond = 2;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule(6);
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule(VM_COUNT);
@Rule
- public CacheRule cacheRule = new CacheRule();
+ public CacheRule cacheRule = new CacheRule(VM_COUNT);
@Rule
- public ClientCacheRule clientCacheRule = new ClientCacheRule();
+ public ClientCacheRule clientCacheRule = new ClientCacheRule(VM_COUNT);
@Rule
public SerializableTemporaryFolder temporaryFolder = new SerializableTemporaryFolder();
@@ -136,7 +140,7 @@ public class ClientServerTransactionFailoverWithMixedVersionServersDistributedTe
}
private void doTransactions(int numOfTransactions, int numOfOperations)
- throws InterruptedException, java.util.concurrent.ExecutionException {
+ throws InterruptedException, ExecutionException {
Thread[] threads = new Thread[numOfTransactions];
FutureTask<TransactionId>[] futureTasks = new FutureTask[numOfTransactions];
TransactionId[] txIds = new TransactionId[numOfTransactions];
@@ -195,7 +199,7 @@ public class ClientServerTransactionFailoverWithMixedVersionServersDistributedTe
clientCacheRule.createClientCache();
}
- private VM rollLocatorToCurrent(VM oldLocator) throws Exception {
+ private VM rollLocatorToCurrent(VM oldLocator) {
// Roll the locator
oldLocator.invoke(() -> stopLocator());
VM rollLocator = host.getVM(VersionManager.CURRENT_VERSION, oldLocator.getId());
@@ -207,7 +211,7 @@ public class ClientServerTransactionFailoverWithMixedVersionServersDistributedTe
Locator.getLocator().stop();
}
- private VM rollServerToCurrent(VM oldServer) throws Exception {
+ private VM rollServerToCurrent(VM oldServer) {
// Roll the server
oldServer.invoke(() -> cacheRule.getCache().close());
VM rollServer = host.getVM(VersionManager.CURRENT_VERSION, oldServer.getId());
@@ -215,7 +219,7 @@ public class ClientServerTransactionFailoverWithMixedVersionServersDistributedTe
return rollServer;
}
- private void createServerRegion(int totalNumBuckets, boolean isAccessor) throws Exception {
+ private void createServerRegion(int totalNumBuckets, boolean isAccessor) {
PartitionAttributesFactory factory = new PartitionAttributesFactory();
factory.setTotalNumBuckets(totalNumBuckets);
if (isAccessor) {
@@ -226,10 +230,10 @@ public class ClientServerTransactionFailoverWithMixedVersionServersDistributedTe
.setPartitionAttributes(partitionAttributes).create(regionName);
TXManagerImpl txManager = cacheRule.getCache().getTxManager();
- txManager.setTransactionTimeToLiveForTest(transactionTimeoutSecond);
+ txManager.setTransactionTimeToLiveForTest(TRANSACTION_TIMEOUT_SECOND);
}
- private void createClientRegion() throws Exception {
+ private void createClientRegion() {
Pool pool = PoolManager.createFactory().addLocator(hostName, locatorPort).create(uniqueName);
ClientRegionFactory crf =
@@ -241,7 +245,7 @@ public class ClientServerTransactionFailoverWithMixedVersionServersDistributedTe
private void beginAndSuspendTransactions(int numOfTransactions, int numOfOperations,
Thread[] threads,
FutureTask<TransactionId>[] futureTasks, TransactionId[] txIds)
- throws InterruptedException, java.util.concurrent.ExecutionException {
+ throws InterruptedException, ExecutionException {
for (int i = 0; i < numOfTransactions; i++) {
FutureTask<TransactionId> futureTask =
new FutureTask<>(() -> beginAndSuspendTransaction(numOfOperations));
@@ -289,8 +293,7 @@ public class ClientServerTransactionFailoverWithMixedVersionServersDistributedTe
}
private void resumeTransactions(int numOfTransactions, int numOfOperations, Thread[] threads,
- TransactionId[] txIds)
- throws InterruptedException {
+ TransactionId[] txIds) {
for (int i = 0; i < numOfTransactions; i++) {
TransactionId txId = txIds[i];
Thread thread = new Thread(() -> {
@@ -333,7 +336,7 @@ public class ClientServerTransactionFailoverWithMixedVersionServersDistributedTe
}
}
- private void unregisterClient(ClientProxyMembershipID clientProxyMembershipID) throws Exception {
+ private void unregisterClient(ClientProxyMembershipID clientProxyMembershipID) {
ClientHealthMonitor clientHealthMonitor = ClientHealthMonitor.getInstance();
clientHealthMonitor.removeAllConnectionsAndUnregisterClient(clientProxyMembershipID,
new Exception());
@@ -385,11 +388,11 @@ public class ClientServerTransactionFailoverWithMixedVersionServersDistributedTe
unregisterClientMultipleTimes(clientProxyMembershipID);
- server1.invoke(() -> verifyTransactionAreExpired(numOfTransactions));
+ server1.invoke(() -> verifyTransactionAreExpired());
}
private void doUnfinishedTransactions(int numOfTransactions, int numOfOperations)
- throws InterruptedException, java.util.concurrent.ExecutionException {
+ throws InterruptedException {
Thread[] threads = new Thread[numOfTransactions];
for (int i = 0; i < numOfTransactions; i++) {
Thread thread = new Thread(() -> startTransaction(numOfOperations));
@@ -416,11 +419,10 @@ public class ClientServerTransactionFailoverWithMixedVersionServersDistributedTe
.isEqualTo(numOfTransactions));
}
- private void verifyTransactionAreExpired(int numOfTransactions) {
+ private void verifyTransactionAreExpired() {
TXManagerImpl txManager = cacheRule.getCache().getTxManager();
Awaitility.await().atMost(60, TimeUnit.SECONDS)
.untilAsserted(
() -> assertThat(txManager.hostedTransactionsInProgressForTest()).isEqualTo(0));
}
-
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/EntriesDoNotExpireDuringGiiRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/EntriesDoNotExpireDuringGiiRegressionTest.java
index 83d6717..1633a59 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/EntriesDoNotExpireDuringGiiRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/EntriesDoNotExpireDuringGiiRegressionTest.java
@@ -28,7 +28,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.junit.After;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
@@ -53,7 +52,6 @@ import org.apache.geode.test.junit.rules.serializable.SerializableErrorCollector
*
* @since GemFire 5.0
*/
-
@SuppressWarnings("serial")
public class EntriesDoNotExpireDuringGiiRegressionTest implements Serializable {
@@ -65,8 +63,8 @@ public class EntriesDoNotExpireDuringGiiRegressionTest implements Serializable {
private VM otherVM;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -162,12 +160,12 @@ public class EntriesDoNotExpireDuringGiiRegressionTest implements Serializable {
private class SlowGiiCacheListener extends CacheListenerAdapter<String, String> {
@Override
- public void afterRegionCreate(final RegionEvent<java.lang.String, java.lang.String> event) {
+ public void afterRegionCreate(final RegionEvent<String, String> event) {
afterRegionCreateInvoked.set(true);
}
@Override
- public void afterInvalidate(final EntryEvent<java.lang.String, java.lang.String> event) {
+ public void afterInvalidate(final EntryEvent<String, String> event) {
errorCollector.checkThat("afterRegionCreate should have been seen",
afterRegionCreateInvoked.get(), is(true));
errorCollector.checkThat("Region should have been initialized",
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/InitializedDiskRegionWithIoExceptionRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/InitializedDiskRegionWithIoExceptionRegressionTest.java
index ec86b06..3672340 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/InitializedDiskRegionWithIoExceptionRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/InitializedDiskRegionWithIoExceptionRegressionTest.java
@@ -55,7 +55,6 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
* <p>
* TRAC #39079: Regions with persistence remain in use after IOException have occurred
*/
-
@SuppressWarnings("serial")
public class InitializedDiskRegionWithIoExceptionRegressionTest implements Serializable {
@@ -66,7 +65,7 @@ public class InitializedDiskRegionWithIoExceptionRegressionTest implements Seria
private VM client;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -74,15 +73,14 @@ public class InitializedDiskRegionWithIoExceptionRegressionTest implements Seria
@Rule
public ClientCacheRule clientCacheRule = new ClientCacheRule();
- /** DistributedDiskDirRule invokes before and after for SerializableTemporaryFolder */
- private SerializableTemporaryFolder temporaryFolder = new SerializableTemporaryFolder();
+ @Rule
+ public DistributedDiskDirRule diskDirsRule = new DistributedDiskDirRule();
- /** DistributedDiskDirRule invokes before and after for SerializableTestName */
- private SerializableTestName testName = new SerializableTestName();
+ @Rule
+ public SerializableTemporaryFolder temporaryFolder = new SerializableTemporaryFolder();
@Rule
- public DistributedDiskDirRule diskDirsRule =
- new DistributedDiskDirRule(temporaryFolder, testName);
+ public SerializableTestName testName = new SerializableTestName();
@Before
public void setUp() throws Exception {
@@ -111,7 +109,7 @@ public class InitializedDiskRegionWithIoExceptionRegressionTest implements Seria
}
@Test
- public void cacheServerPersistWithIOExceptionShouldShutdown() throws Exception {
+ public void cacheServerPersistWithIOExceptionShouldShutdown() {
// create server cache
int port = server.invoke(() -> createServerCache());
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRCustomPartitioningDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRCustomPartitioningDistributedTest.java
index 3438fa2..3ffa089 100755
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRCustomPartitioningDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRCustomPartitioningDistributedTest.java
@@ -25,7 +25,6 @@ import java.util.List;
import java.util.Set;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
@@ -40,7 +39,6 @@ import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.CacheRule;
import org.apache.geode.test.dunit.rules.DistributedRule;
-
@SuppressWarnings("serial")
public class PRCustomPartitioningDistributedTest implements Serializable {
@@ -58,8 +56,8 @@ public class PRCustomPartitioningDistributedTest implements Serializable {
private VM datastoreVM2;
private VM accessorVM3;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -80,7 +78,7 @@ public class PRCustomPartitioningDistributedTest implements Serializable {
}
@Test
- public void testPartitionedRegionOperationsCustomPartitioning() throws Exception {
+ public void testPartitionedRegionOperationsCustomPartitioning() {
datastoreVM0.invoke(() -> createPartitionedRegionWithPartitionResolver());
datastoreVM1.invoke(() -> createPartitionedRegionWithPartitionResolver());
datastoreVM2.invoke(() -> createPartitionedRegionWithPartitionResolver());
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PREntryIdleExpirationDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PREntryIdleExpirationDistributedTest.java
index e5ded37..2d9ec2b 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PREntryIdleExpirationDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PREntryIdleExpirationDistributedTest.java
@@ -17,7 +17,7 @@ package org.apache.geode.internal.cache;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.geode.cache.ExpirationAction.DESTROY;
import static org.apache.geode.cache.RegionShortcut.PARTITION;
-import static org.apache.geode.test.dunit.Host.getHost;
+import static org.apache.geode.test.dunit.VM.getVM;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
@@ -27,7 +27,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import com.google.common.base.Stopwatch;
import org.junit.After;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
@@ -40,32 +39,38 @@ import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.CacheRule;
import org.apache.geode.test.dunit.rules.DistributedRule;
-
+@SuppressWarnings("serial")
public class PREntryIdleExpirationDistributedTest implements Serializable {
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
-
private static final AtomicBoolean KEEP_READING = new AtomicBoolean(true);
private static final String KEY = "KEY";
private static final String VALUE = "VALUE";
- private final VM member1 = getHost(0).getVM(0);
- private final VM member2 = getHost(0).getVM(1);
- private final VM member3 = getHost(0).getVM(2);
- private final String regionName = getClass().getSimpleName();
+ private VM member1;
+ private VM member2;
+ private VM member3;
+ private String regionName;
+
+ @Rule
+ public DistributedRule distributedTRule = new DistributedRule();
@Rule
- public CacheRule cacheRule = CacheRule.builder().createCacheIn(member1).createCacheIn(member2)
- .createCacheIn(member3).createCacheIn(getHost(0).getVM(3)).build();
+ public CacheRule cacheRule = new CacheRule();
@Before
public void setUp() throws Exception {
+ member1 = getVM(0);
+ member2 = getVM(1);
+ member3 = getVM(2);
+
+ regionName = getClass().getSimpleName();
+
VM[] vms = new VM[] {member1, member2, member3};
for (VM vm : vms) {
vm.invoke(() -> {
KEEP_READING.set(true);
+ cacheRule.createCache();
ExpiryTask.suspendExpiration();
createRegion();
});
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryDistributedTest.java
index 88ed204..245dc6f 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryDistributedTest.java
@@ -28,7 +28,6 @@ import java.util.Map;
import org.junit.After;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
@@ -52,7 +51,6 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
/**
* Distributed tests for querying a PartitionedRegion.
*/
-
@SuppressWarnings("serial")
public class PRQueryDistributedTest implements Serializable {
@@ -62,8 +60,8 @@ public class PRQueryDistributedTest implements Serializable {
private VM vm1;
private VM vm2;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryWithIndexAndPdxDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryWithIndexAndPdxDistributedTest.java
index 10c3d92..a560b4e 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryWithIndexAndPdxDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryWithIndexAndPdxDistributedTest.java
@@ -27,7 +27,6 @@ import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import junitparams.naming.TestCaseName;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -54,7 +53,7 @@ import org.apache.geode.test.junit.categories.OQLIndexTest;
/**
* Extracted from {@link PRQueryDistributedTest}.
*/
-@Category({OQLIndexTest.class})
+@Category(OQLIndexTest.class)
@RunWith(JUnitParamsRunner.class)
@SuppressWarnings("serial")
public class PRQueryWithIndexAndPdxDistributedTest implements Serializable {
@@ -65,8 +64,8 @@ public class PRQueryWithIndexAndPdxDistributedTest implements Serializable {
private VM vm0;
private VM vm1;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryWithIndexDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryWithIndexDistributedTest.java
index b17de44..020b2b1 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryWithIndexDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryWithIndexDistributedTest.java
@@ -30,7 +30,6 @@ import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import junitparams.naming.TestCaseName;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -52,7 +51,7 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
/**
* Extracted from {@link PRQueryDistributedTest}.
*/
-@Category({OQLIndexTest.class})
+@Category(OQLIndexTest.class)
@RunWith(JUnitParamsRunner.class)
@SuppressWarnings("serial")
public class PRQueryWithIndexDistributedTest implements Serializable {
@@ -62,8 +61,8 @@ public class PRQueryWithIndexDistributedTest implements Serializable {
private VM vm0;
private VM vm1;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryWithOrderByDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryWithOrderByDistributedTest.java
index 697c94b..5d4a603 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryWithOrderByDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryWithOrderByDistributedTest.java
@@ -29,7 +29,6 @@ import java.sql.Timestamp;
import java.util.Date;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -52,7 +51,7 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
/**
* Extracted from {@link PRQueryDistributedTest}.
*/
-@Category({OQLQueryTest.class})
+@Category(OQLQueryTest.class)
@SuppressWarnings("serial")
public class PRQueryWithOrderByDistributedTest implements Serializable {
@@ -63,8 +62,8 @@ public class PRQueryWithOrderByDistributedTest implements Serializable {
private VM server2;
private VM client;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryWithPdxDuringRebalanceRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryWithPdxDuringRebalanceRegressionTest.java
index 73d482c..e69f466 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryWithPdxDuringRebalanceRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRQueryWithPdxDuringRebalanceRegressionTest.java
@@ -25,7 +25,6 @@ import java.util.concurrent.CancellationException;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -57,7 +56,7 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
* <p>
* TRAC #43102: hang while executing query with pdx objects
*/
-@Category({OQLQueryTest.class})
+@Category(OQLQueryTest.class)
@SuppressWarnings("serial")
public class PRQueryWithPdxDuringRebalanceRegressionTest implements Serializable {
@@ -70,8 +69,8 @@ public class PRQueryWithPdxDuringRebalanceRegressionTest implements Serializable
private VM vm1;
private VM vm2;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRWithIndexAfterRebalanceRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRWithIndexAfterRebalanceRegressionTest.java
index b1d4888..99e7e6b 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRWithIndexAfterRebalanceRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PRWithIndexAfterRebalanceRegressionTest.java
@@ -27,7 +27,6 @@ import java.io.Serializable;
import java.util.List;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -53,7 +52,7 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
* <p>
* TRAC #50749: RegionDestroyedException when running a OQL inside function for a colocated region
*/
-@Category({OQLIndexTest.class})
+@Category(OQLIndexTest.class)
@SuppressWarnings("serial")
public class PRWithIndexAfterRebalanceRegressionTest implements Serializable {
@@ -66,8 +65,8 @@ public class PRWithIndexAfterRebalanceRegressionTest implements Serializable {
private VM vm2;
private VM vm3;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionCloseDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionCloseDistributedTest.java
index 80dc731..b5fef30 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionCloseDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionCloseDistributedTest.java
@@ -14,6 +14,7 @@
*/
package org.apache.geode.internal.cache;
+import static org.apache.geode.test.dunit.Invoke.invokeInEveryVM;
import static org.apache.geode.test.dunit.VM.getVM;
import static org.assertj.core.api.Assertions.assertThat;
@@ -24,7 +25,6 @@ import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import junitparams.naming.TestCaseName;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -38,7 +38,6 @@ import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.CacheRule;
import org.apache.geode.test.dunit.rules.DistributedRule;
-
@RunWith(JUnitParamsRunner.class)
@SuppressWarnings("serial")
public class PartitionedRegionCloseDistributedTest implements Serializable {
@@ -52,11 +51,11 @@ public class PartitionedRegionCloseDistributedTest implements Serializable {
private VM accessor;
private VM[] datastores;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
- public CacheRule cacheRule = CacheRule.builder().createCacheInAll().build();
+ public CacheRule cacheRule = new CacheRule();
@Before
public void setUp() throws Exception {
@@ -67,13 +66,15 @@ public class PartitionedRegionCloseDistributedTest implements Serializable {
datastores[0] = getVM(1);
datastores[1] = getVM(2);
datastores[2] = getVM(3);
+
+ cacheRule.createCache();
+ invokeInEveryVM(() -> cacheRule.createCache());
}
@Test
@Parameters({"CLOSE_REGION", "LOCAL_DESTROY_REGION"})
@TestCaseName("{method}({params})")
- public void redundantDataIsAvailableAfterRemovingOneDatastore(final RegionRemoval regionRemoval)
- throws Exception {
+ public void redundantDataIsAvailableAfterRemovingOneDatastore(final RegionRemoval regionRemoval) {
accessor.invoke("create accessor", () -> createAccessor());
for (VM vm : datastores) {
vm.invoke("create datastore", () -> createDataStore());
@@ -124,7 +125,7 @@ public class PartitionedRegionCloseDistributedTest implements Serializable {
* This test case checks that a closed PR (accessor/datastore) can be recreated.
*/
@Test
- public void closeAndRecreateInAllHasNoData() throws Exception {
+ public void closeAndRecreateInAllHasNoData() {
accessor.invoke("create accessor", () -> createAccessor());
for (VM vm : datastores) {
vm.invoke("create datastore", () -> createDataStore());
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PersistentRegionRecoveryDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PersistentRegionRecoveryDUnitTest.java
index 113db1c..32b242d 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PersistentRegionRecoveryDUnitTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PersistentRegionRecoveryDUnitTest.java
@@ -25,6 +25,7 @@ import java.io.File;
import java.io.IOException;
import java.io.Serializable;
+import org.apache.logging.log4j.Logger;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -48,14 +49,15 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
public class PersistentRegionRecoveryDUnitTest extends JUnit4DistributedTestCase
implements Serializable {
- // private String diskStoreName;
+ private static final Logger logger = LogService.getLogger();
+
private String regionName;
private VM vm0;
private VM vm1;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -73,10 +75,8 @@ public class PersistentRegionRecoveryDUnitTest extends JUnit4DistributedTestCase
regionName = getClass().getSimpleName() + "-" + testName.getMethodName();
}
- private static final org.apache.logging.log4j.Logger logger = LogService.getLogger();
-
@Test
- public void testRecoveryOfAsyncRegionAfterShutdownAfterGIIAndBeforeCrfWritten() throws Exception {
+ public void testRecoveryOfAsyncRegionAfterShutdownAfterGIIAndBeforeCrfWritten() {
vm0.invoke(() -> createAsyncDiskRegion());
vm0.invoke(() -> {
@@ -119,7 +119,7 @@ public class PersistentRegionRecoveryDUnitTest extends JUnit4DistributedTestCase
}
@Test
- public void testRecoveryOfAsyncRegionAfterShutdownAndBeforeCrfWritten() throws Exception {
+ public void testRecoveryOfAsyncRegionAfterShutdownAndBeforeCrfWritten() {
vm0.invoke(() -> createAsyncDiskRegion());
vm1.invoke(() -> createAsyncDiskRegion(true));
@@ -158,7 +158,7 @@ public class PersistentRegionRecoveryDUnitTest extends JUnit4DistributedTestCase
}
@Test
- public void testRecoveryOfAsyncRegionAfterShutdownUsingUntrustedRVV() throws Exception {
+ public void testRecoveryOfAsyncRegionAfterShutdownUsingUntrustedRVV() {
vm0.invoke(() -> createAsyncDiskRegion());
vm0.invoke(() -> {
@@ -355,8 +355,7 @@ public class PersistentRegionRecoveryDUnitTest extends JUnit4DistributedTestCase
}
@Test
- public void testRecoveryFromBackupOfAsyncRegionAfterShutdownAfterGIIAndBeforeCrfWritten()
- throws Exception {
+ public void testRecoveryFromBackupOfAsyncRegionAfterShutdownAfterGIIAndBeforeCrfWritten() {
vm0.invoke(() -> createDiskRegion(false, false, "regionToGetDiskStoreCreated"));
vm1.invoke(() -> createDiskRegion(false, true, "regionToGetDiskStoreCreated"));
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/RegionListenerDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/RegionListenerDistributedTest.java
index 5cb537a..4ad8028 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/RegionListenerDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/RegionListenerDistributedTest.java
@@ -14,6 +14,7 @@
*/
package org.apache.geode.internal.cache;
+import static org.apache.geode.test.dunit.Invoke.invokeInEveryVM;
import static org.apache.geode.test.dunit.VM.getVM;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -22,7 +23,7 @@ import java.io.Serializable;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.junit.ClassRule;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -33,15 +34,19 @@ import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.CacheRule;
import org.apache.geode.test.dunit.rules.DistributedRule;
-
@SuppressWarnings("serial")
public class RegionListenerDistributedTest implements Serializable {
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
- public CacheRule cacheRule = CacheRule.builder().createCacheInAll().disconnectAfter().build();
+ public CacheRule cacheRule = new CacheRule();
+
+ @Before
+ public void setUp() {
+ invokeInEveryVM(() -> cacheRule.createCache());
+ }
@Test
public void testCleanupFailedInitializationInvoked() {
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ReplicateEntryIdleExpirationDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ReplicateEntryIdleExpirationDistributedTest.java
index cb14c45..fb8a248 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ReplicateEntryIdleExpirationDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ReplicateEntryIdleExpirationDistributedTest.java
@@ -27,7 +27,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import com.google.common.base.Stopwatch;
import org.junit.After;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
@@ -42,32 +41,41 @@ import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.CacheRule;
import org.apache.geode.test.dunit.rules.DistributedRule;
-
+@SuppressWarnings("serial")
public class ReplicateEntryIdleExpirationDistributedTest implements Serializable {
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
-
private static final AtomicBoolean KEEP_READING = new AtomicBoolean(true);
private static final String KEY = "KEY";
private static final String VALUE = "VALUE";
- private final VM member1 = getVM(0);
- private final VM member2 = getVM(1);
- private final VM member3 = getVM(2);
- private final String regionName = getClass().getSimpleName();
+ private String regionName;
+
+ private VM member1;
+ private VM member2;
+ private VM member3;
+ private VM member4;
@Rule
- public CacheRule cacheRule = CacheRule.builder().createCacheIn(member1).createCacheIn(member2)
- .createCacheIn(member3).createCacheIn(getVM(3)).build();
+ public DistributedRule distributedRule = new DistributedRule();
+
+ @Rule
+ public CacheRule cacheRule = new CacheRule();
@Before
public void setUp() throws Exception {
+ member1 = getVM(0);
+ member2 = getVM(1);
+ member3 = getVM(2);
+ member4 = getVM(3);
+
+ regionName = getClass().getSimpleName();
+
VM[] vms = new VM[] {member1, member2, member3};
for (VM vm : vms) {
vm.invoke(() -> {
KEEP_READING.set(true);
+ cacheRule.createCache();
ExpiryTask.suspendExpiration();
createRegion();
});
@@ -122,9 +130,9 @@ public class ReplicateEntryIdleExpirationDistributedTest implements Serializable
@Test
public void readsInNormalMemberShouldPreventExpiration() throws Exception {
- VM member4 = getVM(3);
member4.invoke(() -> {
KEEP_READING.set(true);
+ cacheRule.createCache();
ExpiryTask.suspendExpiration();
RegionFactory<String, String> factory = cacheRule.getCache().createRegionFactory();
@@ -204,7 +212,7 @@ public class ReplicateEntryIdleExpirationDistributedTest implements Serializable
memberReading.await();
}
- protected void createRegion() {
+ private void createRegion() {
RegionFactory<String, String> factory = cacheRule.getCache().createRegionFactory(REPLICATE);
factory.setEntryIdleTimeout(new ExpirationAttributes(1, DESTROY));
factory.create(regionName);
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/backup/BackupDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/backup/BackupDistributedTest.java
index ab60bf1..97908b4 100755
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/backup/BackupDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/backup/BackupDistributedTest.java
@@ -105,7 +105,6 @@ public class BackupDistributedTest extends JUnit4DistributedTestCase implements
private static final int NUM_BUCKETS = 15;
- private String uniqueName;
private String regionName1;
private String regionName2;
private String regionName3;
@@ -121,7 +120,7 @@ public class BackupDistributedTest extends JUnit4DistributedTestCase implements
private transient ProcessStreamReader processReader;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -142,7 +141,7 @@ public class BackupDistributedTest extends JUnit4DistributedTestCase implements
vm2 = getVM(2);
vm3 = getVM(3);
- uniqueName = getClass().getSimpleName() + "_" + testName.getMethodName();
+ String uniqueName = getClass().getSimpleName() + "_" + testName.getMethodName();
regionName1 = uniqueName + "_region1";
regionName2 = uniqueName + "_region2";
regionName3 = uniqueName + "_region3";
@@ -903,10 +902,6 @@ public class BackupDistributedTest extends JUnit4DistributedTestCase implements
return cacheRule.getOrCreateCache();
}
- // private String getUniqueName() {
- // return uniqueName;
- // }
-
private File getDiskStoreFor(final VM vm) {
return new File(getDiskDirFor(vm), getUniqueName());
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/backup/IncrementalBackupDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/backup/IncrementalBackupDistributedTest.java
index 0f4d1a6..ada1ca9 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/backup/IncrementalBackupDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/backup/IncrementalBackupDistributedTest.java
@@ -74,7 +74,6 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
/**
* Distributed tests for incremental backup.
*/
-
@SuppressWarnings("serial")
public class IncrementalBackupDistributedTest implements Serializable {
private static final Logger logger = LogService.getLogger();
@@ -85,7 +84,6 @@ public class IncrementalBackupDistributedTest implements Serializable {
private int dataStart;
private int dataEnd = dataStart + DATA_INCREMENT;
- private String uniqueName;
private String diskStoreName1;
private String diskStoreName2;
private String regionName1;
@@ -98,7 +96,7 @@ public class IncrementalBackupDistributedTest implements Serializable {
private transient ProcessStreamReader processReader;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -117,7 +115,7 @@ public class IncrementalBackupDistributedTest implements Serializable {
vm0 = getVM(0);
vm1 = getVM(1);
- uniqueName = getClass().getSimpleName() + "_" + testName.getMethodName();
+ String uniqueName = getClass().getSimpleName() + "_" + testName.getMethodName();
diskStoreName1 = uniqueName + "_diskStore-1";
diskStoreName2 = uniqueName + "_diskStore-2";
@@ -260,7 +258,7 @@ public class IncrementalBackupDistributedTest implements Serializable {
* because its oplogs were missing in the performBackupBaseline.
*/
@Test
- public void testMissingMemberInBaseline() throws Exception {
+ public void testMissingMemberInBaseline() {
// Simulate the missing member by forcing a persistent member to go offline.
PersistentID missingMember = vm0.invoke(() -> getPersistentID(diskStoreName1));
vm0.invoke(() -> cacheRule.getCache().close());
@@ -323,7 +321,7 @@ public class IncrementalBackupDistributedTest implements Serializable {
* performBackupBaseline.
*/
@Test
- public void testIncompleteInBaseline() throws Exception {
+ public void testIncompleteInBaseline() {
// Get the member ID for VM 1 and perform a performBackupBaseline.
String memberId = vm1.invoke(() -> getModifiedMemberId());
validateBackupStatus(vm1.invoke(() -> performBackup(getBaselinePath())));
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/backup/PrepareAndFinishBackupDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/backup/PrepareAndFinishBackupDistributedTest.java
index d9e35ce..28ed17f 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/backup/PrepareAndFinishBackupDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/backup/PrepareAndFinishBackupDistributedTest.java
@@ -69,7 +69,7 @@ import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactor
@RunWith(Parameterized.class)
@UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class)
-@SuppressWarnings({"serial", "unused"})
+@SuppressWarnings("serial,unused")
public class PrepareAndFinishBackupDistributedTest {
private String uniqueName;
@@ -85,7 +85,7 @@ public class PrepareAndFinishBackupDistributedTest {
}
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/ClientFunctionTimeoutRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/ClientFunctionTimeoutRegressionTest.java
index 5f5f2dc..93c88bb 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/ClientFunctionTimeoutRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/ClientFunctionTimeoutRegressionTest.java
@@ -32,7 +32,6 @@ import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.junit.After;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -70,36 +69,39 @@ import org.apache.geode.test.junit.categories.FunctionServiceTest;
* TRAC #51193: The function execution connection on the server is never terminated even if the
* gemfire.CLIENT_FUNCTION_TIMEOUT property is set
*/
-@Category({FunctionServiceTest.class})
+@Category(FunctionServiceTest.class)
@RunWith(JUnitParamsRunner.class)
@SuppressWarnings("serial")
public class ClientFunctionTimeoutRegressionTest implements Serializable {
- private static final String REGION_NAME = "TheRegion";
private static final int TOTAL_NUM_BUCKETS = 4;
private static final int REDUNDANT_COPIES = 1;
private static InternalCache serverCache;
private static InternalClientCache clientCache;
+ private String regionName;
+
private VM server;
private VM client;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public DistributedRestoreSystemProperties restoreSystemProperties =
new DistributedRestoreSystemProperties();
@Before
- public void before() throws Exception {
+ public void setUp() throws Exception {
server = getVM(0);
client = getVM(1);
+
+ regionName = getClass().getSimpleName();
}
@After
- public void after() throws Exception {
+ public void tearDown() throws Exception {
invokeInEveryVM(() -> {
if (clientCache != null) {
clientCache.close();
@@ -116,7 +118,7 @@ public class ClientFunctionTimeoutRegressionTest implements Serializable {
@Parameters({"SERVER,REPLICATE,0", "SERVER,REPLICATE,6000", "REGION,REPLICATE,0",
"REGION,REPLICATE,6000", "REGION,PARTITION,0", "REGION,PARTITION,6000"})
public void executeFunctionUsesClientTimeoutOnServer(final ExecutionTarget executionTarget,
- final RegionType regionType, final int timeout) throws Exception {
+ final RegionType regionType, final int timeout) {
int port = server.invoke(() -> createServerCache(regionType));
client.invoke(() -> createClientCache(client.getHost().getHostName(), port, timeout));
@@ -140,7 +142,7 @@ public class ClientFunctionTimeoutRegressionTest implements Serializable {
ClientRegionFactory<String, String> clientRegionFactory =
clientCache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
- clientRegionFactory.create(REGION_NAME);
+ clientRegionFactory.create(regionName);
}
private int createServerCache(final RegionType regionType) throws IOException {
@@ -167,7 +169,7 @@ public class ClientFunctionTimeoutRegressionTest implements Serializable {
regionFactory = serverCache.createRegionFactory(RegionShortcut.REPLICATE);
}
- regionFactory.create(REGION_NAME);
+ regionFactory.create(regionName);
CacheServer server = serverCache.addCacheServer();
server.setPort(0);
@@ -185,7 +187,7 @@ public class ClientFunctionTimeoutRegressionTest implements Serializable {
if (functionServiceTarget == ExecutionTarget.REGION) {
execution =
- FunctionService.onRegion(clientCache.getRegion(REGION_NAME)).setArguments(timeout);
+ FunctionService.onRegion(clientCache.getRegion(regionName)).setArguments(timeout);
} else {
execution = FunctionService.onServer(clientCache.getDefaultPool()).setArguments(timeout);
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/FunctionExecutionWithExceptionDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/FunctionExecutionWithExceptionDistributedTest.java
index 6332574..316feb6 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/FunctionExecutionWithExceptionDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/FunctionExecutionWithExceptionDistributedTest.java
@@ -32,7 +32,6 @@ import java.util.Set;
import org.junit.After;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -51,7 +50,7 @@ import org.apache.geode.test.dunit.rules.DistributedRule;
import org.apache.geode.test.junit.categories.FunctionServiceTest;
import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
-@Category({FunctionServiceTest.class})
+@Category(FunctionServiceTest.class)
@SuppressWarnings("serial")
public class FunctionExecutionWithExceptionDistributedTest implements Serializable {
@@ -65,8 +64,8 @@ public class FunctionExecutionWithExceptionDistributedTest implements Serializab
private Set<Integer> intKeys;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = CacheRule.builder()
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/TransactionOnBehalfOfClientMemberDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/TransactionOnBehalfOfClientMemberDistributedTest.java
index 938f28f..85b26fe 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/TransactionOnBehalfOfClientMemberDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/TransactionOnBehalfOfClientMemberDistributedTest.java
@@ -19,6 +19,7 @@ import static org.apache.geode.test.dunit.VM.getVM;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
@@ -45,17 +46,19 @@ import org.apache.geode.test.dunit.rules.ClientCacheRule;
import org.apache.geode.test.dunit.rules.DistributedRule;
import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
+@SuppressWarnings("serial")
public class TransactionOnBehalfOfClientMemberDistributedTest implements Serializable {
+
private String hostName;
private String uniqueName;
private String regionName;
+ private int port1;
+
private VM server1;
private VM server2;
- private int port1;
-
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -88,7 +91,7 @@ public class TransactionOnBehalfOfClientMemberDistributedTest implements Seriali
resumeAndCommitTransaction(true, txId);
}
- private int createServerRegion(int totalNumBuckets, boolean isAccessor) throws Exception {
+ private int createServerRegion(int totalNumBuckets, boolean isAccessor) throws IOException {
PartitionAttributesFactory factory = new PartitionAttributesFactory();
factory.setTotalNumBuckets(totalNumBuckets);
if (isAccessor) {
@@ -169,5 +172,4 @@ public class TransactionOnBehalfOfClientMemberDistributedTest implements Seriali
server2.invoke(() -> verifyOnBehalfOfClientMember(false));
server1.invoke(() -> resumeAndCommitTransaction(false, txId));
}
-
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/HARegionQueueSizeRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/HARegionQueueSizeRegressionTest.java
index 162d7e0..eee10a2 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/HARegionQueueSizeRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/HARegionQueueSizeRegressionTest.java
@@ -40,7 +40,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.awaitility.Awaitility;
import org.junit.After;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -66,7 +65,7 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
* <p>
* TRAC #48571: CacheClientProxy.getQueueSizeStat() gives negative numbers when client goes down.
*/
-@Category({ClientSubscriptionTest.class})
+@Category(ClientSubscriptionTest.class)
public class HARegionQueueSizeRegressionTest implements Serializable {
private static final AtomicInteger numOfPuts = new AtomicInteger();
@@ -79,8 +78,8 @@ public class HARegionQueueSizeRegressionTest implements Serializable {
private VM server;
private VM client;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/HARegionQueueThreadIdExpiryRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/HARegionQueueThreadIdExpiryRegressionTest.java
index 4f30187..0a5e268 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/HARegionQueueThreadIdExpiryRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/HARegionQueueThreadIdExpiryRegressionTest.java
@@ -29,7 +29,6 @@ import java.io.IOException;
import java.io.Serializable;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -55,7 +54,7 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
* TRAC #48879: Leaking ThreadIdentifiers and DispatchedAndCurrentEvents objects when client uses
* many short lived threads
*/
-@Category({ClientSubscriptionTest.class})
+@Category(ClientSubscriptionTest.class)
@SuppressWarnings("serial")
public class HARegionQueueThreadIdExpiryRegressionTest implements Serializable {
@@ -68,8 +67,8 @@ public class HARegionQueueThreadIdExpiryRegressionTest implements Serializable {
private String regionName;
private String hostName;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -99,7 +98,7 @@ public class HARegionQueueThreadIdExpiryRegressionTest implements Serializable {
}
@Test
- public void testThreadIdentifiersExpiry() throws Exception {
+ public void testThreadIdentifiersExpiry() {
int puts = 10;
server1.invoke(() -> doPuts(puts));
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/BucketCreationCrashCompletesRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/BucketCreationCrashCompletesRegressionTest.java
index 06ab046..84483dd 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/BucketCreationCrashCompletesRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/BucketCreationCrashCompletesRegressionTest.java
@@ -15,6 +15,7 @@
package org.apache.geode.internal.cache.partitioned;
import static java.util.concurrent.TimeUnit.MINUTES;
+import static org.apache.geode.cache.RegionShortcut.PARTITION;
import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_NETWORK_PARTITION_DETECTION;
import static org.apache.geode.test.dunit.DistributedTestUtils.crashDistributedSystem;
import static org.apache.geode.test.dunit.DistributedTestUtils.getAllDistributedSystemProperties;
@@ -34,10 +35,9 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.apache.geode.CancelException;
-import org.apache.geode.cache.AttributesFactory;
-import org.apache.geode.cache.DataPolicy;
import org.apache.geode.cache.PartitionAttributesFactory;
import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionFactory;
import org.apache.geode.distributed.internal.ClusterDistributionManager;
import org.apache.geode.distributed.internal.DistributionMessage;
import org.apache.geode.distributed.internal.DistributionMessageObserver;
@@ -58,7 +58,7 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
* <p>
* TRAC #39356: Missing PR buckets with HA
*/
-@Category({RegionsTest.class})
+@Category(RegionsTest.class)
@SuppressWarnings("serial")
public class BucketCreationCrashCompletesRegressionTest implements Serializable {
@@ -69,7 +69,7 @@ public class BucketCreationCrashCompletesRegressionTest implements Serializable
private VM vm2;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -130,27 +130,26 @@ public class BucketCreationCrashCompletesRegressionTest implements Serializable
private void createPartitionedRegionWithObserver() {
DistributionMessageObserver.setInstance(new MyRegionObserver());
- PartitionAttributesFactory paf = new PartitionAttributesFactory();
- paf.setRedundantCopies(1);
- paf.setRecoveryDelay(0);
+ PartitionAttributesFactory<?, ?> partitionAttributesFactory = new PartitionAttributesFactory();
+ partitionAttributesFactory.setRedundantCopies(1);
+ partitionAttributesFactory.setRecoveryDelay(0);
- AttributesFactory af = new AttributesFactory();
- af.setDataPolicy(DataPolicy.PARTITION);
- af.setPartitionAttributes(paf.create());
+ RegionFactory<?, ?> regionFactory = getCache().createRegionFactory(PARTITION);
+ regionFactory.setPartitionAttributes(partitionAttributesFactory.create());
- getCache().createRegion(regionName, af.create());
+ regionFactory.create(regionName);
}
private void createAccessorAndCrash() {
- PartitionAttributesFactory<String, String> paf = new PartitionAttributesFactory<>();
- paf.setRedundantCopies(1);
- paf.setLocalMaxMemory(0);
+ PartitionAttributesFactory<String, String> partitionAttributesFactory =
+ new PartitionAttributesFactory<>();
+ partitionAttributesFactory.setRedundantCopies(1);
+ partitionAttributesFactory.setLocalMaxMemory(0);
- AttributesFactory<String, String> af = new AttributesFactory<>();
- af.setDataPolicy(DataPolicy.PARTITION);
- af.setPartitionAttributes(paf.create());
+ RegionFactory<String, String> regionFactory = getCache().createRegionFactory(PARTITION);
+ regionFactory.setPartitionAttributes(partitionAttributesFactory.create());
- Region<String, String> region = getCache().createRegion(regionName, af.create());
+ Region<String, String> region = regionFactory.create(regionName);
// trigger the creation of a bucket, which should trigger the destruction of this VM.
assertThatThrownBy(() -> region.put("ping", "pong")).isInstanceOf(CancelException.class);
@@ -182,15 +181,15 @@ public class BucketCreationCrashCompletesRegressionTest implements Serializable
}
private void createPartitionedRegion() {
- PartitionAttributesFactory paf = new PartitionAttributesFactory();
- paf.setRedundantCopies(1);
- paf.setRecoveryDelay(-1);
- paf.setStartupRecoveryDelay(-1);
+ PartitionAttributesFactory<?, ?> partitionAttributesFactory = new PartitionAttributesFactory();
+ partitionAttributesFactory.setRedundantCopies(1);
+ partitionAttributesFactory.setRecoveryDelay(-1);
+ partitionAttributesFactory.setStartupRecoveryDelay(-1);
- AttributesFactory af = new AttributesFactory();
- af.setPartitionAttributes(paf.create());
+ RegionFactory<?, ?> regionFactory = getCache().createRegionFactory(PARTITION);
+ regionFactory.setPartitionAttributes(partitionAttributesFactory.create());
- getCache().createRegion(regionName, af.create());
+ regionFactory.create(regionName);
}
private void createBucket() {
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/BucketRebalanceStatRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/BucketRebalanceStatRegressionTest.java
index bf0a9b0..ad6177f 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/BucketRebalanceStatRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/BucketRebalanceStatRegressionTest.java
@@ -73,7 +73,7 @@ public class BucketRebalanceStatRegressionTest implements Serializable {
private VM vm1;
@ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ public static DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PRDiskConflictWithColocationDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PRDiskConflictWithColocationDistributedTest.java
index 8940e54..e2de1cd 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PRDiskConflictWithColocationDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PRDiskConflictWithColocationDistributedTest.java
@@ -51,7 +51,6 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
/**
* Extracted from {@link PersistentPartitionedRegionDistributedTest}.
*/
-
@SuppressWarnings("serial")
public class PRDiskConflictWithColocationDistributedTest implements Serializable {
@@ -61,7 +60,7 @@ public class PRDiskConflictWithColocationDistributedTest implements Serializable
private VM vm0;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionDistributedTest.java
index 5d38c96..274939f 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionDistributedTest.java
@@ -21,6 +21,7 @@ import static org.apache.geode.admin.AdminDistributedSystemFactory.getDistribute
import static org.apache.geode.cache.EvictionAction.OVERFLOW_TO_DISK;
import static org.apache.geode.cache.EvictionAttributes.createLRUEntryAttributes;
import static org.apache.geode.cache.Region.SEPARATOR;
+import static org.apache.geode.cache.RegionShortcut.PARTITION_OVERFLOW;
import static org.apache.geode.cache.RegionShortcut.PARTITION_PERSISTENT;
import static org.apache.geode.cache.RegionShortcut.PARTITION_PROXY;
import static org.apache.geode.cache.RegionShortcut.REPLICATE;
@@ -63,7 +64,6 @@ import org.apache.geode.cache.DiskAccessException;
import org.apache.geode.cache.PartitionAttributesFactory;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionFactory;
-import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.cache.execute.Function;
import org.apache.geode.cache.execute.FunctionContext;
import org.apache.geode.cache.execute.FunctionService;
@@ -100,9 +100,8 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
/**
* Tests the basic use cases for PR persistence.
*/
-
@RunWith(JUnitParamsRunner.class)
-@SuppressWarnings("deprecation,serial,unused")
+@SuppressWarnings("serial,unused")
public class PersistentPartitionedRegionDistributedTest implements Serializable {
private static final int NUM_BUCKETS = 15;
@@ -117,7 +116,7 @@ public class PersistentPartitionedRegionDistributedTest implements Serializable
private VM vm3;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule =
@@ -206,11 +205,10 @@ public class PersistentPartitionedRegionDistributedTest implements Serializable
@Test
public void missingDiskStoreCanBeRevoked() throws Exception {
- int numBuckets = 50;
-
vm0.invoke(() -> createPartitionedRegion(1, -1, 113, true));
vm1.invoke(() -> createPartitionedRegion(1, -1, 113, true));
+ int numBuckets = 50;
vm0.invoke(() -> createData(0, numBuckets, "a"));
Set<Integer> bucketsOnVM0 = vm0.invoke(() -> getBucketList());
@@ -854,7 +852,7 @@ public class PersistentPartitionedRegionDistributedTest implements Serializable
*/
@Test
public void doesNotLogSuspectStringDuringCacheClosure() {
- RegionFactory regionFactory = getCache().createRegionFactory(RegionShortcut.PARTITION_OVERFLOW);
+ RegionFactory<?, ?> regionFactory = getCache().createRegionFactory(PARTITION_OVERFLOW);
regionFactory.setEvictionAttributes(createLRUEntryAttributes(50, OVERFLOW_TO_DISK));
regionFactory.create(partitionedRegionName);
@@ -864,12 +862,11 @@ public class PersistentPartitionedRegionDistributedTest implements Serializable
@Test
public void partitionedRegionsCanBeNested() throws Exception {
- int numBuckets = 50;
-
vm0.invoke(() -> createNestedPartitionedRegion());
vm1.invoke(() -> createNestedPartitionedRegion());
vm2.invoke(() -> createNestedPartitionedRegion());
+ int numBuckets = 50;
vm0.invoke(() -> {
createDataFor(0, numBuckets, "a", parentRegion1Name + SEPARATOR + partitionedRegionName);
createDataFor(0, numBuckets, "b", parentRegion2Name + SEPARATOR + partitionedRegionName);
@@ -1357,7 +1354,7 @@ public class PersistentPartitionedRegionDistributedTest implements Serializable
partitionAttributesFactory.setRedundantCopies(1);
RegionFactory<?, ?> regionFactoryPR =
- getCache().createRegionFactory(RegionShortcut.PARTITION_PERSISTENT);
+ getCache().createRegionFactory(PARTITION_PERSISTENT);
regionFactoryPR.setPartitionAttributes(partitionAttributesFactory.create());
regionFactoryPR.createSubregion(parentRegion1, partitionedRegionName);
@@ -1495,7 +1492,7 @@ public class PersistentPartitionedRegionDistributedTest implements Serializable
partitionAttributesFactory.setLocalMaxMemory(500);
RegionFactory<?, ?> regionFactory =
- getCache().createRegionFactory(RegionShortcut.PARTITION_PERSISTENT);
+ getCache().createRegionFactory(PARTITION_PERSISTENT);
regionFactory.setDiskSynchronous(synchronous);
regionFactory.setPartitionAttributes(partitionAttributesFactory.create());
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionRegressionTest.java
index 22aac27..06007ff 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionRegressionTest.java
@@ -67,7 +67,6 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
/**
* RegressionTests extracted from {@link PersistentPartitionedRegionDistributedTest}.
*/
-
@SuppressWarnings("serial,unused")
public class PersistentPartitionedRegionRegressionTest implements Serializable {
@@ -81,7 +80,7 @@ public class PersistentPartitionedRegionRegressionTest implements Serializable {
private VM vm2;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -342,7 +341,7 @@ public class PersistentPartitionedRegionRegressionTest implements Serializable {
* Controller VM sees unexpected PartitionOffLineException while doing ops)
*/
@Test
- public void doesNotWaitForPreviousInstanceOfOnlineServer() throws Exception {
+ public void doesNotWaitForPreviousInstanceOfOnlineServer() {
// Add a hook to disconnect from the distributed system when the initial image message shows up.
vm0.invoke(() -> {
DistributionMessageObserver.setInstance(new DistributionMessageObserver() {
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/QueueRemovalMessageProcessingDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/QueueRemovalMessageProcessingDistributedTest.java
index db13012..737c344 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/QueueRemovalMessageProcessingDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/QueueRemovalMessageProcessingDistributedTest.java
@@ -63,13 +63,12 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
* The test ensures that the EXPIRE_DESTROY events are propagated to the subscriber client and the
* secondary server does process the QRMs for the EXPIRE_DESTROY events.
*/
-@Category({RegionsTest.class})
+@Category(RegionsTest.class)
@SuppressWarnings("serial")
public class QueueRemovalMessageProcessingDistributedTest implements Serializable {
private static final int TOTAL_NUM_BUCKETS = 4;
-
- private static final AtomicInteger destroyedCount = new AtomicInteger();
+ private static final AtomicInteger DESTROYED_COUNT = new AtomicInteger();
private String regionName;
private String hostName;
@@ -83,7 +82,7 @@ public class QueueRemovalMessageProcessingDistributedTest implements Serializabl
private VM client2;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -113,24 +112,24 @@ public class QueueRemovalMessageProcessingDistributedTest implements Serializabl
@After
public void tearDown() throws Exception {
- destroyedCount.set(0);
+ DESTROYED_COUNT.set(0);
invokeInEveryVM(() -> {
- destroyedCount.set(0);
+ DESTROYED_COUNT.set(0);
});
}
@Test
- public void testQRMOfExpiredEventsProcessedSuccessfully() throws Exception {
+ public void testQRMOfExpiredEventsProcessedSuccessfully() {
int putCount = 10;
- // totalEvents = putCount * 2 [eviction-destroys] + 1 [marker message]
- int totalEvents = putCount * 2 + 1;
-
client2.invoke(() -> doPuts(putCount));
identifyPrimaryServer();
- client1.invoke(() -> await().atMost(1, MINUTES).until(() -> destroyedCount.get() == 10));
+ client1.invoke(() -> await().atMost(1, MINUTES).until(() -> DESTROYED_COUNT.get() == 10));
+
+ // totalEvents = putCount * 2 [eviction-destroys] + 1 [marker message]
+ int totalEvents = putCount * 2 + 1;
primary.invoke(() -> verifyClientSubscriptionStatsOnPrimary(totalEvents));
secondary.invoke(() -> verifyClientSubscriptionStatsOnSecondary(totalEvents));
@@ -139,22 +138,23 @@ public class QueueRemovalMessageProcessingDistributedTest implements Serializabl
private int createCacheServerWithPRDatastore() throws IOException {
cacheRule.createCache();
- PartitionAttributesFactory<String, String> paf = new PartitionAttributesFactory<>();
- paf.setRedundantCopies(1);
- paf.setTotalNumBuckets(TOTAL_NUM_BUCKETS);
+ PartitionAttributesFactory<String, String> partitionAttributesFactory =
+ new PartitionAttributesFactory<>();
+ partitionAttributesFactory.setRedundantCopies(1);
+ partitionAttributesFactory.setTotalNumBuckets(TOTAL_NUM_BUCKETS);
- RegionFactory<String, String> rf =
+ RegionFactory<String, String> regionFactory =
cacheRule.getCache().createRegionFactory(RegionShortcut.PARTITION);
- rf.setConcurrencyChecksEnabled(false);
- rf.setEntryTimeToLive(new ExpirationAttributes(3, ExpirationAction.DESTROY));
- rf.setPartitionAttributes(paf.create());
+ regionFactory.setConcurrencyChecksEnabled(false);
+ regionFactory.setEntryTimeToLive(new ExpirationAttributes(3, ExpirationAction.DESTROY));
+ regionFactory.setPartitionAttributes(partitionAttributesFactory.create());
- rf.create(regionName);
+ regionFactory.create(regionName);
- CacheServer server = cacheRule.getCache().addCacheServer();
- server.setPort(0);
- server.start();
- return server.getPort();
+ CacheServer cacheServer = cacheRule.getCache().addCacheServer();
+ cacheServer.setPort(0);
+ cacheServer.start();
+ return cacheServer.getPort();
}
private void createClientCacheWithRI(int port1, int port2, String durableClientId) {
@@ -162,26 +162,26 @@ public class QueueRemovalMessageProcessingDistributedTest implements Serializabl
config.setProperty(DURABLE_CLIENT_ID, durableClientId);
config.setProperty(DURABLE_CLIENT_TIMEOUT, "300000");
- ClientCacheFactory ccf = new ClientCacheFactory(config);
- ccf.addPoolServer(hostName, port1);
- ccf.addPoolServer(hostName, port2);
- ccf.setPoolSubscriptionAckInterval(50);
- ccf.setPoolSubscriptionEnabled(true);
- ccf.setPoolSubscriptionRedundancy(1);
+ ClientCacheFactory clientCacheFactory = new ClientCacheFactory(config);
+ clientCacheFactory.addPoolServer(hostName, port1);
+ clientCacheFactory.addPoolServer(hostName, port2);
+ clientCacheFactory.setPoolSubscriptionAckInterval(50);
+ clientCacheFactory.setPoolSubscriptionEnabled(true);
+ clientCacheFactory.setPoolSubscriptionRedundancy(1);
- clientCacheRule.createClientCache(ccf);
+ clientCacheRule.createClientCache(clientCacheFactory);
- ClientRegionFactory<String, String> crf = clientCacheRule.getClientCache()
+ ClientRegionFactory<String, String> clientRegionFactory = clientCacheRule.getClientCache()
.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
- crf.addCacheListener(new CacheListenerAdapter<String, String>() {
+ clientRegionFactory.addCacheListener(new CacheListenerAdapter<String, String>() {
@Override
public void afterDestroy(EntryEvent<String, String> event) {
- destroyedCount.incrementAndGet();
+ DESTROYED_COUNT.incrementAndGet();
}
});
- Region<String, String> region = crf.create(regionName);
+ Region<String, String> region = clientRegionFactory.create(regionName);
region.registerInterest("ALL_KEYS", true);
clientCacheRule.getClientCache().readyForEvents();
@@ -192,12 +192,12 @@ public class QueueRemovalMessageProcessingDistributedTest implements Serializabl
config.setProperty(DURABLE_CLIENT_ID, durableClientId);
config.setProperty(DURABLE_CLIENT_TIMEOUT, "300000");
- ClientCacheFactory ccf = new ClientCacheFactory(config);
- ccf.setPoolSubscriptionAckInterval(50);
- ccf.setPoolSubscriptionRedundancy(1);
- ccf.addPoolServer(hostName, port);
+ ClientCacheFactory clientCacheFactory = new ClientCacheFactory(config);
+ clientCacheFactory.setPoolSubscriptionAckInterval(50);
+ clientCacheFactory.setPoolSubscriptionRedundancy(1);
+ clientCacheFactory.addPoolServer(hostName, port);
- clientCacheRule.createClientCache(ccf);
+ clientCacheRule.createClientCache(clientCacheFactory);
ClientRegionFactory<String, String> crf = clientCacheRule.getClientCache()
.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
@@ -219,11 +219,8 @@ public class QueueRemovalMessageProcessingDistributedTest implements Serializabl
private boolean allEventsHaveBeenDispatched(final int eventsCount) {
HARegionQueueStats stats = getCacheClientProxy().getHARegionQueue().getStatistics();
-
- int numOfEvents = eventsCount;
long dispatched = stats.getEventsDispatched();
-
- return numOfEvents == dispatched;
+ return eventsCount == dispatched;
}
private void verifyClientSubscriptionStatsOnSecondary(final int eventsCount) {
@@ -234,7 +231,7 @@ public class QueueRemovalMessageProcessingDistributedTest implements Serializabl
long qrmed = stats.getEventsRemovedByQrm();
- return qrmed == numOfEvents || (qrmed + 1) == numOfEvents;
+ return qrmed == numOfEvents || qrmed + 1 == numOfEvents;
// Why +1 above? Because sometimes(TODO: explain further) there may
// not be any QRM sent to the secondary for the last event dispatched
// at primary.
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/RegisterInterestKeysValuesDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/RegisterInterestKeysValuesDistributedTest.java
index b89c2bf..6840c6c 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/RegisterInterestKeysValuesDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/RegisterInterestKeysValuesDistributedTest.java
@@ -55,7 +55,7 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
* <p>
* TRAC #43684: Register interest with policy KEYS_VALUES is inefficient
*/
-@Category({RegionsTest.class})
+@Category(RegionsTest.class)
@SuppressWarnings("serial")
public class RegisterInterestKeysValuesDistributedTest implements Serializable {
@@ -71,7 +71,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
private int port1;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -98,7 +98,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
}
@Test
- public void testRIWithSingleKeyOnRR() throws Exception {
+ public void testRIWithSingleKeyOnRR() {
port1 = server1.invoke(() -> createServerCache(true, false));
server2.invoke(() -> createServerCache(true, false));
server3.invoke(() -> createServerCache(true, false));
@@ -107,7 +107,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
}
@Test
- public void testRIWithAllKeysOnRR() throws Exception {
+ public void testRIWithAllKeysOnRR() {
port1 = server1.invoke(() -> createServerCache(true, false));
server2.invoke(() -> createServerCache(true, false));
server3.invoke(() -> createServerCache(true, false));
@@ -116,7 +116,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
}
@Test
- public void testRIWithKeyListOnRR() throws Exception {
+ public void testRIWithKeyListOnRR() {
port1 = server1.invoke(() -> createServerCache(true, false));
server2.invoke(() -> createServerCache(true, false));
server3.invoke(() -> createServerCache(true, false));
@@ -134,7 +134,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
}
@Test
- public void testRIWithRegularExpressionOnRR() throws Exception {
+ public void testRIWithRegularExpressionOnRR() {
port1 = server1.invoke(() -> createServerCache(true, false));
server2.invoke(() -> createServerCache(true, false));
server3.invoke(() -> createServerCache(true, false));
@@ -143,7 +143,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
}
@Test
- public void testRIWithSingleKeyOnPR() throws Exception {
+ public void testRIWithSingleKeyOnPR() {
port1 = server1.invoke(() -> createServerCache(false, false));
server2.invoke(() -> createServerCache(false, false));
server3.invoke(() -> createServerCache(false, false));
@@ -152,7 +152,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
}
@Test
- public void testRIWithAllKeysOnPR() throws Exception {
+ public void testRIWithAllKeysOnPR() {
port1 = server1.invoke(() -> createServerCache(false, false));
server2.invoke(() -> createServerCache(false, false));
server3.invoke(() -> createServerCache(false, false));
@@ -161,7 +161,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
}
@Test
- public void testRIWithKeyListOnPR() throws Exception {
+ public void testRIWithKeyListOnPR() {
port1 = server1.invoke(() -> createServerCache(false, false));
server2.invoke(() -> createServerCache(false, false));
server3.invoke(() -> createServerCache(false, false));
@@ -179,7 +179,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
}
@Test
- public void testRIWithRegularExpressionOnPR() throws Exception {
+ public void testRIWithRegularExpressionOnPR() {
port1 = server1.invoke(() -> createServerCache(false, false));
server2.invoke(() -> createServerCache(false, false));
server3.invoke(() -> createServerCache(false, false));
@@ -188,7 +188,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
}
@Test
- public void testRIWithMoreEntriesOnPR() throws Exception {
+ public void testRIWithMoreEntriesOnPR() {
port1 = server1.invoke(() -> createServerCache(false, false));
server2.invoke(() -> createServerCache(false, false));
server3.invoke(() -> createServerCache(false, false));
@@ -197,7 +197,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
}
@Test
- public void testRIWithSingleKeyOnEmptyPrimaryOnPR() throws Exception {
+ public void testRIWithSingleKeyOnEmptyPrimaryOnPR() {
port1 = server1.invoke(() -> createServerCache(false, true));
server2.invoke(() -> createServerCache(false, false));
server3.invoke(() -> createServerCache(false, false));
@@ -206,7 +206,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
}
@Test
- public void testRIWithAllKeysOnEmptyPrimaryOnPR() throws Exception {
+ public void testRIWithAllKeysOnEmptyPrimaryOnPR() {
port1 = server1.invoke(() -> createServerCache(false, true));
server2.invoke(() -> createServerCache(false, false));
server3.invoke(() -> createServerCache(false, false));
@@ -215,7 +215,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
}
@Test
- public void testRIWithKeyListOnEmptyPrimaryOnPR() throws Exception {
+ public void testRIWithKeyListOnEmptyPrimaryOnPR() {
port1 = server1.invoke(() -> createServerCache(false, true));
server2.invoke(() -> createServerCache(false, false));
server3.invoke(() -> createServerCache(false, false));
@@ -233,7 +233,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
}
@Test
- public void testRIWithRegularExpressionOnEmptyPrimaryOnPR() throws Exception {
+ public void testRIWithRegularExpressionOnEmptyPrimaryOnPR() {
port1 = server1.invoke(() -> createServerCache(false, true));
server2.invoke(() -> createServerCache(false, false));
server3.invoke(() -> createServerCache(false, false));
@@ -242,7 +242,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
}
@Test
- public void testNativeClientIssueOnPR() throws Exception {
+ public void testNativeClientIssueOnPR() {
port1 = server1.invoke(() -> createServerCache(false, false));
server2.invoke(() -> createServerCache(false, false));
server3.invoke(() -> createServerCache(false, false));
@@ -268,7 +268,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
doOps();
client1.invoke(() -> {
- Region region = clientCache().getRegion(regionName);
+ Region<Object, Object> region = clientCache().getRegion(regionName);
region.registerInterest(keys);
region.registerInterest("UNKNOWN_KEY");
});
@@ -298,7 +298,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
}
private int getExpectedSize(Object keys, String regEx, int numOfPuts) {
- return keys != null ? (keys instanceof List ? ((List) keys).size() : 1)
+ return keys != null ? keys instanceof List ? ((List) keys).size() : 1
: regEx == null ? numOfPuts : regexCount;
}
@@ -337,19 +337,19 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
}
private void registerInterest(Object keys, String regEx) {
- Region region = clientCache().getRegion(regionName);
+ Region<Object, Object> region = clientCache().getRegion(regionName);
if (keys == null && regEx == null) {
region.registerInterest("ALL_KEYS");
} else if (keys != null) {
region.registerInterest(keys);
region.registerInterest("UNKNOWN_KEY");
- } else if (regEx != null) {
+ } else {
region.registerInterestRegex(regEx);
}
}
private void doPuts(int count, String regex, int regexNum) {
- Region region = cache().getRegion(regionName);
+ Region<String, String> region = cache().getRegion(regionName);
for (int i = 0; i < count; i++) {
region.create("KEY_" + i, "VALUE__" + i);
}
@@ -361,7 +361,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
}
private void doOps() {
- Region region = clientCache().getRegion(regionName);
+ Region<String, String> region = clientCache().getRegion(regionName);
for (int i = 0; i < 14; i++) {
region.create("OPKEY_" + i, "OPVALUE__" + i);
}
@@ -388,7 +388,7 @@ public class RegisterInterestKeysValuesDistributedTest implements Serializable {
cacheRule.createCache();
}
- private void createClientCache(ClientCacheFactory ccf) {
- clientCacheRule.createClientCache(ccf);
+ private void createClientCache(ClientCacheFactory clientCacheFactory) {
+ clientCacheRule.createClientCache(clientCacheFactory);
}
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/DeltaPropagationFailureRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/DeltaPropagationFailureRegressionTest.java
index 5b91847..bcbd0ac 100755
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/DeltaPropagationFailureRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/DeltaPropagationFailureRegressionTest.java
@@ -14,6 +14,7 @@
*/
package org.apache.geode.internal.cache.tier;
+import static org.apache.geode.cache.RegionShortcut.REPLICATE;
import static org.apache.geode.internal.cache.tier.DeltaPropagationFailureRegressionTest.DeltaFailure.FROM_DELTA;
import static org.apache.geode.internal.cache.tier.DeltaPropagationFailureRegressionTest.DeltaFailure.TO_DELTA;
import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException;
@@ -30,10 +31,8 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.apache.geode.DeltaSerializationException;
-import org.apache.geode.cache.AttributesFactory;
-import org.apache.geode.cache.DataPolicy;
import org.apache.geode.cache.Region;
-import org.apache.geode.cache.Scope;
+import org.apache.geode.cache.RegionFactory;
import org.apache.geode.cache.server.CacheServer;
import org.apache.geode.internal.cache.tier.sockets.DeltaEOFException;
import org.apache.geode.internal.cache.tier.sockets.FaultyDelta;
@@ -52,7 +51,7 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
*
* @since GemFire 6.1
*/
-@Category({ClientServerTest.class})
+@Category(ClientServerTest.class)
@SuppressWarnings("serial")
public class DeltaPropagationFailureRegressionTest implements Serializable {
@@ -64,7 +63,7 @@ public class DeltaPropagationFailureRegressionTest implements Serializable {
private VM server2;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -113,23 +112,19 @@ public class DeltaPropagationFailureRegressionTest implements Serializable {
private int createServerCache() throws Exception {
cacheRule.createCache();
- AttributesFactory af = new AttributesFactory();
- af.setCloningEnabled(false);
- af.setDataPolicy(DataPolicy.REPLICATE);
- af.setScope(Scope.DISTRIBUTED_ACK);
+ RegionFactory<?, ?> regionFactory = cacheRule.getCache().createRegionFactory(REPLICATE);
+ regionFactory.setCloningEnabled(false);
- cacheRule.getCache().createRegion(regionName, af.create());
+ regionFactory.create(regionName);
- CacheServer server = cacheRule.getCache().addCacheServer();
- server.setPort(0);
- // ensures updates to be sent instead of invalidates
- server.setNotifyBySubscription(true);
- server.start();
- return server.getPort();
+ CacheServer cacheServer = cacheRule.getCache().addCacheServer();
+ cacheServer.setPort(0);
+ cacheServer.start();
+ return cacheServer.getPort();
}
private void putDelta(DeltaFailure deltaFailure) {
- Region region = cacheRule.getCache().getRegion(regionName);
+ Region<String, FaultyDelta> region = cacheRule.getCache().getRegion(regionName);
deltaFailure.putInRegion(region);
}
@@ -142,7 +137,7 @@ public class DeltaPropagationFailureRegressionTest implements Serializable {
this.value = value;
}
- void putInRegion(Region region) {
+ void putInRegion(Region<String, FaultyDelta> region) {
for (int i = 0; i < PUT_COUNT; i++) {
value.setIntVal(i);
value.setBigObj(new byte[] {(byte) (i + 3), (byte) (i + 3)});
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImplClientQueueDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImplClientQueueDistributedTest.java
index ffabb9e..eb45c7a 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImplClientQueueDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImplClientQueueDistributedTest.java
@@ -22,14 +22,12 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
-import java.rmi.RemoteException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.awaitility.Awaitility;
import org.junit.After;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -59,7 +57,7 @@ import org.apache.geode.test.junit.categories.ClientServerTest;
import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
-@Category({ClientServerTest.class})
+@Category(ClientServerTest.class)
@SuppressWarnings("serial")
public class AcceptorImplClientQueueDistributedTest implements Serializable {
@@ -67,11 +65,11 @@ public class AcceptorImplClientQueueDistributedTest implements Serializable {
private String hostName;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
- public CacheRule cacheRule = CacheRule.builder().createCacheIn(getVM(0)).createCacheIn(getVM(1))
+ public CacheRule cacheRule = CacheRule.builder()
.addSystemProperty("BridgeServer.HANDSHAKE_POOL_SIZE", "1").build();
@Rule
@@ -87,11 +85,14 @@ public class AcceptorImplClientQueueDistributedTest implements Serializable {
@Before
public void setUp() throws Exception {
hostName = getHostName();
+
+ getVM(0).invoke(() -> cacheRule.createCache());
+ getVM(1).invoke(() -> cacheRule.createCache());
}
@After
- public void tearDown() throws RemoteException {
- getAllVMs().forEach((vm) -> vm.invoke(() -> {
+ public void tearDown() {
+ getAllVMs().forEach(vm -> vm.invoke(() -> {
InitialImageOperation.slowImageProcessing = 0;
}));
}
@@ -176,17 +177,18 @@ public class AcceptorImplClientQueueDistributedTest implements Serializable {
cache.createClientRegionFactory(ClientRegionShortcut.PROXY);
AtomicInteger eventCount = new AtomicInteger(0);
- Region region = clientRegionFactory.addCacheListener(new CacheListenerAdapter() {
- @Override
- public void afterCreate(EntryEvent event) {
- eventCount.incrementAndGet();
- }
-
- @Override
- public void afterUpdate(EntryEvent event) {
- eventCount.incrementAndGet();
- }
- }).create("subscriptionRegion");
+ Region<?, ?> region =
+ clientRegionFactory.addCacheListener(new CacheListenerAdapter<Object, Object>() {
+ @Override
+ public void afterCreate(EntryEvent event) {
+ eventCount.incrementAndGet();
+ }
+
+ @Override
+ public void afterUpdate(EntryEvent event) {
+ eventCount.incrementAndGet();
+ }
+ }).create("subscriptionRegion");
region.registerInterestRegex(".*", InterestResultPolicy.NONE, true);
cache.readyForEvents();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientDestroyRegionNotificationRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientDestroyRegionNotificationRegressionTest.java
index 8689c9a..6066626 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientDestroyRegionNotificationRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientDestroyRegionNotificationRegressionTest.java
@@ -15,6 +15,8 @@
package org.apache.geode.internal.cache.tier.sockets;
import static java.util.concurrent.TimeUnit.MINUTES;
+import static org.apache.geode.cache.RegionShortcut.REPLICATE;
+import static org.apache.geode.cache.client.ClientRegionShortcut.LOCAL;
import static org.apache.geode.test.dunit.VM.getHostName;
import static org.apache.geode.test.dunit.VM.getVM;
import static org.assertj.core.api.Assertions.assertThat;
@@ -29,9 +31,7 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.apache.geode.cache.RegionFactory;
-import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.cache.client.ClientRegionFactory;
-import org.apache.geode.cache.client.ClientRegionShortcut;
import org.apache.geode.cache.client.PoolManager;
import org.apache.geode.cache.client.internal.Connection;
import org.apache.geode.cache.client.internal.PoolImpl;
@@ -54,7 +54,7 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
* <p>
* TRAC #36269: RegionDestroy operation may get sent to the originator
*/
-@Category({ClientServerTest.class})
+@Category(ClientServerTest.class)
public class ClientDestroyRegionNotificationRegressionTest implements Serializable {
private String hostName;
@@ -68,7 +68,7 @@ public class ClientDestroyRegionNotificationRegressionTest implements Serializab
private VM server2;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -124,10 +124,10 @@ public class ClientDestroyRegionNotificationRegressionTest implements Serializab
CacheServerTestUtil.enableShufflingOfEndpoints();
}
- ClientRegionFactory crf =
- clientCacheRule.getClientCache().createClientRegionFactory(ClientRegionShortcut.LOCAL);
- crf.setPoolName(pool.getName());
- crf.create(regionName);
+ ClientRegionFactory<?, ?> clientRegionFactory =
+ clientCacheRule.getClientCache().createClientRegionFactory(LOCAL);
+ clientRegionFactory.setPoolName(pool.getName());
+ clientRegionFactory.create(regionName);
Connection connection = pool.acquireConnection(new ServerLocation(hostName, port2));
EventID eventId = new EventID(new byte[] {1}, 1, 1);
@@ -139,13 +139,12 @@ public class ClientDestroyRegionNotificationRegressionTest implements Serializab
private int createServerCache() throws IOException {
cacheRule.createCache();
- RegionFactory rf = cacheRule.getCache().createRegionFactory(RegionShortcut.REPLICATE);
- rf.create(regionName);
+ RegionFactory<?, ?> regionFactory = cacheRule.getCache().createRegionFactory(REPLICATE);
+ regionFactory.create(regionName);
- CacheServer server = cacheRule.getCache().addCacheServer();
- server.setPort(0);
- server.setNotifyBySubscription(true);
- server.start();
- return server.getPort();
+ CacheServer cacheServer = cacheRule.getCache().addCacheServer();
+ cacheServer.setPort(0);
+ cacheServer.start();
+ return cacheServer.getPort();
}
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientDestroyRegionUnregisterInterestRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientDestroyRegionUnregisterInterestRegressionTest.java
index 63dffb1..6c6fb3e 100755
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientDestroyRegionUnregisterInterestRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientDestroyRegionUnregisterInterestRegressionTest.java
@@ -14,6 +14,8 @@
*/
package org.apache.geode.internal.cache.tier.sockets;
+import static org.apache.geode.cache.RegionShortcut.REPLICATE;
+import static org.apache.geode.cache.client.ClientRegionShortcut.LOCAL;
import static org.apache.geode.test.dunit.Invoke.invokeInEveryVM;
import static org.apache.geode.test.dunit.VM.getHostName;
import static org.apache.geode.test.dunit.VM.getVM;
@@ -35,9 +37,7 @@ import org.junit.experimental.categories.Category;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionFactory;
-import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.cache.client.ClientRegionFactory;
-import org.apache.geode.cache.client.ClientRegionShortcut;
import org.apache.geode.cache.client.Pool;
import org.apache.geode.cache.client.PoolManager;
import org.apache.geode.cache.client.internal.PoolImpl;
@@ -60,7 +60,7 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
* TRAC #36457: Region Destroy results in unregister interest propagation to server resulting in
* server being falsely marked dead
*/
-@Category({ClientServerTest.class})
+@Category(ClientServerTest.class)
public class ClientDestroyRegionUnregisterInterestRegressionTest implements Serializable {
private String uniqueName;
@@ -73,7 +73,7 @@ public class ClientDestroyRegionUnregisterInterestRegressionTest implements Seri
private VM client2;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -119,10 +119,8 @@ public class ClientDestroyRegionUnregisterInterestRegressionTest implements Seri
client1.invoke(() -> clientCacheRule.getClientCache().getRegion(regionName).destroyRegion());
- client2.invoke(() -> {
- verify(ClientServerObserverHolder.getInstance(), times(0))
- .afterPrimaryIdentificationFromBackup(any());
- });
+ client2.invoke(() -> verify(ClientServerObserverHolder.getInstance(), times(0))
+ .afterPrimaryIdentificationFromBackup(any()));
}
private void createClientCache(int port1, int port2) {
@@ -131,13 +129,13 @@ public class ClientDestroyRegionUnregisterInterestRegressionTest implements Seri
Pool pool = PoolManager.createFactory().addServer(hostName, port1).addServer(hostName, port2)
.setSubscriptionEnabled(true).setMinConnections(4).create(uniqueName);
- ClientRegionFactory crf =
- clientCacheRule.getClientCache().createClientRegionFactory(ClientRegionShortcut.LOCAL);
- crf.setPoolName(pool.getName());
+ ClientRegionFactory<Object, ?> clientRegionFactory =
+ clientCacheRule.getClientCache().createClientRegionFactory(LOCAL);
+ clientRegionFactory.setPoolName(pool.getName());
- Region region = crf.create(regionName);
+ Region<Object, ?> region = clientRegionFactory.create(regionName);
- List listOfKeys = new ArrayList();
+ List<String> listOfKeys = new ArrayList<>();
listOfKeys.add("key-1");
listOfKeys.add("key-2");
listOfKeys.add("key-3");
@@ -150,13 +148,12 @@ public class ClientDestroyRegionUnregisterInterestRegressionTest implements Seri
private int createServerCache() throws IOException {
cacheRule.createCache();
- RegionFactory rf = cacheRule.getCache().createRegionFactory(RegionShortcut.REPLICATE);
+ RegionFactory regionFactory = cacheRule.getCache().createRegionFactory(REPLICATE);
- rf.create(regionName);
+ regionFactory.create(regionName);
CacheServer cacheServer = cacheRule.getCache().addCacheServer();
cacheServer.setPort(0);
- cacheServer.setNotifyBySubscription(true);
cacheServer.start();
return cacheServer.getPort();
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientProxyWithDeltaDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientProxyWithDeltaDistributedTest.java
index a7aa09e..91b75a3 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientProxyWithDeltaDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientProxyWithDeltaDistributedTest.java
@@ -15,11 +15,9 @@
package org.apache.geode.internal.cache.tier.sockets;
import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.apache.geode.internal.AvailablePort.SOCKET;
-import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort;
import static org.apache.geode.test.dunit.Disconnect.disconnectAllFromDS;
import static org.apache.geode.test.dunit.Invoke.invokeInEveryVM;
-import static org.apache.geode.test.dunit.NetworkUtils.getServerHostName;
+import static org.apache.geode.test.dunit.VM.getHostName;
import static org.apache.geode.test.dunit.VM.getVM;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
@@ -32,7 +30,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.After;
import org.junit.Before;
-import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -61,7 +59,7 @@ import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.DistributedRule;
import org.apache.geode.test.junit.categories.ClientSubscriptionTest;
-@Category({ClientSubscriptionTest.class})
+@Category(ClientSubscriptionTest.class)
@SuppressWarnings("serial")
public class ClientProxyWithDeltaDistributedTest implements Serializable {
@@ -78,8 +76,8 @@ public class ClientProxyWithDeltaDistributedTest implements Serializable {
private VM client1;
private VM client2;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Before
public void setUp() throws Exception {
@@ -87,7 +85,7 @@ public class ClientProxyWithDeltaDistributedTest implements Serializable {
client1 = getVM(1);
client2 = getVM(3);
- hostName = getServerHostName(server.getHost());
+ hostName = getHostName();
serverPort = server.invoke(() -> createServerCache());
@@ -113,7 +111,7 @@ public class ClientProxyWithDeltaDistributedTest implements Serializable {
* Verifies that delta put arrives as delta object to client with CACHING_PROXY region
*/
@Test
- public void cachingClientReceivesDeltaUpdates() throws Exception {
+ public void cachingClientReceivesDeltaUpdates() {
client1.invoke(() -> {
clientCache.close();
clientCache = null;
@@ -151,7 +149,7 @@ public class ClientProxyWithDeltaDistributedTest implements Serializable {
* Verifies that delta put arrives as complete object to client with PROXY region
*/
@Test
- public void emptyClientReceivesFullUpdatesInsteadOfDeltaUpdates() throws Exception {
+ public void emptyClientReceivesFullUpdatesInsteadOfDeltaUpdates() {
client2.invoke(() -> {
CacheClientUpdater.isUsedByTest = true;
clientCache.<Integer, DeltaEnabledObject>getRegion(PROXY_NAME).getAttributesMutator()
@@ -179,7 +177,7 @@ public class ClientProxyWithDeltaDistributedTest implements Serializable {
* Verifies that reusing delta object as value does not use delta when putting with new key
*/
@Test
- public void reusingValueForCreatesDoesNotUseDelta() throws Exception {
+ public void reusingValueForCreatesDoesNotUseDelta() {
client1.invoke(() -> {
Region<Integer, DeltaEnabledObject> region = clientCache.getRegion(PROXY_NAME);
DeltaEnabledObject objectWithDelta = new DeltaEnabledObject();
@@ -203,13 +201,13 @@ public class ClientProxyWithDeltaDistributedTest implements Serializable {
regionFactory.setDataPolicy(DataPolicy.REPLICATE);
regionFactory.setScope(Scope.DISTRIBUTED_ACK);
- regionFactory.<Integer, DeltaEnabledObject>create(PROXY_NAME);
- regionFactory.<Integer, DeltaEnabledObject>create(CACHING_PROXY_NAME);
+ regionFactory.create(PROXY_NAME);
+ regionFactory.create(CACHING_PROXY_NAME);
- CacheServer server = cache.addCacheServer();
- server.setPort(getRandomAvailablePort(SOCKET));
- server.start();
- return server.getPort();
+ CacheServer cacheServer = cache.addCacheServer();
+ cacheServer.setPort(0);
+ cacheServer.start();
+ return cacheServer.getPort();
}
private void createClientCacheWithProxyRegion(final String hostName, final int port) {
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientWithInterestFailoverDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientWithInterestFailoverDistributedTest.java
index 08d2078..0e15515 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientWithInterestFailoverDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientWithInterestFailoverDistributedTest.java
@@ -15,8 +15,6 @@
package org.apache.geode.internal.cache.tier.sockets;
import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.apache.geode.internal.AvailablePort.SOCKET;
-import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort;
import static org.apache.geode.test.dunit.Disconnect.disconnectAllFromDS;
import static org.apache.geode.test.dunit.Invoke.invokeInEveryVM;
import static org.apache.geode.test.dunit.NetworkUtils.getServerHostName;
@@ -31,7 +29,7 @@ import java.util.List;
import org.junit.After;
import org.junit.Before;
-import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -55,7 +53,7 @@ import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.DistributedRule;
import org.apache.geode.test.junit.categories.ClientServerTest;
-@Category({ClientServerTest.class})
+@Category(ClientServerTest.class)
@SuppressWarnings("serial")
public class ClientWithInterestFailoverDistributedTest implements Serializable {
@@ -74,8 +72,8 @@ public class ClientWithInterestFailoverDistributedTest implements Serializable {
private VM server;
private VM server2;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Before
public void setUp() throws Exception {
@@ -99,7 +97,7 @@ public class ClientWithInterestFailoverDistributedTest implements Serializable {
}
@Test
- public void clientWithSingleKeyInterestFailsOver() throws Exception {
+ public void clientWithSingleKeyInterestFailsOver() {
client.invoke(() -> registerKey(PROXY_REGION_NAME, 1));
client.invoke(() -> registerKey(CACHING_PROXY_REGION_NAME, 1));
@@ -107,7 +105,7 @@ public class ClientWithInterestFailoverDistributedTest implements Serializable {
}
@Test
- public void clientWithKeyListInterestFailsOver() throws Exception {
+ public void clientWithKeyListInterestFailsOver() {
client.invoke(() -> registerKeys(PROXY_REGION_NAME, 1, 2));
client.invoke(() -> registerKeys(CACHING_PROXY_REGION_NAME, 1, 2));
@@ -115,7 +113,7 @@ public class ClientWithInterestFailoverDistributedTest implements Serializable {
}
@Test
- public void clientWithRegexInterestFailsOver() throws Exception {
+ public void clientWithRegexInterestFailsOver() {
client.invoke(() -> registerRegex(PROXY_REGION_NAME));
client.invoke(() -> registerRegex(CACHING_PROXY_REGION_NAME));
@@ -146,13 +144,13 @@ public class ClientWithInterestFailoverDistributedTest implements Serializable {
regionFactory.setDataPolicy(DataPolicy.REPLICATE);
regionFactory.setScope(Scope.DISTRIBUTED_ACK);
- regionFactory.<Integer, Object>create(PROXY_REGION_NAME);
- regionFactory.<Integer, Object>create(CACHING_PROXY_REGION_NAME);
+ regionFactory.create(PROXY_REGION_NAME);
+ regionFactory.create(CACHING_PROXY_REGION_NAME);
- CacheServer server = cache.addCacheServer();
- server.setPort(getRandomAvailablePort(SOCKET));
- server.start();
- return server.getPort();
+ CacheServer cacheServer = cache.addCacheServer();
+ cacheServer.setPort(0);
+ cacheServer.start();
+ return cacheServer.getPort();
}
/**
@@ -222,7 +220,7 @@ public class ClientWithInterestFailoverDistributedTest implements Serializable {
}
private void registerKeys(final String regionName, final int... keys) {
- Region region = clientCache.getRegion(regionName);
+ Region<Object, ?> region = clientCache.getRegion(regionName);
List<Integer> list = new ArrayList<>();
for (int key : keys) {
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/GetConnectedServerCountRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/GetConnectedServerCountRegressionTest.java
index 500aa99..1442d33 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/GetConnectedServerCountRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/GetConnectedServerCountRegressionTest.java
@@ -56,7 +56,7 @@ public class GetConnectedServerCountRegressionTest implements Serializable {
private VM server3;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -109,9 +109,9 @@ public class GetConnectedServerCountRegressionTest implements Serializable {
.setSubscriptionRedundancy(-1).setSubscriptionMessageTrackingTimeout(54321)
.setIdleTimeout(-1).setPingInterval(200).create(uniqueName);
- ClientRegionFactory crf =
+ ClientRegionFactory clientRegionFactory =
clientCacheRule.getClientCache().createClientRegionFactory(ClientRegionShortcut.LOCAL);
- crf.setPoolName(pool.getName());
+ clientRegionFactory.setPoolName(pool.getName());
}
private void stopServer() {
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/HARegionQueueStatsCloseRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/HARegionQueueStatsCloseRegressionTest.java
index 77eb3db..b63c7f6 100755
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/HARegionQueueStatsCloseRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/HARegionQueueStatsCloseRegressionTest.java
@@ -15,6 +15,8 @@
package org.apache.geode.internal.cache.tier.sockets;
import static java.util.concurrent.TimeUnit.MINUTES;
+import static org.apache.geode.cache.RegionShortcut.REPLICATE;
+import static org.apache.geode.cache.client.ClientRegionShortcut.LOCAL;
import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException;
import static org.apache.geode.test.dunit.VM.getHostName;
import static org.apache.geode.test.dunit.VM.getVM;
@@ -34,9 +36,7 @@ import org.junit.experimental.categories.Category;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionFactory;
-import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.cache.client.ClientRegionFactory;
-import org.apache.geode.cache.client.ClientRegionShortcut;
import org.apache.geode.cache.client.Pool;
import org.apache.geode.cache.client.PoolManager;
import org.apache.geode.cache.server.CacheServer;
@@ -56,7 +56,7 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
* <p>
* TRAC #37210: HARegionQueueStats are never closed
*/
-@Category({ClientServerTest.class})
+@Category(ClientServerTest.class)
public class HARegionQueueStatsCloseRegressionTest implements Serializable {
private String uniqueName;
@@ -69,7 +69,7 @@ public class HARegionQueueStatsCloseRegressionTest implements Serializable {
private VM client;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -102,7 +102,7 @@ public class HARegionQueueStatsCloseRegressionTest implements Serializable {
* dispatchedMessagesMap.
*/
@Test
- public void haRegionQueueClosesStatsWhenClientProxyIsClosed() throws Exception {
+ public void haRegionQueueClosesStatsWhenClientProxyIsClosed() {
addIgnoredException(SocketException.class);
addIgnoredException(IOException.class);
@@ -118,8 +118,8 @@ public class HARegionQueueStatsCloseRegressionTest implements Serializable {
private int createServerCache() throws IOException {
cacheRule.createCache();
- RegionFactory rf = cacheRule.getCache().createRegionFactory(RegionShortcut.REPLICATE);
- rf.create(regionName);
+ RegionFactory<?, ?> regionFactory = cacheRule.getCache().createRegionFactory(REPLICATE);
+ regionFactory.create(regionName);
CacheServer cacheServer = cacheRule.getCache().addCacheServer();
cacheServer.setMaximumTimeBetweenPings(1000000);
@@ -137,11 +137,11 @@ public class HARegionQueueStatsCloseRegressionTest implements Serializable {
.setThreadLocalConnections(true).setReadTimeout(10000).setSocketBufferSize(32768)
.setMinConnections(3).setSubscriptionRedundancy(-1).create(uniqueName);
- ClientRegionFactory crf =
- clientCacheRule.getClientCache().createClientRegionFactory(ClientRegionShortcut.LOCAL);
- crf.setPoolName(pool.getName());
+ ClientRegionFactory<Object, ?> clientRegionFactory =
+ clientCacheRule.getClientCache().createClientRegionFactory(LOCAL);
+ clientRegionFactory.setPoolName(pool.getName());
- Region region = crf.create(regionName);
+ Region<Object, ?> region = clientRegionFactory.create(regionName);
region.registerInterest("ALL_KEYS");
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/MessageTrackingTimeoutRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/MessageTrackingTimeoutRegressionTest.java
index ecd1df0..d6d4d50 100755
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/MessageTrackingTimeoutRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/MessageTrackingTimeoutRegressionTest.java
@@ -26,8 +26,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import org.apache.geode.cache.client.ClientRegionFactory;
-import org.apache.geode.cache.client.ClientRegionShortcut;
import org.apache.geode.cache.client.PoolManager;
import org.apache.geode.cache.client.internal.PoolImpl;
import org.apache.geode.cache.server.CacheServer;
@@ -59,7 +57,7 @@ public class MessageTrackingTimeoutRegressionTest implements Serializable {
private VM server3;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -114,25 +112,17 @@ public class MessageTrackingTimeoutRegressionTest implements Serializable {
private void createClientCache() {
clientCacheRule.createClientCache();
- PoolImpl pool = (PoolImpl) PoolManager.createFactory().addServer(hostName, port1)
+ PoolManager.createFactory().addServer(hostName, port1)
.addServer(hostName, port2).addServer(hostName, port3).setSubscriptionEnabled(true)
.setSubscriptionRedundancy(-1).setSubscriptionMessageTrackingTimeout(54321)
.setIdleTimeout(-1).setPingInterval(200).create(uniqueName);
-
- ClientRegionFactory crf =
- clientCacheRule.getClientCache().createClientRegionFactory(ClientRegionShortcut.LOCAL);
- crf.setPoolName(pool.getName());
}
private void createClientCacheWithDefaultMessageTrackingTimeout() {
clientCacheRule.createClientCache();
- PoolImpl pool = (PoolImpl) PoolManager.createFactory().addServer(hostName, port1)
+ PoolManager.createFactory().addServer(hostName, port1)
.addServer(hostName, port2).addServer(hostName, port3).create(uniqueName);
-
- ClientRegionFactory crf =
- clientCacheRule.getClientCache().createClientRegionFactory(ClientRegionShortcut.LOCAL);
- crf.setPoolName(pool.getName());
}
private PoolImpl findPool(String name) {
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestOnServerWithoutRegionRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestOnServerWithoutRegionRegressionTest.java
index 047fcab..262149e 100755
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestOnServerWithoutRegionRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestOnServerWithoutRegionRegressionTest.java
@@ -15,6 +15,7 @@
package org.apache.geode.internal.cache.tier.sockets;
import static java.util.concurrent.TimeUnit.MINUTES;
+import static org.apache.geode.cache.client.ClientRegionShortcut.LOCAL;
import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException;
import static org.apache.geode.test.dunit.VM.getHostName;
import static org.apache.geode.test.dunit.VM.getVM;
@@ -36,7 +37,6 @@ import org.junit.experimental.categories.Category;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionDestroyedException;
import org.apache.geode.cache.client.ClientRegionFactory;
-import org.apache.geode.cache.client.ClientRegionShortcut;
import org.apache.geode.cache.client.PoolManager;
import org.apache.geode.cache.client.ServerOperationException;
import org.apache.geode.cache.client.internal.PoolImpl;
@@ -72,7 +72,7 @@ public class RegisterInterestOnServerWithoutRegionRegressionTest implements Seri
private VM client;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -112,7 +112,6 @@ public class RegisterInterestOnServerWithoutRegionRegressionTest implements Seri
CacheServer cacheServer = cacheRule.getCache().addCacheServer();
cacheServer.setPort(0);
- cacheServer.setNotifyBySubscription(true);
cacheServer.start();
return cacheServer.getPort();
}
@@ -124,18 +123,18 @@ public class RegisterInterestOnServerWithoutRegionRegressionTest implements Seri
.setSubscriptionEnabled(true).setMinConnections(4).create(uniqueName);
ClientRegionFactory crf =
- clientCacheRule.getClientCache().createClientRegionFactory(ClientRegionShortcut.LOCAL);
+ clientCacheRule.getClientCache().createClientRegionFactory(LOCAL);
crf.setPoolName(pool.getName());
crf.create(regionName);
}
- private void registerInterest() throws Exception {
+ private void registerInterest() {
try (IgnoredException ie = addIgnoredException(RegionDestroyedException.class)) {
- Region region = clientCacheRule.getClientCache().getRegion(regionName);
+ Region<Object, ?> region = clientCacheRule.getClientCache().getRegion(regionName);
assertNotNull(region);
- List listOfKeys = new ArrayList<>();
+ List<String> listOfKeys = new ArrayList<>();
listOfKeys.add("key-1");
listOfKeys.add("key-2");
listOfKeys.add("key-3");
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestServerMetaDataDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestServerMetaDataDistributedTest.java
index fbfd154..31e3a11 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestServerMetaDataDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestServerMetaDataDistributedTest.java
@@ -15,8 +15,7 @@
package org.apache.geode.internal.cache.tier.sockets;
import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.apache.geode.internal.AvailablePort.SOCKET;
-import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort;
+import static org.apache.geode.cache.Region.SEPARATOR;
import static org.apache.geode.test.dunit.Disconnect.disconnectAllFromDS;
import static org.apache.geode.test.dunit.Invoke.invokeInEveryVM;
import static org.apache.geode.test.dunit.NetworkUtils.getServerHostName;
@@ -31,7 +30,7 @@ import java.util.List;
import org.junit.After;
import org.junit.Before;
-import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -54,7 +53,7 @@ import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.DistributedRule;
import org.apache.geode.test.junit.categories.ClientSubscriptionTest;
-@Category({ClientSubscriptionTest.class})
+@Category(ClientSubscriptionTest.class)
@SuppressWarnings("serial")
public class RegisterInterestServerMetaDataDistributedTest implements Serializable {
@@ -70,8 +69,8 @@ public class RegisterInterestServerMetaDataDistributedTest implements Serializab
private VM server;
private VM client;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Before
public void setUp() throws Exception {
@@ -96,7 +95,7 @@ public class RegisterInterestServerMetaDataDistributedTest implements Serializab
}
@Test
- public void registerInterestSingleKeyCanBeInvokedMultipleTimes() throws Exception {
+ public void registerInterestSingleKeyCanBeInvokedMultipleTimes() {
client.invoke(() -> registerKey(PROXY_REGION_NAME, 1));
client.invoke(() -> registerKey(CACHING_PROXY_REGION_NAME, 1));
@@ -115,7 +114,7 @@ public class RegisterInterestServerMetaDataDistributedTest implements Serializab
}
@Test
- public void registerInterestRegexCanBeInvokedMultipleTimes() throws Exception {
+ public void registerInterestRegexCanBeInvokedMultipleTimes() {
client.invoke(() -> registerRegex(PROXY_REGION_NAME, ".*"));
client.invoke(() -> registerRegex(CACHING_PROXY_REGION_NAME, ".*"));
@@ -134,7 +133,7 @@ public class RegisterInterestServerMetaDataDistributedTest implements Serializab
}
@Test
- public void registerInterestKeyListCanBeInvokedMultipleTimes() throws Exception {
+ public void registerInterestKeyListCanBeInvokedMultipleTimes() {
client.invoke(() -> registerKeys(PROXY_REGION_NAME, 1, 2));
client.invoke(() -> registerKeys(CACHING_PROXY_REGION_NAME, 1, 2));
@@ -159,13 +158,13 @@ public class RegisterInterestServerMetaDataDistributedTest implements Serializab
regionFactory.setDataPolicy(DataPolicy.REPLICATE);
regionFactory.setScope(Scope.DISTRIBUTED_ACK);
- regionFactory.<Integer, Object>create(PROXY_REGION_NAME);
- regionFactory.<Integer, Object>create(CACHING_PROXY_REGION_NAME);
+ regionFactory.create(PROXY_REGION_NAME);
+ regionFactory.create(CACHING_PROXY_REGION_NAME);
- CacheServer server = cache.addCacheServer();
- server.setPort(getRandomAvailablePort(SOCKET));
- server.start();
- return server.getPort();
+ CacheServer cacheServer = cache.addCacheServer();
+ cacheServer.setPort(0);
+ cacheServer.start();
+ return cacheServer.getPort();
}
private void createClientCacheWithTwoRegions(final String host, final int port) {
@@ -226,7 +225,7 @@ public class RegisterInterestServerMetaDataDistributedTest implements Serializab
* Register list of keys on given region
*/
private void registerKeys(final String regionName, final int... keys) {
- Region region = clientCache.getRegion(regionName);
+ Region<Object, ?> region = clientCache.getRegion(regionName);
List<Integer> list = new ArrayList<>();
for (int key : keys) {
@@ -251,7 +250,7 @@ public class RegisterInterestServerMetaDataDistributedTest implements Serializab
assertThat(proxy).isNotNull();
await().atMost(30, SECONDS).until(() -> getClientProxy().isAlive() && getClientProxy()
- .getRegionsWithEmptyDataPolicy().containsKey(Region.SEPARATOR + PROXY_REGION_NAME));
+ .getRegionsWithEmptyDataPolicy().containsKey(SEPARATOR + PROXY_REGION_NAME));
}
private void validateServerMetaDataKnowsThatClientRegisteredInterest() {
@@ -261,12 +260,11 @@ public class RegisterInterestServerMetaDataDistributedTest implements Serializab
private void validateServerMetaDataKnowsWhichClientRegionIsEmpty() {
CacheClientProxy proxy = getClientProxy();
+ assertThat(proxy.getRegionsWithEmptyDataPolicy()).containsKey(SEPARATOR + PROXY_REGION_NAME);
assertThat(proxy.getRegionsWithEmptyDataPolicy())
- .containsKey(Region.SEPARATOR + PROXY_REGION_NAME);
- assertThat(proxy.getRegionsWithEmptyDataPolicy())
- .doesNotContainKey(Region.SEPARATOR + CACHING_PROXY_REGION_NAME);
+ .doesNotContainKey(SEPARATOR + CACHING_PROXY_REGION_NAME);
assertThat(proxy.getRegionsWithEmptyDataPolicy()).hasSize(1);
- assertThat(proxy.getRegionsWithEmptyDataPolicy())
- .containsEntry(Region.SEPARATOR + PROXY_REGION_NAME, 0);
+ assertThat(proxy.getRegionsWithEmptyDataPolicy()).containsEntry(SEPARATOR + PROXY_REGION_NAME,
+ 0);
}
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RootRegionsExcludesHARegionsRegressionTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RootRegionsExcludesHARegionsRegressionTest.java
index 9904e4e..a9eadf1 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RootRegionsExcludesHARegionsRegressionTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RootRegionsExcludesHARegionsRegressionTest.java
@@ -69,7 +69,7 @@ public class RootRegionsExcludesHARegionsRegressionTest implements Serializable
private VM client;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -101,13 +101,12 @@ public class RootRegionsExcludesHARegionsRegressionTest implements Serializable
private int createServer() throws IOException {
cacheRule.createCache();
- RegionFactory rf = cacheRule.getCache().createRegionFactory(REPLICATE);
- rf.setEnableSubscriptionConflation(true);
- rf.create(regionName);
+ RegionFactory<?, ?> regionFactory = cacheRule.getCache().createRegionFactory(REPLICATE);
+ regionFactory.setEnableSubscriptionConflation(true);
+ regionFactory.create(regionName);
CacheServer cacheServer = cacheRule.getCache().addCacheServer();
cacheServer.setPort(port);
- cacheServer.setNotifyBySubscription(true);
cacheServer.start();
return cacheServer.getPort();
}
@@ -119,13 +118,14 @@ public class RootRegionsExcludesHARegionsRegressionTest implements Serializable
clientCacheRule.createClientCache(config);
- PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory();
- pf.addServer(hostName, port).setSubscriptionEnabled(true).setSubscriptionRedundancy(0);
+ PoolFactoryImpl poolFactory = (PoolFactoryImpl) PoolManager.createFactory();
+ poolFactory.addServer(hostName, port).setSubscriptionEnabled(true).setSubscriptionRedundancy(0);
- ClientRegionFactory crf = clientCacheRule.getClientCache().createClientRegionFactory(LOCAL);
- crf.setPoolName(pf.create(uniqueName).getName());
+ ClientRegionFactory<?, ?> clientRegionFactory =
+ clientCacheRule.getClientCache().createClientRegionFactory(LOCAL);
+ clientRegionFactory.setPoolName(poolFactory.create(uniqueName).getName());
- crf.create(regionName);
+ clientRegionFactory.create(regionName);
clientCacheRule.getClientCache().readyForEvents();
}
@@ -133,7 +133,7 @@ public class RootRegionsExcludesHARegionsRegressionTest implements Serializable
private void validateRootRegions() {
Set<Region<?, ?>> regions = cacheRule.getCache().rootRegions();
if (regions != null) {
- for (Region region : regions) {
+ for (Region<?, ?> region : regions) {
assertThat(region).isNotInstanceOf(HARegion.class);
}
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventListenerDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventListenerDistributedTest.java
index 79bf74e..b2a50cd 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventListenerDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventListenerDistributedTest.java
@@ -83,7 +83,7 @@ public class AsyncEventListenerDistributedTest implements Serializable {
}
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventListenerWithCacheLoaderDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventListenerWithCacheLoaderDistributedTest.java
index 3c8711d..0747748 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventListenerWithCacheLoaderDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventListenerWithCacheLoaderDistributedTest.java
@@ -74,11 +74,11 @@ public class AsyncEventListenerWithCacheLoaderDistributedTest implements Seriali
@Parameters(name = "dispatcherThreadCount={0}")
public static Iterable<Integer> dispatcherThreadCounts() {
- return Arrays.asList(1, 3); // used to include 3, 5 as well
+ return Arrays.asList(1, 3);
}
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventListenerWithFilterDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventListenerWithFilterDistributedTest.java
index 39105ab..5b9fe12 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventListenerWithFilterDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventListenerWithFilterDistributedTest.java
@@ -95,11 +95,11 @@ public class AsyncEventListenerWithFilterDistributedTest implements Serializable
@Parameters(name = "dispatcherThreadCount={0}")
public static Iterable<Integer> dispatcherThreadCounts() {
- return Arrays.asList(1, 3); // used to include 3, 5 as well
+ return Arrays.asList(1, 3);
}
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/ConcurrentAsyncEventListenerDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/ConcurrentAsyncEventListenerDistributedTest.java
index fbac68c..55d2905 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/ConcurrentAsyncEventListenerDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/ConcurrentAsyncEventListenerDistributedTest.java
@@ -71,7 +71,7 @@ public class ConcurrentAsyncEventListenerDistributedTest implements Serializable
private static final String SUBSTITUTION_PREFIX = "substituted_";
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/ParallelAsyncEventListenerDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/ParallelAsyncEventListenerDistributedTest.java
index 7e5e3fb..c5a3503 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/ParallelAsyncEventListenerDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/ParallelAsyncEventListenerDistributedTest.java
@@ -117,7 +117,7 @@ public class ParallelAsyncEventListenerDistributedTest implements Serializable {
}
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/SerialEventListenerDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/SerialEventListenerDistributedTest.java
index 03b8063..54166b4 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/SerialEventListenerDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/SerialEventListenerDistributedTest.java
@@ -66,7 +66,7 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolde
public class SerialEventListenerDistributedTest implements Serializable {
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/ClientServerJTAFailoverDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/ClientServerJTAFailoverDistributedTest.java
index f019c06..cb6be25 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/ClientServerJTAFailoverDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/ClientServerJTAFailoverDistributedTest.java
@@ -15,6 +15,8 @@
package org.apache.geode.internal.jta;
+import static org.apache.geode.cache.RegionShortcut.PARTITION;
+import static org.apache.geode.cache.client.ClientRegionShortcut.LOCAL;
import static org.apache.geode.test.dunit.VM.getHostName;
import static org.apache.geode.test.dunit.VM.getVM;
import static org.junit.Assert.assertEquals;
@@ -29,13 +31,11 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.apache.geode.cache.PartitionAttributes;
import org.apache.geode.cache.PartitionAttributesFactory;
import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.cache.RegionFactory;
import org.apache.geode.cache.TransactionId;
import org.apache.geode.cache.client.ClientRegionFactory;
-import org.apache.geode.cache.client.ClientRegionShortcut;
import org.apache.geode.cache.client.PoolFactory;
import org.apache.geode.cache.client.PoolManager;
import org.apache.geode.cache.client.internal.InternalClientCache;
@@ -55,7 +55,13 @@ import org.apache.geode.test.dunit.rules.ClientCacheRule;
import org.apache.geode.test.dunit.rules.DistributedRule;
import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
+@SuppressWarnings("serial")
public class ClientServerJTAFailoverDistributedTest implements Serializable {
+
+ private final int key = 1;
+ private final String value = "value1";
+ private final String newValue = "value2";
+
private String hostName;
private String uniqueName;
private String regionName;
@@ -66,12 +72,8 @@ public class ClientServerJTAFailoverDistributedTest implements Serializable {
private int port1;
private int port2;
- private final int key = 1;
- private final String value = "value1";
- private final String newValue = "value2";
-
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -118,14 +120,15 @@ public class ClientServerJTAFailoverDistributedTest implements Serializable {
}
private int createServerRegion(int totalNumBuckets, boolean isAccessor) throws Exception {
- PartitionAttributesFactory factory = new PartitionAttributesFactory();
- factory.setTotalNumBuckets(totalNumBuckets);
+ PartitionAttributesFactory<?, ?> partitionAttributesFactory = new PartitionAttributesFactory();
+ partitionAttributesFactory.setTotalNumBuckets(totalNumBuckets);
if (isAccessor) {
- factory.setLocalMaxMemory(0);
+ partitionAttributesFactory.setLocalMaxMemory(0);
}
- PartitionAttributes partitionAttributes = factory.create();
- cacheRule.getOrCreateCache().createRegionFactory(RegionShortcut.PARTITION)
- .setPartitionAttributes(partitionAttributes).create(regionName);
+
+ RegionFactory regionFactory = cacheRule.getOrCreateCache().createRegionFactory(PARTITION);
+ regionFactory.setPartitionAttributes(partitionAttributesFactory.create());
+ regionFactory.create(regionName);
CacheServer server = cacheRule.getCache().addCacheServer();
server.setPort(0);
@@ -144,10 +147,10 @@ public class ClientServerJTAFailoverDistributedTest implements Serializable {
CacheServerTestUtil.enableShufflingOfEndpoints();
}
- ClientRegionFactory crf =
- clientCacheRule.getClientCache().createClientRegionFactory(ClientRegionShortcut.LOCAL);
- crf.setPoolName(pool.getName());
- crf.create(regionName);
+ ClientRegionFactory<?, ?> clientRegionFactory =
+ clientCacheRule.getClientCache().createClientRegionFactory(LOCAL);
+ clientRegionFactory.setPoolName(pool.getName());
+ clientRegionFactory.create(regionName);
if (ports.length > 1) {
pool.acquireConnection(new ServerLocation(hostName, port1));
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/JMXMBeanDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/JMXMBeanDUnitTest.java
index 220ae72..f5b7257 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/JMXMBeanDUnitTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/management/JMXMBeanDUnitTest.java
@@ -33,22 +33,23 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_KEYSTORE_
import static org.apache.geode.distributed.ConfigurationProperties.SSL_PROTOCOLS;
import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE;
import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD;
-import static org.apache.geode.test.dunit.Host.getHost;
+import static org.apache.geode.test.dunit.VM.getVM;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
+import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+import javax.management.MalformedObjectNameException;
import javax.rmi.ssl.SslRMIClientSocketFactory;
import com.google.common.collect.Maps;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -63,16 +64,25 @@ import org.apache.geode.test.junit.categories.JMXTest;
import org.apache.geode.test.junit.rules.MBeanServerConnectionRule;
import org.apache.geode.util.test.TestUtil;
-
/**
* All the non-ssl enabled locators need to be in a different VM than the ssl enabled locators in
* these tests, otherwise, some tests would fail. Seems like dunit vm tear down did not clean up the
* ssl settings cleanly.
*/
-@Category({JMXTest.class})
+@Category(JMXTest.class)
@SuppressWarnings("serial")
public class JMXMBeanDUnitTest implements Serializable {
+ private final ClusterStartupRule clusterStartupRule = new ClusterStartupRule();
+ private final transient MBeanServerConnectionRule mBeanServerConnectionRule =
+ new MBeanServerConnectionRule();
+
+ @Rule
+ public transient RuleChain ruleChain =
+ RuleChain.outerRule(new DistributedRule()).around(new CleanupDUnitVMsRule())
+ .around(clusterStartupRule).around(
+ mBeanServerConnectionRule);
+
private static Properties legacySSLProperties;
private static Properties sslProperties;
private static Properties sslPropertiesWithMultiKey;
@@ -83,17 +93,6 @@ public class JMXMBeanDUnitTest implements Serializable {
private int jmxPort;
private Properties locatorProperties;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
-
- private transient CleanupDUnitVMsRule cleanupDUnitVMsRule = new CleanupDUnitVMsRule();
- private ClusterStartupRule lsRule = new ClusterStartupRule();
- private transient MBeanServerConnectionRule jmxConnector = new MBeanServerConnectionRule();
-
- @Rule
- public transient RuleChain ruleChain =
- RuleChain.outerRule(cleanupDUnitVMsRule).around(lsRule).around(jmxConnector);
-
@BeforeClass
public static void beforeClass() {
singleKeystore = TestUtil.getResourcePath(JMXMBeanDUnitTest.class, "/ssl/trusted.keystore");
@@ -141,46 +140,46 @@ public class JMXMBeanDUnitTest implements Serializable {
@Test
public void testJMXOverNonSSL() throws Exception {
- lsRule.startLocatorVM(0, locatorProperties);
- jmxConnector.connect(jmxPort);
- validateJmxConnection(jmxConnector);
+ clusterStartupRule.startLocatorVM(0, locatorProperties);
+ mBeanServerConnectionRule.connect(jmxPort);
+ validateJmxConnection(mBeanServerConnectionRule);
}
@Test
- public void testJMXOverNonSSLWithClientUsingIncorrectPort() throws Exception {
+ public void testJMXOverNonSSLWithClientUsingIncorrectPort() {
assertThat(jmxPort).isNotEqualTo(9999);
- lsRule.startLocatorVM(0, locatorProperties);
+ clusterStartupRule.startLocatorVM(0, locatorProperties);
- assertThatThrownBy(() -> jmxConnector.connect(9999))
+ assertThatThrownBy(() -> mBeanServerConnectionRule.connect(9999))
.hasRootCauseExactlyInstanceOf(java.net.ConnectException.class);
}
@Test
- public void testJMXOverSSL() throws Exception {
+ public void testJMXOverSSL() {
locatorProperties.putAll(Maps.fromProperties(sslProperties));
- lsRule.startLocatorVM(0, locatorProperties);
+ clusterStartupRule.startLocatorVM(0, locatorProperties);
remotelyValidateJmxConnection(false);
}
@Test
- public void testJMXOverSSLWithMultiKey() throws Exception {
+ public void testJMXOverSSLWithMultiKey() {
locatorProperties.putAll(Maps.fromProperties(sslPropertiesWithMultiKey));
- lsRule.startLocatorVM(0, locatorProperties);
+ clusterStartupRule.startLocatorVM(0, locatorProperties);
remotelyValidateJmxConnection(true);
}
@Test
- public void testJMXOverLegacySSL() throws Exception {
+ public void testJMXOverLegacySSL() {
locatorProperties.putAll(Maps.fromProperties(legacySSLProperties));
- lsRule.startLocatorVM(0, locatorProperties);
+ clusterStartupRule.startLocatorVM(0, locatorProperties);
remotelyValidateJmxConnection(false);
}
private void remotelyValidateJmxConnection(boolean withAlias) {
- getHost(0).getVM(2).invoke(() -> {
+ getVM(2).invoke(() -> {
beforeClass();
MBeanServerConnectionRule jmx = new MBeanServerConnectionRule();
Map<String, Object> env = getClientEnvironment(withAlias);
@@ -202,7 +201,7 @@ public class JMXMBeanDUnitTest implements Serializable {
}
private void validateJmxConnection(MBeanServerConnectionRule mBeanServerConnectionRule)
- throws Exception {
+ throws IOException, MalformedObjectNameException {
// Get MBean proxy instance that will be used to make calls to registered MBean
DistributedSystemMXBean distributedSystemMXBean =
mBeanServerConnectionRule.getProxyMXBean(DistributedSystemMXBean.class);
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/test/dunit/tests/GetCurrentVmNumDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/test/dunit/tests/GetCurrentVmNumDistributedTest.java
index 234afab..ce94265 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/test/dunit/tests/GetCurrentVmNumDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/test/dunit/tests/GetCurrentVmNumDistributedTest.java
@@ -26,11 +26,10 @@ import org.junit.Test;
import org.apache.geode.test.dunit.rules.DistributedRule;
-
public class GetCurrentVmNumDistributedTest {
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Test
public void returnsNegativeOneInController() {
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/test/dunit/tests/GetPidAndIdAfterBounceDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/test/dunit/tests/GetPidAndIdAfterBounceDistributedTest.java
index 33c3932..c0f3c9b 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/test/dunit/tests/GetPidAndIdAfterBounceDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/test/dunit/tests/GetPidAndIdAfterBounceDistributedTest.java
@@ -24,17 +24,16 @@ import org.junit.Test;
import org.apache.geode.test.dunit.rules.DistributedRule;
-
public class GetPidAndIdAfterBounceDistributedTest {
private int[] idsBefore;
private int[] pidsBefore;
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
idsBefore = new int[getVMCount()];
pidsBefore = new int[getVMCount()];
@@ -46,14 +45,14 @@ public class GetPidAndIdAfterBounceDistributedTest {
}
@Test
- public void getIdShouldReturnSameValueAfterBounce() throws Exception {
+ public void getIdShouldReturnSameValueAfterBounce() {
for (int i = 0; i < getVMCount(); i++) {
assertThat(getVM(i).getId()).isEqualTo(idsBefore[i]);
}
}
@Test
- public void getPidShouldReturnDifferentValueAfterBounce() throws Exception {
+ public void getPidShouldReturnDifferentValueAfterBounce() {
for (int i = 0; i < getVMCount(); i++) {
assertThat(getVM(i).getPid()).isNotEqualTo(pidsBefore[i]);
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/test/dunit/tests/GetPidAndIdDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/test/dunit/tests/GetPidAndIdDistributedTest.java
index df76d50..afcf27c 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/test/dunit/tests/GetPidAndIdDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/test/dunit/tests/GetPidAndIdDistributedTest.java
@@ -25,14 +25,13 @@ import org.apache.geode.internal.process.ProcessUtils;
import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.DistributedRule;
-
public class GetPidAndIdDistributedTest {
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Test
- public void getId_returnsVMSequentialId() throws Exception {
+ public void getId_returnsVMSequentialId() {
for (int i = 0; i < getVMCount(); i++) {
VM vm = getVM(i);
assertThat(vm.getId()).isEqualTo(i);
@@ -40,7 +39,7 @@ public class GetPidAndIdDistributedTest {
}
@Test
- public void getPid_returnsVMProcessId() throws Exception {
+ public void getPid_returnsVMProcessId() {
for (int i = 0; i < getVMCount(); i++) {
VM vm = getVM(i);
int remotePid = vm.invoke(() -> ProcessUtils.identifyPid());
diff --git a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/AsyncInvokeCallableExampleTest.java b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/AsyncInvokeCallableExampleTest.java
index 2ed8b8c..1f21cbb 100644
--- a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/AsyncInvokeCallableExampleTest.java
+++ b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/AsyncInvokeCallableExampleTest.java
@@ -14,46 +14,38 @@
*/
package org.apache.geode.test.dunit.examples;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static org.apache.geode.test.dunit.VM.getVM;
import static org.assertj.core.api.Assertions.assertThat;
-import java.util.concurrent.TimeUnit;
-
-import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
import org.apache.geode.test.dunit.AsyncInvocation;
import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.DistributedRule;
-
-@SuppressWarnings("serial")
public class AsyncInvokeCallableExampleTest {
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Test
public void invokeAsyncAsFuture() throws Exception {
- VM workerVM = getVM(0);
- boolean success = workerVM.invokeAsync(() -> longRunningWorkWithResult()).get();
+ boolean success = getVM(0).invokeAsync(() -> longRunningWorkWithResult()).get();
assertThat(success).isTrue();
}
@Test
public void invokeAsyncAsFutureWithTimeout() throws Exception {
- VM workerVM = getVM(0);
- boolean success =
- workerVM.invokeAsync(() -> longRunningWorkWithResult()).get(1, TimeUnit.MINUTES);
+ boolean success = getVM(0).invokeAsync(() -> longRunningWorkWithResult()).get(1, MINUTES);
assertThat(success).isTrue();
}
@Test
public void invokeAsyncWithExceptionOccurred() throws Exception {
- VM workerVM = getVM(0);
-
AsyncInvocation<Boolean> asyncInvocation =
- workerVM.invokeAsync(() -> longRunningWorkThatThrowsException());
+ getVM(0).invokeAsync(() -> longRunningWorkThatThrowsException());
asyncInvocation.join();
assertThat(asyncInvocation.exceptionOccurred()).isTrue();
@@ -75,7 +67,7 @@ public class AsyncInvokeCallableExampleTest {
*/
@Test(expected = AssertionError.class)
public void invokeAsyncWithAwaitWithTimeout() throws Exception {
- getVM(0).invokeAsync(() -> longRunningWorkThatThrowsException()).await(1, TimeUnit.MINUTES);
+ getVM(0).invokeAsync(() -> longRunningWorkThatThrowsException()).await(1, MINUTES);
}
private static boolean longRunningWorkWithResult() {
diff --git a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/AsyncInvokeRunnableExampleTest.java b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/AsyncInvokeRunnableExampleTest.java
index 9cc4e7a..02fae7d 100644
--- a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/AsyncInvokeRunnableExampleTest.java
+++ b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/AsyncInvokeRunnableExampleTest.java
@@ -19,22 +19,20 @@ import static org.apache.geode.test.dunit.VM.getAllVMs;
import java.util.ArrayList;
import java.util.List;
-import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
import org.apache.geode.test.dunit.AsyncInvocation;
import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.DistributedRule;
-
-@SuppressWarnings("serial")
public class AsyncInvokeRunnableExampleTest {
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Test
- public void invokeAsyncHelloWorldInEachVM() throws Exception {
+ public void invokeAsyncHelloWorldInEachVM() {
for (VM vm : getAllVMs()) {
vm.invokeAsync(() -> System.out.println(vm + " says Hello World!"));
}
diff --git a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/CatchingUnexpectedExceptionExampleTest.java b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/CatchingUnexpectedExceptionExampleTest.java
index be07b3b..8bb58d4 100644
--- a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/CatchingUnexpectedExceptionExampleTest.java
+++ b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/CatchingUnexpectedExceptionExampleTest.java
@@ -32,18 +32,17 @@ import org.apache.geode.internal.cache.LocalRegion;
import org.apache.geode.test.dunit.SerializableRunnable;
import org.apache.geode.test.dunit.rules.DistributedRule;
-
@SuppressWarnings("serial")
public class CatchingUnexpectedExceptionExampleTest implements Serializable {
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
/**
* Don't do this! Catch Exception and invoke fail => anti-pattern
*/
@Test
- public void createRegion_withTryCatch_DO_NOT_DO_THIS() throws Exception {
+ public void createRegion_withTryCatch_DO_NOT_DO_THIS() {
getVM(0).invoke(new SerializableRunnable("Create Region") {
@Override
public void run() {
@@ -63,10 +62,10 @@ public class CatchingUnexpectedExceptionExampleTest implements Serializable {
* Use "throws Exception" is better!
*/
@Test
- public void createRegion_withThrowsException_THIS_IS_BETTER() throws Exception {
+ public void createRegion_withThrowsException_THIS_IS_BETTER() {
getVM(0).invoke(new SerializableRunnable("Create Region") {
@Override
- public void run() throws Exception {
+ public void run() {
Cache cache = new CacheFactory().create();
RegionFactory regionFactory = cache.createRegionFactory(new AttributesFactory().create());
LocalRegion region = (LocalRegion) regionFactory.create("region1");
@@ -79,7 +78,7 @@ public class CatchingUnexpectedExceptionExampleTest implements Serializable {
* Use lambda without having to specify run() with throws Exception -- best!
*/
@Test
- public void createRegion_withLambda_THIS_IS_BEST() throws Exception {
+ public void createRegion_withLambda_THIS_IS_BEST() {
getVM(0).invoke("Create Region", () -> {
Cache cache = new CacheFactory().create();
RegionFactory regionFactory = cache.createRegionFactory(new AttributesFactory().create());
diff --git a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/InvokeRunnableExampleTest.java b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/InvokeRunnableExampleTest.java
index d6a1757..3badbb9 100644
--- a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/InvokeRunnableExampleTest.java
+++ b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/InvokeRunnableExampleTest.java
@@ -18,27 +18,26 @@ import static org.apache.geode.test.dunit.VM.getAllVMs;
import static org.apache.geode.test.dunit.VM.getVM;
import static org.apache.geode.test.dunit.VM.getVMCount;
-import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.DistributedRule;
-
public class InvokeRunnableExampleTest {
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Test
- public void invokeHelloWorldForEachVMInGetAllVMs() throws Exception {
+ public void invokeHelloWorldForEachVMInGetAllVMs() {
for (VM vm : getAllVMs()) {
vm.invoke(() -> System.out.println(vm + " says Hello World!"));
}
}
@Test
- public void invokeHelloWorldInEachVMInOrder() throws Exception {
+ public void invokeHelloWorldInEachVMInOrder() {
for (int whichVM = 0; whichVM < getVMCount(); whichVM++) {
VM vm = getVM(whichVM);
vm.invoke(() -> System.out.println(vm + " says Hello World!"));
diff --git a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/LocatorPortClusterExampleTest.java b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/LocatorPortClusterExampleTest.java
index 2ee0d24..d01bb4d 100644
--- a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/LocatorPortClusterExampleTest.java
+++ b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/LocatorPortClusterExampleTest.java
@@ -34,12 +34,11 @@ import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.DistributedRule;
-
@SuppressWarnings("serial")
public class LocatorPortClusterExampleTest implements Serializable {
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
private static InternalCache cache;
@@ -68,7 +67,7 @@ public class LocatorPortClusterExampleTest implements Serializable {
}
@Test
- public void clusterHasDUnitVMCountPlusTwoByDefault() throws Exception {
+ public void clusterHasDUnitVMCountPlusTwoByDefault() {
int dunitVMCount = getVMCount();
assertThat(cache.getDistributionManager().getViewMembers()).hasSize(dunitVMCount + 2);
}
diff --git a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/ReplaceTryFinallyExampleTest.java b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/ReplaceTryFinallyExampleTest.java
index ed501d6..aab0f9b 100644
--- a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/ReplaceTryFinallyExampleTest.java
+++ b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/examples/ReplaceTryFinallyExampleTest.java
@@ -16,17 +16,15 @@ package org.apache.geode.test.dunit.examples;
import org.junit.After;
import org.junit.Before;
-import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
import org.apache.geode.test.dunit.rules.DistributedRule;
-
-@SuppressWarnings("serial")
public class ReplaceTryFinallyExampleTest {
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Test
public void doNotUseTryFinallyInTest() {
@@ -49,11 +47,11 @@ public class ReplaceTryFinallyExampleTest {
}
@Test
- public void useBeforeAndAfterInstead() throws Exception {
+ public void useBeforeAndAfterInstead() {
// perform testing that needs behaveSlowly
}
public static class Bar {
- static boolean behaveSlowly = false;
+ static boolean behaveSlowly;
}
}
diff --git a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/CacheRuleBuilderDistributedTest.java b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/CacheRuleBuilderDistributedTest.java
index 12b342b..7cd7ba8 100644
--- a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/CacheRuleBuilderDistributedTest.java
+++ b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/CacheRuleBuilderDistributedTest.java
@@ -36,7 +36,7 @@ import org.apache.geode.test.dunit.rules.DistributedRule;
public class CacheRuleBuilderDistributedTest {
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Test
public void defaultDoesNothing() {
@@ -85,11 +85,14 @@ public class CacheRuleBuilderDistributedTest {
/**
* Used by test {@link #defaultDoesNothing()}.
+ *
+ * <p>
+ * NOTE: please keep the use of deprecated GemFireCacheImpl.getInstance().
*/
public static class DefaultDoesNothing implements Serializable {
@Rule
- public CacheRule cacheRule = CacheRule.builder().build();
+ public CacheRule cacheRule = new CacheRule();
@Test
public void getCache_returnsNullInAllVMs() {
diff --git a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/CacheRuleDistributedTest.java b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/CacheRuleDistributedTest.java
index f561857..fa36e74 100644
--- a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/CacheRuleDistributedTest.java
+++ b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/CacheRuleDistributedTest.java
@@ -36,7 +36,7 @@ import org.apache.geode.test.dunit.rules.DistributedRule;
public class CacheRuleDistributedTest {
@Rule
- public DistributedRule distributedTestRule = new DistributedRule();
+ public DistributedRule distributedRule = new DistributedRule();
@Test
public void defaultDoesNothing() {
diff --git a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/DistributedRestoreSystemPropertiesDistributedTest.java b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/DistributedRestoreSystemPropertiesDistributedTest.java
index 479c31b..373b120 100644
--- a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/DistributedRestoreSystemPropertiesDistributedTest.java
+++ b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/DistributedRestoreSystemPropertiesDistributedTest.java
@@ -31,7 +31,7 @@ import org.junit.Test;
import org.apache.geode.test.dunit.rules.DistributedRestoreSystemProperties;
import org.apache.geode.test.dunit.rules.DistributedRule;
-
+@SuppressWarnings("serial")
public class DistributedRestoreSystemPropertiesDistributedTest {
private static final String NULL_PROPERTY = "NULL_PROPERTY";
@@ -39,7 +39,7 @@ public class DistributedRestoreSystemPropertiesDistributedTest {
private static final String PREEXISTING_VALUE = "PREEXISTING_VALUE";
@ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ public static DistributedRule distributedRule = new DistributedRule();
@BeforeClass
public static void assertPreconditions() {
@@ -74,7 +74,7 @@ public class DistributedRestoreSystemPropertiesDistributedTest {
}
@Test
- public void nullPropertyWithDifferentValues() throws Exception {
+ public void nullPropertyWithDifferentValues() {
runTestWithValidation(NullPropertyWithDifferentValues.class);
assertThat(System.getProperty(NULL_PROPERTY)).isNull();
@@ -86,7 +86,7 @@ public class DistributedRestoreSystemPropertiesDistributedTest {
}
@Test
- public void preexistingPropertyWithDifferentValues() throws Exception {
+ public void preexistingPropertyWithDifferentValues() {
runTestWithValidation(NullPropertyWithDifferentValues.class);
assertThat(System.getProperty(PREEXISTING_PROPERTY)).isEqualTo(PREEXISTING_VALUE);
@@ -107,7 +107,7 @@ public class DistributedRestoreSystemPropertiesDistributedTest {
new DistributedRestoreSystemProperties();
@Test
- public void nullPropertyWithDifferentValues() throws Exception {
+ public void nullPropertyWithDifferentValues() {
System.setProperty(NULL_PROPERTY, "controller");
getVM(0).invoke(() -> System.setProperty(NULL_PROPERTY, "vm0"));
getVM(1).invoke(() -> System.setProperty(NULL_PROPERTY, "vm1"));
@@ -126,7 +126,7 @@ public class DistributedRestoreSystemPropertiesDistributedTest {
new DistributedRestoreSystemProperties();
@Test
- public void preexistingPropertyWithDifferentValues() throws Exception {
+ public void preexistingPropertyWithDifferentValues() {
System.setProperty(PREEXISTING_PROPERTY, "controller");
getVM(0).invoke(() -> System.setProperty(PREEXISTING_PROPERTY, "vm0"));
getVM(1).invoke(() -> System.setProperty(PREEXISTING_PROPERTY, "vm1"));
diff --git a/geode-dunit/src/main/java/org/apache/geode/test/dunit/rules/CacheRule.java b/geode-dunit/src/main/java/org/apache/geode/test/dunit/rules/CacheRule.java
index a75c22f..7b6ce63 100644
--- a/geode-dunit/src/main/java/org/apache/geode/test/dunit/rules/CacheRule.java
+++ b/geode-dunit/src/main/java/org/apache/geode/test/dunit/rules/CacheRule.java
@@ -15,6 +15,7 @@
package org.apache.geode.test.dunit.rules;
import static org.apache.geode.test.dunit.Disconnect.disconnectAllFromDS;
+import static org.apache.geode.test.dunit.VM.DEFAULT_VM_COUNT;
import static org.apache.geode.test.dunit.standalone.DUnitLauncher.getDistributedSystemProperties;
import static org.assertj.core.api.Assertions.assertThat;
@@ -107,7 +108,12 @@ public class CacheRule extends AbstractDistributedRule {
this(new Builder());
}
+ public CacheRule(final int vmCount) {
+ this(new Builder().vmCount(vmCount));
+ }
+
CacheRule(final Builder builder) {
+ super(builder.vmCount);
createCacheInAll = builder.createCacheInAll;
createCache = builder.createCache;
disconnectAfter = builder.disconnectAfter;
@@ -262,14 +268,16 @@ public class CacheRule extends AbstractDistributedRule {
*/
public static class Builder {
+ private final List<VM> createCacheInVMs = new ArrayList<>();
+ private final Properties systemProperties = new Properties();
+
private boolean createCacheInAll;
private boolean createCache;
private boolean disconnectAfter;
private boolean destroyRegions;
private boolean replaceConfig;
- private List<VM> createCacheInVMs = new ArrayList<>();
private Properties config = new Properties();
- private Properties systemProperties = new Properties();
+ private int vmCount = DEFAULT_VM_COUNT;
public Builder() {
// nothing
@@ -346,6 +354,11 @@ public class CacheRule extends AbstractDistributedRule {
return this;
}
+ public Builder vmCount(final int vmCount) {
+ this.vmCount = vmCount;
+ return this;
+ }
+
public CacheRule build() {
return new CacheRule(this);
}
diff --git a/geode-dunit/src/main/java/org/apache/geode/test/dunit/rules/ClientCacheRule.java b/geode-dunit/src/main/java/org/apache/geode/test/dunit/rules/ClientCacheRule.java
index 824b55b..ad7b452 100644
--- a/geode-dunit/src/main/java/org/apache/geode/test/dunit/rules/ClientCacheRule.java
+++ b/geode-dunit/src/main/java/org/apache/geode/test/dunit/rules/ClientCacheRule.java
@@ -15,6 +15,7 @@
package org.apache.geode.test.dunit.rules;
import static org.apache.geode.test.dunit.Disconnect.disconnectAllFromDS;
+import static org.apache.geode.test.dunit.VM.DEFAULT_VM_COUNT;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.ArrayList;
@@ -81,6 +82,10 @@ public class ClientCacheRule extends AbstractDistributedRule {
this(new Builder());
}
+ public ClientCacheRule(final int vmCount) {
+ this(new Builder());
+ }
+
ClientCacheRule(final Builder builder) {
createClientCache = builder.createClientCache;
disconnectAfter = builder.disconnectAfter;
@@ -166,11 +171,13 @@ public class ClientCacheRule extends AbstractDistributedRule {
*/
public static class Builder {
+ private final List<VM> createClientCacheInVMs = new ArrayList<>();
+ private final Properties systemProperties = new Properties();
+
private boolean createClientCache;
private boolean disconnectAfter;
- private List<VM> createClientCacheInVMs = new ArrayList<>();
private Properties config = new Properties();
- private Properties systemProperties = new Properties();
+ private int vmCount = DEFAULT_VM_COUNT;
public Builder() {
// nothing
@@ -228,6 +235,11 @@ public class ClientCacheRule extends AbstractDistributedRule {
return this;
}
+ public Builder vmCount(final int vmCount) {
+ this.vmCount = vmCount;
+ return this;
+ }
+
public ClientCacheRule build() {
return new ClientCacheRule(this);
}
diff --git a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/GatewayLegacyAuthenticationRegressionTest.java b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/GatewayLegacyAuthenticationRegressionTest.java
index 3bc4880..e0243ad 100644
--- a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/GatewayLegacyAuthenticationRegressionTest.java
+++ b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/GatewayLegacyAuthenticationRegressionTest.java
@@ -38,7 +38,6 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -95,8 +94,8 @@ public class GatewayLegacyAuthenticationRegressionTest implements Serializable {
private int londonReceiverPort;
private int newYorkReceiverPort;
- @ClassRule
- public static DistributedRule distributedTestRule = new DistributedRule();
+ @Rule
+ public DistributedRule distributedRule = new DistributedRule();
@Rule
public CacheRule cacheRule = new CacheRule();
@@ -327,11 +326,6 @@ public class GatewayLegacyAuthenticationRegressionTest implements Serializable {
}
return new TestPrincipal(userName);
}
-
- @Override
- public void close() {
- // nothing
- }
}
public static class TestPeerAuthInitialize implements AuthInitialize {
@@ -371,11 +365,6 @@ public class GatewayLegacyAuthenticationRegressionTest implements Serializable {
return newProps;
}
-
- @Override
- public void close() {
- // nothing
- }
}
public static class TestClientOrReceiverAuthenticator implements Authenticator {
@@ -410,10 +399,5 @@ public class GatewayLegacyAuthenticationRegressionTest implements Serializable {
}
return new TestPrincipal(userName);
}
-
- @Override
- public void close() {
- // nothing
- }
}
}