X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fe2t%2Fe2t.go;fp=test%2Fe2t%2Fe2t.go;h=119e59e5efe86fb0b2a60e64fb4db9cd989adcb9;hb=4511475f03107eb53c88545649898e3cfbcc2765;hp=0000000000000000000000000000000000000000;hpb=59f84608ec15c016958a6e0e0ddd813f376c0925;p=ric-plt%2Fsubmgr.git diff --git a/test/e2t/e2t.go b/test/e2t/e2t.go new file mode 100644 index 0000000..119e59e --- /dev/null +++ b/test/e2t/e2t.go @@ -0,0 +1,58 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ + +package main + +import ( + "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" + submgr "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/control" + "errors" +) + +type E2t struct { +} + +func (e E2t ) Consume(mtype, sub_id int, len int, payload []byte) (err error) { + asn1 := submgr.Asn1{} + message, err := asn1.Decode(payload) + if err != nil { + xapp.Logger.Debug("E2T asn1Decoding failure due to "+ err.Error()) + return + } + xapp.Logger.Info("E2T Received Message content: %v", message) + err = e.subscriptionResponse(sub_id) + return +} + +func (e E2t ) subscriptionResponse(sub_id int) (err error) { + asn1 := submgr.Asn1{} + payload, err := asn1.Encode(submgr.RmrPayload{8, sub_id, "E2T: RCO Subscribed"}) + if err != nil { + return + } + if !xapp.Rmr.Send(12011, sub_id, len(payload), payload) { + err = errors.New("rmr.Send() failed") + } + return +} + +func main() { + e2t := E2t{} + xapp.Run(e2t) +}