1 package org.onap.appc.adapter.messaging.dmaap.impl;
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotNull;
5 import static org.junit.Assert.assertNull;
6 import static org.junit.Assert.fail;
8 import java.util.Arrays;
9 import java.util.Collection;
10 import java.util.HashSet;
11 import java.util.Properties;
14 import org.junit.Ignore;
15 import org.junit.Test;
17 public class TestDmaapProducerImpl {
18 String[] hostList = { "192.168.1.1" };
19 Collection<String> hosts = new HashSet<String>(Arrays.asList(hostList));
21 String topic = "JunitTopicOne";
22 String group = "junit-client";
23 String id = "junit-consumer-one";
25 String secret = "secret";
29 public void testDmaapProducerImplSingleTopic() {
30 DmaapProducerImpl producer = new DmaapProducerImpl(hosts, topic, key, secret);
32 assertNotNull(producer);
34 Properties props = producer.getProperties();
38 assertEquals("key", props.getProperty("username"));
39 assertEquals("secret", props.getProperty("password"));
43 public void testDmaapProducerImplMultipleTopic() {
44 String[] topicList = { "topic1", "topic2" };
45 Set<String> topicNames = new HashSet<String>(Arrays.asList(topicList));
47 DmaapProducerImpl producer = new DmaapProducerImpl(hosts, topicNames, key, secret);
49 assertNotNull(producer);
51 Properties props = producer.getProperties();
55 assertEquals("key", props.getProperty("username"));
56 assertEquals("secret", props.getProperty("password"));
61 public void testDmaapProducerImplNoUserPass() {
62 DmaapProducerImpl producer = new DmaapProducerImpl(hosts, topic, null, null);
64 assertNotNull(producer);
66 Properties props = producer.getProperties();
70 assertNull(props.getProperty("username"));
71 assertNull(props.getProperty("password"));
75 public void testUpdateCredentials() {
76 DmaapProducerImpl producer = new DmaapProducerImpl(hosts, topic, null, null);
78 assertNotNull(producer);
80 Properties props = producer.getProperties();
84 assertNull(props.getProperty("username"));
85 assertNull(props.getProperty("password"));
87 producer.updateCredentials(key, secret);
89 props = producer.getProperties();
93 assertEquals("key", props.getProperty("username"));
94 assertEquals("secret", props.getProperty("password"));
100 public void testPost() {
101 fail("Not yet implemented");
105 public void testCloseNoClient() {
106 DmaapProducerImpl producer = new DmaapProducerImpl(hosts, topic, key, secret);
108 assertNotNull(producer);
115 public void testCloseWithClient() {
116 fail("Not yet implemented");
120 public void testUseHttps() {
121 DmaapProducerImpl producer = new DmaapProducerImpl(hosts, topic, key, secret);
123 assertNotNull(producer);
125 assertEquals(false, producer.isHttps());
127 producer.useHttps(true);
129 assertEquals(true, producer.isHttps());