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.util.ArrayList;
\r
28 import java.util.Collection;
\r
29 import java.util.concurrent.TimeUnit;
\r
31 import org.junit.After;
\r
32 import org.junit.Before;
\r
33 import org.junit.Test;
\r
35 import com.att.nsa.mr.client.HostSelector;
\r
36 import com.att.nsa.mr.client.MRClient;
\r
37 import com.att.nsa.mr.client.MRClientBuilders;
\r
39 public class MRClientBuildersTest {
\r
41 private Collection<String> hostSet = new ArrayList<String>();
\r
42 private MRClientBuilders.ConsumerBuilder builder = null;
\r
43 private MRClientBuilders.PublisherBuilder pBuilder = null;
\r
44 private String[] hostArray = new String[10];
\r
47 public void setUp() throws Exception {
\r
49 for (int i = 0; i < 10; i++) {
\r
50 hostSet.add("host" + (i + 1));
\r
51 hostArray[i] = "host" + (i + 1);
\r
54 builder = new MRClientBuilders.ConsumerBuilder();
\r
56 pBuilder = new MRClientBuilders.PublisherBuilder();
\r
61 public void tearDown() throws Exception {
\r
66 public void testUsingHosts() {
\r
68 builder.usingHosts("hostList");
\r
74 public void testUsingHosts2() {
\r
76 builder.usingHosts(hostSet);
\r
82 public void testOnTopic() {
\r
84 builder.onTopic("testTopic");
\r
90 public void testKnownAs() {
\r
92 builder.knownAs("CG1", "23");
\r
98 public void testAuthenticatedBy() {
\r
100 builder.authenticatedBy("apikey", "apisecret");
\r
106 public void testWaitAtServer() {
\r
108 builder.waitAtServer(100);
\r
114 public void testReceivingAtMost() {
\r
116 builder.receivingAtMost(100);
\r
122 public void testWithServerSideFilter() {
\r
124 builder.withServerSideFilter("filter");
\r
130 public void testBuild() {
\r
135 } catch (IllegalArgumentException e) {
\r
142 public void testUsingHosts3() {
\r
144 pBuilder.usingHosts("testTopic");
\r
150 public void testUsingHosts4() {
\r
152 pBuilder.usingHosts(hostArray);
\r
158 public void testUsingHosts5() {
\r
160 pBuilder.usingHosts(hostSet);
\r
166 public void testOnTopic2() {
\r
168 pBuilder.onTopic("testTopic");
\r
174 public void testLimitBatch() {
\r
176 pBuilder.limitBatch(100, 10);
\r
182 public void testWithCompresion() {
\r
184 pBuilder.withCompresion();
\r
190 public void testWithoutCompresion() {
\r
192 pBuilder.withoutCompresion();
\r
198 public void testEnableCompresion() {
\r
200 pBuilder.enableCompresion(true);
\r
206 public void testAuthenticatedBy2() {
\r
208 pBuilder.authenticatedBy("apikey", "apisecret");
\r
214 public void testBuild2() {
\r
219 } catch (IllegalArgumentException e) {
\r
226 public void test$testInject() {
\r
230 MRClientBuilders.$testInject(builder.build());
\r
231 } catch (IllegalArgumentException e) {
\r
238 public void test$testInject2() {
\r
242 MRClientBuilders.$testInject(pBuilder.build());
\r
243 } catch (IllegalArgumentException e) {
\r