2 ==================================================================================
4 Copyright (c) 2018-2019 AT&T Intellectual Property.
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================================
21 * Created on: Mar, 2020
22 * Author: Shraboni Jana
26 #include<gtest/gtest.h>
27 #include<rapidjson/stringbuffer.h>
28 #include<rapidjson/writer.h>
31 #define HC_MSG_SIZE 512
34 TEST(Xapp, RMRHealthCheck){
36 int total_num_msgs = 2;
37 int num_attempts = 10;
39 std::unique_ptr<XappRmr> rmr;
40 rmr = std::make_unique<XappRmr>("4560",num_attempts);
45 std::unique_ptr<Xapp> hw_xapp = std::make_unique<Xapp>(std::ref(config),std::ref(*rmr));
47 std::unique_ptr<XappMsgHandler> mp_handler = std::make_unique<XappMsgHandler>("HW-Xapp-id");
49 hw_xapp->start_xapp_receiver(std::ref(*mp_handler));
53 hdr.message_type = RIC_HEALTH_CHECK_REQ;
54 char strMsg[HC_MSG_SIZE];
56 for(int i = 0; i < total_num_msgs; i++){
57 snprintf(strMsg,HC_MSG_SIZE, "HelloWorld: RMR Health Check %d", i);
58 clock_gettime(CLOCK_REALTIME, &(hdr.ts));
59 hdr.payload_length = strlen(strMsg);
61 bool res = rmr->xapp_rmr_send(&hdr,(void*)strMsg);
69 TEST(Xapp, A1HealthCheck){
71 //Read the json file and send it using rmr.
72 string json = "{\"policy_type_id\": \"1\",\"policy_instance_id\":\"3d2157af-6a8f-4a7c-810f-38c2f824bf12\",\"operation\": \"CREATE\"}";
73 int n = json.length();
75 strcpy(strMsg, json.c_str());
81 std::unique_ptr<XappRmr> rmr;
82 rmr = std::make_unique<XappRmr>("4560",num_attempts);
87 std::unique_ptr<Xapp> hw_xapp = std::make_unique<Xapp>(std::ref(config),std::ref(*rmr));
89 std::unique_ptr<XappMsgHandler> mp_handler = std::make_unique<XappMsgHandler>("HW-Xapp-id");
91 hw_xapp->start_xapp_receiver(std::ref(*mp_handler));
95 hdr.message_type = A1_POLICY_REQ;
96 clock_gettime(CLOCK_REALTIME, &(hdr.ts));
99 hdr.payload_length = strlen(strMsg);
101 bool res_msg1 = rmr->xapp_rmr_send(&hdr,(void*)strMsg);
102 ASSERT_TRUE(res_msg1);
106 bool res_msg2 = rmr->xapp_rmr_send(&hdr,(void*)strMsg);
107 ASSERT_TRUE(res_msg2);