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.
19 This source code is part of the near-RT RIC (RAN Intelligent Controller)
20 platform project (RICP).
22 ==================================================================================
25 Mnemonic: httprestful_test.go
26 Abstract: HTTPRestful unit tests
35 xfmodel "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models"
36 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
37 "github.com/go-openapi/swag"
38 "github.com/spf13/viper"
44 "routing-manager/pkg/models"
45 "routing-manager/pkg/rpe"
46 "routing-manager/pkg/rtmgr"
47 "routing-manager/pkg/sbi"
48 "routing-manager/pkg/sdl"
49 "routing-manager/pkg/stub"
55 var BasicXAppLists = []byte(`[
57 "name":"xapp-01","status":"unknown","version":"1.2.3",
59 {"name":"xapp-01-instance-01","status":"pending","ip":"172.16.1.103","port":4555,
60 "txMessages":["ControlIndication"],
61 "rxMessages":["LoadIndication","Reset"]
63 {"name":"xapp-01-instance-02","status":"pending","ip":"10.244.1.12","port":4561,
64 "txMessages":["ControlIndication","SNStatusTransfer"],
65 "rxMessages":["LoadIndication","HandoverPreparation"]
71 var SubscriptionResp = []byte(`{"ID":"deadbeef1234567890", "Version":0, "EventType":"all"}`)
73 var E2TListResp = []byte(`[{"e2tAddress":"127.0.0.1:0","ranNames":["RanM0","RanN0"]},{"e2tAddress":"127.0.0.1:1","ranNames":["RanM1","RanN1"]},{"e2tAddress":"127.0.0.1:2","ranNames":["RanM2","RanN2"]},{"e2tAddress":"127.0.0.1:3","ranNames":["RanM3","RanN3"]}]`)
75 var SubscriptionList = []byte(`[{"SubscriptionId":11,"Meid":"Test-Gnb","Endpoint":["127.0.0.1:4056"]}]`)
77 var InvalidSubResp = []byte(`{"Version":0, "EventType":all}`)
79 type Consumer struct{}
81 func (m Consumer) Consume(params *xapp.RMRParams) (err error) {
82 xapp.Sdl.Store("myKey", params.Payload)
87 func TestMain(m *testing.M) {
88 go xapp.RunWithParams(Consumer{}, viper.GetBool("db.waitForSdl"))
89 time.Sleep(time.Duration(5) * time.Second)
94 func TestValidateXappCallbackData_1(t *testing.T) {
95 data := models.XappCallbackData{
96 XApps: *swag.String("[]"),
97 Version: *swag.Int64(1),
98 Event: *swag.String("someevent"),
99 ID: *swag.String("123456")}
101 err := validateXappCallbackData(&data)
103 t.Error("Invalid XApp callback data: " + err.Error())
107 func TestValidateXappCallbackDataInvalid(t *testing.T) {
108 data := models.XappCallbackData{}
109 err := validateXappCallbackData(&data)
113 func TestValidateXappSubscriptionsData(t *testing.T) {
115 rtmgr.RMRConnStatus = make(map[string]bool)
116 ep := make(map[string]*rtmgr.Endpoint)
117 ep["dummy"] = &rtmgr.Endpoint{Uuid: "10.0.0.1:0", Name: "E2TERM", XAppType: "app1", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: true}
119 data := models.XappSubscriptionData{
120 Address: swag.String("10.1.1.1"),
122 SubscriptionID: swag.Int32(123456)}
125 err = validateXappSubscriptionData(&data)
130 data1 := models.XappSubscriptionData{
131 Address: swag.String(""),
133 SubscriptionID: swag.Int32(123456)}
134 err = validateXappSubscriptionData(&data1)
137 data2 := models.E2tData{
138 E2TAddress: swag.String(""),
140 /*err = validateE2tData(&data2)*/
142 //e2tchannel := make(chan *models.E2tData, 10)
143 _ = CreateNewE2tHandleHandlerImpl(&data2)
144 //defer close(e2tchannel)
146 //test case for provideXappSubscriptionHandleImp
147 //datachannel := make(chan *models.XappSubscriptionData, 10)
148 sdlEngine, _ = sdl.GetSdl("file")
149 sbiEngine, _ = sbi.GetSbi("rmrpush")
150 rpeEngine, _ = rpe.GetRpe("rmrpush")
151 _ = ProvideXappSubscriptionHandleImpl(&data1)
152 //defer close(datachannel)
154 //test case for deleteXappSubscriptionHandleImpl
155 _ = DeleteXappSubscriptionHandleImpl(&data1)
157 data3 := models.XappSubscriptionData{
158 Address: swag.String("10.55.55.5"),
160 SubscriptionID: swag.Int32(123456)}
161 //test case for deleteXappSubscriptionHandleImpl
162 _ = DeleteXappSubscriptionHandleImpl(&data3)
163 data4 := models.XappSubscriptionData{
164 Address: swag.String("1.5.5.5"),
166 SubscriptionID: swag.Int32(1236)}
167 _ = DeleteXappSubscriptionHandleImpl(&data4)
171 func TestValidateE2tDataEmpty(t *testing.T) {
172 data := models.E2tData{
173 E2TAddress: swag.String(""),
175 err, _ := validateE2tData(&data)
179 func TestValidateE2tDataDNSLookUPfails(t *testing.T) {
180 rtmgr.RMRConnStatus = make(map[string]bool)
181 data := models.E2tData{
182 E2TAddress: swag.String("e2t.1com:1234"),
184 err, _ := validateE2tData(&data)
188 func TestValidateE2tDataInvalid(t *testing.T) {
189 rtmgr.RMRConnStatus = make(map[string]bool)
190 data := models.E2tData{
191 E2TAddress: swag.String("10.101.01.1"),
193 err, _ := validateE2tData(&data)
197 func TestValidateE2tDatavalid(t *testing.T) {
198 rtmgr.RMRConnStatus = make(map[string]bool)
199 data := models.E2tData{
200 E2TAddress: swag.String("10.101.01.1:8098"),
203 err, _ := validateE2tData(&data)
206 _ = CreateNewE2tHandleHandlerImpl(&data)
210 func TestValidateE2tDatavalidEndpointPresent(t *testing.T) {
211 rtmgr.RMRConnStatus = make(map[string]bool)
212 data := models.E2tData{
213 E2TAddress: swag.String("10.101.01.1:8098"),
216 // insert endpoint for testing purpose
217 uuid := "10.101.01.1:8098"
218 ep := &rtmgr.Endpoint{
223 err, _ := validateE2tData(&data)
226 // delete endpoint for at end of test case
227 delete(rtmgr.Eps, uuid)
231 func TestValidateDeleteE2tData(t *testing.T) {
233 rtmgr.RMRConnStatus = make(map[string]bool)
235 data := models.E2tDeleteData{
236 E2TAddress: swag.String(""),
239 err := validateDeleteE2tData(&data)
240 if err.Error() != "E2TAddress is empty!!!" {
245 data = models.E2tDeleteData{
246 E2TAddress: swag.String("10.101.01.1:8098"),
249 err = validateDeleteE2tData(&data)
255 //################ Create End Point dummy entry
256 uuid := "10.101.01.1:8098"
257 ep := &rtmgr.Endpoint{
261 //#####################
263 data = models.E2tDeleteData{
264 E2TAddress: swag.String("10.101.01.1:8098"),
265 RanAssocList: models.RanE2tMap{
266 {E2TAddress: swag.String("10.101.01.1:8098")},
270 err = validateDeleteE2tData(&data)
275 // delete endpoint for at end of test case
276 //################ Delete End Point dummy entry
277 delete(rtmgr.Eps, uuid)
278 //#####################
282 //################ Create End Point dummy entry
283 uuid = "10.101.01.1:9991"
284 ep = &rtmgr.Endpoint{
289 uuid = "10.101.01.1:9992"
290 ep = &rtmgr.Endpoint{
294 //#####################
296 data = models.E2tDeleteData{
297 E2TAddress: swag.String("10.101.01:8098"),
298 RanAssocList: models.RanE2tMap{
299 {E2TAddress: swag.String("10.101.01.1:9991")},
300 {E2TAddress: swag.String("10.101.01.1:9992")},
304 err = validateDeleteE2tData(&data)
308 //################ Delete End Point dummy entry
309 delete(rtmgr.Eps, "10.101.01.1:9991")
310 delete(rtmgr.Eps, "10.101.01.1:9992")
311 //#####################
315 data = models.E2tDeleteData{
316 E2TAddress: swag.String("10.101.01:8098"),
317 RanAssocList: models.RanE2tMap{
318 {E2TAddress: swag.String("10.101.01.19991")},
322 err = validateDeleteE2tData(&data)
323 if err.Error() != "E2T Delete - RanAssocList E2TAddress is not a proper format like ip:port, 10.101.01.19991" {
328 func TestValidateE2TAddressRANListData(t *testing.T) {
330 data := models.RanE2tMap{
332 E2TAddress: swag.String(""),
335 err := validateE2TAddressRANListData(data)
340 data = models.RanE2tMap{
342 E2TAddress: swag.String("10.101.01.1:8098"),
345 err = validateE2TAddressRANListData(data)
352 func TestAssociateRanToE2THandlerImpl(t *testing.T) {
354 data := models.RanE2tMap{
356 E2TAddress: swag.String("10.101.01.1:8098"),
359 err := AssociateRanToE2THandlerImpl(data)
364 //################ Create End Point dummy entry
365 uuid := "10.101.01.1:8098"
366 ep := &rtmgr.Endpoint{
370 //#####################
372 data = models.RanE2tMap{
374 E2TAddress: swag.String("10.101.01.1:8098"),
377 err = AssociateRanToE2THandlerImpl(data)
382 //################ Delete End Point dummy entry
383 delete(rtmgr.Eps, uuid)
384 //#####################
387 func TestDisassociateRanToE2THandlerImpl(t *testing.T) {
389 data := models.RanE2tMap{
391 E2TAddress: swag.String("10.101.01.1:8098"),
394 err := DisassociateRanToE2THandlerImpl(data)
398 //################ Create End Point dummy entry
399 uuid := "10.101.01.1:8098"
400 ep := &rtmgr.Endpoint{
404 //#####################
406 data = models.RanE2tMap{
408 E2TAddress: swag.String("10.101.01.1:8098"),
411 err = DisassociateRanToE2THandlerImpl(data)
416 //################ Delete End Point dummy entry
417 delete(rtmgr.Eps, uuid)
418 //#####################
421 func TestDeleteE2tHandleHandlerImpl(t *testing.T) {
423 data := models.E2tDeleteData{
424 E2TAddress: swag.String(""),
426 err := DeleteE2tHandleHandlerImpl(&data)
431 //################ Create End Point dummy entry
432 uuid := "10.101.01.1:8098"
433 ep := &rtmgr.Endpoint{
437 //#####################
439 data = models.E2tDeleteData{
440 E2TAddress: swag.String("10.101.01.1:8098"),
442 err = DeleteE2tHandleHandlerImpl(&data)
446 //################ Delete End Point dummy entry
447 delete(rtmgr.Eps, uuid)
448 //#####################
451 func TestSubscriptionExists(t *testing.T) {
453 data := models.XappSubscriptionData{
454 Address: swag.String("10.0.0.0"),
456 SubscriptionID: swag.Int32(1234)}
458 rtmgr.Subs = *stub.ValidSubscriptions
460 yes_no := subscriptionExists(&data)
461 yes_no = addSubscription(&rtmgr.Subs, &data)
462 yes_no = addSubscription(&rtmgr.Subs, &data)
463 yes_no = delSubscription(&rtmgr.Subs, &data)
464 yes_no = delSubscription(&rtmgr.Subs, &data)
468 func TestAddSubscriptions(t *testing.T) {
470 subdata := models.XappSubscriptionData{
471 Address: swag.String("10.0.0.0"),
473 SubscriptionID: swag.Int32(1234)}
475 rtmgr.Subs = *stub.ValidSubscriptions
476 yes_no := addSubscription(&rtmgr.Subs, &subdata)
480 func TestHttpInstance(t *testing.T) {
481 sdlEngine, _ := sdl.GetSdl("file")
482 rpeEngine, _ := rpe.GetRpe("rmrpush")
483 sbiEngine, _ := sbi.GetSbi("rmrpush")
484 httpinstance := NewHttpRestful()
485 err := httpinstance.Terminate()
487 fmt.Printf("sbiEngine = %v", sbiEngine)
489 createMockPlatformComponents()
490 //ts := createMockAppmgrWithData("127.0.0.1:3000", BasicXAppLists, nil)
494 err = httpinstance.Initialize(XMURL, "httpgetter", "rt.json", "config.json", E2MURL, sdlEngine, rpeEngine, &m)
497 func TestXappCallbackWithData(t *testing.T) {
498 data := models.XappCallbackData{
499 XApps: *swag.String("[]"),
500 Version: *swag.Int64(1),
501 Event: *swag.String("someevent"),
502 ID: *swag.String("123456")}
503 _, _ = recvXappCallbackData(&data)
506 func TestXappCallbackNodata(t *testing.T) {
507 //data := *models.XappCallbackData
508 _, _ = recvXappCallbackData(nil)
511 func TestE2TwithData(t *testing.T) {
512 data2 := models.E2tData{
513 E2TAddress: swag.String("1.2.3.4"),
514 RanNamelist: []string{"ran1", "ran2"},
516 _, _, _ = recvNewE2Tdata(&data2)
519 func TestE2TwithNoData(t *testing.T) {
520 _, _, _ = recvNewE2Tdata(nil)
523 func TestProvideXappSubscriptionHandleImpl(t *testing.T) {
525 data := models.XappSubscriptionData{
526 Address: swag.String("10.0.0.0"),
528 SubscriptionID: swag.Int32(1234)}
529 _ = ProvideXappSubscriptionHandleImpl(&data)
532 func createMockAppmgrWithData(url string, g []byte, p []byte, t []byte) *httptest.Server {
533 l, err := net.Listen("tcp", url)
535 fmt.Println("Failed to create listener: " + err.Error())
537 ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
538 if r.Method == "GET" && r.URL.String() == "/ric/v1/xapps" {
539 w.Header().Add("Content-Type", "application/json")
540 w.WriteHeader(http.StatusOK)
543 if r.Method == "POST" && r.URL.String() == "/ric/v1/subscriptions" {
544 w.Header().Add("Content-Type", "application/json")
545 w.WriteHeader(http.StatusCreated)
548 if r.Method == "GET" && r.URL.String() == "/ric/v1/e2t/list" {
549 w.Header().Add("Content-Type", "application/json")
550 w.WriteHeader(http.StatusOK)
560 func createMockSubmgrWithData(url string, t []byte) *httptest.Server {
561 l, err := net.Listen("tcp", url)
563 fmt.Println("Failed to create listener: " + err.Error())
565 ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
567 if r.Method == "GET" && r.URL.String() == "//ric/v1/subscriptions" {
568 w.Header().Add("Content-Type", "application/json")
569 w.WriteHeader(http.StatusOK)
580 func createMockPlatformComponents() {
581 var filename = "config.json"
582 file, _ := json.MarshalIndent(stub.ValidPlatformComponents, "", "")
583 filestr := string(file)
584 filestr = "{\"PlatformComponents\":" + filestr + "}"
585 file = []byte(filestr)
586 _ = ioutil.WriteFile(filename, file, 644)
589 func TestProvideXappHandleHandlerImpl(t *testing.T) {
590 data := models.XappCallbackData{
591 XApps: *swag.String("[]"),
592 Version: *swag.Int64(1),
593 Event: *swag.String("someevent"),
594 ID: *swag.String("123456")}
595 err := ProvideXappHandleHandlerImpl(&data)
597 //Empty XappCallbackdata
598 data1 := models.XappCallbackData{}
599 err = ProvideXappHandleHandlerImpl(&data1)
603 func TestValidateXappCallbackData(t *testing.T) {
604 data := models.XappCallbackData{
605 XApps: *swag.String("[]"),
606 Version: *swag.Int64(1),
607 Event: *swag.String("someevent"),
608 ID: *swag.String("123456")}
610 err := validateXappCallbackData(&data)
612 t.Error("Invalid XApp callback data: " + err.Error())
616 func TestValidateXappCallbackDataWithInvalidData(t *testing.T) {
617 data := models.XappCallbackData{
618 XApps: *swag.String("{}"),
619 Version: *swag.Int64(1),
620 Event: *swag.String("someevent"),
621 ID: *swag.String("123456")}
623 err := validateXappCallbackData(&data)
625 t.Error("Invalid XApp callback data: " + err.Error())
629 func TestHttpGetXAppsInvalidData(t *testing.T) {
630 _, err := httpGetXApps(XMURL)
632 t.Error("No XApp data received: " + err.Error())
636 func TestHttpGetXAppsWithValidData(t *testing.T) {
638 ts := createMockAppmgrWithData("127.0.0.1:3000", BasicXAppLists, nil, nil)
642 xapplist, err := httpGetXApps(XMURL)
644 t.Error("Error occured: " + err.Error())
646 if len(*xapplist) != expected {
647 t.Error("Invalid XApp data: got " + string(len(*xapplist)) + ", expected " + string(expected))
652 func TestRetrieveStartupDataTimeout(t *testing.T) {
653 sdlEngine, _ := sdl.GetSdl("file")
654 createMockPlatformComponents()
655 err := retrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", E2MURL, sdlEngine)
657 t.Error("Cannot retrieve startup data: " + err.Error())
660 os.Remove("config.json")
663 func TestRetrieveStartupData(t *testing.T) {
664 ts := createMockAppmgrWithData("127.0.0.1:3000", BasicXAppLists, SubscriptionResp, nil)
668 ts1 := createMockAppmgrWithData("127.0.0.1:8085", nil, nil, E2TListResp)
672 ts2 := createMockSubmgrWithData("127.0.0.1:8089", SubscriptionList)
676 sdlEngine, _ := sdl.GetSdl("file")
677 var httpRestful, _ = GetNbi("httpRESTful")
678 createMockPlatformComponents()
679 httpRestful.(*HttpRestful).RetrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", E2MURL, sdlEngine)
680 //err := retrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", sdlEngine)
682 t.Error("Cannot retrieve startup data: " + err.Error())
685 os.Remove("config.json")
688 func TestRetrieveStartupDatawithInvalidE2MUrl(t *testing.T) {
689 ts := createMockAppmgrWithData("127.0.0.1:3000", BasicXAppLists, SubscriptionResp, nil)
693 ts1 := createMockAppmgrWithData("127.0.0.1:8085", nil, nil, E2TListResp)
697 ts2 := createMockSubmgrWithData("127.0.0.1:8089", SubscriptionList)
702 sdlEngine, _ := sdl.GetSdl("file")
703 var httpRestful, _ = GetNbi("httpRESTful")
704 createMockPlatformComponents()
706 E2MURL1 := "http://127.0.0.1:8080/ric/v1/e2t/list"
707 httpRestful.(*HttpRestful).RetrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", E2MURL1, sdlEngine)
709 os.Remove("config.json")
711 func TestRetrieveStartupDataWithInvalidSubResp(t *testing.T) {
712 ts := createMockAppmgrWithData("127.0.0.1:3000", BasicXAppLists, InvalidSubResp, nil)
715 sdlEngine, _ := sdl.GetSdl("file")
716 var httpRestful, _ = GetNbi("httpRESTful")
717 createMockPlatformComponents()
718 err := httpRestful.(*HttpRestful).RetrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", E2MURL, sdlEngine)
720 t.Error("Cannot retrieve startup data: " + err.Error())
723 os.Remove("config.json")
726 func TestInvalidarguments(t *testing.T) {
727 _ = PostSubReq("\n", "nbifinterface")
728 _ = PostSubReq("xmurl", "\n")
731 func TestInitEngine(t *testing.T) {
735 func TestUpdateXappSubscription(t *testing.T) {
736 ep := make(map[string]*rtmgr.Endpoint)
737 ep["dummy"] = &rtmgr.Endpoint{Uuid: "10.0.0.1:0", Name: "E2TERM", XAppType: "app1", Ip: "10.1.1.1", Port: 1234, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: true}
742 xapp := models.XappElement{
743 Address: swag.String("10.1.1.1"),
747 var b models.XappList
749 _ = UpdateXappSubscriptionHandleImpl(&b, 10)
751 //Test case when subscriptions already exist
752 data := models.XappSubscriptionData{
753 Address: swag.String("10.0.0.0"),
755 SubscriptionID: swag.Int32(12345)}
757 rtmgr.Subs = *stub.ValidSubscriptions
759 subscriptionExists(&data)
760 addSubscription(&rtmgr.Subs, &data)
761 _ = UpdateXappSubscriptionHandleImpl(&b, 10)
765 func TestDumpDebugdata(t *testing.T) {
766 _, _ = DumpDebugData()
769 func TestDumpDebugdata1(t *testing.T) {
770 _, _ = DumpDebugData()
773 func TestManagerRequest(t *testing.T) {
774 var params xapp.RMRParams
775 var rmrmeid xapp.RMRMeid
776 sdlEngine, _ = sdl.GetSdl("file")
777 sbiEngine, _ = sbi.GetSbi("rmrpush")
778 rpeEngine, _ = rpe.GetRpe("rmrpush")
779 rmrmeid.RanName = "gnb1"
780 c := Control{make(chan *xapp.RMRParams)}
781 params.Payload = []byte{1, 2, 3, 4}
784 params.Meid = &rmrmeid
785 params.Src = "sender"
786 params.PayloadLen = 4
788 c.handleUpdateToRoutingManagerRequest(¶ms)
791 func TestRecievermr(t *testing.T) {
792 var params xapp.RMRParams
793 var rmrmeid xapp.RMRMeid
794 sdlEngine, _ = sdl.GetSdl("file")
795 sbiEngine, _ = sbi.GetSbi("rmrpush")
796 rpeEngine, _ = rpe.GetRpe("rmrpush")
797 rmrmeid.RanName = "gnb1"
799 params.Payload = []byte{1, 2, 3, 4}
801 params.Meid = &rmrmeid
802 params.Src = "sender"
803 params.PayloadLen = 4
805 c := Control{make(chan *xapp.RMRParams)}
806 params.Mtype = xapp.RICMessageTypes["RMRRM_REQ_TABLE"]
807 c.recievermr(¶ms)
808 params.Mtype = xapp.RICMessageTypes["RMRRM_TABLE_STATE"]
809 c.recievermr(¶ms)
811 c.recievermr(¶ms)
813 rtmgr.Rtmgr_ready = true
814 params.Mtype = xapp.RICMessageTypes["RMRRM_REQ_TABLE"]
815 c.recievermr(¶ms)
816 time.Sleep(time.Duration(5) * time.Second)
819 func TestAddDelRmr(t *testing.T) {
820 sdlEngine, _ = sdl.GetSdl("file")
821 sbiEngine, _ = sbi.GetSbi("rmrpush")
822 rpeEngine, _ = rpe.GetRpe("rmrpush")
823 var routelist models.Routelist
824 mtype := uint32(1234)
825 tendpoint := "goofle.com"
826 listofroutes := models.AddRmrRoute{SubscriptionID: 0, SenderEndPoint: "nokia.com", MessageType: &mtype, TargetEndPoint: &tendpoint}
827 listofroutes2 := models.AddRmrRoute{SubscriptionID: 1, SenderEndPoint: "", MessageType: &mtype, TargetEndPoint: &tendpoint}
828 listofroutes3 := models.AddRmrRoute{MessageType: &mtype, TargetEndPoint: &tendpoint}
829 Adddelrmrroute(routelist, false)
830 routelist = append(routelist, &listofroutes)
831 routelist = append(routelist, &listofroutes2)
832 routelist = append(routelist, &listofroutes3)
833 routelist = append(routelist, &listofroutes3)
834 Adddelrmrroute(routelist, true)
836 Adddelrmrroute(routelist, false)
839 func TestPopulateSubscription(t *testing.T) {
840 var sublist xfmodel.SubscriptionList
842 subdata := xfmodel.SubscriptionData{ClientEndpoint: []string{"xapp1.com:3800"}, SubscriptionID: -1, Meid: ""}
843 subdata2 := xfmodel.SubscriptionData{ClientEndpoint: []string{"xapp2.com:3800"}, SubscriptionID: 11, Meid: ""}
844 subdata3 := xfmodel.SubscriptionData{ClientEndpoint: []string{"xapp3.com:3800"}, SubscriptionID: 221, Meid: ""}
845 sublist = append(sublist, &subdata)
846 sublist = append(sublist, &subdata2)
847 sublist = append(sublist, &subdata3)
849 PopulateSubscription(sublist)