From 2acd02bc20885c1f26539b30b27625cbef39ef84 Mon Sep 17 00:00:00 2001 From: Patrick Brady Date: Tue, 24 Apr 2018 21:59:48 -0700 Subject: Possible fix for event listener Change-Id: Ie2eaf7f3d02bdd0b8adae964d3abf905781f996f Signed-off-by: Patrick Brady Issue-ID: APPC-859 --- .../adapter/messaging/dmaap/http/CommonHttpClient.java | 15 +++++++-------- .../messaging/dmaap/http/TestCommonHttpClient.java | 16 ---------------- .../messaging/dmaap/http/TestHttpDmaapConsumerImpl.java | 11 ----------- .../messaging/dmaap/http/TestHttpDmaapProducerImpl.java | 11 ----------- .../adapter/factory/DmaapMessageAdapterFactoryImpl.java | 14 +++++++++----- 5 files changed, 16 insertions(+), 51 deletions(-) (limited to 'appc-adapters/appc-dmaap-adapter') diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/http/CommonHttpClient.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/http/CommonHttpClient.java index 0749eb185..259972844 100644 --- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/http/CommonHttpClient.java +++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/http/CommonHttpClient.java @@ -52,23 +52,22 @@ abstract class CommonHttpClient { } protected HttpGet getReq(URI uri, int timeoutMs) throws AuthenticationException { - if (authStr == null) { - throw new AuthenticationException("All DMaaP requests require authentication and none was provided."); - } HttpGet out = (uri == null) ? new HttpGet() : new HttpGet(uri); - out.setHeader("Authorization", String.format("Basic %s", authStr)); + if (authStr != null) { + out.setHeader("Authorization", String.format("Basic %s", authStr)); + } + out.setConfig(getConfig(timeoutMs)); return out; } protected HttpPost postReq(String url) throws AuthenticationException { - if (authStr == null) { - throw new AuthenticationException("All DMaaP requests require authentication and none was provided."); - } HttpPost out = (url == null) ? new HttpPost() : new HttpPost(url); - out.setHeader("Authorization", String.format("Basic %s", authStr)); + if (authStr != null) { + out.setHeader("Authorization", String.format("Basic %s", authStr)); + } out.setConfig(getConfig(0)); return out; } diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/http/TestCommonHttpClient.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/http/TestCommonHttpClient.java index 1d6fcfd43..660a6e4bc 100644 --- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/http/TestCommonHttpClient.java +++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/http/TestCommonHttpClient.java @@ -69,14 +69,6 @@ public class TestCommonHttpClient { assertEquals(httpGet.getConfig().getSocketTimeout(), TIMEOUT + TIMEOUT_OFFSET); } - @Test(expected = AuthenticationException.class) - public void shoudNotGetHttpRequest_whenBasicAuthNotSet() throws AuthenticationException { - - noBasicAuth(); - - commonHttpClient.getReq(URI, TIMEOUT); - } - @Test public void shouldPostHttpRequest_whenSetBasicAuth() throws AuthenticationException { @@ -90,14 +82,6 @@ public class TestCommonHttpClient { assertEquals(httpPost.getConfig().getSocketTimeout(), TIMEOUT_OFFSET); } - @Test(expected = AuthenticationException.class) - public void shoudNotPostHttpRequest_whenBasicAuthNotSet() throws AuthenticationException { - - noBasicAuth(); - - commonHttpClient.postReq(URL); - } - @Test public void shouldGetClient() { assertNotNull(commonHttpClient.getClient()); diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/http/TestHttpDmaapConsumerImpl.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/http/TestHttpDmaapConsumerImpl.java index d5707c22f..ea9a5e921 100644 --- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/http/TestHttpDmaapConsumerImpl.java +++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/http/TestHttpDmaapConsumerImpl.java @@ -106,17 +106,6 @@ public class TestHttpDmaapConsumerImpl { verifyNoMoreInteractions(httpClient, httpResponse, statusLine, entity); } - @Test - public void shouldNotGetHttpRequest_whenCredencialsAreNotProvided() { - - httpDmaapConsumer.updateCredentials(null, null); - - List output = httpDmaapConsumer.fetch(TIMEOUT_MS, LIMIT); - - assertTrue(output.isEmpty()); - verifyNoMoreInteractions(httpClient, httpResponse, statusLine, entity); - } - @Test public void shouldNotBeSuccessful_whenHttpResponseIsOtherThanOk() throws Exception { diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/http/TestHttpDmaapProducerImpl.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/http/TestHttpDmaapProducerImpl.java index a3d2e3afa..01e41a857 100644 --- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/http/TestHttpDmaapProducerImpl.java +++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/http/TestHttpDmaapProducerImpl.java @@ -92,17 +92,6 @@ public class TestHttpDmaapProducerImpl { verifyNoMoreInteractions(httpClient, httpResponse, statusLine); } - @Test - public void shouldNotPostHttpRequest_whenCredencialsAreNotProvided() { - - httpDmaapProducer.updateCredentials(null, null); - - boolean successful = httpDmaapProducer.post(PARTITION, DATA); - - assertFalse(successful); - verifyNoMoreInteractions(httpClient, httpResponse, statusLine); - } - @Test public void shouldNotBeSuccessful_whenHttpResponseIsOtherThanOk() throws Exception { diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java index 5fe2d0391..85110f2f2 100644 --- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java +++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java @@ -30,25 +30,29 @@ import java.util.Set; import org.onap.appc.adapter.message.Consumer; import org.onap.appc.adapter.message.MessageAdapterFactory; import org.onap.appc.adapter.message.Producer; -import org.onap.appc.adapter.messaging.dmaap.impl.DmaapConsumerImpl; -import org.onap.appc.adapter.messaging.dmaap.impl.DmaapProducerImpl; +import org.onap.appc.adapter.messaging.dmaap.http.HttpDmaapConsumerImpl; +import org.onap.appc.adapter.messaging.dmaap.http.HttpDmaapProducerImpl; public class DmaapMessageAdapterFactoryImpl implements MessageAdapterFactory { @Override public Producer createProducer(Collection pools, String writeTopic, String apiKey, String apiSecret) { - return new DmaapProducerImpl(pools, writeTopic,apiKey, apiSecret); + return new HttpDmaapProducerImpl(pools, writeTopic); } @Override public Producer createProducer(Collection pools, Set writeTopics, String apiKey, String apiSecret) { - return new DmaapProducerImpl(pools, writeTopics, apiKey, apiSecret); + String topic = ""; + for(String s : writeTopics){ + topic = s; + } + return new HttpDmaapProducerImpl(pools,topic); } @Override public Consumer createConsumer(Collection pool, String readTopic, String clientName, String clientId, String filterJson, String apiKey, String apiSecret) { - return new DmaapConsumerImpl(pool, readTopic, clientName, clientId, apiKey, apiSecret, filterJson); + return new HttpDmaapConsumerImpl(pool, readTopic, clientName, clientId, apiKey, apiSecret, filterJson); } } -- cgit 1.2.3-korg