0d151b9aef3efd179e8e8ce045304eb9de1d37a2
[dmaap/messagerouter/dmaapclient.git] / src / test / java / org / onap / dmaap / mr / client / MRClientFactoryTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
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
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
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=========================================================
21  */
22
23 package org.onap.dmaap.mr.client;
24
25 import static org.junit.Assert.assertTrue;
26
27 import java.io.IOException;
28 import java.util.ArrayList;
29 import java.util.Collection;
30 import java.util.concurrent.TimeUnit;
31
32 import org.junit.After;
33 import org.junit.Before;
34 import org.junit.Test;
35
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;
40
41 public class MRClientFactoryTest {
42
43     private Collection<String> hostSet = new ArrayList<String>();
44
45     private String[] hostArray = new String[10];
46
47     @Before
48     public void setUp() throws Exception {
49
50         for (int i = 0; i < 10; i++) {
51             hostSet.add("host" + (i + 1));
52             hostArray[i] = "host" + (i + 1);
53         }
54     }
55
56     @After
57     public void tearDown() throws Exception {
58
59     }
60
61     @Test
62     public void testCreateConsumer() {
63
64         MRClientFactory.createConsumer("hostList hostList2", "testTopic");
65         assertTrue(true);
66
67     }
68
69     @Test
70     public void testCreateConsumer2() {
71
72         MRClientFactory.createConsumer(hostSet, "testTopic");
73         assertTrue(true);
74
75     }
76
77     @Test
78     public void testCreateConsumer3() {
79
80         MRClientFactory.createConsumer(hostSet, "testTopic", "filter");
81         assertTrue(true);
82
83     }
84
85     @Test
86     public void testCreateConsumer4() {
87
88         MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22");
89         assertTrue(true);
90
91     }
92
93     @Test
94     public void testCreateConsumer5() {
95
96         MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22", 100, 100);
97         assertTrue(true);
98
99     }
100
101     @Test
102     public void testCreateConsumer6() {
103
104         MRClientFactory.createConsumer("hostList", "testTopic", "CG1", "22", 100, 100, "filter", "apikey", "apisecret");
105         assertTrue(true);
106
107     }
108
109     @Test
110     public void testCreateConsumer7() {
111
112         MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22", 100, 100, "filter", "apikey", "apisecret");
113         assertTrue(true);
114
115     }
116
117     @Test
118     public void testCreateSimplePublisher() {
119
120         MRClientFactory.createSimplePublisher("hostList", "testTopic");
121         assertTrue(true);
122
123     }
124
125     @Test
126     public void testCreateBatchingPublisher1() {
127
128         MRClientFactory.createBatchingPublisher("hostList", "testTopic", 100, 10);
129         assertTrue(true);
130
131     }
132
133     @Test
134     public void testCreateBatchingPublisher2() {
135
136         MRClientFactory.createBatchingPublisher("hostList", "testTopic", 100, 10, true);
137         assertTrue(true);
138
139     }
140
141     @Test
142     public void testCreateBatchingPublisher3() {
143
144         MRClientFactory.createBatchingPublisher(hostArray, "testTopic", 100, 10, true);
145         assertTrue(true);
146
147     }
148
149     @Test
150     public void testCreateBatchingPublisher4() {
151
152     MRClientFactory.createBatchingPublisher(hostSet, "testTopic", 100, 10, true);
153         assertTrue(true);
154
155     }
156
157     @Test
158     public void testCreateBatchingPublisher5() {
159
160         MRClientFactory.createBatchingPublisher("host", "testTopic", "username", "password", 100, 10, true,
161                 "protocolFlag");
162         assertTrue(true);
163
164     }
165
166     @Test
167     public void testCreateBatchingPublisher6() {
168
169         try {
170             MRClientFactory.createBatchingPublisher("/producer");
171         } catch (IOException e) {
172             // TODO Auto-generated catch block
173             e.printStackTrace();
174         }
175         assertTrue(true);
176
177     }
178
179     @Test
180     public void testCreateBatchingPublisher7() {
181
182         try {
183             MRClientFactory.createBatchingPublisher("/producer", true);
184         } catch (IOException e) {
185             // TODO Auto-generated catch block
186             e.printStackTrace();
187         }
188         assertTrue(true);
189
190     }
191
192     @Test
193     public void testCreateIdentityManager() {
194
195         MRClientFactory.createIdentityManager(hostSet, "apikey", "apisecret");
196
197         assertTrue(true);
198
199     }
200
201     @Test
202     public void testCreateTopicManager() {
203
204         MRClientFactory.createTopicManager(hostSet, "apikey", "apisecret");
205
206         assertTrue(true);
207
208     }
209
210     @Test
211     public void testCreateConsumer8() {
212
213         try {
214             MRClientFactory.createConsumer("/consumer");
215         } catch (IOException e) {
216             // TODO Auto-generated catch block
217             e.printStackTrace();
218         }
219
220         assertTrue(true);
221
222     }
223
224     @Test
225     public void testCreateConsumer9() {
226
227         MRClientFactory.createConsumer("host", "topic", "username", "password", "group", "23", "protocolFlag",
228                 "/consumer", 1, 2);
229
230         assertTrue(true);
231
232     }
233
234     @Test
235     public void testCreateConsumer10() {
236
237         MRClientFactory.createConsumer("host", "topic", "username", "password", "group", "23", 1, 2, "protocolFlag",
238                 "/consumer");
239
240         assertTrue(true);
241
242     }
243     
244     @Test
245     public void test$testInject() {
246
247         MRClientFactory.$testInject(null);
248         assertTrue(true);
249
250     }
251
252 }