fe034a5ad1117b1a1ba2de539eee9bcd9527198a
[dmaap/messagerouter/msgrtr.git] / src / test / java / com / att / nsa / cambria / metrics / publisher / impl / DMaaPCambriaConsumerImplTest.java
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * ONAP Policy Engine\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ============LICENSE_END=========================================================\r
19  */\r
20 \r
21 \r
22 package com.att.nsa.cambria.metrics.publisher.impl;\r
23 \r
24 import static org.junit.Assert.*;\r
25 \r
26 import java.io.IOException;\r
27 import java.util.ArrayList;\r
28 import java.util.Collection;\r
29 import java.util.List;\r
30 \r
31 import org.junit.After;\r
32 import org.junit.Before;\r
33 import org.junit.Test;\r
34 \r
35 import com.att.dmf.mr.metrics.publisher.impl.DMaaPCambriaConsumerImpl;\r
36 \r
37 public class DMaaPCambriaConsumerImplTest {\r
38         \r
39         private DMaaPCambriaConsumerImpl consumer = null; \r
40         @Before\r
41         public void setUp() throws Exception {\r
42                 \r
43                 Collection<String> hosts = new ArrayList<String>();\r
44                 \r
45                 for (int i = 0; i < 5; i++) {\r
46                         hosts.add("host"+(i+1));\r
47                 }\r
48                 consumer = new DMaaPCambriaConsumerImpl(hosts, "testTopic", "consumerGroup1", "1", 2000, 200, "hi", \r
49                                 "9AMFFNIZpusO54oG","6BY86UQcio2LJdgyU7Cwg5oQ");\r
50         }\r
51 \r
52         @After\r
53         public void tearDown() throws Exception {\r
54         }\r
55 \r
56         @Test\r
57         public void testStringToList() {\r
58                 \r
59                 List<String> response = DMaaPCambriaConsumerImpl.stringToList("Hello world, this is a test string");\r
60                 assertNotNull(response);\r
61                 \r
62                 \r
63         }\r
64         \r
65         @Test\r
66         public void testFetch() {\r
67                 \r
68                 Iterable<String> response = null;\r
69                 boolean flag = true;\r
70                 try {\r
71                         response = consumer.fetch(200, 20);\r
72                 } catch (IOException e) {\r
73                         flag = false;\r
74                         // TODO Auto-generated catch block\r
75                         e.printStackTrace();\r
76                 }\r
77                 if(flag) {\r
78                         assertNotNull(response);\r
79                 } else {\r
80                         assertTrue(true);\r
81                 }\r
82                 \r
83         }\r
84         \r
85         \r
86         @Test\r
87         public void testCreateUrlPath() {\r
88         \r
89                 String response = consumer.createUrlPath(200, 20);\r
90                 assertNotNull(response);\r
91         }\r
92 \r
93 \r
94 }\r