geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinmeil...@apache.org
Subject [02/32] incubator-geode git commit: GEODE-235: Add region name to EntryEventImpl toString
Date Fri, 15 Apr 2016 03:07:31 GMT
GEODE-235: Add region name to EntryEventImpl toString

A new EntryEventImplTest was added. It currently only
verifies that the toString output includes the region name.

This closes #125


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

Branch: refs/heads/feature/GEODE-17-2
Commit: c67a1c913d72062044767717078d8c5bcc5200a9
Parents: 39e94bc
Author: Scott Jewell <sjewell@pivotal.io>
Authored: Tue Apr 5 11:03:06 2016 -0700
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Tue Apr 12 10:50:49 2016 -0700

----------------------------------------------------------------------
 .../gemfire/internal/cache/EntryEventImpl.java  |  4 +-
 .../internal/cache/EntryEventImplTest.java      | 71 ++++++++++++++++++++
 2 files changed, 74 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c67a1c91/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java
index ba9ac11..3c87654 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java
@@ -2306,6 +2306,8 @@ public class EntryEventImpl
 
     buf.append("op=");
     buf.append(getOperation());
+    buf.append(";region=");
+    buf.append(getRegion().getFullPath());
     buf.append(";key=");
     buf.append(this.getKey());
     buf.append(";oldValue=");
@@ -3121,4 +3123,4 @@ public class EntryEventImpl
   public final void setLoadedFromHDFS(boolean loadedFromHDFS) {
     this.loadedFromHDFS = loadedFromHDFS;
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c67a1c91/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/EntryEventImplTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/EntryEventImplTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/EntryEventImplTest.java
new file mode 100644
index 0000000..c3e057c
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/EntryEventImplTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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.internal.cache;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.mockito.Mockito;
+
+import com.gemstone.gemfire.cache.Operation;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+import static org.mockito.Mockito.*;
+
+@Category(UnitTest.class)
+public class EntryEventImplTest {
+
+  String expectedRegionName = "ExpectedFullRegionPathName";
+  String key = "key1";
+  String value = "value1";
+  KeyInfo keyInfo = new KeyInfo(key, value, null);
+
+  @Test
+  public void verifyToStringOutputHasRegionName() {
+    // mock a region object
+    LocalRegion region = mock(LocalRegion.class);
+    doReturn(expectedRegionName).when(region).getFullPath();
+    doReturn(keyInfo).when(region).getKeyInfo(any(), any(), any());
+
+    // create entryevent for the region
+    EntryEventImpl e = createEntryEvent(region);
+    
+    // The name of the region should be in the toString text
+    String toStringValue = e.toString();
+    assertTrue("String " + expectedRegionName + " was not in toString text: " + toStringValue,
toStringValue.indexOf(expectedRegionName) > 0);
+
+    // verify that toString called getFullPath method of region object
+    verify(region, Mockito.times(1)).getFullPath();
+  }
+
+  private EntryEventImpl createEntryEvent(LocalRegion l) {
+    // create a dummy event id
+    byte[] memId = { 1,2,3 };
+    EventID eventId = new EventID(memId, 11, 12, 13);
+
+    // create an event
+    EntryEventImpl event = EntryEventImpl.create(l, Operation.CREATE, key,
+        value, null,  false /* origin remote */, null,
+        false /* generateCallbacks */,
+        eventId);
+    // avoid calling invokeCallbacks
+    event.callbacksInvoked(true);
+
+    return event;
+  }
+}
\ No newline at end of file


Mime
View raw message