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>
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
* 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.
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.appc.adapter.restHealthcheck.impl;
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 {
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
public class RequestContext {
* ONAP : APPC
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* 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.
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
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.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
/**
* Test the RequestContext object
public void setup() {
// config.setProperty(Constants.PROPERTY_RETRY_DELAY, "1");
// config.setProperty(Constants.PROPERTY_RETRY_LIMIT, "3");
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
}
rc.setTimeToLiveSeconds(rc.getRetryDelay() * 3);
// rc.setTimeToLiveMS(rc.getRetryDelay() * 3000L - 1L); // not quite adequate for 3 retries
}
*/
@Test
public void testRetryDelayProperty() {
*/
@Test
public void testRetryDelayProperty() {
- assertEquals(10, rc.getRetryDelay());
+ assertEquals(10, new RequestContext(null).getRetryDelay());
@Test
public void testDelay() {
long future = System.currentTimeMillis() + (rc.getRetryDelay() * 1000L);
@Test
public void testDelay() {
long future = System.currentTimeMillis() + (rc.getRetryDelay() * 1000L);
assertTrue(System.currentTimeMillis() >= future);
}
assertTrue(System.currentTimeMillis() >= future);
}
assertTrue(rc.getTotalDuration() >= 2 * delay);
rc.reset();
rc.delay();
assertTrue(rc.getTotalDuration() >= 2 * delay);
rc.reset();
rc.delay();
- // Ensure exceeded timeToLive
+ // Ensure exceeded timeToLive
try {
Thread.sleep(1L);
} catch (Throwable e) {
try {
Thread.sleep(1L);
} catch (Throwable e) {