diff options
author | Renu Kumari <renu.kumari@bell.ca> | 2021-08-25 09:32:35 -0400 |
---|---|---|
committer | Renu Kumari <renu.kumari@bell.ca> | 2021-08-25 09:32:35 -0400 |
commit | 8b935c7f04b76ba8203ff6ccab4790a2c2612ff1 (patch) | |
tree | 34fafca2854471059cb3ba45b0f7adf4d30b0035 /cps-service/src/test/groovy/org | |
parent | 86c74c79cb45992d9f2ec134477cae41cd26651b (diff) |
Add timeout to async test-cases
Issue-ID: CPS-526
Signed-off-by: Renu Kumari <renu.kumari@bell.ca>
Change-Id: Icf46f94090a615bf945eb70b58edf86c0c509155
Diffstat (limited to 'cps-service/src/test/groovy/org')
-rw-r--r-- | cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy index 0a2d3d9988..ab727671e1 100644 --- a/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy @@ -32,6 +32,8 @@ import org.springframework.test.context.ContextConfiguration import spock.lang.Shared import spock.lang.Specification +import java.util.concurrent.TimeUnit + @SpringBootTest @EnableAsync @EnableConfigurationProperties @@ -71,9 +73,11 @@ class NotificationServiceSpec extends Specification { mockCpsDataUpdatedEventFactory.createCpsDataUpdatedEvent(dataspaceName, myAnchorName) >> cpsDataUpdatedEvent when: 'dataUpdatedEvent is received' def future = objectUnderTest.processDataUpdatedEvent(dataspaceName, myAnchorName) - and: 'async processing is completed' - future.get() - then: 'notification is sent' + and: 'wait for async processing is completed' + future.get(10, TimeUnit.SECONDS) + then: 'async process completed successfully' + future.isDone() + and: 'notification is sent' expectedSendNotificationCount * mockNotificationPublisher.sendNotification(cpsDataUpdatedEvent) where: scenario | dataspaceName || expectedSendNotificationCount @@ -89,9 +93,11 @@ class NotificationServiceSpec extends Specification { { throw new Exception("Could not create event") } when: 'event is sent for processing' def future = objectUnderTest.processDataUpdatedEvent(myDataspacePublishedName, myAnchorName) - and: 'async processing is completed' - future.get() - then: 'error is handled and not thrown to caller' + and: 'wait for async processing is completed' + future.get(10, TimeUnit.SECONDS) + then: 'async process completed successfully' + future.isDone() + and: 'error is handled and not thrown to caller' notThrown Exception 1 * spyNotificationErrorHandler.onException(_, _, _, _) } |