RmrSrcId and RmrRtgSvc handling improved

Change-Id: I9f68e9d6c7e4a1c7e2aa71256de9efcfdf4ec405
Signed-off-by: Juha Hyttinen <juha.hyttinen@nokia.com>
diff --git a/pkg/control/ut_ctrl_submgr_test.go b/pkg/control/ut_ctrl_submgr_test.go
index 3a57177..45147c8 100644
--- a/pkg/control/ut_ctrl_submgr_test.go
+++ b/pkg/control/ut_ctrl_submgr_test.go
@@ -34,9 +34,9 @@
 	c *Control
 }
 
-func createSubmgrControl(rtfile string, port uint16, rtport uint16) *testingSubmgrControl {
+func createSubmgrControl(srcId teststub.RmrSrcId, rtgSvc teststub.RmrRtgSvc) *testingSubmgrControl {
 	mainCtrl = &testingSubmgrControl{}
-	mainCtrl.RmrControl.Init("SUBMGRCTL", rtfile, port, rtport)
+	mainCtrl.RmrControl.Init("SUBMGRCTL", srcId, rtgSvc)
 	mainCtrl.c = NewControl()
 	xapp.SetReadyCB(mainCtrl.ReadyCB, nil)
 	go xapp.RunWithParams(mainCtrl.c, false)
diff --git a/pkg/control/ut_test.go b/pkg/control/ut_test.go
index 05d34b8..b1f9889 100644
--- a/pkg/control/ut_test.go
+++ b/pkg/control/ut_test.go
@@ -23,6 +23,7 @@
 	"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
 	"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststubdummy"
 	"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
+	"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
 	"os"
 	"testing"
 )
@@ -110,77 +111,78 @@
 	//
 	// NOTE3: Ports per entity:
 	//
-	// DataPort Entity
-	// RoutePort (svc) will be DataPort+1
+	// Entity
 	// -------------------
-	// 14560   submgr
-	// 15560   e2term1 stub
-	// 15660   e2term2 stub
-	// 13560   xapp1 stub
-	// 13660   xapp2 stub
-	// 16560   dummy stub
-	//
+
+	mainsrc := teststub.RmrSrcId{xapptweaks.RmrEndpoint{"localhost", 14560}}
+	xapp1src := teststub.RmrSrcId{xapptweaks.RmrEndpoint{"localhost", 13560}}
+	xapp2src := teststub.RmrSrcId{xapptweaks.RmrEndpoint{"localhost", 13660}}
+	e2term1src := teststub.RmrSrcId{xapptweaks.RmrEndpoint{"localhost", 15560}}
+	e2term2src := teststub.RmrSrcId{xapptweaks.RmrEndpoint{"localhost", 15660}}
+	dummysrc := teststub.RmrSrcId{xapptweaks.RmrEndpoint{"localhost", 16560}}
+
 	//---------------------------------
 	rt := &teststub.RmrRouteTable{}
-	rt.AddRoute(12010, "", -1, "localhost:14560")
-	rt.AddRoute(12010, "localhost:14560", -1, "%meid")
-	rt.AddRoute(12011, "localhost:15560", -1, "localhost:14560")
-	rt.AddRoute(12012, "localhost:15560", -1, "localhost:14560")
-	rt.AddRoute(12011, "localhost:15660", -1, "localhost:14560")
-	rt.AddRoute(12012, "localhost:15660", -1, "localhost:14560")
-	rt.AddRoute(12011, "localhost:14560", -1, "localhost:13660;localhost:13560")
-	rt.AddRoute(12012, "localhost:14560", -1, "localhost:13660;localhost:13560")
-	rt.AddRoute(12020, "", -1, "localhost:14560")
-	rt.AddRoute(12020, "localhost:14560", -1, "%meid")
-	rt.AddRoute(12021, "localhost:15560", -1, "localhost:14560")
-	rt.AddRoute(12022, "localhost:15560", -1, "localhost:14560")
-	rt.AddRoute(12021, "localhost:15660", -1, "localhost:14560")
-	rt.AddRoute(12022, "localhost:15660", -1, "localhost:14560")
-	rt.AddRoute(12021, "localhost:14560", -1, "localhost:13660;localhost:13560")
-	rt.AddRoute(12022, "localhost:14560", -1, "localhost:13660;localhost:13560")
-	rt.AddRoute(55555, "", -1, "localhost:13660;localhost:13560;localhost:15560;localhost:15660;localhost:16560")
+	rt.AddRoute(12010, "", -1, mainsrc.String())
+	rt.AddRoute(12010, mainsrc.String(), -1, "%meid")
+	rt.AddRoute(12011, e2term1src.String(), -1, mainsrc.String())
+	rt.AddRoute(12012, e2term1src.String(), -1, mainsrc.String())
+	rt.AddRoute(12011, e2term2src.String(), -1, mainsrc.String())
+	rt.AddRoute(12012, e2term2src.String(), -1, mainsrc.String())
+	rt.AddRoute(12011, mainsrc.String(), -1, xapp2src.String()+";"+xapp1src.String())
+	rt.AddRoute(12012, mainsrc.String(), -1, xapp2src.String()+";"+xapp1src.String())
+	rt.AddRoute(12020, "", -1, mainsrc.String())
+	rt.AddRoute(12020, mainsrc.String(), -1, "%meid")
+	rt.AddRoute(12021, e2term1src.String(), -1, mainsrc.String())
+	rt.AddRoute(12022, e2term1src.String(), -1, mainsrc.String())
+	rt.AddRoute(12021, e2term2src.String(), -1, mainsrc.String())
+	rt.AddRoute(12022, e2term2src.String(), -1, mainsrc.String())
+	rt.AddRoute(12021, mainsrc.String(), -1, xapp2src.String()+";"+xapp1src.String())
+	rt.AddRoute(12022, mainsrc.String(), -1, xapp2src.String()+";"+xapp1src.String())
+	rt.AddRoute(55555, "", -1, xapp2src.String()+";"+xapp1src.String()+";"+e2term1src.String()+";"+e2term2src.String()+";"+dummysrc.String())
 
-	rt.AddMeid("localhost:15560", []string{"RAN_NAME_1", "RAN_NAME_2"})
-	rt.AddMeid("localhost:15660", []string{"RAN_NAME_11", "RAN_NAME_12"})
+	rt.AddMeid(e2term1src.String(), []string{"RAN_NAME_1", "RAN_NAME_2"})
+	rt.AddMeid(e2term2src.String(), []string{"RAN_NAME_11", "RAN_NAME_12"})
 
-	rtfilename, _ := teststub.CreateTmpFile(rt.GetTable())
-	defer os.Remove(rtfilename)
-	tent.Logger.Info("table[%s]", rt.GetTable())
+	rt.Enable()
+	defer rt.Disable()
+	tent.Logger.Info("rttable[%s]", rt.Table())
+
 	//---------------------------------
 	//
 	//---------------------------------
 	tent.Logger.Info("### submgr ctrl run ###")
-	mainCtrl = createSubmgrControl(rtfilename, 14560, 0)
+	mainCtrl = createSubmgrControl(mainsrc, teststub.RmrRtgSvc{})
 
 	//---------------------------------
 	//
 	//---------------------------------
 	tent.Logger.Info("### xapp1 stub run ###")
-	xappConn1 = teststube2ap.CreateNewE2Stub("xappstub1", rtfilename, 13560, 0, "RMRXAPP1STUB", 55555)
+	xappConn1 = teststube2ap.CreateNewE2Stub("xappstub1", xapp1src, teststub.RmrRtgSvc{}, "RMRXAPP1STUB", 55555)
 
 	//---------------------------------
 	//
 	//---------------------------------
 	tent.Logger.Info("### xapp2 stub run ###")
-	xappConn2 = teststube2ap.CreateNewE2Stub("xappstub2", rtfilename, 13660, 0, "RMRXAPP2STUB", 55555)
+	xappConn2 = teststube2ap.CreateNewE2Stub("xappstub2", xapp2src, teststub.RmrRtgSvc{}, "RMRXAPP2STUB", 55555)
 
 	//---------------------------------
 	//
 	//---------------------------------
 	tent.Logger.Info("### e2term1 stub run ###")
-	e2termConn1 = teststube2ap.CreateNewE2termStub("e2termstub1", rtfilename, 15560, 0, "RMRE2TERMSTUB1", 55555)
+	e2termConn1 = teststube2ap.CreateNewE2termStub("e2termstub1", e2term1src, teststub.RmrRtgSvc{}, "RMRE2TERMSTUB1", 55555)
 
 	//---------------------------------
 	//
 	//---------------------------------
 	tent.Logger.Info("### e2term2 stub run ###")
-	e2termConn2 = teststube2ap.CreateNewE2termStub("e2termstub2", rtfilename, 15660, 0, "RMRE2TERMSTUB2", 55555)
+	e2termConn2 = teststube2ap.CreateNewE2termStub("e2termstub2", e2term2src, teststub.RmrRtgSvc{}, "RMRE2TERMSTUB2", 55555)
 
 	//---------------------------------
 	// Just to test dummy stub
 	//---------------------------------
 	tent.Logger.Info("### dummy stub run ###")
-	dummystub = teststubdummy.CreateNewRmrDummyStub("dummystub", rtfilename, 16560, 0, "DUMMYSTUB", 55555)
+	dummystub = teststubdummy.CreateNewRmrDummyStub("dummystub", dummysrc, teststub.RmrRtgSvc{}, "DUMMYSTUB", 55555)
 
 	//---------------------------------
 	// Testing message sending
diff --git a/pkg/teststub/controlRmr.go b/pkg/teststub/controlRmr.go
index 41a6606..18b821e 100644
--- a/pkg/teststub/controlRmr.go
+++ b/pkg/teststub/controlRmr.go
@@ -20,9 +20,6 @@
 
 import (
 	"fmt"
-	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
-	"os"
-	"strconv"
 	"testing"
 )
 
@@ -31,9 +28,9 @@
 //-----------------------------------------------------------------------------
 type RmrControl struct {
 	TestWrapper
-	syncChan  chan struct{}
-	DataPort  uint16
-	RoutePort uint16
+	RmrSrcId
+	RmrRtgSvc
+	syncChan chan struct{}
 }
 
 func (tc *RmrControl) ReadyCB(data interface{}) {
@@ -45,20 +42,15 @@
 	<-tc.syncChan
 }
 
-func (tc *RmrControl) Init(desc string, rtfile string, port uint16, rtport uint16) {
+func (tc *RmrControl) Init(desc string, srcId RmrSrcId, rtgSvc RmrRtgSvc) {
 	tc.TestWrapper.Init(desc)
-	tc.DataPort = port
-	tc.RoutePort = rtport
-	os.Setenv("RMR_SEED_RT", rtfile)
-	xapp.Logger.Info("Using rt file %s", os.Getenv("RMR_SEED_RT"))
-	if tc.DataPort > 0 {
-		os.Setenv("RMR_SRC_ID", "localhost:"+strconv.FormatUint(uint64(tc.DataPort), 10))
-		xapp.Logger.Info("Using src id  %s", os.Getenv("RMR_SRC_ID"))
-	}
-	if tc.RoutePort > 0 {
-		os.Setenv("RMR_RTG_SVC", "localhost:"+strconv.FormatUint(uint64(tc.RoutePort), 10))
-		xapp.Logger.Info("Using rtg svc  %s", os.Getenv("RMR_RTG_SVC"))
-	}
+
+	tc.RmrSrcId = srcId
+	tc.RmrSrcId.Enable()
+
+	tc.RmrRtgSvc = rtgSvc
+	tc.RmrRtgSvc.Enable()
+
 	tc.syncChan = make(chan struct{})
 }
 
diff --git a/pkg/teststub/controlRmrStub.go b/pkg/teststub/controlRmrStub.go
index f14bd1f..0f207e8 100644
--- a/pkg/teststub/controlRmrStub.go
+++ b/pkg/teststub/controlRmrStub.go
@@ -68,14 +68,14 @@
 	}
 }
 
