[ https://issues.apache.org/jira/browse/GEODE-7678?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17107633#comment-17107633 ]
ASF GitHub Bot commented on GEODE-7678: --------------------------------------- agingade commented on a change in pull request #4987: URL: https://github.com/apache/geode/pull/4987#discussion_r425403916 ########## File path: geode-core/src/distributedTest/java/org/apache/geode/cache/PRCacheListenerDistributedTest.java ########## @@ -79,4 +118,206 @@ protected int expectedInvalidates() { protected int expectedDestroys() { return 1; } + + @Test + public void afterRegionDestroyIsInvokedInEveryMember() { + CacheListener<String, Integer> listener = new RegionDestroyCountingCacheListener(); + Region<String, Integer> region = createRegion(regionName, listener); + + for (int i = 0; i < getVMCount(); i++) { + getVM(i).invoke(() -> { + withData(createRegion(regionName, listener)); + }); + } + + region.destroyRegion(); + + assertThat(sharedCountersRule.getTotal(REGION_DESTROY)).isEqualTo(expectedRegionDestroys()); + } + + @Test + public void afterRegionDestroyIsInvokedOnNodeWithListener() { + CacheListener<String, Integer> listener = new RegionDestroyCountingCacheListener(); + Region<String, Integer> region = createRegion(regionName, listener); + + for (int i = 0; i < getVMCount(); i++) { + getVM(i).invoke(() -> { + withData(createRegion(regionName, null)); + }); + } + + region.destroyRegion(); + + assertThat(sharedCountersRule.getTotal(REGION_DESTROY)).isEqualTo(1); + } + + @Test + public void afterRegionDestroyIsInvokedOnRemoteNodeWithListener() { + CacheListener<String, Integer> listener = new RegionDestroyCountingCacheListener(); + Region<String, Integer> region = createRegion(regionName, null); + + getVM(0).invoke(() -> { + createRegion(regionName, listener); + }); + + for (int i = 1; i < getVMCount(); i++) { + getVM(i).invoke(() -> { + withData(createRegion(regionName, null)); + }); + } + + region.destroyRegion(); + + assertThat(sharedCountersRule.getTotal(REGION_DESTROY)).isEqualTo(1); + } + + @Test + public void afterRegionDestroyIsInvokedOnAccessorAndDataMembers() { + CacheListener<String, Integer> listener = new RegionDestroyCountingCacheListener(); + Region<String, Integer> region = createAccessorRegion(regionName, listener); + for (int i = 0; i < getVMCount(); i++) { + getVM(i).invoke(() -> { + withData(createRegion(regionName, listener)); + }); + } + + region.destroyRegion(); + + assertThat(sharedCountersRule.getTotal(REGION_DESTROY)).isEqualTo(expectedRegionDestroys()); + } + + @Test + public void afterRegionDestroyIsInvokedOnAccessor() { + CacheListener<String, Integer> listener = new RegionDestroyCountingCacheListener(); + Region<String, Integer> region = createAccessorRegion(regionName, listener); + + for (int i = 0; i < getVMCount(); i++) { + getVM(i).invoke(() -> { + withData(createRegion(regionName, null)); + }); + } + + region.destroyRegion(); + + assertThat(sharedCountersRule.getTotal(REGION_DESTROY)).isEqualTo(1); + } + + @Test + public void afterRegionDestroyIsInvokedNonOnNonAccessor() { Review comment: Good catch. Will be addressed in the next checkin. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Partitioned Region clear operations must invoke cache level listeners > --------------------------------------------------------------------- > > Key: GEODE-7678 > URL: https://issues.apache.org/jira/browse/GEODE-7678 > Project: Geode > Issue Type: Sub-task > Components: regions > Reporter: Nabarun Nag > Assignee: Anilkumar Gingade > Priority: Major > Labels: GeodeCommons, GeodeOperationAPI > > Clear operations are successful and CacheListener.afterRegionClear(), > CacheWriter.beforeRegionClear() are invoked. > > Acceptance : > * DUnit tests validating the above behavior. > * Test coverage to when a member departs in this scenario > * Test coverage to when a member restarts in this scenario > * Unit tests with complete code coverage for the newly written code. > -- This message was sent by Atlassian Jira (v8.3.4#803005)