2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright © 2018 IBM.
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.dmaap.mr.client;
25 import static org.junit.Assert.assertTrue;
27 import java.io.IOException;
28 import java.util.ArrayList;
29 import java.util.Collection;
30 import java.util.concurrent.TimeUnit;
32 import org.junit.After;
33 import org.junit.Before;
34 import org.junit.Test;
36 import org.onap.dmaap.mr.client.HostSelector;
37 import org.onap.dmaap.mr.client.MRClient;
38 import org.onap.dmaap.mr.client.MRClientBuilders;
39 import org.onap.dmaap.mr.client.MRClientFactory;
41 public class MRClientFactoryTest {
43 private Collection<String> hostSet = new ArrayList<String>();
45 private String[] hostArray = new String[10];
48 public void setUp() throws Exception {
50 for (int i = 0; i < 10; i++) {
51 hostSet.add("host" + (i + 1));
52 hostArray[i] = "host" + (i + 1);
57 public void tearDown() throws Exception {
62 public void testCreateConsumer() {
64 MRClientFactory.createConsumer("hostList hostList2", "testTopic");
70 public void testCreateConsumer2() {
72 MRClientFactory.createConsumer(hostSet, "testTopic");
78 public void testCreateConsumer3() {
80 MRClientFactory.createConsumer(hostSet, "testTopic", "filter");
86 public void testCreateConsumer4() {
88 MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22");
94 public void testCreateConsumer5() {
96 MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22", 100, 100);
102 public void testCreateConsumer6() {
104 MRClientFactory.createConsumer("hostList", "testTopic", "CG1", "22", 100, 100, "filter", "apikey", "apisecret");
110 public void testCreateConsumer7() {
112 MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22", 100, 100, "filter", "apikey", "apisecret");
118 public void testCreateSimplePublisher() {
120 MRClientFactory.createSimplePublisher("hostList", "testTopic");
126 public void testCreateBatchingPublisher1() {
128 MRClientFactory.createBatchingPublisher("hostList", "testTopic", 100, 10);
134 public void testCreateBatchingPublisher2() {
136 MRClientFactory.createBatchingPublisher("hostList", "testTopic", 100, 10, true);
142 public void testCreateBatchingPublisher3() {
144 MRClientFactory.createBatchingPublisher(hostArray, "testTopic", 100, 10, true);
150 public void testCreateBatchingPublisher4() {
152 MRClientFactory.createBatchingPublisher(hostSet, "testTopic", 100, 10, true);
158 public void testCreateBatchingPublisher5() {
160 MRClientFactory.createBatchingPublisher("host", "testTopic", "username", "password", 100, 10, true,
167 public void testCreateBatchingPublisher6() {
170 MRClientFactory.createBatchingPublisher("/producer");
171 } catch (IOException e) {
172 // TODO Auto-generated catch block
180 public void testCreateBatchingPublisher7() {
183 MRClientFactory.createBatchingPublisher("/producer", true);
184 } catch (IOException e) {
185 // TODO Auto-generated catch block
193 public void testCreateIdentityManager() {
195 MRClientFactory.createIdentityManager(hostSet, "apikey", "apisecret");
202 public void testCreateTopicManager() {
204 MRClientFactory.createTopicManager(hostSet, "apikey", "apisecret");
211 public void testCreateConsumer8() {
214 MRClientFactory.createConsumer("/consumer");
215 } catch (IOException e) {
216 // TODO Auto-generated catch block
225 public void testCreateConsumer9() {
227 MRClientFactory.createConsumer("host", "topic", "username", "password", "group", "23", "protocolFlag",
235 public void testCreateConsumer10() {
237 MRClientFactory.createConsumer("host", "topic", "username", "password", "group", "23", 1, 2, "protocolFlag",
245 public void test$testInject() {
247 MRClientFactory.$testInject(null);