X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fxapp%2Fxapp_test.go;h=1aacc5ef9e3722ed2473f743e37258e5c245ab78;hb=467a99f0a3e5352ce77514ca2e3f9cc316fa9afc;hp=51ac171ed3cea137249a32dd6e23035f798081f8;hpb=2e78e42c5896b61b77ab3a97e45704f6749161b2;p=ric-plt%2Fxapp-frame.git diff --git a/pkg/xapp/xapp_test.go b/pkg/xapp/xapp_test.go old mode 100755 new mode 100644 index 51ac171..1aacc5e --- a/pkg/xapp/xapp_test.go +++ b/pkg/xapp/xapp_test.go @@ -32,8 +32,9 @@ import ( type Consumer struct { } -func (m Consumer) Consume(mtype, sid, len int, payload []byte) (err error) { - Sdl.Store("myKey", payload) +func (m Consumer) Consume(params *RMRParams) (err error) { + //Logger.Info("Message received - type=%d subId=%d meid=%v xid=%s src=%s", params.Mtype, params.SubId, params.Meid.RanName, params.Xid, params.Src) + Sdl.Store("myKey", params.Payload) return nil } @@ -100,7 +101,13 @@ func TestInjectQueryFailures(t *testing.T) { func TestMessagesReceivedSuccessfully(t *testing.T) { for i := 0; i < 100; i++ { - Rmr.Send(10004, 1111, 100, []byte{1, 2, 3, 4, 5, 6}) + params := &RMRParams{} + params.Mtype = 10004 + params.SubId = -1 + params.Payload = []byte{1, 2, 3, 4, 5, 6} + params.Meid = &RMRMeid{PlmnID: "1234", EnbID: "7788", RanName: "RanName-1234"} + params.Xid = "TestXID" + Rmr.SendMsg(params) } // Allow time to process the messages @@ -132,16 +139,6 @@ func TestMessagesReceivedSuccessfully(t *testing.T) { } } -func TestGetgNBList(t *testing.T) { - Rnib.Store("Kiikale", "Hello") - Rnib.Store("mykey", "myval") - - v, _ := Rnib.GetgNBList() - if v["Kiikale"] != "Hello" || v["mykey"] != "myval" { - t.Errorf("Error: GetgNBList failed!") - } -} - func TestSubscribeChannels(t *testing.T) { var NotificationCb = func(ch string, events ...string) { if ch != "channel1" { @@ -159,9 +156,32 @@ func TestSubscribeChannels(t *testing.T) { } } +func TestGetRicMessageSuccess(t *testing.T) { + id, ok := Rmr.GetRicMessageId("RIC_SUB_REQ") + if !ok || id != 12010 { + t.Errorf("Error: GetRicMessageId failed: id=%d", id) + } + + name := Rmr.GetRicMessageName(12010) + if name != "RIC_SUB_REQ" { + t.Errorf("Error: GetRicMessageName failed: name=%s", name) + } +} + +func TestGetRicMessageFails(t *testing.T) { + id, ok := Rmr.GetRicMessageId("INVALID") + if ok { + t.Errorf("Error: GetRicMessageId returned invalid value id=%d", id) + } + + name := Rmr.GetRicMessageName(123456) + if name != "" { + t.Errorf("Error: GetRicMessageName returned invalid value: name=%s", name) + } +} + func TestTeardown(t *testing.T) { Sdl.Clear() - Rnib.Clear() } // Helper functions @@ -185,4 +205,4 @@ func getMetrics(t *testing.T) string { response := executeRequest(req) return response.Body.String() -} \ No newline at end of file +}