Return-Path: X-Original-To: apmail-geode-commits-archive@minotaur.apache.org Delivered-To: apmail-geode-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7C68318AFA for ; Tue, 23 Feb 2016 20:24:35 +0000 (UTC) Received: (qmail 74359 invoked by uid 500); 23 Feb 2016 20:24:30 -0000 Delivered-To: apmail-geode-commits-archive@geode.apache.org Received: (qmail 74332 invoked by uid 500); 23 Feb 2016 20:24:30 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 74323 invoked by uid 99); 23 Feb 2016 20:24:30 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Feb 2016 20:24:30 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id EB8651A42A2 for ; Tue, 23 Feb 2016 20:24:29 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.549 X-Spam-Level: X-Spam-Status: No, score=-3.549 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.329] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id zZVwJ7QVlphd for ; Tue, 23 Feb 2016 20:24:23 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with SMTP id F2CC760D40 for ; Tue, 23 Feb 2016 20:24:14 +0000 (UTC) Received: (qmail 65592 invoked by uid 99); 23 Feb 2016 20:22:58 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Feb 2016 20:22:58 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B87EAE8E83; Tue, 23 Feb 2016 20:22:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: klund@apache.org To: commits@geode.incubator.apache.org Date: Tue, 23 Feb 2016 20:23:48 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [52/94] [abbrv] incubator-geode git commit: Fixing a couple of a files that were renamed to directories 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 Authored: Fri Feb 19 17:12:56 2016 -0800 Committer: Dan Smith 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 - * - *
- * cache = Fakes.cache();
- * Mockito.when(cache.getName()).thenReturn(...)
- * 
- * 
- * 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
+ * 
+ * 
+ * cache = Fakes.cache();
+ * Mockito.when(cache.getName()).thenReturn(...)
+ * 
+ * 
+ * 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
+ * 
+ * 
+ * cache = Fakes.cache();
+ * Mockito.when(cache.getName()).thenReturn(...)
+ * 
+ * 
+ * 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() {
+  }
+
+}