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.util.ArrayList;
31 import java.util.Collection;
33 import static org.junit.Assert.assertTrue;
35 public class MRClientBuildersTest {
37 private Collection<String> hostSet = new ArrayList<String>();
38 private MRClientBuilders.ConsumerBuilder builder = null;
39 private MRClientBuilders.PublisherBuilder pBuilder = null;
40 private String[] hostArray = new String[10];
43 public void setUp() throws Exception {
45 for (int i = 0; i < 10; i++) {
46 hostSet.add("host" + (i + 1));
47 hostArray[i] = "host" + (i + 1);
50 builder = new MRClientBuilders.ConsumerBuilder();
52 pBuilder = new MRClientBuilders.PublisherBuilder();
57 public void tearDown() throws Exception {
62 public void testUsingHosts() {
64 builder.usingHosts("hostList");
70 public void testUsingHosts2() {
72 builder.usingHosts(hostSet);
78 public void testOnTopic() {
80 builder.onTopic("testTopic");
86 public void testKnownAs() {
88 builder.knownAs("CG1", "23");
94 public void testAuthenticatedBy() {
96 builder.authenticatedBy("apikey", "apisecret");
102 public void testWaitAtServer() {
104 builder.waitAtServer(100);
110 public void testReceivingAtMost() {
112 builder.receivingAtMost(100);
118 public void testWithServerSideFilter() {
120 builder.withServerSideFilter("filter");
126 public void testBuild() {
131 } catch (IllegalArgumentException e) {
138 public void testUsingHosts3() {
140 pBuilder.usingHosts("testTopic");
146 public void testUsingHosts4() {
148 pBuilder.usingHosts(hostArray);
154 public void testUsingHosts5() {
156 pBuilder.usingHosts(hostSet);
162 public void testOnTopic2() {
164 pBuilder.onTopic("testTopic");
170 public void testLimitBatch() {
172 pBuilder.limitBatch(100, 10);
178 public void testWithCompresion() {
180 pBuilder.withCompresion();
186 public void testWithoutCompresion() {
188 pBuilder.withoutCompresion();
194 public void testEnableCompresion() {
196 pBuilder.enableCompresion(true);
202 public void testAuthenticatedBy2() {
204 pBuilder.authenticatedBy("apikey", "apisecret");
210 public void testBuild2() {
215 } catch (IllegalArgumentException e) {
222 public void test$testInject() {
226 MRClientBuilders.$testInject(builder.build());
227 } catch (IllegalArgumentException e) {
234 public void test$testInject2() {
238 MRClientBuilders.$testInject(pBuilder.build());
239 } catch (IllegalArgumentException e) {