update the package name
[dmaap/messagerouter/msgrtr.git] / src / test / java / org / onap / dmaap / mr / apiServer / metrics / cambria / DMaaPMetricsSenderTest.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.mr.apiServer.metrics.cambria;
22
23
24 import static org.junit.Assert.assertTrue;
25
26 import java.io.File;
27
28 import org.junit.After;
29 import org.junit.Before;
30 import org.junit.Test;
31
32 import com.att.ajsc.filemonitor.AJSCPropertiesMap;
33 import org.onap.dmaap.mr.apiServer.metrics.cambria.DMaaPMetricsSender;
34
35 public class DMaaPMetricsSenderTest {
36
37         @Before
38         public void setUp() throws Exception {
39                 ClassLoader classLoader = getClass().getClassLoader();          
40                 AJSCPropertiesMap.refresh(new File(classLoader.getResource("MsgRtrApi.properties").getFile()));
41         }
42
43         @After
44         public void tearDown() throws Exception {
45         }
46         
47         @Test
48         public void testSendPeriodically() {
49                 
50                 DMaaPMetricsSender sender = new DMaaPMetricsSender(null, "url", "testTopic");
51                 try {
52                         sender.sendPeriodically(null, null, "testTopic");
53                 } catch (org.json.JSONException e) {
54                         // TODO Auto-generated catch block
55                         e.printStackTrace();
56                 } catch (NullPointerException e) {
57                         // TODO Auto-generated catch block
58                         //e.printStackTrace();
59                         assertTrue(true);
60                 } catch (NoClassDefFoundError e) {
61                         // TODO Auto-generated catch block
62                         //e.printStackTrace();
63                         assertTrue(true);
64                 }                       
65                 
66                 String trueValue = "True";
67                 assertTrue(trueValue.equalsIgnoreCase("True"));
68                 
69         }
70         
71         @Test
72         public void testSendPeriodically2() {
73                 
74                 DMaaPMetricsSender sender = new DMaaPMetricsSender(null, "url", "testTopic");
75                 try {
76                         sender.sendPeriodically(null, null, "url", "testTopic", 2);
77                 } catch (org.json.JSONException e) {
78                         // TODO Auto-generated catch block
79                         e.printStackTrace();
80                 } catch (NullPointerException e) {
81                         // TODO Auto-generated catch block
82                         //e.printStackTrace();
83                         assertTrue(true);
84                 }       
85                 
86                 String trueValue = "True";
87                 assertTrue(trueValue.equalsIgnoreCase("True"));
88                 
89         }
90         
91         @Test
92         public void testSend() {
93                 
94                 DMaaPMetricsSender sender = new DMaaPMetricsSender(null, "url", "testTopic");
95                 try {
96                         sender.send();
97                 } catch (org.json.JSONException e) {
98                         // TODO Auto-generated catch block
99                         e.printStackTrace();
100                 } catch (NullPointerException e) {
101                         // TODO Auto-generated catch block
102                         //e.printStackTrace();
103                         assertTrue(true);
104                 }               
105                 
106                 String trueValue = "True";
107                 assertTrue(trueValue.equalsIgnoreCase("True"));
108                 
109         }
110         
111         @Test
112         public void testRun() {
113                 
114                 DMaaPMetricsSender sender = new DMaaPMetricsSender(null, "url", "testTopic");
115                 try {
116                         sender.run();
117                 } catch (org.json.JSONException e) {
118                         // TODO Auto-generated catch block
119                         e.printStackTrace();
120                 } catch (NullPointerException e) {
121                         // TODO Auto-generated catch block
122                         //e.printStackTrace();
123                         assertTrue(true);
124                 }               
125                 
126                 String trueValue = "True";
127                 assertTrue(trueValue.equalsIgnoreCase("True"));
128                 
129         }
130
131 }