summaryrefslogtreecommitdiffstats
path: root/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/test/java
diff options
context:
space:
mode:
authorHao Kuang <Hao.Kuang@amdocs.com>2017-08-18 16:07:56 +0000
committerPatrick Brady <pb071s@att.com>2017-08-18 20:16:17 +0000
commit7fec0d41c1fdfdb0eef04c6df8fb4b5368a975a5 (patch)
treee18d5951fc7888f68af1c2f059234ab6bbd7978a /appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/test/java
parent5b7590935559fe9e286a703dc662a60b47b7ed1a (diff)
Fix ExecutionQueue cannot be cleaned
Fix that LCM Requests in Execution Queue continue after Stop OAM request sent. Fix that Appc-Ansible bundle cannot be fully stopped because of NPE. Issue-Id: APPC-159 Change-Id: I8f0a3a79a5c572ad84e66f71b4ddb47118704302 Signed-off-by: Hao Kuang <Hao.Kuang@amdocs.com>
Diffstat (limited to 'appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/test/java')
-rw-r--r--appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/test/java/org/openecomp/appc/executionqueue/ExecutionQueueServiceTest.java (renamed from appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/test/java/org/openecomp/appc/executionqueue/TestExecutionQueueService.java)57
1 files changed, 25 insertions, 32 deletions
diff --git a/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/test/java/org/openecomp/appc/executionqueue/TestExecutionQueueService.java b/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/test/java/org/openecomp/appc/executionqueue/ExecutionQueueServiceTest.java
index 6e9584894..067b6c3e7 100644
--- a/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/test/java/org/openecomp/appc/executionqueue/TestExecutionQueueService.java
+++ b/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/test/java/org/openecomp/appc/executionqueue/ExecutionQueueServiceTest.java
@@ -25,50 +25,43 @@
package org.openecomp.appc.executionqueue;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
import org.mockito.Mockito;
+import org.mockito.Spy;
import org.openecomp.appc.exceptions.APPCException;
-import org.openecomp.appc.executionqueue.ExecutionQueueService;
-import org.openecomp.appc.executionqueue.impl.ExecutionQueueServiceFactory;
-import org.powermock.api.mockito.PowerMockito;
+import org.openecomp.appc.executionqueue.helper.Util;
+import org.openecomp.appc.executionqueue.impl.ExecutionQueueServiceImpl;
+import org.openecomp.appc.executionqueue.impl.QueueManager;
+import org.powermock.modules.junit4.PowerMockRunner;
-import java.util.concurrent.TimeUnit;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.times;
+@RunWith(PowerMockRunner.class)
+public class ExecutionQueueServiceTest {
-public class TestExecutionQueueService {
+ @InjectMocks
+ private ExecutionQueueServiceImpl service;
+ @Spy
+ private QueueManager queueManager = new QueueManager();
+ @Spy
+ private Util executionQueueUtil = new Util();
- @Test
- public void testPositiveFlow(){
- Message message = new Message();
- ExecutionQueueService service = ExecutionQueueServiceFactory.getExecutionQueueService();
- try {
- service.putMessage(message);
- waitFor(5000);
- Assert.assertTrue(message.isRunExecuted());
- } catch (APPCException e) {
- Assert.fail(e.toString());
- }
+ @Before
+ public void setup() {
+ Mockito.doReturn(true).when(queueManager).enqueueTask(any());
}
-// @Test
- public void testTimeout(){
- ExecutionQueueService service = ExecutionQueueServiceFactory.getExecutionQueueService();
+ @Test
+ public void testPositiveFlow() {
Message message = new Message();
- Listener listener = new Listener();
- service.registerMessageExpirationListener(listener);
try {
- service.putMessage(message,1, TimeUnit.MILLISECONDS);
- waitFor(5000);
- Assert.assertTrue(listener.isListenerExecuted());
+ service.putMessage(message);
+ Mockito.verify(queueManager, times(1)).enqueueTask(any());
} catch (APPCException e) {
- e.printStackTrace();
- }
- }
-
- private void waitFor(long milliSeconds){
- try {
- Thread.sleep(milliSeconds);
- } catch (InterruptedException e) {
Assert.fail(e.toString());
}
}