update the package name
[dmaap/messagerouter/messageservice.git] / src / test / java / org / onap / dmaap / tools / ConfigToolTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21  package org.onap.dmaap.tools;
22
23 import static org.junit.Assert.*;
24
25 import java.lang.reflect.Constructor;
26 import java.lang.reflect.InvocationTargetException;
27 import java.lang.reflect.Method;
28
29 import org.junit.After;
30 import org.junit.Before;
31 import org.junit.Test;
32
33 public class ConfigToolTest {
34
35         private String[] parts = new String[5];
36
37         @Before
38         public void setUp() throws Exception {
39
40                 for (int i = 0; i < parts.length; i++) {
41                         parts[i] = "string" + (i + 1);
42                 }
43         }
44
45         @After
46         public void tearDown() throws Exception {
47         }
48
49         public void callMethodViaReflection(String outer, String inner, String methodName, Object... args) {
50
51                 String foreNameString = outer + "$" + inner;
52                 Object parent = new ConfigTool();
53
54                 Class<?> innerClass;
55                 try {
56                         innerClass = Class.forName(foreNameString);
57                         Constructor<?> constructor = innerClass.getDeclaredConstructor(ConfigTool.class);
58                         constructor.setAccessible(true);
59                         Object child = constructor.newInstance(parent);
60
61                         // invoking method on inner class object
62                         Method method = innerClass.getDeclaredMethod(methodName, null);
63                         method.setAccessible(true);// in case of unaccessible method
64                         method.invoke(child, args);
65                 } catch (ClassNotFoundException e) {
66                         // TODO Auto-generated catch block
67                         e.printStackTrace();
68                 } catch (NoSuchMethodException e) {
69                         // TODO Auto-generated catch block
70                         e.printStackTrace();
71                 } catch (SecurityException e) {
72                         // TODO Auto-generated catch block
73                         e.printStackTrace();
74                 } catch (InstantiationException e) {
75                         // TODO Auto-generated catch block
76                         e.printStackTrace();
77                 } catch (IllegalAccessException e) {
78                         // TODO Auto-generated catch block
79                         e.printStackTrace();
80                 } catch (IllegalArgumentException e) {
81                         // TODO Auto-generated catch block
82                         e.printStackTrace();
83                 } catch (InvocationTargetException e) {
84                         // TODO Auto-generated catch block
85                         e.printStackTrace();
86                 }
87
88                 assertTrue(true);
89
90         }
91
92         @Test
93         public void testGetMatches() {
94
95                 callMethodViaReflection("ConfigTool", "ListTopicCommand", "getMatches");
96
97                 assertTrue(true);
98
99         }
100
101         @Test
102         public void testCheckReady() {
103
104                 callMethodViaReflection("ConfigTool", "ListTopicCommand", "checkReady", null);
105
106                 assertTrue(true);
107
108         }
109
110         @Test
111         public void testExecute() {
112
113                 callMethodViaReflection("ConfigTool", "ListTopicCommand", "execute", parts, null, null);
114
115                 assertTrue(true);
116
117         }
118
119         @Test
120         public void testDisplayHelp() {
121
122                 callMethodViaReflection("ConfigTool", "ListTopicCommand", "displayHelp", null);
123
124                 assertTrue(true);
125
126         }
127
128         @Test
129         public void testGetMatches2() {
130
131                 callMethodViaReflection("ConfigTool", "WriteTopicCommand", "getMatches");
132
133                 assertTrue(true);
134
135         }
136
137         @Test
138         public void testCheckReady2() {
139
140                 callMethodViaReflection("ConfigTool", "WriteTopicCommand", "checkReady", null);
141
142                 assertTrue(true);
143
144         }
145
146         @Test
147         public void testExecute2() {
148
149                 callMethodViaReflection("ConfigTool", "WriteTopicCommand", "execute", parts, null, null);
150
151                 assertTrue(true);
152
153         }
154
155         @Test
156         public void testDisplayHelp2() {
157
158                 callMethodViaReflection("ConfigTool", "WriteTopicCommand", "displayHelp", null);
159
160                 assertTrue(true);
161
162         }
163
164         @Test
165         public void testGetMatches3() {
166
167                 callMethodViaReflection("ConfigTool", "ReadTopicCommand", "getMatches");
168
169                 assertTrue(true);
170
171         }
172
173         @Test
174         public void testCheckReady3() {
175
176                 callMethodViaReflection("ConfigTool", "ReadTopicCommand", "checkReady", null);
177
178                 assertTrue(true);
179
180         }
181
182         @Test
183         public void testExecute3() {
184
185                 callMethodViaReflection("ConfigTool", "ReadTopicCommand", "execute", parts, null, null);
186
187                 assertTrue(true);
188
189         }
190
191         @Test
192         public void testDisplayHelp3() {
193
194                 callMethodViaReflection("ConfigTool", "ReadTopicCommand", "displayHelp", null);
195
196                 assertTrue(true);
197
198         }
199
200         @Test
201         public void testGetMatches4() {
202
203                 callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "getMatches");
204
205                 assertTrue(true);
206
207         }
208
209         @Test
210         public void testCheckReady4() {
211
212                 callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "checkReady", null);
213
214                 assertTrue(true);
215
216         }
217
218         @Test
219         public void testExecute4() {
220
221                 callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "execute", parts, null, null);
222
223                 assertTrue(true);
224
225         }
226
227         @Test
228         public void testDisplayHelp4() {
229
230                 callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "displayHelp", null);
231
232                 assertTrue(true);
233
234         }
235
236         @Test
237         public void testGetMatches5() {
238
239                 callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "getMatches");
240
241                 assertTrue(true);
242
243         }
244
245         @Test
246         public void testCheckReady5() {
247
248                 callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "checkReady", null);
249
250                 assertTrue(true);
251
252         }
253
254         @Test
255         public void testExecute5() {
256
257                 callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "execute", parts, null, null);
258
259                 assertTrue(true);
260
261         }
262
263         @Test
264         public void testDisplayHelp5() {
265
266                 callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "displayHelp", null);
267
268                 assertTrue(true);
269
270         }
271         
272         @Test
273         public void testGetMatches6() {
274
275                 callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "getMatches");
276
277                 assertTrue(true);
278
279         }
280
281         @Test
282         public void testCheckReady6() {
283
284                 callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "checkReady", null);
285
286                 assertTrue(true);
287
288         }
289
290         @Test
291         public void testExecute6() {
292
293                 callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "execute", parts, null, null);
294
295                 assertTrue(true);
296
297         }
298
299         @Test
300         public void testDisplayHelp6() {
301
302                 callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "displayHelp", null);
303
304                 assertTrue(true);
305
306         }
307         
308         @Test
309         public void testGetMatches7() {
310
311                 callMethodViaReflection("ConfigTool", "PutApiCommand", "getMatches");
312
313                 assertTrue(true);
314
315         }
316
317         @Test
318         public void testCheckReady7() {
319
320                 callMethodViaReflection("ConfigTool", "PutApiCommand", "checkReady", null);
321
322                 assertTrue(true);
323
324         }
325
326         @Test
327         public void testExecute7() {
328
329                 callMethodViaReflection("ConfigTool", "PutApiCommand", "execute", parts, null, null);
330
331                 assertTrue(true);
332
333         }
334
335         @Test
336         public void testDisplayHelp7() {
337
338                 callMethodViaReflection("ConfigTool", "PutApiCommand", "displayHelp", null);
339
340                 assertTrue(true);
341
342         }
343         
344         @Test
345         public void testGetMatches8() {
346
347                 callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "getMatches");
348
349                 assertTrue(true);
350
351         }
352
353         @Test
354         public void testCheckReady8() {
355
356                 callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "checkReady", null);
357
358                 assertTrue(true);
359
360         }
361
362         @Test
363         public void testExecute8() {
364
365                 callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "execute", parts, null, null);
366
367                 assertTrue(true);
368
369         }
370
371         @Test
372         public void testDisplayHelp8() {
373
374                 callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "displayHelp", null);
375
376                 assertTrue(true);
377
378         }
379         
380         @Test
381         public void testGetMatches9() {
382
383                 callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "getMatches");
384
385                 assertTrue(true);
386
387         }
388
389         @Test
390         public void testCheckReady9() {
391
392                 callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "checkReady", null);
393
394                 assertTrue(true);
395
396         }
397
398         @Test
399         public void testExecute9() {
400
401                 callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "execute", parts, null, null);
402
403                 assertTrue(true);
404
405         }
406
407         @Test
408         public void testDisplayHelp9() {
409
410                 callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "displayHelp", null);
411
412                 assertTrue(true);
413
414         }
415         
416         @Test
417         public void testGetMatches10() {
418
419                 callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "getMatches");
420
421                 assertTrue(true);
422
423         }
424
425         @Test
426         public void testCheckReady10() {
427
428                 callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "checkReady", null);
429
430                 assertTrue(true);
431
432         }
433
434         @Test
435         public void testExecute10() {
436
437                 callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "execute", parts, null, null);
438
439                 assertTrue(true);
440
441         }
442
443         @Test
444         public void testDisplayHelp10() {
445
446                 callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "displayHelp", null);
447
448                 assertTrue(true);
449
450         }
451         
452         @Test
453         public void testGetMatches11() {
454
455                 callMethodViaReflection("ConfigTool", "NodeFetchCommand", "getMatches");
456
457                 assertTrue(true);
458
459         }
460
461         @Test
462         public void testCheckReady11() {
463
464                 callMethodViaReflection("ConfigTool", "NodeFetchCommand", "checkReady", null);
465
466                 assertTrue(true);
467
468         }
469
470         @Test
471         public void testExecute11() {
472
473                 callMethodViaReflection("ConfigTool", "NodeFetchCommand", "execute", parts, null, null);
474
475                 assertTrue(true);
476
477         }
478
479         @Test
480         public void testDisplayHelp11() {
481
482                 callMethodViaReflection("ConfigTool", "NodeFetchCommand", "displayHelp", null);
483
484                 assertTrue(true);
485
486         }
487         
488         @Test
489         public void testGetMatches12() {
490
491                 callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "getMatches");
492
493                 assertTrue(true);
494
495         }
496
497         @Test
498         public void testCheckReady12() {
499
500                 callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "checkReady", null);
501
502                 assertTrue(true);
503
504         }
505
506         @Test
507         public void testExecute12() {
508
509                 callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "execute", parts, null, null);
510
511                 assertTrue(true);
512
513         }
514
515         @Test
516         public void testDisplayHelp12() {
517
518                 callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "displayHelp", null);
519
520                 assertTrue(true);
521
522         }
523 }