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/submgr/pkg/xapptweaks"
29 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
33 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
36 type RmrDummyStub struct {
37 teststub.RmrStubControl
42 //-----------------------------------------------------------------------------
44 //-----------------------------------------------------------------------------
45 func CreateNewRmrDummyStub(desc string, srcId teststub.RmrSrcId, rtgSvc teststub.RmrRtgSvc, stat string, mtypeseed int) *RmrDummyStub {
46 dummyStub := &RmrDummyStub{}
47 dummyStub.RmrStubControl.Init(desc, srcId, rtgSvc, stat, mtypeseed)
48 dummyStub.reqMsg = mtypeseed + 1
49 dummyStub.respMsg = mtypeseed + 2
53 //-----------------------------------------------------------------------------
55 //-----------------------------------------------------------------------------
57 func (tc *RmrDummyStub) SendReq(t *testing.T, plen int) {
58 tc.Logger.Info("SendReq")
63 params := xapptweaks.NewParams(nil)
64 params.Mtype = tc.reqMsg
67 params.Payload = make([]byte, len)
69 params.Meid = &xapp.RMRMeid{RanName: "TEST"}
73 snderr := tc.RmrSend(params, 5)
75 tc.TestError(t, "%s", snderr.Error())
80 func (tc *RmrDummyStub) SendResp(t *testing.T, plen int) {
81 tc.Logger.Info("SendReq")
86 params := xapptweaks.NewParams(nil)
87 params.Mtype = tc.respMsg
89 params.Payload = make([]byte, len)
91 params.Meid = &xapp.RMRMeid{RanName: "TEST"}
95 snderr := tc.RmrSend(params, 5)
97 tc.TestError(t, "%s", snderr.Error())
102 func (tc *RmrDummyStub) RecvReq(t *testing.T) bool {
103 tc.Logger.Info("RecvReq")
105 msg := tc.WaitMsg(15)
107 if msg.Mtype != tc.reqMsg {
108 tc.TestError(t, "Received wrong mtype expected %d got %d, error", tc.reqMsg, msg.Mtype)
113 tc.TestError(t, "Not Received msg within %d secs", 15)
118 func (tc *RmrDummyStub) RecvResp(t *testing.T) bool {
119 tc.Logger.Info("RecvResp")
121 msg := tc.WaitMsg(15)
123 if msg.Mtype != tc.respMsg {
124 tc.TestError(t, "Received wrong mtype expected %d got %d, error", tc.respMsg, msg.Mtype)
129 tc.TestError(t, "Not Received msg within %d secs", 15)