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