2 ==================================================================================
4 Copyright (c) 2019-2020 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 ==================================================================================
19 #ifndef TEST_TEST_SUBS_H_
20 #define TEST_TEST_SUBS_H_
23 #include<gtest/gtest.h>
25 #define BUFFER_SIZE 1024
28 //generating a E2AP Subscription Message
29 TEST(SUBSCRIPTION, Request){
32 subscription_helper din;
33 subscription_helper dout;
35 subscription_request sub_req;
36 subscription_request sub_recv;
38 unsigned char buf[BUFFER_SIZE];
39 size_t buf_size = BUFFER_SIZE;
43 //Random Data for request
46 std::string event_def = "HelloWorld Event Definition";
48 din.set_request(request_id);
49 din.set_function_id(function_id);
50 din.set_event_def(event_def.c_str(), event_def.length());
52 std::string act_def = "HelloWorld Action Definition";
54 din.add_action(1,1,(void*)act_def.c_str(), act_def.length(), 0);
56 res = sub_req.encode_e2ap_subscription(&buf[0], &buf_size, din);
63 //create a MOck e2term
66 const char* meid = "test1";
67 const char* sub_id = "sub1";
68 //Send the Subscription Response.
70 hdr.message_type = RIC_SUB_RESP;
71 clock_gettime(CLOCK_REALTIME, &(hdr.ts));
72 const char* strMsg = "Subscription Response for MEID: test1";
73 hdr.payload_length = strlen(strMsg);
74 strcpy((char*)hdr.meid, meid);
75 strcpy((char*)hdr.sid,sub_id);
76 int total_num_msgs = 2;
77 int num_attempts = 10;
79 std::unique_ptr<XappRmr> rmr;
80 rmr = std::make_unique<XappRmr>("4591",num_attempts);
81 rmr->xapp_rmr_init(true);
85 std::unique_ptr<Xapp> hw_xapp = std::make_unique<Xapp>(std::ref(config),std::ref(*rmr));
87 bool res_msg = rmr->xapp_rmr_send(&hdr,(void*)strMsg);
89 mdclog_write(MDCLOG_INFO, "Message Sent Successfully");
96 #endif /* TEST_TEST_SUBS_H_ */