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 11E3A199AA for ; Fri, 15 Apr 2016 03:07:43 +0000 (UTC) Received: (qmail 44950 invoked by uid 500); 15 Apr 2016 03:07:42 -0000 Delivered-To: apmail-geode-commits-archive@geode.apache.org Received: (qmail 44903 invoked by uid 500); 15 Apr 2016 03:07:42 -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 43490 invoked by uid 99); 15 Apr 2016 03:07:33 -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; Fri, 15 Apr 2016 03:07:33 +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 3A82B1A069D for ; Fri, 15 Apr 2016 03:07:33 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.221 X-Spam-Level: X-Spam-Status: No, score=-3.221 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.001] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id mm818mmnr1gP for ; Fri, 15 Apr 2016 03:07:31 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with SMTP id E92BF5FB06 for ; Fri, 15 Apr 2016 03:07:30 +0000 (UTC) Received: (qmail 43408 invoked by uid 99); 15 Apr 2016 03:07:30 -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; Fri, 15 Apr 2016 03:07:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3BB25E0211; Fri, 15 Apr 2016 03:07:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jinmeiliao@apache.org To: commits@geode.incubator.apache.org Date: Fri, 15 Apr 2016 03:07:31 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [02/32] incubator-geode git commit: GEODE-235: Add region name to EntryEventImpl toString 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 Authored: Tue Apr 5 11:03:06 2016 -0700 Committer: Darrel Schneider 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