geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From upthewatersp...@apache.org
Subject [3/3] incubator-geode git commit: Using a Rule to clear System properties in RegionDirectoryJUnitTest
Date Thu, 27 Aug 2015 01:07:49 GMT
Using a Rule to clear System properties in RegionDirectoryJUnitTest

I found that on some systems the @After to clear the properties was
running after the SystemPropertiesInvariant rule.


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

Branch: refs/heads/feature/GEODE-11
Commit: 07528954ea254e0538e9e95a7b6419cae8cc9f29
Parents: 7efa4c1
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Wed Aug 26 17:28:29 2015 -0700
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Wed Aug 26 17:28:29 2015 -0700

----------------------------------------------------------------------
 .../directory/RegionDirectoryJUnitTest.java     | 23 ++++++++++++++------
 1 file changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/07528954/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/directory/RegionDirectoryJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/directory/RegionDirectoryJUnitTest.java
b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/directory/RegionDirectoryJUnitTest.java
index 3c14c31..cd88a46 100644
--- a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/directory/RegionDirectoryJUnitTest.java
+++ b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/directory/RegionDirectoryJUnitTest.java
@@ -7,8 +7,10 @@ import java.util.concurrent.ConcurrentHashMap;
 import org.apache.lucene.store.BaseDirectoryTestCase;
 import org.apache.lucene.store.Directory;
 import org.junit.After;
+import org.junit.Rule;
 import org.junit.experimental.categories.Category;
 
+import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
 import com.gemstone.gemfire.cache.lucene.internal.filesystem.ChunkKey;
 import com.gemstone.gemfire.cache.lucene.internal.filesystem.File;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
@@ -22,16 +24,23 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
  */
 @Category(UnitTest.class)
 public class RegionDirectoryJUnitTest extends BaseDirectoryTestCase {
+  @Rule
+  public SystemPropertiesRestoreRule restoreProps = new SystemPropertiesRestoreRule();
   
-  @After
-  public void clearLog4J() {
-    //The lucene test ensures that no system properties
-    //have been modified by the test. GFE leaves this property
-    //set
-    System.clearProperty("log4j.configurationFile");
-  }
+//  @After
+//  public void clearLog4J() {
+//    //The lucene test ensures that no system properties
+//    //have been modified by the test. GFE leaves this property
+//    //set
+//    System.clearProperty("log4j.configurationFile");
+//  }
   
   protected Directory getDirectory(Path path) throws IOException {
+    
+    //This is super lame, but log4j automatically sets the system property, and the lucene
+    //test asserts that no system properties have changed. Unfortunately, there is no
+    //way to control the order of rules, so we can't clear this property with a rule
+    //or @After method. Instead, do it in the close method of the directory.
     return new RegionDirectory(new ConcurrentHashMap<String, File>(), new ConcurrentHashMap<ChunkKey,
byte[]>());
   }
 }


Mime
View raw message