You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by al...@apache.org on 2021/07/12 06:19:34 UTC

[geode] branch develop updated: GEODE-9421: Remove BatchRemoval NPE logs from JUnit tests (#6683)

This is an automated email from the ASF dual-hosted git repository.

alberto pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new d361a99  GEODE-9421: Remove BatchRemoval NPE logs from JUnit tests (#6683)
d361a99 is described below

commit d361a99806df0bda6da886bd142bd71ff4ad504b
Author: Alberto Gomez <al...@est.tech>
AuthorDate: Mon Jul 12 08:18:10 2021 +0200

    GEODE-9421: Remove BatchRemoval NPE logs from JUnit tests (#6683)
    
    ParallelAsyncEventQueueImplTest and ParallelGatewaySenderImplTest classes were mocking InternalRegion
    but were not providing an implementation for cache.getCancelCriterion().
    This led to a null pointer exception in the BatchRemoval thread code that,
    even though it did not affect the tests, provoked that a log message with
    a null pointer exception was printed.
    
    The solution consists of adding a response in the mock using when() for the cache.getCancelCriterion() method.
---
 .../cache/asyncqueue/internal/ParallelAsyncEventQueueImplTest.java    | 4 +++-
 .../cache/wan/internal/parallel/ParallelGatewaySenderImplTest.java    | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/geode-core/src/test/java/org/apache/geode/cache/asyncqueue/internal/ParallelAsyncEventQueueImplTest.java b/geode-core/src/test/java/org/apache/geode/cache/asyncqueue/internal/ParallelAsyncEventQueueImplTest.java
index b85149c..15879f3 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/asyncqueue/internal/ParallelAsyncEventQueueImplTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/asyncqueue/internal/ParallelAsyncEventQueueImplTest.java
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -50,7 +51,7 @@ public class ParallelAsyncEventQueueImplTest {
 
   @Before
   public void setUp() {
-    cache = mock(InternalCache.class);
+    cache = mock(InternalCache.class, RETURNS_DEEP_STUBS);
     statisticsClock = mock(StatisticsClock.class);
     statsFactory = mock(StatisticsFactory.class);
     attrs = new GatewaySenderAttributes();
@@ -60,6 +61,7 @@ public class ParallelAsyncEventQueueImplTest {
     InternalDistributedSystem system = mock(InternalDistributedSystem.class);
     when(cache.getInternalDistributedSystem()).thenReturn(system);
     when(cache.getDistributedSystem()).thenReturn(system);
+    when(cache.getCancelCriterion().isCancelInProgress()).thenReturn(false);
     ClusterDistributionManager distributionManager = mock(ClusterDistributionManager.class);
     when(system.getDistributionManager()).thenReturn(distributionManager);
     when(distributionManager.getDistributedSystemId()).thenReturn(-1);
diff --git a/geode-wan/src/test/java/org/apache/geode/cache/wan/internal/parallel/ParallelGatewaySenderImplTest.java b/geode-wan/src/test/java/org/apache/geode/cache/wan/internal/parallel/ParallelGatewaySenderImplTest.java
index 56c5b72..aef02f1 100644
--- a/geode-wan/src/test/java/org/apache/geode/cache/wan/internal/parallel/ParallelGatewaySenderImplTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/cache/wan/internal/parallel/ParallelGatewaySenderImplTest.java
@@ -18,6 +18,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -47,7 +48,7 @@ public class ParallelGatewaySenderImplTest {
 
   @Before
   public void setUp() {
-    cache = mock(InternalCache.class);
+    cache = mock(InternalCache.class, RETURNS_DEEP_STUBS);
     statisticsClock = mock(StatisticsClock.class);
     attrs = new GatewaySenderAttributes();
     attrs.setParallel(true);
@@ -55,6 +56,7 @@ public class ParallelGatewaySenderImplTest {
     InternalDistributedSystem system = mock(InternalDistributedSystem.class);
     when(cache.getInternalDistributedSystem()).thenReturn(system);
     when(cache.getDistributedSystem()).thenReturn(system);
+    when(cache.getCancelCriterion().isCancelInProgress()).thenReturn(false);
     ClusterDistributionManager distributionManager = mock(ClusterDistributionManager.class);
     when(system.getDistributionManager()).thenReturn(distributionManager);
     when(distributionManager.getDistributedSystemId()).thenReturn(-1);