summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
250db09)
Change-Id: Ie2eaf7f3d02bdd0b8adae964d3abf905781f996f
Signed-off-by: Patrick Brady <pb071s@att.com>
Issue-ID: APPC-859
}
protected HttpGet getReq(URI uri, int timeoutMs) throws AuthenticationException {
}
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);
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 {
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);
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;
}
out.setConfig(getConfig(0));
return out;
}
assertEquals(httpGet.getConfig().getSocketTimeout(), TIMEOUT + TIMEOUT_OFFSET);
}
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 {
@Test
public void shouldPostHttpRequest_whenSetBasicAuth() throws AuthenticationException {
assertEquals(httpPost.getConfig().getSocketTimeout(), TIMEOUT_OFFSET);
}
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());
@Test
public void shouldGetClient() {
assertNotNull(commonHttpClient.getClient());
verifyNoMoreInteractions(httpClient, httpResponse, statusLine, entity);
}
verifyNoMoreInteractions(httpClient, httpResponse, statusLine, entity);
}
- @Test
- public void shouldNotGetHttpRequest_whenCredencialsAreNotProvided() {
-
- httpDmaapConsumer.updateCredentials(null, null);
-
- List<String> output = httpDmaapConsumer.fetch(TIMEOUT_MS, LIMIT);
-
- assertTrue(output.isEmpty());
- verifyNoMoreInteractions(httpClient, httpResponse, statusLine, entity);
- }
-
@Test
public void shouldNotBeSuccessful_whenHttpResponseIsOtherThanOk() throws Exception {
@Test
public void shouldNotBeSuccessful_whenHttpResponseIsOtherThanOk() throws Exception {
verifyNoMoreInteractions(httpClient, httpResponse, statusLine);
}
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 {
@Test
public void shouldNotBeSuccessful_whenHttpResponseIsOtherThanOk() throws Exception {
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.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<String> pools, String writeTopic, String apiKey, String apiSecret) {
public class DmaapMessageAdapterFactoryImpl implements MessageAdapterFactory {
@Override
public Producer createProducer(Collection<String> pools, String writeTopic, String apiKey, String apiSecret) {
- return new DmaapProducerImpl(pools, writeTopic,apiKey, apiSecret);
+ return new HttpDmaapProducerImpl(pools, writeTopic);
}
@Override
public Producer createProducer(Collection<String> pools, Set<String> writeTopics, String apiKey, String apiSecret) {
}
@Override
public Producer createProducer(Collection<String> pools, Set<String> 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<String> pool, String readTopic,
String clientName, String clientId, String filterJson, String apiKey, String apiSecret) {
}
@Override
public Consumer createConsumer(Collection<String> 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);