geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject [2/3] incubator-geode git commit: mock of DistributedSystem for real GemFireCacheImpl now passes
Date Thu, 19 May 2016 00:03:00 GMT
mock of DistributedSystem for real GemFireCacheImpl now passes


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

Branch: refs/heads/feature/GEODE-1246
Commit: f03a4c81342639d8f44aeff464a360d5a5a62458
Parents: edabd63
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Wed May 18 15:43:29 2016 -0700
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Wed May 18 15:43:29 2016 -0700

----------------------------------------------------------------------
 .../gemfire/distributed/internal/locks/DLockService.java  |  9 ++++-----
 .../gemfire/internal/cache/GemFireCacheImplTest.java      |  2 +-
 .../test/java/com/gemstone/gemfire/test/fake/Fakes.java   | 10 ++++++++++
 3 files changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f03a4c81/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DLockService.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DLockService.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DLockService.java
index 610944e..844a93d 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DLockService.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DLockService.java
@@ -133,7 +133,7 @@ public class DLockService extends DistributedLockService {
   private DLockRecoverGrantorProcessor.MessageProcessor recoverGrantorProcessor;
   
   /** Thread-safe reference to DistributedLockStats */
-  private final DistributedLockStats dlockStats = getOrCreateStats();
+  private final DistributedLockStats dlockStats;
   
   /** 
    * Protects {@link #lockGrantorId}, {@link #grantor} and 
@@ -2145,6 +2145,7 @@ public class DLockService extends DistributedLockService {
                          boolean destroyOnDisconnect,
                          boolean automateFreeResources) {
     super();
+    this.dlockStats = getOrCreateStats(ds);
     this.serialNumber = createSerialNumber();
     this.serviceName = serviceName;
     this.ds = (InternalDistributedSystem) ds;
@@ -3185,12 +3186,10 @@ public class DLockService extends DistributedLockService {
   }
   
   /** Get or create static dlock stats */
-  protected static synchronized DistributedLockStats getOrCreateStats() {
+  protected static synchronized DistributedLockStats getOrCreateStats(DistributedSystem ds)
{
     if (stats == DUMMY_STATS) {
-      InternalDistributedSystem ds =
-          InternalDistributedSystem.getAnyInstance();
       Assert.assertTrue(ds != null, 
-          "Cannot find any instance of InternalDistributedSystem");
+          "Need an instance of InternalDistributedSystem");
       StatisticsFactory statFactory = ds;
       long statId = OSProcess.getId();
       stats = new DLockStats(statFactory, statId);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f03a4c81/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/GemFireCacheImplTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/GemFireCacheImplTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/GemFireCacheImplTest.java
index 1870c84..162f08e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/GemFireCacheImplTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/GemFireCacheImplTest.java
@@ -27,7 +27,7 @@ public class GemFireCacheImplTest {
   @Test
   public void test() {
     
-    GemFireCacheImpl gfc = GemFireCacheImpl.createWithAsyncEventListeners(Fakes.distributedSystem(),
null);
+    GemFireCacheImpl gfc = GemFireCacheImpl.createWithAsyncEventListeners(Fakes.distributedSystem(),
new CacheConfig());
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f03a4c81/geode-core/src/test/java/com/gemstone/gemfire/test/fake/Fakes.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/fake/Fakes.java b/geode-core/src/test/java/com/gemstone/gemfire/test/fake/Fakes.java
index 2a1fd8e..16734b5 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/fake/Fakes.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/fake/Fakes.java
@@ -18,11 +18,14 @@ package com.gemstone.gemfire.test.fake;
 
 import static org.mockito.Mockito.*;
 
+import java.io.File;
 import java.net.UnknownHostException;
 
 import org.junit.Assert;
 
 import com.gemstone.gemfire.CancelCriterion;
+import com.gemstone.gemfire.LogWriter;
+import com.gemstone.gemfire.Statistics;
 import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.DataPolicy;
 import com.gemstone.gemfire.cache.Region;
@@ -65,6 +68,8 @@ public class Fakes {
     DistributionManager distributionManager = mock(DistributionManager.class);
     CancelCriterion systemCancelCriterion = mock(CancelCriterion.class);
     DSClock clock = mock(DSClock.class);
+    LogWriter logger = mock(LogWriter.class);
+    Statistics stats = mock(Statistics.class);
     
     InternalDistributedMember member;
     try {
@@ -73,6 +78,8 @@ public class Fakes {
       throw new RuntimeException(e);
     }
     
+    when(config.getCacheXmlFile()).thenReturn(new File(""));
+    when(config.getDeployWorkingDir()).thenReturn(new File("."));
     
     when(cache.getDistributedSystem()).thenReturn(system);
     when(cache.getMyId()).thenReturn(member);
@@ -84,6 +91,9 @@ public class Fakes {
     when(system.getDistributionManager()).thenReturn(distributionManager);
     when(system.getCancelCriterion()).thenReturn(systemCancelCriterion);
     when(system.getClock()).thenReturn(clock);
+    when(system.getLogWriter()).thenReturn(logger);
+    when(system.createAtomicStatistics(any(), any(), anyLong())).thenReturn(stats);
+    when(system.createAtomicStatistics(any(), any())).thenReturn(stats);
 
     when(distributionManager.getId()).thenReturn(member);
     when(distributionManager.getConfig()).thenReturn(config);


Mime
View raw message