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