You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/06/03 19:56:49 UTC
[3/7] incubator-geode git commit: Convert junit3 to junit4 and
cleanup tests.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/CacheLifecycleListenerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/CacheLifecycleListenerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/CacheLifecycleListenerJUnitTest.java
index f2a4a8d..15d75a7 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/CacheLifecycleListenerJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/CacheLifecycleListenerJUnitTest.java
@@ -16,38 +16,33 @@
*/
package com.gemstone.gemfire.internal.cache;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import junit.framework.TestCase;
-
/**
* Tests notifications of CacheLifecycleListener from GemFireCacheImpl.
- *
*/
@Category(IntegrationTest.class)
public class CacheLifecycleListenerJUnitTest {
@Test
- public void testAddAndRemoveNull() {
+ public void testAddAndRemoveNull() throws Exception {
GemFireCacheImpl.addCacheLifecycleListener(null);
GemFireCacheImpl.removeCacheLifecycleListener(null);
}
@Test
- public void testRemoveNonExistent() {
+ public void testRemoveNonExistent() throws Exception {
final List<CacheLifecycleCallback> cacheCreatedCallbacks = new ArrayList<CacheLifecycleCallback>();
final List<CacheLifecycleCallback> cacheClosedCallbacks = new ArrayList<CacheLifecycleCallback>();
final TestCacheLifecycleListener listener = new TestCacheLifecycleListener(cacheCreatedCallbacks, cacheClosedCallbacks);
@@ -55,7 +50,7 @@ public class CacheLifecycleListenerJUnitTest {
}
@Test
- public void testCallbacks() {
+ public void testCallbacks() throws Exception {
final List<CacheLifecycleCallback> cacheCreatedCallbacks = new ArrayList<CacheLifecycleCallback>();
final List<CacheLifecycleCallback> cacheClosedCallbacks = new ArrayList<CacheLifecycleCallback>();
@@ -98,7 +93,7 @@ public class CacheLifecycleListenerJUnitTest {
}
@Test
- public void testRemoveBeforeCreate() {
+ public void testRemoveBeforeCreate() throws Exception {
final List<CacheLifecycleCallback> cacheCreatedCallbacks = new ArrayList<CacheLifecycleCallback>();
final List<CacheLifecycleCallback> cacheClosedCallbacks = new ArrayList<CacheLifecycleCallback>();
@@ -136,7 +131,7 @@ public class CacheLifecycleListenerJUnitTest {
}
@Test
- public void testRemoveBeforeClose() {
+ public void testRemoveBeforeClose() throws Exception {
final List<CacheLifecycleCallback> cacheCreatedCallbacks = new ArrayList<CacheLifecycleCallback>();
final List<CacheLifecycleCallback> cacheClosedCallbacks = new ArrayList<CacheLifecycleCallback>();
@@ -178,7 +173,7 @@ public class CacheLifecycleListenerJUnitTest {
}
@Test
- public void testCallbacksRepeat() {
+ public void testCallbacksRepeat() throws Exception {
final List<CacheLifecycleCallback> cacheCreatedCallbacks = new ArrayList<CacheLifecycleCallback>();
final List<CacheLifecycleCallback> cacheClosedCallbacks = new ArrayList<CacheLifecycleCallback>();
@@ -247,7 +242,7 @@ public class CacheLifecycleListenerJUnitTest {
}
@Test
- public void testAddAfterCreate() {
+ public void testAddAfterCreate() throws Exception {
final List<CacheLifecycleCallback> cacheCreatedCallbacks = new ArrayList<CacheLifecycleCallback>();
final List<CacheLifecycleCallback> cacheClosedCallbacks = new ArrayList<CacheLifecycleCallback>();
@@ -285,7 +280,7 @@ public class CacheLifecycleListenerJUnitTest {
}
}
- static final class CacheLifecycleCallback {
+ private static final class CacheLifecycleCallback {
private final GemFireCacheImpl cache;
private final long timeStamp;
@@ -300,7 +295,7 @@ public class CacheLifecycleListenerJUnitTest {
}
}
- static final class TestCacheLifecycleListener implements CacheLifecycleListener {
+ private static final class TestCacheLifecycleListener implements CacheLifecycleListener {
private final List<CacheLifecycleCallback> cacheCreatedCallbacks;
private final List<CacheLifecycleCallback> cacheClosedCallbacks;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentMapLocalJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentMapLocalJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentMapLocalJUnitTest.java
index 587aa55..2471ffd 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentMapLocalJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentMapLocalJUnitTest.java
@@ -16,29 +16,22 @@
*/
package com.gemstone.gemfire.internal.cache;
-import java.util.Properties;
+import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.DataPolicy;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionShortcut;
-import com.gemstone.gemfire.cache.client.ClientCache;
-import com.gemstone.gemfire.cache.client.ClientCacheFactory;
-import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import junit.framework.TestCase;
-
@Category(IntegrationTest.class)
-public class ConcurrentMapLocalJUnitTest {
+public class ConcurrentMapLocalJUnitTest { // TODO: reformat
private Cache cache;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentRollingAndRegionOperationsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentRollingAndRegionOperationsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentRollingAndRegionOperationsJUnitTest.java
index fa6c3f9..224b700 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentRollingAndRegionOperationsJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ConcurrentRollingAndRegionOperationsJUnitTest.java
@@ -21,7 +21,7 @@ import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Assert;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -79,16 +79,16 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
assertTrue(hasBeenNotified);
}
catch (InterruptedException e) {
- fail("exception not expected here");
+ throw new AssertionError("exception not expected here", e);
}
}
}
try {
- Assert.assertEquals("Value2", getValueOnDisk(region));
+ assertEquals("Value2", getValueOnDisk(region));
}
catch (EntryNotFoundException e) {
logWriter.error("Exception occured", e);
- fail("Entry not found although was supposed to be there");
+ throw new AssertionError("Entry not found although was supposed to be there", e);
}
}
@@ -118,17 +118,17 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
assertTrue(hasBeenNotified);
}
catch (InterruptedException e) {
- fail("exception not expected here");
+ throw new AssertionError("exception not expected here", e);
}
}
}
try {
- Assert.assertEquals("Value1", getValueOnDisk(region));
- Assert.assertEquals("Value1", getValueInHTree(region));
+ assertEquals("Value1", getValueOnDisk(region));
+ assertEquals("Value1", getValueInHTree(region));
}
catch (EntryNotFoundException e) {
logWriter.error("Exception occured", e);
- fail("Entry not found although was supposed to be there");
+ throw new AssertionError("Entry not found although was supposed to be there", e);
}
}
@@ -153,7 +153,7 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
assertTrue(hasBeenNotified);
}
catch (InterruptedException e) {
- fail("exception not expected here");
+ throw new AssertionError("exception not expected here", e);
}
}
}
@@ -162,7 +162,7 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
}
catch (Exception e) {
logWriter.error("Exception occured", e);
- fail("failed while trying to destroy due to " + e);
+ throw new AssertionError("failed while trying to destroy due to ", e);
}
boolean entryNotFound = false;
try {
@@ -206,7 +206,7 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
assertTrue(hasBeenNotified);
}
catch (InterruptedException e) {
- fail("exception not expected here");
+ throw new AssertionError("exception not expected here", e);
}
}
}
@@ -257,17 +257,17 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
assertTrue(hasBeenNotified);
}
catch (InterruptedException e) {
- fail("exception not expected here");
+ throw new AssertionError("exception not expected here", e);
}
}
}
region.put("Key", "Value2");
try {
- Assert.assertEquals("Value2", getValueOnDisk(region));
+ assertEquals("Value2", getValueOnDisk(region));
}
catch (EntryNotFoundException e) {
logWriter.error("Exception occured", e);
- fail("Entry not found although was supposed to be there");
+ throw new AssertionError("Entry not found although was supposed to be there", e);
}
}
@@ -292,18 +292,18 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
assertTrue(hasBeenNotified);
}
catch (InterruptedException e) {
- fail("exception not expected here");
+ throw new AssertionError("exception not expected here", e);
}
}
}
region.get("Key");
try {
- Assert.assertEquals("Value1", getValueOnDisk(region));
- Assert.assertEquals("Value1", getValueInHTree(region));
+ assertEquals("Value1", getValueOnDisk(region));
+ assertEquals("Value1", getValueInHTree(region));
}
catch (EntryNotFoundException e) {
logWriter.error("Exception occured", e);
- fail("Entry not found although was supposed to be there");
+ throw new AssertionError("Entry not found although was supposed to be there", e);
}
}
@@ -328,7 +328,7 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
assertTrue(hasBeenNotified);
}
catch (InterruptedException e) {
- fail("exception not expected here");
+ throw new AssertionError("exception not expected here", e);
}
}
}
@@ -337,7 +337,7 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
}
catch (Exception e1) {
logWriter.error("Exception occured", e1);
- fail("encounter exception when not expected " + e1);
+ throw new AssertionError("encounter exception when not expected ", e1);
}
boolean entryNotFound = false;
try {
@@ -380,7 +380,7 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
assertTrue(hasBeenNotified);
}
catch (InterruptedException e) {
- fail("exception not expected here");
+ throw new AssertionError("exception not expected here", e);
}
}
}
@@ -424,7 +424,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
((DiskEntry)re).getDiskId());
}
- public void DARREL_DISABLE_testSyncPutBeforeRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testSyncPutBeforeRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -437,7 +439,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
region.destroyRegion();
}
- public void DARREL_DISABLE_testAsyncPutBeforeRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testAsyncPutBeforeRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -450,7 +454,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
region.destroyRegion();
}
- public void DARREL_DISABLE_testSyncPutAfterRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testSyncPutAfterRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -463,7 +469,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
region.destroyRegion();
}
- public void DARREL_DISABLE_testAsyncPutAfterRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testAsyncPutAfterRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -476,7 +484,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
region.destroyRegion();
}
- public void DARREL_DISABLE_testSyncGetBeforeRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testSyncGetBeforeRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -489,7 +499,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
region.destroyRegion();
}
- public void DARREL_DISABLE_testAsyncGetBeforeRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testAsyncGetBeforeRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -502,7 +514,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
region.destroyRegion();
}
- public void DARREL_DISABLE_testSyncGetAfterRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testSyncGetAfterRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -515,7 +529,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
region.destroyRegion();
}
- public void DARREL_DISABLE_testAsyncGetAfterRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testAsyncGetAfterRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -528,7 +544,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
region.destroyRegion();
}
- public void DARREL_DISABLE_testSyncClearBeforeRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testSyncClearBeforeRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -541,7 +559,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
region.destroyRegion();
}
- public void DARREL_DISABLE_testAsyncClearBeforeRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testAsyncClearBeforeRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -554,7 +574,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
region.destroyRegion();
}
- public void DARREL_DISABLE_testSyncClearAfterRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testSyncClearAfterRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -567,7 +589,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
region.destroyRegion();
}
- public void DARREL_DISABLE_testAsyncClearAfterRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testAsyncClearAfterRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -580,7 +604,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
region.destroyRegion();
}
- public void DARREL_DISABLE_testSyncDelBeforeRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testSyncDelBeforeRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -593,7 +619,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
region.destroyRegion();
}
- public void DARREL_DISABLE_testAsyncDelBeforeRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testAsyncDelBeforeRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -606,7 +634,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
region.destroyRegion();
}
- public void DARREL_DISABLE_testSyncDelAfterRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testSyncDelAfterRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -619,7 +649,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
region.destroyRegion();
}
- public void DARREL_DISABLE_testAsyncDelAfterRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testAsyncDelAfterRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -632,7 +664,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
region.destroyRegion();
}
- public void DARREL_DISABLE_testCloseBeforeRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testCloseBeforeRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -644,7 +678,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
closeBeforeRoll(region);
}
- public void DARREL_DISABLE_testCloseAfterRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testCloseAfterRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -659,7 +695,9 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
diskRegionProperties, Scope.LOCAL);
}
- public void DARREL_DISABLE_testconcurrentPutAndRoll()
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testconcurrentPutAndRoll()
{
DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
diskRegionProperties.setDiskDirs(dirs);
@@ -702,7 +740,7 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
testFailed = true;
failureCause = "Exception occured when it was not supposed to occur, Exception is "
+ e + "in concurrentPutAndRoll";
- fail("exception not expected here");
+ throw new AssertionError("exception not expected here", e);
}
}
}
@@ -719,7 +757,7 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
testFailed = true;
failureCause = "Exception occured when it was not supposed to occur, Exception is "
+ e + "in concurrentPutAndRoll";
- fail("exception not expected here");
+ throw new AssertionError("exception not expected here", e);
}
}
startTime = System.currentTimeMillis();
@@ -746,7 +784,7 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
}
}
catch (InterruptedException e) {
- fail("exception not expected here");
+ throw new AssertionError("exception not expected here", e);
}
}
if (this.totalTime < 2000) {
@@ -762,8 +800,6 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
* is not yet destroyed but by the time a basicGet is done,the oplog gets
* destroyed & the get operation sees the file length zero or it may encounter
* null pointer exception while retrieving the oplog.
- *
- *
*/
@Test
public void testConcurrentRollingAndGet()
@@ -806,8 +842,7 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
catch (Exception e) {
encounteredFailure = true;
logWriter.error("Test encountered exception ", e);
- fail(" Test failed as could not obtain value from disk.Exception = "
- + e);
+ throw new AssertionError(" Test failed as could not obtain value from disk.Exception = ", e);
}
}
@@ -834,9 +869,7 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
}
catch (InterruptedException e) {
logWriter.error("Main thread encountered exception ", e);
-
- fail(" Test failed as main thread encountered exception = " + e);
-
+ throw new AssertionError(" Test failed as main thread encountered exception = ", e);
}
}
@@ -877,7 +910,7 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
}
catch (Exception e) {
logWriter.error("Exception occured", e);
- fail("Exception occured when it was not supposed to occur");
+ throw new AssertionError("Exception occured when it was not supposed to occur", e);
}
}
});
@@ -891,13 +924,13 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
}
}
catch (InterruptedException e) {
- fail("exception not expected here");
+ throw new AssertionError("exception not expected here", e);
}
}
try {
th.join(5000);
} catch (InterruptedException ignore) {
- fail("exception not expected here");
+ throw new AssertionError("exception not expected here", ignore);
}
assertFalse(th.isAlive());
assertFalse(failureCause, testFailed);
@@ -918,7 +951,7 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
}
catch (Exception e) {
logWriter.error("Exception occured", e);
- fail("Exception occured when it was not supposed to occur");
+ throw new AssertionError("Exception occured when it was not supposed to occur", e);
}
}
});
@@ -938,7 +971,7 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
try {
th.join(5000);
} catch (InterruptedException ignore) {
- fail("exception not expected here");
+ throw new AssertionError("exception not expected here", ignore);
}
assertFalse(th.isAlive());
assertFalse(failureCause, testFailed);
@@ -967,7 +1000,7 @@ public class ConcurrentRollingAndRegionOperationsJUnitTest extends DiskRegionTes
testFailed = true;
failureCause = "Exception occured when it was not supposed to occur, due to "
+ e;
- fail("Exception occured when it was not supposed to occur, due to " + e);
+ throw new AssertionError("Exception occured when it was not supposed to occur, due to ", e);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskOfflineCompactionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskOfflineCompactionJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskOfflineCompactionJUnitTest.java
index 4ab4544..8a266df 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskOfflineCompactionJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskOfflineCompactionJUnitTest.java
@@ -16,6 +16,8 @@
*/
package com.gemstone.gemfire.internal.cache;
+import static org.junit.Assert.*;
+
import java.io.File;
import java.io.IOException;
import java.util.Properties;
@@ -23,19 +25,8 @@ import java.util.Properties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
-import static org.junit.Assert.*;
-
-import com.gemstone.gemfire.internal.Version;
-
-import junit.framework.TestCase;
-
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
@@ -46,27 +37,22 @@ import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.internal.HeapDataOutputStream;
import com.gemstone.gemfire.internal.InternalDataSerializer;
+import com.gemstone.gemfire.internal.Version;
import com.gemstone.gemfire.internal.cache.versions.RegionVersionHolder;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
/**
* Tests offline compaction
- *
- *
*/
@Category(IntegrationTest.class)
-public class DiskOfflineCompactionJUnitTest
-{
-
- protected static Cache cache = null;
-
- protected static DistributedSystem ds = null;
+public class DiskOfflineCompactionJUnitTest {
// In this test, entry version, region version, member id, each will be 1 byte
- final static int versionsize = 3;
+ private static final int versionsize = 3;
- static {
- }
+ private static Cache cache = null;
+
+ private static DistributedSystem ds = null;
private int getDSID(LocalRegion lr) {
return lr.getDistributionManager().getDistributedSystemId();
@@ -231,8 +217,7 @@ public class DiskOfflineCompactionJUnitTest
}
@Test
- public void testTwoEntriesWithUpdateAndDestroy()
- throws Exception {
+ public void testTwoEntriesWithUpdateAndDestroy() throws Exception {
DiskStoreFactory dsf = cache.createDiskStoreFactory();
dsf.setAutoCompact(false);
String name = "testTwoEntriesWithUpdateAndDestroy";
@@ -567,8 +552,7 @@ public class DiskOfflineCompactionJUnitTest
}
@Test
- public void testForceRollTwoEntriesWithUpdates()
- throws Exception {
+ public void testForceRollTwoEntriesWithUpdates() throws Exception {
DiskStoreFactory dsf = cache.createDiskStoreFactory();
dsf.setAutoCompact(false);
String name = "testForceRollTwoEntriesWithUpdates";
@@ -653,8 +637,7 @@ public class DiskOfflineCompactionJUnitTest
}
@Test
- public void testForceRollTwoEntriesWithUpdateAndDestroy()
- throws Exception {
+ public void testForceRollTwoEntriesWithUpdateAndDestroy() throws Exception {
DiskStoreFactory dsf = cache.createDiskStoreFactory();
dsf.setAutoCompact(false);
String name = "testForceRollTwoEntriesWithUpdateAndDestroy";
@@ -747,7 +730,7 @@ public class DiskOfflineCompactionJUnitTest
}
// uitl methods for calculation
- public static int getValueSizeInOplog(Object value) {
+ private static int getValueSizeInOplog(Object value) {
if (value instanceof String) {
return getStrSizeInOplog((String)value);
} else if (value instanceof byte[]) {
@@ -756,33 +739,40 @@ public class DiskOfflineCompactionJUnitTest
}
return -1;
}
- public static int getStrSizeInOplog(String str) {
+
+ private static int getStrSizeInOplog(String str) {
// string saved in UTF format will use 3 bytes extra.
// 4 is hard-coded overhead in Oplog for each string
return str.length()+3+4;
}
- public static int getSize4Create(int extra_byte_num_per_entry, String key, Object value) {
+
+ static int getSize4Create(int extra_byte_num_per_entry, String key, Object value) {
int createsize = 1 /* opcode */ + 1 /* userbits */ + versionsize + extra_byte_num_per_entry
+ getStrSizeInOplog(key) + 1 /* drid */ + getValueSizeInOplog(value) + 1 /* END_OF_RECORD_ID */;
return createsize;
}
- public static int getSize4UpdateWithKey(int extra_byte_num_per_entry, String key, Object value) {
+
+ private static int getSize4UpdateWithKey(int extra_byte_num_per_entry, String key, Object value) {
return getSize4UpdateWithoutKey(extra_byte_num_per_entry, value) + getStrSizeInOplog(key);
}
- public static int getSize4UpdateWithoutKey(int extra_byte_num_per_entry, Object value) {
+
+ private static int getSize4UpdateWithoutKey(int extra_byte_num_per_entry, Object value) {
int updatesize = 1 /* opcode */ + 1 /* userbits */ + versionsize + extra_byte_num_per_entry
+ 1 /* drid */ + getValueSizeInOplog(value) +1 /* delta */ + 1 /* END_OF_RECORD_ID */;
return updatesize;
}
- public static int getSize4TombstoneWithKey(int extra_byte_num_per_entry, String key) {
+
+ static int getSize4TombstoneWithKey(int extra_byte_num_per_entry, String key) {
return getSize4TombstoneWithoutKey(extra_byte_num_per_entry) + getStrSizeInOplog(key);
}
- public static int getSize4TombstoneWithoutKey(int extra_byte_num_per_entry) {
+
+ private static int getSize4TombstoneWithoutKey(int extra_byte_num_per_entry) {
int tombstonesize = 1 /* opcode */ + 1 /* userbits */ + versionsize + extra_byte_num_per_entry
+ 1 /* drid */ +1 /* delta */ + 1 /* END_OF_RECORD_ID */;
return tombstonesize;
}
- public static int getRVVSize(int drMapSize, int[] numOfMemberPerDR, boolean gcRVV) {
+
+ static int getRVVSize(int drMapSize, int[] numOfMemberPerDR, boolean gcRVV) {
// if there's one member in rvv, total size is 9 bytes:
// 0: OPLOG_RVV. 1: drMap.size()==1, 2: disRegionId, 3: getRVVTrusted
// 4: memberToVersion.size()==1, 5: memberid, 6-7: versionHolder 8: END_OF_RECORD_ID
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskOldAPIsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskOldAPIsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskOldAPIsJUnitTest.java
index 7d2cc99..c0e4e88 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskOldAPIsJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskOldAPIsJUnitTest.java
@@ -16,32 +16,34 @@
*/
package com.gemstone.gemfire.internal.cache;
-import java.io.*;
-import java.util.*;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.util.Properties;
+import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
-import com.gemstone.gemfire.cache.*;
-import com.gemstone.gemfire.internal.Assert;
-import com.gemstone.gemfire.distributed.*;
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.DiskWriteAttributesFactory;
+import com.gemstone.gemfire.cache.EvictionAction;
+import com.gemstone.gemfire.cache.EvictionAttributes;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import junit.framework.TestCase;
-
/**
* Tests the old disk apis to make sure they do the correct thing.
* Once we drop these old deprecated disk apis then this unit test can be removed.
- *
- *
*/
@Category(IntegrationTest.class)
-public class DiskOldAPIsJUnitTest
-{
+public class DiskOldAPIsJUnitTest {
protected static Cache cache = null;
@@ -74,11 +76,12 @@ public class DiskOldAPIsJUnitTest
* Make sure that if diskWriteAttributes sets sync then it shows up in the new apis.
*/
@Test
- public void testSyncBit() {
+ public void testSyncBit() throws Exception {
doSyncBitTest(true);
doSyncBitTest(false);
doSyncBitTest(true);
}
+
private void doSyncBitTest(boolean destroyRegion) {
DiskWriteAttributesFactory dwaf = new DiskWriteAttributesFactory();
dwaf.setSynchronous(true);
@@ -202,7 +205,7 @@ public class DiskOldAPIsJUnitTest
* Note that the isSync bit is tested by another method.
*/
@Test
- public void testDWA_1() {
+ public void testDWA_1() throws Exception {
DiskWriteAttributesFactory dwaf = new DiskWriteAttributesFactory();
dwaf.setMaxOplogSize(1);
dwaf.setTimeInterval(333);
@@ -252,7 +255,7 @@ public class DiskOldAPIsJUnitTest
}
@Test
- public void testDWA_2() {
+ public void testDWA_2() throws Exception {
DiskWriteAttributesFactory dwaf = new DiskWriteAttributesFactory();
dwaf.setMaxOplogSize(2);
dwaf.setTimeInterval(1);
@@ -302,7 +305,7 @@ public class DiskOldAPIsJUnitTest
* Make sure the old diskDirs apis get mapped onto the diskStore.
*/
@Test
- public void testDiskDirs() {
+ public void testDiskDirs() throws Exception {
File f1 = new File("testDiskDir1");
f1.mkdir();
File f2 = new File("testDiskDir2");
@@ -360,7 +363,7 @@ public class DiskOldAPIsJUnitTest
* Make sure the old diskDirs apis get mapped onto the diskStore.
*/
@Test
- public void testDiskDirsAndSizes() {
+ public void testDiskDirsAndSizes() throws Exception {
File f1 = new File("testDiskDir1");
f1.mkdir();
File f2 = new File("testDiskDir2");
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegCacheXmlJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegCacheXmlJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegCacheXmlJUnitTest.java
index 9c6f7f4..132cd69 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegCacheXmlJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegCacheXmlJUnitTest.java
@@ -16,24 +16,28 @@
*/
package com.gemstone.gemfire.internal.cache;
+import static org.junit.Assert.*;
+
import java.io.File;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Properties;
import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
-import junit.framework.*;
-
import com.gemstone.gemfire.SystemFailure;
-import com.gemstone.gemfire.cache.*;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.CacheTransactionManager;
+import com.gemstone.gemfire.cache.DiskStore;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.util.test.TestUtil;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.util.test.TestUtil;
/**
* This test is for testing Disk attributes set via xml.
@@ -44,16 +48,15 @@ import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
* @since 5.1
*/
@Category(IntegrationTest.class)
-public class DiskRegCacheXmlJUnitTest
-{
- Cache cache = null;
+public class DiskRegCacheXmlJUnitTest {
+
+ private Cache cache = null;
- DistributedSystem ds = null;
+ private DistributedSystem ds = null;
- protected static File[] dirs = null;
+ private static File[] dirs = null;
- public void mkDirAndConnectDs()
- {
+ private void mkDirAndConnectDs() {
File file1 = new File("d1");
file1.mkdir();
file1.deleteOnExit();
@@ -74,19 +77,12 @@ public class DiskRegCacheXmlJUnitTest
props.setProperty("mcast-port", "0");
props.setProperty("cache-xml-file", path);
ds = DistributedSystem.connect(props);
- try {
- // Create the cache which causes the cache-xml-file to be parsed
- cache = CacheFactory.create(ds);
- }
- catch (Exception ex) {
- ds.getLogWriter().error("Exception occured",ex);
- fail("failed to create cache due to "+ex);
- }
+ // Create the cache which causes the cache-xml-file to be parsed
+ cache = CacheFactory.create(ds);
}
@Test
- public void testDiskRegCacheXml()
- {
+ public void testDiskRegCacheXml() throws Exception {
mkDirAndConnectDs();
// Get the region1 which is a subregion of /root
Region region1 = cache.getRegion("/root1/PersistSynchRollingOplog1");
@@ -219,30 +215,21 @@ public class DiskRegCacheXmlJUnitTest
deleteFiles();
}
- private static void deleteFiles()
- {
+ private static void deleteFiles() {
for (int i = 0; i < dirs.length; i++) {
File[] files = dirs[i].listFiles();
for (int j = 0; j < files.length; j++) {
files[j].delete();
}
}
-
}
-
-
- @After
- public void tearDown() throws Exception
- {
- /*if (cache != null && !cache.isClosed()) {
- cache.close();
- }*/
+ @After
+ public void tearDown() throws Exception {
try {
if (cache != null && !cache.isClosed()) {
for (Iterator itr = cache.rootRegions().iterator(); itr.hasNext();) {
Region root = (Region)itr.next();
-// String name = root.getName();
if(root.isDestroyed() || root instanceof HARegion) {
continue;
}
@@ -260,21 +247,10 @@ public class DiskRegCacheXmlJUnitTest
}
}
finally {
- try {
- closeCache();
- }
- catch (VirtualMachineError e) {
- SystemFailure.initiateFailure(e);
- throw e;
- }
- catch (Throwable t) {
- ds.getLogWriter().error("Error in closing the cache ", t);
-
- }
+ closeCache();
}
}
-
-
+
/** Close the cache */
private synchronized final void closeCache() {
if (cache != null) {
@@ -295,4 +271,3 @@ public class DiskRegCacheXmlJUnitTest
}
}
}// end of DiskRegCacheXmlJUnitTest
-
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionClearJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionClearJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionClearJUnitTest.java
index 7e58329..f9a17c5 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionClearJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionClearJUnitTest.java
@@ -16,6 +16,8 @@
*/
package com.gemstone.gemfire.internal.cache;
+import static org.junit.Assert.*;
+
import java.util.Iterator;
import java.util.Properties;
@@ -24,30 +26,20 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
import com.gemstone.gemfire.SystemFailure;
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.CacheTransactionManager;
import com.gemstone.gemfire.cache.DataPolicy;
-import com.gemstone.gemfire.cache.DiskStore;
-import com.gemstone.gemfire.cache.DiskStoreFactory;
-import com.gemstone.gemfire.cache.EntryEvent;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionAttributes;
import com.gemstone.gemfire.cache.RegionEvent;
import com.gemstone.gemfire.cache.Scope;
import com.gemstone.gemfire.distributed.DistributedSystem;
-import com.gemstone.gemfire.internal.cache.versions.VersionStamp;
import com.gemstone.gemfire.test.dunit.ThreadUtils;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-// @TODO: use DiskRegionTestingBase and DiskRegionHelperFactory
/**
* Test methods to ensure that disk Clear is apparently atomic to region clear.
*
@@ -55,19 +47,20 @@ import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
* wait for clear and if it is successfully recorded in memory than it should
* be recored on disk. Else if not successfully recorded in memory than should not be
* recorded on disk
- *
+ *
+ * TODO: use DiskRegionTestingBase and DiskRegionHelperFactory
*/
@Category(IntegrationTest.class)
public class DiskRegionClearJUnitTest {
- static Region testRegion = null;
- static Object returnObject = null;
- static boolean done = false;
- static volatile int counter = 0;
- static volatile boolean cleared = false;
- static volatile long entries = 0;
- static Cache cache = null;
- static DistributedSystem distributedSystem = null;
+ private static Region testRegion = null;
+ private static Object returnObject = null;
+ private static boolean done = false;
+ private static volatile int counter = 0;
+ private static volatile boolean cleared = false;
+ private static volatile long entries = 0;
+ private static Cache cache = null;
+ private static DistributedSystem distributedSystem = null;
private static String regionName = "TestRegion";
@@ -85,7 +78,6 @@ public class DiskRegionClearJUnitTest {
RegionAttributes regionAttributes = factory.create();
testRegion = cache.createRegion("TestRegion1", regionAttributes);
CacheObserverHolder.setInstance(new CacheObserverListener());
-
}
@After
@@ -101,7 +93,7 @@ public class DiskRegionClearJUnitTest {
try {
root.localDestroyRegion("teardown");
}
- catch (VirtualMachineError e) {
+ catch (VirtualMachineError e) { // TODO: remove all this error handling
SystemFailure.initiateFailure(e);
throw e;
}
@@ -115,7 +107,7 @@ public class DiskRegionClearJUnitTest {
try {
closeCache();
}
- catch (VirtualMachineError e) {
+ catch (VirtualMachineError e) { // TODO: remove all this error handling
SystemFailure.initiateFailure(e);
throw e;
}
@@ -140,7 +132,6 @@ public class DiskRegionClearJUnitTest {
testRegion.clear();
assertEquals(0, dr.getStats().getNumEntriesInVM());
}
-
/** Close the cache */
private static synchronized final void closeCache() {
@@ -185,37 +176,32 @@ public class DiskRegionClearJUnitTest {
}
}
ThreadUtils.join(thread, 10 * 60 * 1000);
- Assert.assertTrue(counter == 3);
+ assertTrue(counter == 3);
if(!cleared)
fail("clear not done although puts have been done");
}
@Test
- public void testRecreateRegionAndCacheNegative() {
- try {
- LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER = false;
- for(long i=0;i<100; i++) {
- testRegion.put(new Long(i), new Long(i));
- }
- testRegion.clear();
- assertEquals(0, testRegion.size());
- cache.close();
- distributedSystem.disconnect();
- Properties properties = new Properties();
- properties.setProperty("mcast-port", "0");
- properties.setProperty("locators", "");
- distributedSystem = DistributedSystem.connect(properties);
- cache = CacheFactory.create(distributedSystem);
- AttributesFactory factory = new AttributesFactory();
- factory.setScope(Scope.DISTRIBUTED_ACK);
- factory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
- RegionAttributes regionAttributes = factory.create();
- testRegion = cache.createRegion("TestRegion1", regionAttributes);
-
+ public void testRecreateRegionAndCacheNegative() throws Exception {
+ LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER = false;
+ for(long i=0;i<100; i++) {
+ testRegion.put(new Long(i), new Long(i));
}
- catch (Exception e) {
- fail("test failed due to "+e);
- }
+ testRegion.clear();
+ assertEquals(0, testRegion.size());
+ cache.close();
+ distributedSystem.disconnect();
+ Properties properties = new Properties();
+ properties.setProperty("mcast-port", "0");
+ properties.setProperty("locators", "");
+ distributedSystem = DistributedSystem.connect(properties);
+ cache = CacheFactory.create(distributedSystem);
+ AttributesFactory factory = new AttributesFactory();
+ factory.setScope(Scope.DISTRIBUTED_ACK);
+ factory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
+ RegionAttributes regionAttributes = factory.create();
+ testRegion = cache.createRegion("TestRegion1", regionAttributes);
+
System.out.println("keySet after recovery = " + testRegion.keySet());
assertEquals(0, testRegion.size());
}
@@ -223,34 +209,32 @@ public class DiskRegionClearJUnitTest {
@Test
public void testRecreateRegionAndCachePositive() {
int size = 0;
- LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER = false;
- for(long i=0;i<1000; i++) {
- testRegion.put(new Long(i), new Long(i));
- }
- testRegion.clear();
- for(long i=0;i<1000; i++) {
- testRegion.put(new Long(i), new Long(i));
- }
- assertEquals(1000, testRegion.size());
- cache.close();
- distributedSystem.disconnect();
- Properties properties = new Properties();
- properties.setProperty("mcast-port", "0");
- properties.setProperty("locators", "");
- distributedSystem = DistributedSystem.connect(properties);
- cache = CacheFactory.create(distributedSystem);
- AttributesFactory factory = new AttributesFactory();
- factory.setScope(Scope.DISTRIBUTED_ACK);
- factory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
- RegionAttributes regionAttributes = factory.create();
- testRegion = cache.createRegion("TestRegion1", regionAttributes);
+ LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER = false;
+ for(long i=0;i<1000; i++) {
+ testRegion.put(new Long(i), new Long(i));
+ }
+ testRegion.clear();
+ for(long i=0;i<1000; i++) {
+ testRegion.put(new Long(i), new Long(i));
+ }
+ assertEquals(1000, testRegion.size());
+ cache.close();
+ distributedSystem.disconnect();
+ Properties properties = new Properties();
+ properties.setProperty("mcast-port", "0");
+ properties.setProperty("locators", "");
+ distributedSystem = DistributedSystem.connect(properties);
+ cache = CacheFactory.create(distributedSystem);
+ AttributesFactory factory = new AttributesFactory();
+ factory.setScope(Scope.DISTRIBUTED_ACK);
+ factory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
+ RegionAttributes regionAttributes = factory.create();
+ testRegion = cache.createRegion("TestRegion1", regionAttributes);
assertEquals(1000, testRegion.size());
}
-
- protected static class Thread1 implements Runnable {
-
-
+ private static class Thread1 implements Runnable {
+
public void run() {
for(long i=0 ; i< 100 ; i++) {
testRegion.put(new Long(i), new Long(i));
@@ -259,15 +243,14 @@ public class DiskRegionClearJUnitTest {
}
}
- protected static class Thread2 implements Runnable {
+ private static class Thread2 implements Runnable {
public void run() {
testRegion.clear();
}
}
- protected static class CacheObserverListener extends CacheObserverAdapter {
-
+ private static class CacheObserverListener extends CacheObserverAdapter {
public void afterRegionClear(RegionEvent event) {
cleared = true;
@@ -281,8 +264,6 @@ public class DiskRegionClearJUnitTest {
}
}
- protected static class CacheObserver extends CacheObserverAdapter
- {
-
+ private static class CacheObserver extends CacheObserverAdapter {
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionIllegalArguementsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionIllegalArguementsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionIllegalArguementsJUnitTest.java
index b9bfa17..dbc90c9 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionIllegalArguementsJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionIllegalArguementsJUnitTest.java
@@ -16,6 +16,8 @@
*/
package com.gemstone.gemfire.internal.cache;
+import static org.junit.Assert.*;
+
import java.io.File;
import java.util.Properties;
@@ -24,24 +26,19 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
-import junit.framework.TestCase;
-
-import com.gemstone.gemfire.cache.*;
-import com.gemstone.gemfire.distributed.*;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.DiskStoreFactory;
+import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
/**
* This test tests Illegal arguements being passed to create disk regions. The
* creation of the DWA object should throw a relevant exception if the
* arguements specified are incorrect.
- *
- *
*/
@Category(IntegrationTest.class)
-public class DiskRegionIllegalArguementsJUnitTest
-{
+public class DiskRegionIllegalArguementsJUnitTest {
protected static Cache cache = null;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionIllegalCacheXMLvaluesJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionIllegalCacheXMLvaluesJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionIllegalCacheXMLvaluesJUnitTest.java
index 6787d10..2697bd3 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionIllegalCacheXMLvaluesJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionIllegalCacheXMLvaluesJUnitTest.java
@@ -16,38 +16,30 @@
*/
package com.gemstone.gemfire.internal.cache;
+import static org.junit.Assert.*;
+
import java.io.File;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
-import junit.framework.TestCase;
-
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.CacheXmlException;
import com.gemstone.gemfire.distributed.DistributedSystem;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.util.test.TestUtil;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.util.test.TestUtil;
/**
* This test tests Illegal arguements being passed to
* create disk regions. The creation of the DWA object should
* throw a relevant exception if the arguements specified are incorrect.
- *
- *
*/
@Category(IntegrationTest.class)
-public class DiskRegionIllegalCacheXMLvaluesJUnitTest
-{
+public class DiskRegionIllegalCacheXMLvaluesJUnitTest {
- public void createRegion(String path)
- {
+ public void createRegion(String path) {
DistributedSystem ds = null;
try {
boolean exceptionOccured = false;
@@ -87,59 +79,51 @@ public class DiskRegionIllegalCacheXMLvaluesJUnitTest
}
}
-
/**
* test Illegal max oplog size
*/
-
@Test
- public void testMaxOplogSize()
- {
+ public void testMaxOplogSize() {
createRegion("faultyDiskXMLsForTesting/incorrect_max_oplog_size.xml");
}
+ @Ignore("TODO: test is empty")
@Test
- public void testSynchronous()
- {}
+ public void testSynchronous() {
+ }
@Test
- public void testIsRolling()
- {
+ public void testIsRolling() {
createRegion("faultyDiskXMLsForTesting/incorrect_roll_oplogs_value.xml");
}
@Test
- public void testDiskDirSize()
- {
+ public void testDiskDirSize() {
createRegion("faultyDiskXMLsForTesting/incorrect_dir_size.xml");
}
@Test
- public void testDiskDirs()
- {
+ public void testDiskDirs() {
createRegion("faultyDiskXMLsForTesting/incorrect_dir.xml");
}
@Test
- public void testBytesThreshold()
- {
+ public void testBytesThreshold() {
createRegion("faultyDiskXMLsForTesting/incorrect_bytes_threshold.xml");
}
@Test
- public void testTimeInterval()
- {
+ public void testTimeInterval() {
createRegion("faultyDiskXMLsForTesting/incorrect_time_interval.xml");
}
@Test
- public void testMixedDiskStoreWithDiskDir()
- {
+ public void testMixedDiskStoreWithDiskDir() {
createRegion("faultyDiskXMLsForTesting/mixed_diskstore_diskdir.xml");
}
+
@Test
- public void testMixedDiskStoreWithDWA()
- {
+ public void testMixedDiskStoreWithDWA() {
createRegion("faultyDiskXMLsForTesting/mixed_diskstore_diskwriteattrs.xml");
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskStoreFactoryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskStoreFactoryJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskStoreFactoryJUnitTest.java
index 38a1c5f..ea18f59 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskStoreFactoryJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskStoreFactoryJUnitTest.java
@@ -16,36 +16,39 @@
*/
package com.gemstone.gemfire.internal.cache;
-import java.io.*;
-import java.util.*;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.Arrays;
+import java.util.Properties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
-import com.gemstone.gemfire.cache.*;
-import com.gemstone.gemfire.internal.Assert;
-import com.gemstone.gemfire.distributed.*;
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.DiskStore;
+import com.gemstone.gemfire.cache.DiskStoreFactory;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import junit.framework.TestCase;
-
/**
* Tests DiskStoreFactory
- *
- *
*/
@Category(IntegrationTest.class)
-public class DiskStoreFactoryJUnitTest
-{
+public class DiskStoreFactoryJUnitTest {
- protected static Cache cache = null;
+ private static Cache cache = null;
- protected static DistributedSystem ds = null;
- protected static Properties props = new Properties();
+ private static DistributedSystem ds = null;
+ private static Properties props = new Properties();
static {
props.setProperty("mcast-port", "0");
@@ -61,7 +64,7 @@ public class DiskStoreFactoryJUnitTest
createCache();
}
- protected Cache createCache() {
+ private Cache createCache() {
cache = new CacheFactory(props).create();
ds = cache.getDistributedSystem();
return cache;
@@ -72,7 +75,7 @@ public class DiskStoreFactoryJUnitTest
cache.close();
}
- /*
+ /**
* Test method for
* 'com.gemstone.gemfire.cache.DiskWriteAttributes.getDefaultInstance()'
*/
@@ -189,6 +192,7 @@ public class DiskStoreFactoryJUnitTest
} catch (IllegalArgumentException expected) {
}
}
+
@Test
public void testTimeInterval() {
DiskStoreFactory dsf = cache.createDiskStoreFactory();
@@ -209,6 +213,7 @@ public class DiskStoreFactoryJUnitTest
} catch (IllegalArgumentException expected) {
}
}
+
@Test
public void testMaxOplogSize() {
DiskStoreFactory dsf = cache.createDiskStoreFactory();
@@ -235,6 +240,7 @@ public class DiskStoreFactoryJUnitTest
} catch (IllegalArgumentException expected) {
}
}
+
@Test
public void testFlush() {
DiskStoreFactory dsf = cache.createDiskStoreFactory();
@@ -349,7 +355,7 @@ public class DiskStoreFactoryJUnitTest
removeFiles(diskStore);
}
- protected void removeFiles(DiskStore diskStore) {
+ private void removeFiles(DiskStore diskStore) {
final String diskStoreName = diskStore.getName();
File[] dirs = diskStore.getDiskDirs();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OfflineSnapshotJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OfflineSnapshotJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OfflineSnapshotJUnitTest.java
index 129d942..bab336b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OfflineSnapshotJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OfflineSnapshotJUnitTest.java
@@ -20,19 +20,14 @@ import java.io.File;
import java.io.FilenameFilter;
import java.util.HashMap;
import java.util.Map;
-import java.util.Map.Entry;
+import com.examples.snapshot.MyObject;
+import com.examples.snapshot.MyPdxSerializer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
-import junit.framework.TestCase;
-
-import com.examples.snapshot.MyObject;
-import com.examples.snapshot.MyPdxSerializer;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.DiskStore;
@@ -40,12 +35,11 @@ import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.snapshot.RegionGenerator;
import com.gemstone.gemfire.cache.snapshot.RegionGenerator.RegionType;
import com.gemstone.gemfire.cache.snapshot.RegionGenerator.SerializationType;
-import com.gemstone.gemfire.cache.snapshot.SnapshotIterator;
-import com.gemstone.gemfire.cache.snapshot.SnapshotReader;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
@Category(IntegrationTest.class)
public class OfflineSnapshotJUnitTest {
+
private RegionGenerator rgen;
private Cache cache;
@@ -94,7 +88,7 @@ public class OfflineSnapshotJUnitTest {
}
}
- public Map<Integer, MyObject> createExpected(SerializationType type, int count) {
+ private Map<Integer, MyObject> createExpected(SerializationType type, int count) {
Map<Integer, MyObject> expected = new HashMap<Integer, MyObject>();
for (int i = 0; i < count; i++) {
expected.put(i, rgen.createData(type, i, "The number is " + i));
@@ -124,7 +118,7 @@ public class OfflineSnapshotJUnitTest {
}
}
- public void reset() {
+ private void reset() {
CacheFactory cf = new CacheFactory()
.set("mcast-port", "0")
.set("log-level", "error")
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogJUnitTest.java
index b259b79..b283ec3 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogJUnitTest.java
@@ -16,12 +16,7 @@
*/
package com.gemstone.gemfire.internal.cache;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
import java.io.File;
import java.io.FileInputStream;
@@ -36,10 +31,10 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.IntStream;
+import com.jayway.awaitility.Awaitility;
import org.apache.commons.io.FileUtils;
-import org.junit.After;
import org.junit.Assert;
-import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -62,13 +57,13 @@ import com.gemstone.gemfire.test.dunit.Wait;
import com.gemstone.gemfire.test.dunit.WaitCriterion;
import com.gemstone.gemfire.test.junit.categories.FlakyTest;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import com.jayway.awaitility.Awaitility;
/**
* Testing Oplog API's
*/
@Category(IntegrationTest.class)
public class OplogJUnitTest extends DiskRegionTestingBase {
+
boolean proceed = false;
private final DiskRegionProperties diskProps = new DiskRegionProperties();
@@ -2293,10 +2288,10 @@ public class OplogJUnitTest extends DiskRegionTestingBase {
/**
* Tests if buffer size is set but time is not set , the asynch writer gets
* awakened on buffer size basis
- *
*/
- public void DARREL_DISABLE_testAsynchWriterAttribBehaviour2()
- {
+ @Ignore("TODO:DARREL_DISABLE: test is disabled")
+ @Test
+ public void testAsynchWriterAttribBehaviour2() {
DiskStoreFactory dsf = cache.createDiskStoreFactory();
((DiskStoreFactoryImpl)dsf).setMaxOplogSizeInBytes(10000);
dsf.setQueueSize(2);
@@ -2445,8 +2440,9 @@ public class OplogJUnitTest extends DiskRegionTestingBase {
*/
//Now we preallocate spaces for if files and also crfs and drfs. So the below test is not valid
// any more. See revision: r42359 and r42320. So disabling this test.
- public void _testPreblowErrorCondition()
- {
+ @Ignore("TODO: test is disabled")
+ @Test
+ public void testPreblowErrorCondition() {
DiskStoreFactory dsf = cache.createDiskStoreFactory();
((DiskStoreFactoryImpl)dsf).setMaxOplogSizeInBytes(100000000L * 1024L * 1024L * 1024L);
dsf.setAutoCompact(false);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PRDataStoreMemoryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PRDataStoreMemoryJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PRDataStoreMemoryJUnitTest.java
index 31c8db8..563644c 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PRDataStoreMemoryJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PRDataStoreMemoryJUnitTest.java
@@ -16,6 +16,8 @@
*/
package com.gemstone.gemfire.internal.cache;
+import static org.junit.Assert.*;
+
import java.util.Properties;
import org.junit.After;
@@ -23,30 +25,24 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
-import junit.framework.TestCase;
-
-import com.gemstone.gemfire.cache.PartitionAttributesFactory;
-import com.gemstone.gemfire.distributed.DistributedSystem;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.cache.CacheException;
import com.gemstone.gemfire.cache.PartitionAttributes;
+import com.gemstone.gemfire.cache.PartitionAttributesFactory;
import com.gemstone.gemfire.cache.RegionFactory;
+import com.gemstone.gemfire.distributed.DistributedSystem;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
/**
* Tests memory allocation operations on a PartitionedRegion on a single node.
- *
*/
@Category(IntegrationTest.class)
public class PRDataStoreMemoryJUnitTest {
- static DistributedSystem sys;
+ private static DistributedSystem sys;
- static Cache cache;
+ private static Cache cache;
@Before
public void setUp() throws Exception {
@@ -79,8 +75,7 @@ public class PRDataStoreMemoryJUnitTest {
}
@Test
- public void testCurrentAllocatedMemory() throws Exception
- {
+ public void testCurrentAllocatedMemory() throws Exception {
PartitionedRegion regionAck1 = (PartitionedRegion)defineRegionFactory()
.create("testCurrentAllocatedemory");
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionSerializableObjectJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionSerializableObjectJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionSerializableObjectJUnitTest.java
index 1b2205e..5a50487 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionSerializableObjectJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionSerializableObjectJUnitTest.java
@@ -23,51 +23,47 @@ package com.gemstone.gemfire.internal.cache;
*
*/
-import java.util.*;
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.test.dunit.ThreadUtils;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import junit.framework.TestCase;
-
@Category(IntegrationTest.class)
-public class PartitionedRegionSerializableObjectJUnitTest
-{
- String regionName = "SerizableRegion";
+public class PartitionedRegionSerializableObjectJUnitTest {
+
+ private String regionName = "SerizableRegion";
/** It is common region for all the threads */
- Region root;
+ private Region root;
/**
* It is map to store thread name and list of objects which are created by
* that thread.
*/
- static Map thread2List = new HashMap();
+ private static Map thread2List = new HashMap();
- static int MAX_COUNT = 10;
+ private static int MAX_COUNT = 10;
- static int MAX_THREADS = 10;
+ private static int MAX_THREADS = 10;
/**
* This test creates a region and threads. This Region is common to all the
* threads which perform get, put operations on that region. Object used
* during these operations are serializable. key and value in the partition
* region are same.
- *
*/
@Test
- public void testOperationsWithSerializableObject()
- {
-
+ public void testOperationsWithSerializableObject() {
int localMaxMemory = 50;
Thread threadArr[] = new Thread[10];
root = PartitionedRegionTestHelper.createPartitionedRegion(regionName,
@@ -103,16 +99,15 @@ public class PartitionedRegionSerializableObjectJUnitTest
* This class creates thread that take list of the objects from thread2List
* Map and performs get operation with these objects as key and verifying
* result with itself because key and values are same in the partition Region
- *
*/
- public class getThread extends Thread
- {
+ private class getThread extends Thread {
+
getThread(String threadName) {
super(threadName);
}
- public void run()
- {
+ @Override
+ public void run() {
Region pr = PartitionedRegionTestHelper
.getExistingRegion(Region.SEPARATOR + regionName);
assertNotNull(pr);
@@ -141,17 +136,15 @@ public class PartitionedRegionSerializableObjectJUnitTest
* This class create threads that put the serializable objects in the partion
* region and also add the the list of the serializable objects to the
* thread2List map
- *
*/
+ private class putThread extends Thread {
- public class putThread extends Thread
- {
putThread(String threadName) {
super(threadName);
}
- public void run()
- {
+ @Override
+ public void run() {
Region pr = PartitionedRegionTestHelper
.getExistingRegion(Region.SEPARATOR + regionName);
assertNotNull(pr);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/RegionEntryFlagsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/RegionEntryFlagsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/RegionEntryFlagsJUnitTest.java
index c2795cf..72caae4 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/RegionEntryFlagsJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/RegionEntryFlagsJUnitTest.java
@@ -19,6 +19,8 @@
*/
package com.gemstone.gemfire.internal.cache;
+import static org.junit.Assert.*;
+
import java.util.Set;
import org.junit.After;
@@ -26,10 +28,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
-import junit.framework.TestCase;
-
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.Region.Entry;
import com.gemstone.gemfire.cache.Scope;
@@ -41,13 +39,10 @@ import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
* This test verifies the flag's on-off switching for
* boolean flags in AbstractRegionEntry.
* Currently a byte array is used to maintain two flags.
- *
- *
*/
@Category(IntegrationTest.class)
public class RegionEntryFlagsJUnitTest {
-
@Before
public void setUp() throws Exception {
CacheUtils.startCache();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/BlockingHARegionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/BlockingHARegionJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/BlockingHARegionJUnitTest.java
index 4b36b79..465770a 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/BlockingHARegionJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/BlockingHARegionJUnitTest.java
@@ -16,35 +16,38 @@
*/
package com.gemstone.gemfire.internal.cache.ha;
+import static org.junit.Assert.*;
+
import java.util.Properties;
-import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
-import junit.framework.TestCase;
-
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.internal.cache.EventID;
-import com.gemstone.gemfire.internal.AvailablePort;
import com.gemstone.gemfire.test.dunit.ThreadUtils;
import com.gemstone.gemfire.test.dunit.Wait;
import com.gemstone.gemfire.test.dunit.WaitCriterion;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
@Category(IntegrationTest.class)
-public class BlockingHARegionJUnitTest
-{
- static Cache cache = null;
+public class BlockingHARegionJUnitTest {
+
+ private static Cache cache = null;
+
+ /** boolean to record an exception occurence in another thread**/
+ private static volatile boolean exceptionOccured = false;
+ /** StringBuffer to store the exception**/
+ private static StringBuffer exceptionString = new StringBuffer();
+ /** boolen to quit the for loop**/
+ private static volatile boolean quitForLoop = false;
@Before
- public void setUp() throws Exception
- {
+ public void setUp() throws Exception {
Properties props = new Properties();
props.setProperty("mcast-port", "0");
if (cache != null) {
@@ -54,15 +57,13 @@ public class BlockingHARegionJUnitTest
.connect(props));
}
-/**
- * This test has a scenario where the HAReqionQueue capacity is just 1. There will
- * be two thread. One doing a 1000 puts and the other doing a 1000 takes. The validation
- * for this test is that it should not encounter any exceptions
- *
- */
+ /**
+ * This test has a scenario where the HAReqionQueue capacity is just 1. There will
+ * be two thread. One doing a 1000 puts and the other doing a 1000 takes. The validation
+ * for this test is that it should not encounter any exceptions
+ */
@Test
- public void testBoundedPuts()
- {
+ public void testBoundedPuts() throws Exception {
try {
exceptionOccured = false;
HARegionQueueAttributes harqa = new HARegionQueueAttributes();
@@ -104,8 +105,7 @@ public class BlockingHARegionJUnitTest
*
*/
@Test
- public void testPutBeingBlocked()
- {
+ public void testPutBeingBlocked() throws Exception {
try {
exceptionOccured = false;
quitForLoop = false;
@@ -174,8 +174,7 @@ public class BlockingHARegionJUnitTest
*
*/
@Test
- public void testConcurrentPutsNotExceedingLimit()
- {
+ public void testConcurrentPutsNotExceedingLimit() throws Exception {
try {
exceptionOccured = false;
quitForLoop = false;
@@ -245,95 +244,87 @@ public class BlockingHARegionJUnitTest
* put simultaneously. They will reach a state where the queue is full and they will all
* go in a wait state. the region size would be verified to be 20000 (10000 puts and 10000 DACE objects).
* then the threads are interrupted and made to quit the loop
- *
- *TODO:
- *
*/
- public void _testConcurrentPutsTakesNotExceedingLimit()
- {
- try {
- exceptionOccured = false;
- quitForLoop = false;
- HARegionQueueAttributes harqa = new HARegionQueueAttributes();
- harqa.setBlockingQueueCapacity(10000);
- final HARegionQueue hrq = HARegionQueue.getHARegionQueueInstance(
- "BlockingHARegionJUnitTest_Region", cache, harqa,
- HARegionQueue.BLOCKING_HA_QUEUE, false);
- Thread thread1 = new DoPuts(hrq,40000,1);
- Thread thread2 = new DoPuts(hrq,40000,2);
- Thread thread3 = new DoPuts(hrq,40000,3);
- Thread thread4 = new DoPuts(hrq,40000,4);
- Thread thread5 = new DoPuts(hrq,40000,5);
-
- Thread thread6 = new DoTake(hrq,5000);
- Thread thread7 = new DoTake(hrq,5000);
- Thread thread8 = new DoTake(hrq,5000);
- Thread thread9 = new DoTake(hrq,5000);
- Thread thread10 = new DoTake(hrq,5000);
-
- thread1.start();
- thread2.start();
- thread3.start();
- thread4.start();
- thread5.start();
-
- thread6.start();
- thread7.start();
- thread8.start();
- thread9.start();
- thread10.start();
-
- ThreadUtils.join(thread6, 30 * 1000);
- ThreadUtils.join(thread7, 30 * 1000);
- ThreadUtils.join(thread8, 30 * 1000);
- ThreadUtils.join(thread9, 30 * 1000);
- ThreadUtils.join(thread10, 30 * 1000);
-
- WaitCriterion ev = new WaitCriterion() {
- public boolean done() {
- return hrq.region.size() == 20000;
- }
- public String description() {
- return null;
- }
- };
- Wait.waitForCriterion(ev, 30 * 1000, 200, true);
-
- assertTrue(thread1.isAlive());
- assertTrue(thread2.isAlive());
- assertTrue(thread3.isAlive());
- assertTrue(thread4.isAlive());
- assertTrue(thread5.isAlive());
-
- assertTrue(hrq.region.size()==20000);
-
- quitForLoop = true;
-
- Thread.sleep(2000);
-
- thread1.interrupt();
- thread2.interrupt();
- thread3.interrupt();
- thread4.interrupt();
- thread5.interrupt();
-
- Thread.sleep(2000);
-
-
- ThreadUtils.join(thread1, 30 * 1000);
- ThreadUtils.join(thread2, 30 * 1000);
- ThreadUtils.join(thread3, 30 * 1000);
- ThreadUtils.join(thread4, 30 * 1000);
- ThreadUtils.join(thread5, 30 * 1000);
-
- cache.close();
- }
- catch (Exception e) {
- fail(" Test encountered an exception "+e);
- }
+ @Ignore("TODO: test is disabled")
+ @Test
+ public void testConcurrentPutsTakesNotExceedingLimit() throws Exception {
+ exceptionOccured = false;
+ quitForLoop = false;
+ HARegionQueueAttributes harqa = new HARegionQueueAttributes();
+ harqa.setBlockingQueueCapacity(10000);
+ final HARegionQueue hrq = HARegionQueue.getHARegionQueueInstance(
+ "BlockingHARegionJUnitTest_Region", cache, harqa,
+ HARegionQueue.BLOCKING_HA_QUEUE, false);
+ Thread thread1 = new DoPuts(hrq,40000,1);
+ Thread thread2 = new DoPuts(hrq,40000,2);
+ Thread thread3 = new DoPuts(hrq,40000,3);
+ Thread thread4 = new DoPuts(hrq,40000,4);
+ Thread thread5 = new DoPuts(hrq,40000,5);
+
+ Thread thread6 = new DoTake(hrq,5000);
+ Thread thread7 = new DoTake(hrq,5000);
+ Thread thread8 = new DoTake(hrq,5000);
+ Thread thread9 = new DoTake(hrq,5000);
+ Thread thread10 = new DoTake(hrq,5000);
+
+ thread1.start();
+ thread2.start();
+ thread3.start();
+ thread4.start();
+ thread5.start();
+
+ thread6.start();
+ thread7.start();
+ thread8.start();
+ thread9.start();
+ thread10.start();
+
+ ThreadUtils.join(thread6, 30 * 1000);
+ ThreadUtils.join(thread7, 30 * 1000);
+ ThreadUtils.join(thread8, 30 * 1000);
+ ThreadUtils.join(thread9, 30 * 1000);
+ ThreadUtils.join(thread10, 30 * 1000);
+
+ WaitCriterion ev = new WaitCriterion() {
+ public boolean done() {
+ return hrq.region.size() == 20000;
+ }
+ public String description() {
+ return null;
+ }
+ };
+ Wait.waitForCriterion(ev, 30 * 1000, 200, true);
+
+ assertTrue(thread1.isAlive());
+ assertTrue(thread2.isAlive());
+ assertTrue(thread3.isAlive());
+ assertTrue(thread4.isAlive());
+ assertTrue(thread5.isAlive());
+
+ assertTrue(hrq.region.size()==20000);
+
+ quitForLoop = true;
+
+ Thread.sleep(2000);
+
+ thread1.interrupt();
+ thread2.interrupt();
+ thread3.interrupt();
+ thread4.interrupt();
+ thread5.interrupt();
+
+ Thread.sleep(2000);
+
+
+ ThreadUtils.join(thread1, 30 * 1000);
+ ThreadUtils.join(thread2, 30 * 1000);
+ ThreadUtils.join(thread3, 30 * 1000);
+ ThreadUtils.join(thread4, 30 * 1000);
+ ThreadUtils.join(thread5, 30 * 1000);
+
+ cache.close();
}
-
-
+
/**
* Tests the bug in HARegionQueue where the take side put permit is not being
* incremented when the event arriving at the queue which has optimistically
@@ -341,11 +332,9 @@ public class BlockingHARegionJUnitTest
* has a sequence ID less than the last dispatched sequence ID. This event is
* rightly rejected from entering the queue but the take permit also needs to
* increase & a notify issued
- *
- */
+ */
@Test
- public void testHARQMaxCapacity_Bug37627()
- {
+ public void testHARQMaxCapacity_Bug37627() throws Exception {
try {
exceptionOccured = false;
quitForLoop = false;
@@ -383,9 +372,6 @@ public class BlockingHARegionJUnitTest
fail(" Test failed due to " + exceptionString);
}
}
- catch (Exception e) {
- fail(" Test failed due to " + e);
- }
finally {
if (cache != null) {
cache.close();
@@ -394,39 +380,32 @@ public class BlockingHARegionJUnitTest
}
-
-
- /** boolean to record an exception occurence in another thread**/
- static volatile boolean exceptionOccured = false;
-/** StringBuffer to store the exception**/
- static StringBuffer exceptionString = new StringBuffer();
- /** boolen to quit the for loop**/
- static volatile boolean quitForLoop = false;
-
/**
* class which does specified number of puts on the queue
- *
*/
- static class DoPuts extends Thread
- {
+ private static class DoPuts extends Thread {
+
HARegionQueue regionQueue = null;
final int numberOfPuts;
+
DoPuts(HARegionQueue haRegionQueue, int numberOfPuts) {
this.regionQueue = haRegionQueue;
this.numberOfPuts = numberOfPuts;
}
-/**
- * region id can be specified to generate Thread unique events
- */
+
+ /**
+ * region id can be specified to generate Thread unique events
+ */
int regionId = 0;
+
DoPuts(HARegionQueue haRegionQueue, int numberOfPuts, int regionId) {
this.regionQueue = haRegionQueue;
this.numberOfPuts = numberOfPuts;
this.regionId = regionId;
}
-
- public void run()
- {
+
+ @Override
+ public void run() {
for (int i = 0; i < numberOfPuts; i++) {
try {
this.regionQueue.put(new ConflatableObject("" + i, "" + i,
@@ -451,8 +430,8 @@ public class BlockingHARegionJUnitTest
* class which does a specified number of takes
*
*/
- static class DoTake extends Thread
- {
+ private static class DoTake extends Thread {
+
final HARegionQueue regionQueue;
final int numberOfTakes;
@@ -461,8 +440,8 @@ public class BlockingHARegionJUnitTest
this.numberOfTakes = numberOfTakes;
}
- public void run()
- {
+ @Override
+ public void run() {
for (int i = 0; i < numberOfTakes; i++) {
try {
assertNotNull(this.regionQueue.take());
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d4a62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/ThreadIdentifierJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/ThreadIdentifierJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/ThreadIdentifierJUnitTest.java
index 66ee622..110b64d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/ThreadIdentifierJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/ThreadIdentifierJUnitTest.java
@@ -24,8 +24,6 @@ import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.internal.cache.ha.ThreadIdentifier.WanType;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junit.framework.TestCase;
-
@Category(UnitTest.class)
public class ThreadIdentifierJUnitTest {