geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject [1/2] geode git commit: added unit test
Date Thu, 20 Apr 2017 18:19:11 GMT
Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-2801 30703224e -> 232a61e67


added unit test


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

Branch: refs/heads/feature/GEODE-2801
Commit: b8e466e4bbec11902b57cd0dc6302d55f09d52de
Parents: 3070322
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Thu Apr 20 11:17:58 2017 -0700
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Thu Apr 20 11:17:58 2017 -0700

----------------------------------------------------------------------
 .../internal/cache/DiskInitFileJUnitTest.java   | 57 ++++++++++++++++++++
 1 file changed, 57 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/b8e466e4/geode-core/src/test/java/org/apache/geode/internal/cache/DiskInitFileJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/DiskInitFileJUnitTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/DiskInitFileJUnitTest.java
index 6f2cf6c..5e545d9 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/DiskInitFileJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/DiskInitFileJUnitTest.java
@@ -116,5 +116,62 @@ public class DiskInitFileJUnitTest {
 
     dif.close();
   }
+  
+  @Test
+  public void testKrfIds() {
+    // create a mock statistics factory for creating directory holders
+    final StatisticsFactory sf = context.mock(StatisticsFactory.class);
+    context.checking(new Expectations() {
+      {
+        ignoring(sf);
+      }
+    });
+    // Add a mock region to the init file so it doesn't
+    // delete the file when the init file is closed
+    final DiskRegionView drv = context.mock(DiskRegionView.class);
+    context.checking(new Expectations() {
+      {
+        ignoring(drv);
+      }
+    });
+    // Create a mock disk store impl. All we need to do is return
+    // this init file directory.
+    final DiskStoreImpl parent = context.mock(DiskStoreImpl.class);
+    context.checking(new Expectations() {
+      {
+        allowing(parent).getInfoFileDir();
+        will(returnValue(new DirectoryHolder(sf, testDirectory, 0, 0)));
+        ignoring(parent);
+      }
+    });
+    
+    DiskInitFile dif = new DiskInitFile("testKrfIds", parent, false, Collections.<File>emptySet());
+    assertEquals(false, dif.hasKrf(1));
+    dif.cmnKrfCreate(1);
+    assertEquals(true, dif.hasKrf(1));
+    assertEquals(false, dif.hasKrf(2));
+    dif.cmnKrfCreate(2);
+    assertEquals(true, dif.hasKrf(2));
+    dif.createRegion(drv);
+    dif.forceCompaction();
+    dif.close();
+
+    dif = new DiskInitFile("testKrfIds", parent, true, Collections.<File>emptySet());
+    assertEquals(true, dif.hasKrf(1));
+    assertEquals(true, dif.hasKrf(2));
+    dif.cmnCrfDelete(1);
+    assertEquals(false, dif.hasKrf(1));
+    assertEquals(true, dif.hasKrf(2));
+    dif.cmnCrfDelete(2);
+    assertEquals(false, dif.hasKrf(2));
+    dif.createRegion(drv);
+    dif.forceCompaction();
+    dif.close();
+    
+    dif = new DiskInitFile("testKrfIds", parent, true, Collections.<File>emptySet());
+    assertEquals(false, dif.hasKrf(1));
+    assertEquals(false, dif.hasKrf(2));
+    dif.destroy();
+  }
 
 }


Mime
View raw message