geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [52/94] [abbrv] incubator-geode git commit: Fixing a couple of a files that were renamed to directories
Date Tue, 23 Feb 2016 20:23:48 GMT
Fixing a couple of a files that were renamed to directories

These two files should have been moved to the appropriate directory
under geode-core. Instead, the file was moved to a file named after the
directory.


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

Branch: refs/heads/feature/GEODE-953
Commit: 9eb7a058ed83e3e0b4351db6502cce4dc6cfdc8f
Parents: 5beaaed
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Fri Feb 19 17:12:56 2016 -0800
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Fri Feb 19 17:12:56 2016 -0800

----------------------------------------------------------------------
 .../gemstone/gemfire/management/internal/beans  | 106 -------------------
 .../beans/DistributedSystemBridgeJUnitTest.java | 106 +++++++++++++++++++
 .../test/java/com/gemstone/gemfire/test/fake    |  99 -----------------
 .../com/gemstone/gemfire/test/fake/Fakes.java   |  99 +++++++++++++++++
 4 files changed, 205 insertions(+), 205 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9eb7a058/geode-core/src/test/java/com/gemstone/gemfire/management/internal/beans
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/beans b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/beans
deleted file mode 100644
index 84b39d4..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/beans
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.management.internal.beans;
-
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.*;
-import static org.mockito.Mockito.*;
-
-import java.io.IOException;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.mockito.InOrder;
-
-import com.gemstone.gemfire.admin.internal.BackupDataStoreHelper;
-import com.gemstone.gemfire.admin.internal.FinishBackupRequest;
-import com.gemstone.gemfire.admin.internal.PrepareBackupRequest;
-import com.gemstone.gemfire.distributed.internal.DM;
-import com.gemstone.gemfire.distributed.internal.locks.DLockService;
-import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-import com.gemstone.gemfire.internal.cache.persistence.BackupManager;
-import com.gemstone.gemfire.internal.cache.persistence.PersistentMemberManager;
-import com.gemstone.gemfire.test.fake.Fakes;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-@Category(UnitTest.class)
-public class DistributedSystemBridgeJUnitTest {
-  
-  private GemFireCacheImpl cache;
-  private BackupManager backupManager;
-
-  @Before
-  public void createCache() throws IOException {
-    cache = Fakes.cache();
-    PersistentMemberManager memberManager = mock(PersistentMemberManager.class);
-    backupManager = mock(BackupManager.class);
-    when(cache.startBackup(any())).thenReturn(backupManager);
-    when(cache.getPersistentMemberManager()).thenReturn(memberManager);
-    when(cache.getBackupManager()).thenReturn(backupManager);
-    
-    DLockService dlock = mock(DLockService.class);
-    when(dlock.lock(any(), anyLong(), anyLong())).thenReturn(true);
-    
-    DLockService.addLockServiceForTests(BackupDataStoreHelper.LOCK_SERVICE_NAME, dlock);
-    GemFireCacheImpl.setInstanceForTests(cache);
-  }
-  
-  @After
-  public void clearCache() {
-    GemFireCacheImpl.setInstanceForTests(null);
-    DLockService.removeLockServiceForTests(BackupDataStoreHelper.LOCK_SERVICE_NAME);
-  }
-  
-  @Test
-  public void testSucessfulBackup() throws Exception {
-    DM dm = cache.getDistributionManager();
-    
-    DistributedSystemBridge bridge = new DistributedSystemBridge(null);
-    bridge.backupAllMembers("/tmp", null);
-    
-    InOrder inOrder = inOrder(dm, backupManager);
-    inOrder.verify(dm).putOutgoing(isA(PrepareBackupRequest.class));
-    inOrder.verify(backupManager).prepareBackup();
-    inOrder.verify(dm).putOutgoing(isA(FinishBackupRequest.class));
-    inOrder.verify(backupManager).finishBackup(any(), any(), eq(false));
-  }
-
-  @Test
-  public void testPrepareErrorAbortsBackup() throws Exception {
-    DM dm = cache.getDistributionManager();
-    PersistentMemberManager memberManager = mock(PersistentMemberManager.class);
-    BackupManager backupManager = mock(BackupManager.class);
-    when(cache.startBackup(any())).thenReturn(backupManager);
-    when(cache.getPersistentMemberManager()).thenReturn(memberManager);
-    when(cache.getBackupManager()).thenReturn(backupManager);
-    when(dm.putOutgoing(isA(PrepareBackupRequest.class))).thenThrow(new RuntimeException("Fail
the prepare"));
-    
-    
-    DistributedSystemBridge bridge = new DistributedSystemBridge(null);
-    try {
-      bridge.backupAllMembers("/tmp", null);
-      fail("Should have failed with an exception");
-    } catch(RuntimeException expected) {
-      
-    }
-    
-    verify(dm).putOutgoing(isA(FinishBackupRequest.class));
-    verify(backupManager).finishBackup(any(), any(), eq(true));
-  }
-}
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/beans/DistributedSystemBridgeJUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/beans/DistributedSystemBridgeJUnitTest.java
new file mode 100644
index 0000000..84b39d4
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/beans/DistributedSystemBridgeJUnitTest.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.management.internal.beans;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.*;
+
+import java.io.IOException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.mockito.InOrder;
+
+import com.gemstone.gemfire.admin.internal.BackupDataStoreHelper;
+import com.gemstone.gemfire.admin.internal.FinishBackupRequest;
+import com.gemstone.gemfire.admin.internal.PrepareBackupRequest;
+import com.gemstone.gemfire.distributed.internal.DM;
+import com.gemstone.gemfire.distributed.internal.locks.DLockService;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.internal.cache.persistence.BackupManager;
+import com.gemstone.gemfire.internal.cache.persistence.PersistentMemberManager;
+import com.gemstone.gemfire.test.fake.Fakes;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class DistributedSystemBridgeJUnitTest {
+  
+  private GemFireCacheImpl cache;
+  private BackupManager backupManager;
+
+  @Before
+  public void createCache() throws IOException {
+    cache = Fakes.cache();
+    PersistentMemberManager memberManager = mock(PersistentMemberManager.class);
+    backupManager = mock(BackupManager.class);
+    when(cache.startBackup(any())).thenReturn(backupManager);
+    when(cache.getPersistentMemberManager()).thenReturn(memberManager);
+    when(cache.getBackupManager()).thenReturn(backupManager);
+    
+    DLockService dlock = mock(DLockService.class);
+    when(dlock.lock(any(), anyLong(), anyLong())).thenReturn(true);
+    
+    DLockService.addLockServiceForTests(BackupDataStoreHelper.LOCK_SERVICE_NAME, dlock);
+    GemFireCacheImpl.setInstanceForTests(cache);
+  }
+  
+  @After
+  public void clearCache() {
+    GemFireCacheImpl.setInstanceForTests(null);
+    DLockService.removeLockServiceForTests(BackupDataStoreHelper.LOCK_SERVICE_NAME);
+  }
+  
+  @Test
+  public void testSucessfulBackup() throws Exception {
+    DM dm = cache.getDistributionManager();
+    
+    DistributedSystemBridge bridge = new DistributedSystemBridge(null);
+    bridge.backupAllMembers("/tmp", null);
+    
+    InOrder inOrder = inOrder(dm, backupManager);
+    inOrder.verify(dm).putOutgoing(isA(PrepareBackupRequest.class));
+    inOrder.verify(backupManager).prepareBackup();
+    inOrder.verify(dm).putOutgoing(isA(FinishBackupRequest.class));
+    inOrder.verify(backupManager).finishBackup(any(), any(), eq(false));
+  }
+
+  @Test
+  public void testPrepareErrorAbortsBackup() throws Exception {
+    DM dm = cache.getDistributionManager();
+    PersistentMemberManager memberManager = mock(PersistentMemberManager.class);
+    BackupManager backupManager = mock(BackupManager.class);
+    when(cache.startBackup(any())).thenReturn(backupManager);
+    when(cache.getPersistentMemberManager()).thenReturn(memberManager);
+    when(cache.getBackupManager()).thenReturn(backupManager);
+    when(dm.putOutgoing(isA(PrepareBackupRequest.class))).thenThrow(new RuntimeException("Fail
the prepare"));
+    
+    
+    DistributedSystemBridge bridge = new DistributedSystemBridge(null);
+    try {
+      bridge.backupAllMembers("/tmp", null);
+      fail("Should have failed with an exception");
+    } catch(RuntimeException expected) {
+      
+    }
+    
+    verify(dm).putOutgoing(isA(FinishBackupRequest.class));
+    verify(backupManager).finishBackup(any(), any(), eq(true));
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9eb7a058/geode-core/src/test/java/com/gemstone/gemfire/management/internal/beans/DistributedSystemBridgeJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/beans/DistributedSystemBridgeJUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/beans/DistributedSystemBridgeJUnitTest.java
new file mode 100644
index 0000000..84b39d4
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/beans/DistributedSystemBridgeJUnitTest.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.management.internal.beans;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.*;
+
+import java.io.IOException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.mockito.InOrder;
+
+import com.gemstone.gemfire.admin.internal.BackupDataStoreHelper;
+import com.gemstone.gemfire.admin.internal.FinishBackupRequest;
+import com.gemstone.gemfire.admin.internal.PrepareBackupRequest;
+import com.gemstone.gemfire.distributed.internal.DM;
+import com.gemstone.gemfire.distributed.internal.locks.DLockService;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.internal.cache.persistence.BackupManager;
+import com.gemstone.gemfire.internal.cache.persistence.PersistentMemberManager;
+import com.gemstone.gemfire.test.fake.Fakes;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class DistributedSystemBridgeJUnitTest {
+  
+  private GemFireCacheImpl cache;
+  private BackupManager backupManager;
+
+  @Before
+  public void createCache() throws IOException {
+    cache = Fakes.cache();
+    PersistentMemberManager memberManager = mock(PersistentMemberManager.class);
+    backupManager = mock(BackupManager.class);
+    when(cache.startBackup(any())).thenReturn(backupManager);
+    when(cache.getPersistentMemberManager()).thenReturn(memberManager);
+    when(cache.getBackupManager()).thenReturn(backupManager);
+    
+    DLockService dlock = mock(DLockService.class);
+    when(dlock.lock(any(), anyLong(), anyLong())).thenReturn(true);
+    
+    DLockService.addLockServiceForTests(BackupDataStoreHelper.LOCK_SERVICE_NAME, dlock);
+    GemFireCacheImpl.setInstanceForTests(cache);
+  }
+  
+  @After
+  public void clearCache() {
+    GemFireCacheImpl.setInstanceForTests(null);
+    DLockService.removeLockServiceForTests(BackupDataStoreHelper.LOCK_SERVICE_NAME);
+  }
+  
+  @Test
+  public void testSucessfulBackup() throws Exception {
+    DM dm = cache.getDistributionManager();
+    
+    DistributedSystemBridge bridge = new DistributedSystemBridge(null);
+    bridge.backupAllMembers("/tmp", null);
+    
+    InOrder inOrder = inOrder(dm, backupManager);
+    inOrder.verify(dm).putOutgoing(isA(PrepareBackupRequest.class));
+    inOrder.verify(backupManager).prepareBackup();
+    inOrder.verify(dm).putOutgoing(isA(FinishBackupRequest.class));
+    inOrder.verify(backupManager).finishBackup(any(), any(), eq(false));
+  }
+
+  @Test
+  public void testPrepareErrorAbortsBackup() throws Exception {
+    DM dm = cache.getDistributionManager();
+    PersistentMemberManager memberManager = mock(PersistentMemberManager.class);
+    BackupManager backupManager = mock(BackupManager.class);
+    when(cache.startBackup(any())).thenReturn(backupManager);
+    when(cache.getPersistentMemberManager()).thenReturn(memberManager);
+    when(cache.getBackupManager()).thenReturn(backupManager);
+    when(dm.putOutgoing(isA(PrepareBackupRequest.class))).thenThrow(new RuntimeException("Fail
the prepare"));
+    
+    
+    DistributedSystemBridge bridge = new DistributedSystemBridge(null);
+    try {
+      bridge.backupAllMembers("/tmp", null);
+      fail("Should have failed with an exception");
+    } catch(RuntimeException expected) {
+      
+    }
+    
+    verify(dm).putOutgoing(isA(FinishBackupRequest.class));
+    verify(backupManager).finishBackup(any(), any(), eq(true));
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9eb7a058/geode-core/src/test/java/com/gemstone/gemfire/test/fake
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/fake b/geode-core/src/test/java/com/gemstone/gemfire/test/fake
deleted file mode 100644
index ffb4896..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/fake
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.test.fake;
-
-import static org.mockito.Mockito.*;
-
-import java.net.UnknownHostException;
-
-import org.junit.Assert;
-
-import com.gemstone.gemfire.CancelCriterion;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.distributed.internal.DistributionManager;
-import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
-import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
-import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-
-/**
- * Factory methods for fake objects for use in test.
- * 
- * These fakes are essentially mock objects with some limited
- * functionality. For example the fake cache can return a fake
- * distributed system.
- * 
- * All of the fakes returned by this class are Mockito.mocks, so
- * they can be modified by using Mockito stubbing, ie
- * 
- * <pre>
- * cache = Fakes.cache();
- * Mockito.when(cache.getName()).thenReturn(...)
- * <pre>
- * 
- * Please help extend this class by adding other commonly
- * used objects to this collection of fakes.
- */
-public class Fakes {
-  
-  /**
-   * A fake cache, which contains a fake distributed
-   * system, distribution manager, etc.
-   */
-  public static GemFireCacheImpl cache() {
-    GemFireCacheImpl cache = mock(GemFireCacheImpl.class);
-    InternalDistributedSystem system = mock(InternalDistributedSystem.class);
-    DistributionConfig config = mock(DistributionConfig.class);
-    DistributionManager distributionManager = mock(DistributionManager.class);
-    CancelCriterion systemCancelCriterion = mock(CancelCriterion.class);
-    
-    InternalDistributedMember member;
-    try {
-      member = new InternalDistributedMember("localhost", 5555);
-    } catch (UnknownHostException e) {
-      throw new RuntimeException(e);
-    }
-    
-    
-    when(cache.getDistributedSystem()).thenReturn(system);
-    when(cache.getMyId()).thenReturn(member);
-    when(cache.getDistributionManager()).thenReturn(distributionManager);
-    when(cache.getCancelCriterion()).thenReturn(systemCancelCriterion);
-    
-    when(system.getDistributedMember()).thenReturn(member);
-    when(system.getConfig()).thenReturn(config);
-    when(system.getDistributionManager()).thenReturn(distributionManager);
-    when(system.getCancelCriterion()).thenReturn(systemCancelCriterion);
-    
-    when(distributionManager.getId()).thenReturn(member);
-    when(distributionManager.getConfig()).thenReturn(config);
-    when(distributionManager.getSystem()).thenReturn(system);
-    when(distributionManager.getCancelCriterion()).thenReturn(systemCancelCriterion);
-    
-    return cache;
-  }
-
-  /**
-   * A fake distributed system, which contains a fake distribution manager.
-   */
-  public static InternalDistributedSystem distributedSystem() {
-    return cache().getDistributedSystem();
-  }
-
-  private Fakes() {
-  }
-
-}
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
new file mode 100644
index 0000000..ffb4896
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/fake/Fakes.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.fake;
+
+import static org.mockito.Mockito.*;
+
+import java.net.UnknownHostException;
+
+import org.junit.Assert;
+
+import com.gemstone.gemfire.CancelCriterion;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.DistributionManager;
+import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
+import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+
+/**
+ * Factory methods for fake objects for use in test.
+ * 
+ * These fakes are essentially mock objects with some limited
+ * functionality. For example the fake cache can return a fake
+ * distributed system.
+ * 
+ * All of the fakes returned by this class are Mockito.mocks, so
+ * they can be modified by using Mockito stubbing, ie
+ * 
+ * <pre>
+ * cache = Fakes.cache();
+ * Mockito.when(cache.getName()).thenReturn(...)
+ * <pre>
+ * 
+ * Please help extend this class by adding other commonly
+ * used objects to this collection of fakes.
+ */
+public class Fakes {
+  
+  /**
+   * A fake cache, which contains a fake distributed
+   * system, distribution manager, etc.
+   */
+  public static GemFireCacheImpl cache() {
+    GemFireCacheImpl cache = mock(GemFireCacheImpl.class);
+    InternalDistributedSystem system = mock(InternalDistributedSystem.class);
+    DistributionConfig config = mock(DistributionConfig.class);
+    DistributionManager distributionManager = mock(DistributionManager.class);
+    CancelCriterion systemCancelCriterion = mock(CancelCriterion.class);
+    
+    InternalDistributedMember member;
+    try {
+      member = new InternalDistributedMember("localhost", 5555);
+    } catch (UnknownHostException e) {
+      throw new RuntimeException(e);
+    }
+    
+    
+    when(cache.getDistributedSystem()).thenReturn(system);
+    when(cache.getMyId()).thenReturn(member);
+    when(cache.getDistributionManager()).thenReturn(distributionManager);
+    when(cache.getCancelCriterion()).thenReturn(systemCancelCriterion);
+    
+    when(system.getDistributedMember()).thenReturn(member);
+    when(system.getConfig()).thenReturn(config);
+    when(system.getDistributionManager()).thenReturn(distributionManager);
+    when(system.getCancelCriterion()).thenReturn(systemCancelCriterion);
+    
+    when(distributionManager.getId()).thenReturn(member);
+    when(distributionManager.getConfig()).thenReturn(config);
+    when(distributionManager.getSystem()).thenReturn(system);
+    when(distributionManager.getCancelCriterion()).thenReturn(systemCancelCriterion);
+    
+    return cache;
+  }
+
+  /**
+   * A fake distributed system, which contains a fake distribution manager.
+   */
+  public static InternalDistributedSystem distributedSystem() {
+    return cache().getDistributedSystem();
+  }
+
+  private Fakes() {
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9eb7a058/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
new file mode 100644
index 0000000..ffb4896
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/fake/Fakes.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.fake;
+
+import static org.mockito.Mockito.*;
+
+import java.net.UnknownHostException;
+
+import org.junit.Assert;
+
+import com.gemstone.gemfire.CancelCriterion;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.DistributionManager;
+import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
+import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+
+/**
+ * Factory methods for fake objects for use in test.
+ * 
+ * These fakes are essentially mock objects with some limited
+ * functionality. For example the fake cache can return a fake
+ * distributed system.
+ * 
+ * All of the fakes returned by this class are Mockito.mocks, so
+ * they can be modified by using Mockito stubbing, ie
+ * 
+ * <pre>
+ * cache = Fakes.cache();
+ * Mockito.when(cache.getName()).thenReturn(...)
+ * <pre>
+ * 
+ * Please help extend this class by adding other commonly
+ * used objects to this collection of fakes.
+ */
+public class Fakes {
+  
+  /**
+   * A fake cache, which contains a fake distributed
+   * system, distribution manager, etc.
+   */
+  public static GemFireCacheImpl cache() {
+    GemFireCacheImpl cache = mock(GemFireCacheImpl.class);
+    InternalDistributedSystem system = mock(InternalDistributedSystem.class);
+    DistributionConfig config = mock(DistributionConfig.class);
+    DistributionManager distributionManager = mock(DistributionManager.class);
+    CancelCriterion systemCancelCriterion = mock(CancelCriterion.class);
+    
+    InternalDistributedMember member;
+    try {
+      member = new InternalDistributedMember("localhost", 5555);
+    } catch (UnknownHostException e) {
+      throw new RuntimeException(e);
+    }
+    
+    
+    when(cache.getDistributedSystem()).thenReturn(system);
+    when(cache.getMyId()).thenReturn(member);
+    when(cache.getDistributionManager()).thenReturn(distributionManager);
+    when(cache.getCancelCriterion()).thenReturn(systemCancelCriterion);
+    
+    when(system.getDistributedMember()).thenReturn(member);
+    when(system.getConfig()).thenReturn(config);
+    when(system.getDistributionManager()).thenReturn(distributionManager);
+    when(system.getCancelCriterion()).thenReturn(systemCancelCriterion);
+    
+    when(distributionManager.getId()).thenReturn(member);
+    when(distributionManager.getConfig()).thenReturn(config);
+    when(distributionManager.getSystem()).thenReturn(system);
+    when(distributionManager.getCancelCriterion()).thenReturn(systemCancelCriterion);
+    
+    return cache;
+  }
+
+  /**
+   * A fake distributed system, which contains a fake distribution manager.
+   */
+  public static InternalDistributedSystem distributedSystem() {
+    return cache().getDistributedSystem();
+  }
+
+  private Fakes() {
+  }
+
+}


Mime
View raw message