agingade commented on a change in pull request #4987:
URL: https://github.com/apache/geode/pull/4987#discussion_r417692159
##########
File path:
geode-core/src/distributedTest/java/org/apache/geode/cache/ReplicateCacheListenerDistributedTest.java
##########
@@ -302,4 +349,64 @@ public void afterDestroy(final EntryEvent<String, Integer>
event) {
errorCollector.checkThat(event.getNewValue(), nullValue());
}
}
+
+ protected class ClearCountingCacheListener extends BaseCacheListener {
+
+ @Override
+ public void afterCreate(final EntryEvent<String, Integer> event) {
+ sharedCountersRule.increment(CREATES);
+ }
+
+ @Override
+ public void afterUpdate(final EntryEvent<String, Integer> event) {
+ sharedCountersRule.increment(UPDATES);
+ }
+
+ @Override
+ public void afterRegionClear(RegionEvent<String, Integer> event) {
+
+ sharedCountersRule.increment(CLEAR);
+ if
(!event.getRegion().getAttributes().getDataPolicy().withPartitioning()) {
+ if (event.isOriginRemote()) {
+ errorCollector.checkThat(event.getDistributedMember(),
+ not(cacheRule.getSystem().getDistributedMember()));
+ } else {
+ errorCollector.checkThat(event.getDistributedMember(),
+ equalTo(cacheRule.getSystem().getDistributedMember()));
+ }
+ }
+ errorCollector.checkThat(event.getOperation(),
equalTo(Operation.REGION_CLEAR));
+ errorCollector.checkThat(event.getRegion().getName(),
equalTo(regionName));
+ }
+ }
+
+ protected class RegionDestroyCountingCacheListener extends BaseCacheListener
{
+
+ @Override
+ public void afterCreate(final EntryEvent<String, Integer> event) {
+ sharedCountersRule.increment(CREATES);
+ }
+
+ @Override
+ public void afterUpdate(final EntryEvent<String, Integer> event) {
+ sharedCountersRule.increment(UPDATES);
+ }
+
+ @Override
+ public void afterRegionDestroy(final RegionEvent<String, Integer> event) {
+ sharedCountersRule.increment(REGION_DESTROY);
+
+ if
(!event.getRegion().getAttributes().getDataPolicy().withPartitioning()) {
+ if (event.isOriginRemote()) {
+ errorCollector.checkThat(event.getDistributedMember(),
+ not(cacheRule.getSystem().getDistributedMember()));
+ } else {
+ errorCollector.checkThat(event.getDistributedMember(),
+ equalTo(cacheRule.getSystem().getDistributedMember()));
+ }
+ }
Review comment:
In the tests, i have seen both types of implementation, where keeping
duplicate code in the test, so that its easier to understand the test and
modify that specific test. In this case, i will keep it separate and as i
commented for Donal's earlier review we can come back to this test and refactor
it.
----------------------------------------------------------------
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