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