-func (tc *RmrStubControl) Init(desc string, rtfile string, port uint16, rtport uint16, stat string, initMsg int) {
+func (tc *RmrStubControl) Init(desc string, srcId RmrSrcId, rtgSvc RmrRtgSvc, stat string, initMsg int) {
 	tc.InitMsg = initMsg
 	tc.Active = false
 	tc.RecvChan = make(chan *xapptweaks.RMRParams)
-	tc.RmrControl.Init(desc, rtfile, port, rtport)
+	tc.RmrControl.Init(desc, srcId, rtgSvc)
 	tc.RmrWrapper.Init()
 
-	tc.Rmr = xapp.NewRMRClientWithParams("tcp:"+strconv.FormatUint(uint64(port), 10), 65534, 1, 0, stat)
+	tc.Rmr = xapp.NewRMRClientWithParams("tcp:"+strconv.FormatUint(uint64(srcId.Port), 10), 65534, 1, 0, stat)
 	tc.Rmr.SetReadyCB(tc.ReadyCB, nil)
 	go tc.Rmr.Start(tc)
 
diff --git a/pkg/teststub/rmrenv.go b/pkg/teststub/rmrenv.go
new file mode 100644
index 0000000..5a57b56
--- /dev/null
+++ b/pkg/teststub/rmrenv.go
@@ -0,0 +1,148 @@
+/*
+==================================================================================
+  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 teststub
+
+import (
+	"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
+	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+	"os"
+	"strconv"
+)
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+
+type RmrRouteTable struct {
+	tmpfile string
+	routes  []string
+	meids   []string
+}
+
+func (rrt *RmrRouteTable) AddRoute(mtype int, src string, subid int, trg string) {
+
+	line := "mse|"
+	line += strconv.FormatInt(int64(mtype), 10)
+	if len(src) > 0 {
+		line += "," + src
+	}
+	line += "|"
+	line += strconv.FormatInt(int64(subid), 10)
+	line += "|"
+	line += trg
+	rrt.routes = append(rrt.routes, line)
+}
+
+func (rrt *RmrRouteTable) AddMeid(trg string, meids []string) {
+
+	line := "mme_ar"
+	line += "|"
+	line += trg
+	line += "|"
+	for _, str := range meids {
+		line += " " + str
+	}
+	rrt.meids = append(rrt.meids, line)
+}
+
+func (rrt *RmrRouteTable) DelMeid(meids []string) {
+
+	line := "mme_del"
+	line += "|"
+	for _, str := range meids {
+		line += " " + str
+	}
+	rrt.meids = append(rrt.meids, line)
+}
+
+func (rrt *RmrRouteTable) FileName() string {
+	return rrt.tmpfile
+}
+
+func (rrt *RmrRouteTable) Table() string {
+	allrt := "newrt|start\n"
+	for _, val := range rrt.routes {
+		allrt += val + "\n"
+	}
+	allrt += "newrt|end\n"
+	allrt += "meid_map | start\n"
+	for _, val := range rrt.meids {
+		allrt += val + "\n"
+	}
+	allrt += "meid_map | end | " + strconv.FormatInt(int64(len(rrt.meids)), 10) + "\n"
+	return allrt
+}
+
+func (rrt *RmrRouteTable) Enable() {
+	if len(rrt.tmpfile) > 0 {
+		os.Remove(rrt.tmpfile)
+	}
+	rrt.tmpfile, _ = CreateTmpFile(rrt.Table())
+	os.Setenv("RMR_SEED_RT", rrt.tmpfile)
+	xapp.Logger.Info("Using rt file %s", os.Getenv("RMR_SEED_RT"))
+}
+
+func (rrt *RmrRouteTable) Disable() {
+	if len(rrt.tmpfile) > 0 {
+		os.Remove(rrt.tmpfile)
+		os.Unsetenv("RMR_SEED_RT")
+		rrt.tmpfile = ""
+		xapp.Logger.Info("Not using rt file ")
+	}
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+
+type RmrSrcId struct {
+	xapptweaks.RmrEndpoint
+}
+
+func (rsi *RmrSrcId) Enable() {
+	if rsi.Port > 0 {
+		os.Setenv("RMR_SRC_ID", rsi.String())
+		xapp.Logger.Info("Using src id  %s", os.Getenv("RMR_SRC_ID"))
+	}
+}
+
+func (rsi *RmrSrcId) Disable() {
+	os.Unsetenv("RMR_SRC_ID")
+	xapp.Logger.Info("Not using Using src id")
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type RmrRtgSvc struct {
+	xapptweaks.RmrEndpoint
+}
+
+func (rrs *RmrRtgSvc) Enable() {
+	if rrs.Port > 0 {
+		os.Setenv("RMR_RTG_SVC", rrs.String())
+		xapp.Logger.Info("Using rtg svc  %s", os.Getenv("RMR_SRC_ID"))
+	}
+}
+
+func (rrs *RmrRtgSvc) Disable() {
+	os.Unsetenv("RMR_RTG_SVC")
+	xapp.Logger.Info("Not using Using rtg svc")
+}
diff --git a/pkg/teststub/rmrroutetable.go b/pkg/teststub/rmrroutetable.go
deleted file mode 100644
index 281110c..0000000
--- a/pkg/teststub/rmrroutetable.go
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-==================================================================================
-  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 teststub
-
-import (
-	"strconv"
-)
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-
-type RmrRouteTable struct {
-	routes []string
-	meids  []string
-}
-
-func (rrt *RmrRouteTable) AddRoute(mtype int, src string, subid int, trg string) {
-
-	line := "mse|"
-	line += strconv.FormatInt(int64(mtype), 10)
-	if len(src) > 0 {
-		line += "," + src
-	}
-	line += "|"
-	line += strconv.FormatInt(int64(subid), 10)
-	line += "|"
-	line += trg
-	rrt.routes = append(rrt.routes, line)
-}
-
-func (rrt *RmrRouteTable) AddMeid(trg string, meids []string) {
-
-	line := "mme_ar"
-	line += "|"
-	line += trg
-	line += "|"
-	for _, str := range meids {
-		line += " " + str
-	}
-	rrt.meids = append(rrt.meids, line)
-}
-
-func (rrt *RmrRouteTable) DelMeid(meids []string) {
-
-	line := "mme_del"
-	line += "|"
-	for _, str := range meids {
-		line += " " + str
-	}
-	rrt.meids = append(rrt.meids, line)
-}
-
-func (rrt *RmrRouteTable) GetTable() string {
-	allrt := "newrt|start\n"
-	for _, val := range rrt.routes {
-		allrt += val + "\n"
-	}
-	allrt += "newrt|end\n"
-	allrt += "meid_map | start\n"
-	for _, val := range rrt.meids {
-		allrt += val + "\n"
-	}
-	allrt += "meid_map | end | " + strconv.FormatInt(int64(len(rrt.meids)), 10) + "\n"
-	return allrt
-}
diff --git a/pkg/teststubdummy/stubRmrDummy.go b/pkg/teststubdummy/stubRmrDummy.go
index c4745ba..b3b4352 100644
--- a/pkg/teststubdummy/stubRmrDummy.go
+++ b/pkg/teststubdummy/stubRmrDummy.go
@@ -42,9 +42,9 @@
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-func CreateNewRmrDummyStub(desc string, rtfile string, port uint16, rtport uint16, stat string, mtypeseed int) *RmrDummyStub {
+func CreateNewRmrDummyStub(desc string, srcId teststub.RmrSrcId, rtgSvc teststub.RmrRtgSvc, stat string, mtypeseed int) *RmrDummyStub {
 	dummyStub := &RmrDummyStub{}
-	dummyStub.RmrStubControl.Init(desc, rtfile, port, rtport, stat, mtypeseed)
+	dummyStub.RmrStubControl.Init(desc, srcId, rtgSvc, stat, mtypeseed)
 	dummyStub.reqMsg = mtypeseed + 1
 	dummyStub.respMsg = mtypeseed + 2
 	return dummyStub
@@ -54,14 +54,18 @@
 //
 //-----------------------------------------------------------------------------
 
-func (tc *RmrDummyStub) SendReq(t *testing.T) {
+func (tc *RmrDummyStub) SendReq(t *testing.T, plen int) {
 	tc.Logger.Info("SendReq")
-	var dummyBuf []byte = make([]byte, 100)
+	len := plen
+	if len == 0 {
+		len = 100
+	}
 	params := xapptweaks.NewParams(nil)
 	params.Mtype = tc.reqMsg
 	params.SubId = -1
-	params.Payload = dummyBuf
-	params.PayloadLen = 100
+
+	params.Payload = make([]byte, len)
+	params.PayloadLen = 0
 	params.Meid = &xapp.RMRMeid{RanName: "TEST"}
 	params.Xid = "TEST"
 	params.Mbuf = nil
@@ -73,6 +77,44 @@
 	return
 }
 
+func (tc *RmrDummyStub) SendResp(t *testing.T, plen int) {
+	tc.Logger.Info("SendReq")
+	len := plen
+	if len == 0 {
+		len = 100
+	}
+	params := xapptweaks.NewParams(nil)
+	params.Mtype = tc.respMsg
+	params.SubId = -1
+	params.Payload = make([]byte, len)
+	params.PayloadLen = 0
+	params.Meid = &xapp.RMRMeid{RanName: "TEST"}
+	params.Xid = "TEST"
+	params.Mbuf = nil
+
+	snderr := tc.RmrSend(params, 5)
+	if snderr != nil {
+		tc.TestError(t, "%s", snderr.Error())
+	}
+	return
+}
+
+func (tc *RmrDummyStub) RecvReq(t *testing.T) bool {
+	tc.Logger.Info("RecvReq")
+
+	msg := tc.WaitMsg(15)
+	if msg != nil {
+		if msg.Mtype != tc.reqMsg {
+			tc.TestError(t, "Received wrong mtype expected %d got %d, error", tc.reqMsg, msg.Mtype)
+			return false
+		}
+		return true
+	} else {
+		tc.TestError(t, "Not Received msg within %d secs", 15)
+	}
+	return false
+}
+
 func (tc *RmrDummyStub) RecvResp(t *testing.T) bool {
 	tc.Logger.Info("RecvResp")
 
@@ -88,27 +130,3 @@
 	}
 	return false
 }
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-func RmrDummyHandleMessage(msg *xapptweaks.RMRParams, mtypeseed int, rmr xapptweaks.XAppWrapperIf) (bool, error) {
-	if msg.Mtype == mtypeseed+1 {
-		var dummyBuf []byte = make([]byte, 100)
-		params := xapptweaks.NewParams(nil)
-		params.Mtype = mtypeseed + 2
-		params.SubId = msg.SubId
-		params.Payload = dummyBuf
-		params.PayloadLen = 100
-		params.Meid = msg.Meid
-		params.Xid = msg.Xid
-		params.Mbuf = nil
-		rmr.GetLogger().Info("SEND DUMMY RESP: %s", params.String())
-		err := rmr.RmrSend(params, 5)
-		if err != nil {
-			rmr.GetLogger().Error("RmrDummyHandleMessage: err(%s)", err.Error())
-		}
-		return true, err
-	}
-	return false, nil
-}
diff --git a/pkg/teststube2ap/stubE2.go b/pkg/teststube2ap/stubE2.go
index c99df73..5804f74 100644
--- a/pkg/teststube2ap/stubE2.go
+++ b/pkg/teststube2ap/stubE2.go
@@ -54,9 +54,9 @@
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-func CreateNewE2Stub(desc string, rtfile string, port uint16, rtport uint16, stat string, mtypeseed int) *E2Stub {
+func CreateNewE2Stub(desc string, srcId teststub.RmrSrcId, rtgSvc teststub.RmrRtgSvc, stat string, mtypeseed int) *E2Stub {
 	tc := &E2Stub{}
-	tc.RmrStubControl.Init(desc, rtfile, port, rtport, stat, mtypeseed)
+	tc.RmrStubControl.Init(desc, srcId, rtgSvc, stat, mtypeseed)
 	tc.xid_seq = 1
 	tc.SetCheckXid(true)
 	return tc
@@ -65,9 +65,9 @@
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-func CreateNewE2termStub(desc string, rtfile string, port uint16, rtport uint16, stat string, mtypeseed int) *E2Stub {
+func CreateNewE2termStub(desc string, srcId teststub.RmrSrcId, rtgSvc teststub.RmrRtgSvc, stat string, mtypeseed int) *E2Stub {
 	tc := &E2Stub{}
-	tc.RmrStubControl.Init(desc, rtfile, port, rtport, stat, mtypeseed)
+	tc.RmrStubControl.Init(desc, srcId, rtgSvc, stat, mtypeseed)
 	tc.xid_seq = 1
 	tc.SetCheckXid(false)
 	return tc