summaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-rest-healthcheck-adapter
diff options
context:
space:
mode:
authorJoss Armstrong <joss.armstrong@ericsson.com>2019-02-06 10:34:35 +0000
committerPatrick Brady <patrick.brady@att.com>2019-02-06 21:38:44 +0000
commit8ceb16a925d8ebd0ae05f6745a68507e990d9395 (patch)
treed31196454de547f992061019d01358bcbe836e0d /appc-adapters/appc-rest-healthcheck-adapter
parent163ec605f4b3029a3b945530ed995ec8be457796 (diff)
Reduce unit test duration from 40s to 4s
Mocked retry delay value to a lower value to reduce test time Issue-ID: APPC-1393 Change-Id: I98ea66b4cd0cc47d1861544bb70ec4c0e665e394 Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-adapters/appc-rest-healthcheck-adapter')
-rw-r--r--appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/impl/RequestContext.java4
-rw-r--r--appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/test/java/org/onap/appc/adapter/restHealthcheck/impl/RequestContextTest.java13
2 files changed, 10 insertions, 7 deletions
diff --git a/appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/impl/RequestContext.java b/appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/impl/RequestContext.java
index 0df9a7789..288951f04 100644
--- a/appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/impl/RequestContext.java
+++ b/appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/impl/RequestContext.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,8 +27,6 @@
package org.onap.appc.adapter.restHealthcheck.impl;
-import org.onap.appc.Constants;
-import org.onap.appc.configuration.Configuration;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
public class RequestContext {
diff --git a/appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/test/java/org/onap/appc/adapter/restHealthcheck/impl/RequestContextTest.java b/appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/test/java/org/onap/appc/adapter/restHealthcheck/impl/RequestContextTest.java
index 1e442b0c1..4186ee111 100644
--- a/appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/test/java/org/onap/appc/adapter/restHealthcheck/impl/RequestContextTest.java
+++ b/appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/test/java/org/onap/appc/adapter/restHealthcheck/impl/RequestContextTest.java
@@ -3,6 +3,8 @@
* ONAP : APPC
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,11 +29,13 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Mockito;
// import org.onap.appc.Constants;
import org.onap.appc.adapter.restHealthcheck.impl.RequestContext;
// import org.onap.appc.configuration.Configuration;
// import org.onap.appc.configuration.ConfigurationFactory;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.powermock.reflect.Whitebox;
/**
* Test the RequestContext object
@@ -54,7 +58,8 @@ public class RequestContextTest {
public void setup() {
// config.setProperty(Constants.PROPERTY_RETRY_DELAY, "1");
// config.setProperty(Constants.PROPERTY_RETRY_LIMIT, "3");
- rc = new RequestContext(null);
+ rc = Mockito.spy(new RequestContext(null));
+ Whitebox.setInternalState(rc, "retryDelay", 1);
rc.setTimeToLiveSeconds(rc.getRetryDelay() * 3);
// rc.setTimeToLiveMS(rc.getRetryDelay() * 3000L - 1L); // not quite adequate for 3 retries
}
@@ -64,7 +69,7 @@ public class RequestContextTest {
*/
@Test
public void testRetryDelayProperty() {
- assertEquals(10, rc.getRetryDelay());
+ assertEquals(10, new RequestContext(null).getRetryDelay());
}
/**
@@ -89,9 +94,7 @@ public class RequestContextTest {
@Test
public void testDelay() {
long future = System.currentTimeMillis() + (rc.getRetryDelay() * 1000L);
-
rc.delay();
-
assertTrue(System.currentTimeMillis() >= future);
}
@@ -161,7 +164,7 @@ public class RequestContextTest {
assertTrue(rc.getTotalDuration() >= 2 * delay);
rc.reset();
rc.delay();
- // Ensure exceeded timeToLive
+ // Ensure exceeded timeToLive
try {
Thread.sleep(1L);
} catch (Throwable e) {