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/01/19 22:46:03 UTC

[05/22] incubator-geode git commit: GEODE-765: Ignore gemfire.properties file and convert to JUnit 4

GEODE-765: Ignore gemfire.properties file and convert to JUnit 4


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

Branch: refs/heads/feature/GEODE-217
Commit: 0b5b30af80f24a903dc21542e13b799036a41606
Parents: 678451a
Author: Kirk Lund <kl...@pivotal.io>
Authored: Mon Jan 11 12:17:29 2016 -0800
Committer: Kirk Lund <kl...@pivotal.io>
Committed: Mon Jan 11 12:17:29 2016 -0800

----------------------------------------------------------------------
 .../gemfire/redis/ConcurrentStartTest.java      | 34 +++++++++++++++++---
 1 file changed, 29 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0b5b30af/gemfire-core/src/test/java/com/gemstone/gemfire/redis/ConcurrentStartTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/redis/ConcurrentStartTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/redis/ConcurrentStartTest.java
index b5954b8..6c11c96 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/redis/ConcurrentStartTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/redis/ConcurrentStartTest.java
@@ -18,11 +18,16 @@ package com.gemstone.gemfire.redis;
 
 import static org.junit.Assert.assertFalse;
 
+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.cache.Cache;
 import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.distributed.DistributedSystem;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
@@ -30,20 +35,39 @@ import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
 @Category(IntegrationTest.class)
 public class ConcurrentStartTest {
 
-  int numServers = 10;
+  private Cache cache;
+  private int numServers = 10;
+  
+  @Rule
+  public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+  
+  @Before
+  public void setUp() {
+    System.setProperty(DistributedSystem.PROPERTIES_FILE_PROPERTY, getClass().getSimpleName() + ".properties");
+  }
+
+  @After
+  public void tearDown() {
+    if (this.cache != null) {
+      this.cache.close();
+      this.cache = null;
+    }
+  }
+  
   @Test
   public void testCachelessStart() throws InterruptedException {
     runNServers(numServers);
     GemFireCacheImpl.getInstance().close();
   }
+  
   @Test
   public void testCachefulStart() throws InterruptedException {
     CacheFactory cf = new CacheFactory();
     cf.set("mcast-port", "0");
     cf.set("locators", "");
-    Cache c = cf.create();
+    this.cache = cf.create();
+    
     runNServers(numServers);
-    c.close();
   }
   
   private void runNServers(int n) throws InterruptedException {
@@ -68,7 +92,7 @@ public class ConcurrentStartTest {
     }
     for (Thread t : threads)
       t.join();
-    Cache c = GemFireCacheImpl.getInstance();
-    assertFalse(c.isClosed());
+    this.cache = GemFireCacheImpl.getInstance();
+    assertFalse(this.cache.isClosed());
   }
 }