2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.dmaap.mr.cambria.backends.kafka;
23 import static org.junit.Assert.assertTrue;
26 import java.io.IOException;
27 import java.util.ArrayList;
28 import java.util.List;
30 import org.junit.After;
31 import org.junit.Before;
32 import org.junit.ClassRule;
33 import org.junit.Test;
35 import com.att.ajsc.filemonitor.AJSCPropertiesMap;
36 import org.onap.dmaap.dmf.mr.backends.Publisher.message;
37 import com.att.nsa.drumlin.till.nv.rrNvReadable.missingReqdSetting;
39 import kafka.common.FailedToSendMessageException;
40 import kafka.producer.KeyedMessage;
42 public class KafkaPublisherTest {
47 public void setUp() throws Exception {
48 ClassLoader classLoader = getClass().getClassLoader();
49 AJSCPropertiesMap.refresh(new File(classLoader.getResource("MsgRtrApi.properties").getFile()));
53 public void tearDown() throws Exception {
57 public void testSendMessages() {
59 String topic = "testTopic";
61 KafkaPublisher kafka = null;
63 kafka = new KafkaPublisher(null);
65 } catch (missingReqdSetting e) {
66 // TODO Auto-generated catch block
68 } catch (NoClassDefFoundError e) {
70 kafka.sendMessage(topic, null);
71 } catch (NullPointerException e1) {
72 // TODO Auto-generated catch block
74 } catch (FailedToSendMessageException e1) {
75 // TODO Auto-generated catch block
77 } catch (IOException e1) {
78 // TODO Auto-generated catch block
81 } catch (FailedToSendMessageException e) {
82 // TODO Auto-generated catch block
89 public void testSendBatchMessage() {
91 String topic = "testTopic";
93 KafkaPublisher kafka = null;
94 ArrayList<KeyedMessage<String, String>> kms = null;
96 kafka = new KafkaPublisher(null);
98 } catch (missingReqdSetting e) {
99 // TODO Auto-generated catch block
101 } catch (NoClassDefFoundError e) {
103 kafka.sendBatchMessage(topic, kms);
104 } catch (NullPointerException e1) {
105 // TODO Auto-generated catch block
107 } catch (IOException e1) {
108 // TODO Auto-generated catch block
109 e1.printStackTrace();
111 } catch (FailedToSendMessageException e) {
112 // TODO Auto-generated catch block
119 public void sendMessages() {
121 String topic = "testTopic";
123 List<message> msgs = null;
125 KafkaPublisher kafka = null;
126 //ArrayList<KeyedMessage<String, String>> kms = null;
128 kafka = new KafkaPublisher(null);
130 } catch (missingReqdSetting e) {
131 // TODO Auto-generated catch block
133 } catch (NoClassDefFoundError e) {
135 kafka.sendMessages(topic, msgs);
136 } catch (NullPointerException e1) {
137 // TODO Auto-generated catch block
139 } catch (FailedToSendMessageException e1) {
140 // TODO Auto-generated catch block
141 e1.printStackTrace();
142 } catch (IOException e1) {
143 // TODO Auto-generated catch block
144 e1.printStackTrace();
146 } catch (FailedToSendMessageException e) {
147 // TODO Auto-generated catch block