2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
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 // EXAMPLE HOW TO HAVE RMR STUB
27 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
28 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
32 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
35 type RmrDummyStub struct {
36 teststub.RmrStubControl
41 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
44 func CreateNewRmrDummyStub(desc string, srcId teststub.RmrSrcId, rtgSvc teststub.RmrRtgSvc, stat string, mtypeseed int) *RmrDummyStub {
45 dummyStub := &RmrDummyStub{}
46 dummyStub.RmrStubControl.Init(desc, srcId, rtgSvc, stat, mtypeseed)
47 dummyStub.reqMsg = mtypeseed + 1
48 dummyStub.respMsg = mtypeseed + 2
52 //-----------------------------------------------------------------------------
54 //-----------------------------------------------------------------------------
56 func (tc *RmrDummyStub) SendReq(t *testing.T, plen int) {
62 params := &xapp.RMRParams{}
63 params.Mtype = tc.reqMsg
66 params.Payload = make([]byte, len)
68 params.Meid = &xapp.RMRMeid{RanName: "TEST"}
72 snderr := tc.SendWithRetry(params, false, 5)
74 tc.TestError(t, "%s", snderr.Error())
79 func (tc *RmrDummyStub) SendResp(t *testing.T, plen int) {
85 params := &xapp.RMRParams{}
86 params.Mtype = tc.respMsg
88 params.Payload = make([]byte, len)
90 params.Meid = &xapp.RMRMeid{RanName: "TEST"}
94 snderr := tc.SendWithRetry(params, false, 5)
96 tc.TestError(t, "%s", snderr.Error())
101 func (tc *RmrDummyStub) RecvReq(t *testing.T) bool {
104 msg := tc.WaitMsg(15)
106 if msg.Mtype != tc.reqMsg {
107 tc.TestError(t, "Received wrong mtype expected %d got %d, error", tc.reqMsg, msg.Mtype)
112 tc.TestError(t, "Not Received msg within %d secs", 15)
117 func (tc *RmrDummyStub) RecvResp(t *testing.T) bool {
120 msg := tc.WaitMsg(15)
122 if msg.Mtype != tc.respMsg {
123 tc.TestError(t, "Received wrong mtype expected %d got %d, error", tc.respMsg, msg.Mtype)
128 tc.TestError(t, "Not Received msg within %d secs", 15)