aboutsummaryrefslogtreecommitdiffstats
path: root/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactoryTest.java
diff options
context:
space:
mode:
authorgrabinsk <maciej.grabinski@nokia.com>2019-05-15 12:49:47 +0200
committergrabinsk <maciej.grabinski@nokia.com>2019-05-15 15:35:58 +0200
commit4d53427075cf4e5deaee88d59bc4b9a03d2fc225 (patch)
tree695b7e67c230b86c706ee57ac549d8447293ed95 /rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactoryTest.java
parent3f6de371dcd59126e2e7933d31f970391a1ad517 (diff)
Fix loading of ssl keys from external files for dmaap and AAI client4.0.0-ONAP1.1.6dublin
Change-Id: I18a68656ddfc8290e17fb483900c26baf3e25ba6 Issue-ID: DCAEGEN2-1503 Signed-off-by: grabinsk <maciej.grabinski@nokia.com>
Diffstat (limited to 'rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactoryTest.java')
-rw-r--r--rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactoryTest.java27
1 files changed, 19 insertions, 8 deletions
diff --git a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactoryTest.java b/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactoryTest.java
index 80cf2243..2a891dcd 100644
--- a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactoryTest.java
+++ b/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactoryTest.java
@@ -26,13 +26,16 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
+import java.net.URISyntaxException;
+import java.nio.file.Paths;
+
class DmaaPRestTemplateFactoryTest {
- private static final String KEY_STORE_RESOURCE_PATH = "/org.onap.dcae.jks";
- private static final String KEYSTORE_PASSWORD_RESOURCE_PATH = "/keystore.password";
- private static final String TRUSTSTORE_PASSWORD_RESOURCE_PATH = "/truststore.password";
- private static final String TRUST_STORE_RESOURCE_PATH = "/org.onap.dcae.trust.jks";
+ private static final String KEY_STORE_FILE_PATH = testResourceToPath("/org.onap.dcae.jks");
+ private static final String KEYSTORE_PASSWORD_FILE_PATH = testResourceToPath("/keystore.password");
+ private static final String TRUSTSTORE_PASSWORD_FILE_PATH = testResourceToPath("/truststore.password");
+ private static final String TRUST_STORE_FILE_PATH = testResourceToPath("/org.onap.dcae.trust.jks");
private DmaapPublisherConfiguration publisherConfiguration = mock(DmaapPublisherConfiguration.class);
private DmaaPRestTemplateFactory factory = new DmaaPRestTemplateFactory();
@@ -46,13 +49,21 @@ class DmaaPRestTemplateFactoryTest {
@Test
void build_shouldCreateRestTemplateWithSslConfiguration() {
when(publisherConfiguration.enableDmaapCertAuth()).thenReturn(true);
- when(publisherConfiguration.keyStorePath()).thenReturn(KEY_STORE_RESOURCE_PATH);
+ when(publisherConfiguration.keyStorePath()).thenReturn(KEY_STORE_FILE_PATH);
when(publisherConfiguration.keyStorePasswordPath()).thenReturn(
- KEYSTORE_PASSWORD_RESOURCE_PATH);
- when(publisherConfiguration.trustStorePath()).thenReturn(TRUST_STORE_RESOURCE_PATH);
+ KEYSTORE_PASSWORD_FILE_PATH);
+ when(publisherConfiguration.trustStorePath()).thenReturn(TRUST_STORE_FILE_PATH);
when(publisherConfiguration.trustStorePasswordPath()).thenReturn(
- TRUSTSTORE_PASSWORD_RESOURCE_PATH);
+ TRUSTSTORE_PASSWORD_FILE_PATH);
Assertions.assertNotNull(factory.build(publisherConfiguration));
}
+
+ private static String testResourceToPath(String resource) {
+ try {
+ return Paths.get(DmaaPRestTemplateFactoryTest.class.getResource(resource).toURI()).toString();
+ } catch (URISyntaxException e) {
+ throw new RuntimeException("Failed resolving test resource path", e);
+ }
+ }
} \ No newline at end of file