diff options
author | PatrikBuhr <patrik.buhr@est.tech> | 2019-04-04 14:41:34 +0000 |
---|---|---|
committer | PatrikBuhr <patrik.buhr@est.tech> | 2019-04-04 14:41:34 +0000 |
commit | 814ddd12e695433b8c6a760cc9424dc1c0bae4d1 (patch) | |
tree | e0d5d295e8419311f7f53b2baa0501e395150163 /datafile-dmaap-client/src/test | |
parent | d90535ce664cfde22e0670c950498a114388df99 (diff) |
Improved logging
Fixed problem with startup which lead
to that the REST API was not working running
locally.
Fixed problem with DmaapProducerHttpClient which would use
no timeout, which can lead to infinitly haninging threads.
A long timeout is used instead.
Change-Id: I28469b1b3aaad0dab4cf247bb8af968e71a60133
Issue-ID: DCAEGEN2-1305
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
Diffstat (limited to 'datafile-dmaap-client/src/test')
-rw-r--r-- | datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerHttpClientTest.java (renamed from datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClientTest.java) | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClientTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerHttpClientTest.java index 91c4c334..92a14997 100644 --- a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClientTest.java +++ b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerHttpClientTest.java @@ -32,6 +32,7 @@ import java.nio.charset.StandardCharsets; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; +import java.time.Duration; import java.util.HashMap; import java.util.Map; import java.util.concurrent.Future; @@ -59,18 +60,18 @@ import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPub * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 7/4/18 * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a> */ -class DmaapProducerReactiveHttpClientTest { +class DmaapProducerHttpClientTest { private static final String HOST = "54.45.33.2"; private static final String HTTPS_SCHEME = "https"; private static final int PORT = 1234; private static final String USER_NAME = "dradmin"; - private static final int TWO_SECOND_TIMEOUT = 2000; + private static final Duration TWO_SECOND_TIMEOUT = Duration.ofSeconds(2); private static final Map<String, String> CONTEXT_MAP = new HashMap<>(); - private DmaapProducerReactiveHttpClient producerClientUnderTestSpy; + private DmaapProducerHttpClient producerClientUnderTestSpy; private DmaapPublisherConfiguration dmaapPublisherConfigurationMock = mock(DmaapPublisherConfiguration.class); @@ -88,7 +89,7 @@ class DmaapProducerReactiveHttpClientTest { when(dmaapPublisherConfigurationMock.dmaapUserName()).thenReturn("dradmin"); when(dmaapPublisherConfigurationMock.dmaapUserPassword()).thenReturn("dradmin"); - producerClientUnderTestSpy = spy(new DmaapProducerReactiveHttpClient(dmaapPublisherConfigurationMock)); + producerClientUnderTestSpy = spy(new DmaapProducerHttpClient(dmaapPublisherConfigurationMock)); clientBuilderMock = mock(IHttpAsyncClientBuilder.class); clientMock = mock(CloseableHttpAsyncClient.class); @@ -110,6 +111,7 @@ class DmaapProducerReactiveHttpClientTest { verify(clientBuilderMock).setSSLContext(any(SSLContext.class)); verify(clientBuilderMock).setSSLHostnameVerifier(any(NoopHostnameVerifier.class)); verify(clientBuilderMock).setRedirectStrategy(PublishRedirectStrategy.INSTANCE); + verify(clientBuilderMock).setDefaultRequestConfig(any()); verify(clientBuilderMock).build(); verifyNoMoreInteractions(clientBuilderMock); @@ -138,9 +140,9 @@ class DmaapProducerReactiveHttpClientTest { verify(clientBuilderMock).setSSLHostnameVerifier(any(NoopHostnameVerifier.class)); verify(clientBuilderMock).setDefaultRequestConfig(requestConfigCaptor.capture()); RequestConfig requestConfig = requestConfigCaptor.getValue(); - assertEquals(TWO_SECOND_TIMEOUT, requestConfig.getSocketTimeout()); - assertEquals(TWO_SECOND_TIMEOUT, requestConfig.getConnectTimeout()); - assertEquals(TWO_SECOND_TIMEOUT, requestConfig.getConnectionRequestTimeout()); + assertEquals(TWO_SECOND_TIMEOUT.toMillis(), requestConfig.getSocketTimeout()); + assertEquals(TWO_SECOND_TIMEOUT.toMillis(), requestConfig.getConnectTimeout()); + assertEquals(TWO_SECOND_TIMEOUT.toMillis(), requestConfig.getConnectionRequestTimeout()); verify(clientBuilderMock).build(); verifyNoMoreInteractions(clientBuilderMock); |