2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package com.att.nsa.mr.client;
\r
23 import static org.junit.Assert.assertTrue;
\r
25 import java.io.IOException;
\r
26 import java.util.ArrayList;
\r
27 import java.util.Collection;
\r
28 import java.util.concurrent.TimeUnit;
\r
30 import org.junit.After;
\r
31 import org.junit.Before;
\r
32 import org.junit.Test;
\r
34 import com.att.nsa.mr.client.HostSelector;
\r
35 import com.att.nsa.mr.client.MRClient;
\r
36 import com.att.nsa.mr.client.MRClientBuilders;
\r
37 import com.att.nsa.mr.client.MRClientFactory;
\r
39 public class MRClientFactoryTest {
\r
41 private Collection<String> hostSet = new ArrayList<String>();
\r
43 private MRClientFactory factory = null;
\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
55 factory = new MRClientFactory();
\r
60 public void tearDown() throws Exception {
\r
65 public void testCreateConsumer() {
\r
67 MRClientFactory.createConsumer("hostList hostList2", "testTopic");
\r
73 public void testCreateConsumer2() {
\r
75 MRClientFactory.createConsumer(hostSet, "testTopic");
\r
81 public void testCreateConsumer3() {
\r
83 MRClientFactory.createConsumer(hostSet, "testTopic", "filter");
\r
89 public void testCreateConsumer4() {
\r
91 MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22");
\r
97 public void testCreateConsumer5() {
\r
99 MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22", 100, 100);
\r
105 public void testCreateConsumer6() {
\r
107 MRClientFactory.createConsumer("hostList", "testTopic", "CG1", "22", 100, 100, "filter", "apikey", "apisecret");
\r
113 public void testCreateConsumer7() {
\r
115 MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22", 100, 100, "filter", "apikey", "apisecret");
\r
121 public void testCreateSimplePublisher() {
\r
123 MRClientFactory.createSimplePublisher("hostList", "testTopic");
\r
129 public void testCreateBatchingPublisher1() {
\r
131 MRClientFactory.createBatchingPublisher("hostList", "testTopic", 100, 10);
\r
137 public void testCreateBatchingPublisher2() {
\r
139 MRClientFactory.createBatchingPublisher("hostList", "testTopic", 100, 10, true);
\r
145 public void testCreateBatchingPublisher3() {
\r
147 MRClientFactory.createBatchingPublisher(hostArray, "testTopic", 100, 10, true);
\r
153 public void testCreateBatchingPublisher4() {
\r
155 MRClientFactory.createBatchingPublisher(hostSet, "testTopic", 100, 10, true);
\r
161 public void testCreateBatchingPublisher5() {
\r
163 MRClientFactory.createBatchingPublisher("host", "testTopic", "username", "password", 100, 10, true,
\r
164 "protocolFlag", "/producer");
\r
170 public void testCreateBatchingPublisher6() {
\r
173 MRClientFactory.createBatchingPublisher("/producer");
\r
174 } catch (IOException e) {
\r
175 // TODO Auto-generated catch block
\r
176 e.printStackTrace();
\r
183 public void testCreateBatchingPublisher7() {
\r
186 MRClientFactory.createBatchingPublisher("/producer", true);
\r
187 } catch (IOException e) {
\r
188 // TODO Auto-generated catch block
\r
189 e.printStackTrace();
\r
196 public void testCreateIdentityManager() {
\r
198 MRClientFactory.createIdentityManager(hostSet, "apikey", "apisecret");
\r
205 public void testCreateTopicManager() {
\r
207 MRClientFactory.createTopicManager(hostSet, "apikey", "apisecret");
\r
214 public void testCreateConsumer8() {
\r
217 MRClientFactory.createConsumer("/consumer");
\r
218 } catch (IOException e) {
\r
219 // TODO Auto-generated catch block
\r
220 e.printStackTrace();
\r
228 public void testCreateConsumer9() {
\r
230 MRClientFactory.createConsumer("host", "topic", "username", "password", "group", "23", "protocolFlag",
\r
231 "/consumer", 1, 2);
\r
238 public void testCreateConsumer10() {
\r
240 MRClientFactory.createConsumer("host", "topic", "username", "password", "group", "23", 1, 2, "protocolFlag",
\r
248 public void test$testInject() {
\r
250 MRClientFactory.$testInject(null);
\r