geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [08/19] incubator-geode git commit: GEODE-701: fix tests using FREE_OFF_HEAP_MEMORY_PROPERTY
Date Thu, 21 Jan 2016 19:08:54 GMT
GEODE-701: fix tests using FREE_OFF_HEAP_MEMORY_PROPERTY

Fixes: GEODE-701, GEODE-712, GEODE-791, GEODE-792, GEODE-793.
Tests that change the FREE_OFF_HEAP_MEMORY_PROPERTY system property
now use the RestoreSystemProperties rule to ensure that the properties
are restored to their original values.


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/7c4dda25
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/7c4dda25
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/7c4dda25

Branch: refs/heads/feature/GEODE-715
Commit: 7c4dda25832460babb877717fb96e087a7dd2772
Parents: 06a7dbd
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Tue Jan 19 15:34:45 2016 -0800
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Wed Jan 20 10:32:06 2016 -0800

----------------------------------------------------------------------
 .../internal/offheap/LifecycleListenerJUnitTest.java        | 9 ++++++---
 .../gemfire/internal/offheap/OffHeapStorageJUnitTest.java   | 4 ++++
 .../internal/offheap/SimpleMemoryAllocatorJUnitTest.java    | 7 ++++++-
 3 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c4dda25/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/LifecycleListenerJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/LifecycleListenerJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/LifecycleListenerJUnitTest.java
index 4fba65b..5e54b73 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/LifecycleListenerJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/LifecycleListenerJUnitTest.java
@@ -26,18 +26,22 @@ import java.util.List;
 
 import org.junit.After;
 import org.junit.Assert;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
 import org.junit.experimental.categories.Category;
 
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
 /**
- * Tests SimpleMemoryAllocatorImpl.LifecycleListener
+ * Tests LifecycleListener
  * 
  * @author Kirk Lund
  */
 @Category(UnitTest.class)
 public class LifecycleListenerJUnitTest {
+  @Rule
+  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
 
   private final List<LifecycleListenerCallback> afterCreateCallbacks = new ArrayList<LifecycleListenerCallback>();
   private final List<LifecycleListenerCallback> afterReuseCallbacks = new ArrayList<LifecycleListenerCallback>();
@@ -100,7 +104,7 @@ public class LifecycleListenerJUnitTest {
 
     LifecycleListener.addLifecycleListener(this.listener);
 
-    assertEquals(false, Boolean.getBoolean(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY));
+    System.setProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "false");
 
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024); // 1k
     SimpleMemoryAllocatorImpl ma = createAllocator(new NullOutOfOffHeapMemoryListener(),
new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[] { slab });
@@ -144,7 +148,6 @@ public class LifecycleListenerJUnitTest {
   }
   
   private void closeAndFree(SimpleMemoryAllocatorImpl ma) {
-    assertEquals(false, Boolean.getBoolean(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY));
     System.setProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "true");
     try {
       ma.close();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c4dda25/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
index 24fb82b..07b65d9 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
@@ -29,7 +29,9 @@ import java.util.concurrent.TimeUnit;
 
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
 import org.junit.experimental.categories.Category;
 
 import com.gemstone.gemfire.OutOfOffHeapMemoryException;
@@ -43,6 +45,8 @@ import com.jayway.awaitility.Awaitility;
 
 @Category(UnitTest.class)
 public class OffHeapStorageJUnitTest {
+  @Rule
+  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
 
   private final static long MEGABYTE = 1024 * 1024;
   private final static long GIGABYTE = 1024 * 1024 * 1024;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c4dda25/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
index 3c10382..e9095ed 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
@@ -24,7 +24,9 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.concurrent.atomic.AtomicReference;
 
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
 import org.junit.experimental.categories.Category;
 
 import com.gemstone.gemfire.OutOfOffHeapMemoryException;
@@ -35,6 +37,8 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
 @Category(UnitTest.class)
 public class SimpleMemoryAllocatorJUnitTest {
+  @Rule
+  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
 
   private static int round(int multiple, int v) {
     return ((v+multiple-1)/multiple)*multiple;
@@ -130,6 +134,7 @@ public class SimpleMemoryAllocatorJUnitTest {
   }
   @Test
   public void testCreate() {
+    System.setProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "false");
     {
       NullOutOfOffHeapMemoryListener listener = new NullOutOfOffHeapMemoryListener();
       NullOffHeapMemoryStats stats = new NullOffHeapMemoryStats();
@@ -439,7 +444,7 @@ public class SimpleMemoryAllocatorJUnitTest {
 
   @Test
   public void testClose() {
-    assertEquals(false, Boolean.getBoolean(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY));
+    System.setProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "false");
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024*1024);
     boolean freeSlab = true;
     UnsafeMemoryChunk[] slabs = new UnsafeMemoryChunk[]{slab};


Mime
View raw message