From 8b35ccbcaa5c61fa9dfce1add0ec8b1d10f84c72 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Tue, 30 Apr 2019 14:39:43 -0400 Subject: Cancel PDP timers in PAP When a response is received by PAP from a PDP, the associated timer (and listener) are not being cancelled. As a result, when the timer later expired, PAP was re-sending the request. Modified the code to fix this. Change-Id: Id63f76622c01d286c169b618f8369b849ff31085 Issue-ID: POLICY-1715 Signed-off-by: Jim Hahn --- .../onap/policy/pap/main/comm/msgdata/RequestImplTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'main/src/test') diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/RequestImplTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/RequestImplTest.java index 2446533e..3d90fcbb 100644 --- a/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/RequestImplTest.java +++ b/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/RequestImplTest.java @@ -109,6 +109,9 @@ public class RequestImplTest extends CommonRequestBase { PdpStateChange msg2 = new PdpStateChange(); req.reconfigure(msg2, null); + // should have cancelled the first timer + verify(timer).cancel(); + // should only be one token in the queue QueueToken token = queue.poll(); assertNotNull(token); @@ -133,6 +136,9 @@ public class RequestImplTest extends CommonRequestBase { PdpStateChange msg2 = new PdpStateChange(); req.reconfigure(msg2, null); + // should have cancelled the first timer + verify(timer).cancel(); + // should only be one token in the queue QueueToken token = queue.poll(); assertNotNull(token); @@ -193,6 +199,9 @@ public class RequestImplTest extends CommonRequestBase { verify(timers, times(1)).register(any(), any()); verify(publisher, times(1)).enqueue(any()); assertNull(queue.poll()); + + // should NOT have cancelled the timer + verify(timer, never()).cancel(); } @Test @@ -400,6 +409,7 @@ public class RequestImplTest extends CommonRequestBase { verify(listener).success(PDP1); verify(listener, never()).failure(any(), any()); + verify(timer).cancel(); } @Test @@ -424,6 +434,7 @@ public class RequestImplTest extends CommonRequestBase { verify(listener, never()).success(any()); verify(listener).failure(DIFFERENT, "PDP name does not match"); + verify(timer).cancel(); } @Test -- cgit 1.2.3-korg