2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright © 2018 IBM.
8 * Modifications Copyright © 2021 Orange.
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.dmaap.mr.client;
26 import org.junit.After;
27 import org.junit.Before;
28 import org.junit.Test;
30 import java.io.IOException;
31 import java.util.ArrayList;
32 import java.util.Collection;
34 import static org.junit.Assert.assertTrue;
37 public class MRClientFactoryTest {
39 private Collection<String> hostSet = new ArrayList<String>();
41 private String[] hostArray = new String[10];
44 public void setUp() throws Exception {
46 for (int i = 0; i < 10; i++) {
47 hostSet.add("host" + (i + 1));
48 hostArray[i] = "host" + (i + 1);
53 public void tearDown() throws Exception {
58 public void testCreateConsumer() {
60 MRClientFactory.createConsumer("hostList hostList2", "testTopic");
66 public void testCreateConsumer2() {
68 MRClientFactory.createConsumer(hostSet, "testTopic");
74 public void testCreateConsumer3() {
75 MRClientFactory.createConsumer(hostSet, "testTopic", "filter");
80 public void testCreateConsumer4() {
81 MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22");
86 public void testCreateConsumer5() {
87 MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22", 100, 100);
92 public void testCreateConsumer6() {
93 MRClientFactory.createConsumer("hostList", "testTopic", "CG1", "22", 100, 100, "filter", "apikey", "apisecret");
98 public void testCreateConsumer7() {
99 MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22", 100, 100, "filter", "apikey", "apisecret");
104 public void testCreateSimplePublisher() {
105 MRClientFactory.createSimplePublisher("hostList", "testTopic");
110 public void testCreateBatchingPublisher1() {
111 MRClientFactory.createBatchingPublisher("hostList", "testTopic", 100, 10);
116 public void testCreateBatchingPublisher2() {
117 MRClientFactory.createBatchingPublisher("hostList", "testTopic", 100, 10, true);
122 public void testCreateBatchingPublisher3() {
123 MRClientFactory.createBatchingPublisher(hostArray, "testTopic", 100, 10, true);
128 public void testCreateBatchingPublisher4() {
129 MRClientFactory.createBatchingPublisher(hostSet, "testTopic", 100, 10, true);
134 public void testCreateBatchingPublisher5() {
135 MRClientFactory.createBatchingPublisher("host", "testTopic", "username", "password", 100, 10, true,
140 @Test(expected = IOException.class)
141 public void testCreateBatchingPublisher6() throws IOException {
142 MRClientFactory.createBatchingPublisher("/producer");
145 @Test(expected = IOException.class)
146 public void testCreateBatchingPublisher7() throws IOException {
147 MRClientFactory.createBatchingPublisher("/producer", true);
151 public void testCreateIdentityManager() {
152 MRClientFactory.createIdentityManager(hostSet, "apikey", "apisecret");
157 public void testCreateTopicManager() {
158 MRClientFactory.createTopicManager(hostSet, "apikey", "apisecret");
162 @Test(expected = IOException.class)
163 public void testCreateConsumer8() throws IOException {
164 MRClientFactory.createConsumer("/consumer");
168 public void testCreateConsumer9() {
169 MRClientFactory.createConsumer("host", "topic", "username", "password", "group", "23", "protocolFlag",
175 public void testCreateConsumer10() {
176 MRClientFactory.createConsumer("host", "topic", "username", "password", "group", "23", 1, 2, "protocolFlag",
182 public void test$testInject() {
183 MRClientFactory.$testInject(null);