Generalized unittest stubs so frame can be used also in other apps

Change-Id: I1d2acc8ee50184d61c4eb24fb5c76e0927203c99
Signed-off-by: Juha Hyttinen <juha.hyttinen@nokia.com>
diff --git a/Dockerfile b/Dockerfile
index 969abcb..057f4e8 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -128,6 +128,10 @@
 
 # test formating (not important)
 RUN test -z "$(/usr/local/go/bin/gofmt -l pkg/control/*.go)"
+RUN test -z "$(/usr/local/go/bin/gofmt -l pkg/teststub/*.go)"
+RUN test -z "$(/usr/local/go/bin/gofmt -l pkg/teststubdummy/*.go)"
+RUN test -z "$(/usr/local/go/bin/gofmt -l pkg/teststube2ap/*.go)"
+RUN test -z "$(/usr/local/go/bin/gofmt -l pkg/xapptweaks/*.go)"
 
 
 #
diff --git a/container-tag.yaml b/container-tag.yaml
index a67cace..b67c429 100644
--- a/container-tag.yaml
+++ b/container-tag.yaml
@@ -2,4 +2,4 @@
 # By default this file is in the docker build directory,
 # but the location can configured in the JJB template.
 ---
-tag: 0.13.0
+tag: "4.0.0.1"
diff --git a/go.sum b/go.sum
index 1edade9..2666194 100644
--- a/go.sum
+++ b/go.sum
@@ -9,10 +9,9 @@
 gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.21/go.mod h1:SQBZLy1HP94i1vQ3y730wGFsrHqZtgPaEkzPgtqBNw0=
 gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.2.0 h1:7edCLIQtk9xCwxTtLRUlXr8wQ6nmr/Mo4ZoqjF3m0NE=
 gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.2.0/go.mod h1:2Y8gw2jqj9urI8VFqFQn7BX0J3A852+YrXVV9V8gOt4=
-gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.0.20 h1:qf/oWdgXq5iCB38rHO/NfHgD21DOGpKELPgkmvpDExA=
-gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.0.20/go.mod h1:WHzMFLWFYnKZzAT76Lu8wXqcM9MQ9hHM0sxlV45icSw=
 gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.0.23 h1:T8Q6dtYFsTXg60Xyz4GhsmEHsi9TdPbgc44caQpVgXY=
 gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.0.23/go.mod h1:WHzMFLWFYnKZzAT76Lu8wXqcM9MQ9hHM0sxlV45icSw=
+github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
 github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
@@ -121,6 +120,7 @@
 github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
 github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
 github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
 github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/gorilla/mux v1.7.1 h1:Dw4jY2nghMMRsh1ol8dv1axHkDwMQK2DHerMNJsIpJU=
 github.com/gorilla/mux v1.7.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
@@ -130,6 +130,7 @@
 github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
 github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
 github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
+github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
 github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
 github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
@@ -137,9 +138,11 @@
 github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
 github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
+github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
 github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
 github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
 github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
+github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
 github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
 github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
 github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
@@ -157,12 +160,15 @@
 github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
 github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w=
 github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo=
 github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
 github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
 github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
 github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
 github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
 github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -205,6 +211,7 @@
 github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
 github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
 github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
+github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
 github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
 github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
 github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
@@ -267,9 +274,12 @@
 google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
 gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
 gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
 gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
 gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
 gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/pkg/control/control.go b/pkg/control/control.go
index 1d64f3c..1103727 100755
--- a/pkg/control/control.go
+++ b/pkg/control/control.go
@@ -23,11 +23,11 @@
 	"fmt"
 	"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
 	rtmgrclient "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client"
+	"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
 	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
 	httptransport "github.com/go-openapi/runtime/client"
 	"github.com/go-openapi/strfmt"
 	"github.com/spf13/viper"
-	"sync"
 	"time"
 )
 
@@ -35,6 +35,25 @@
 //
 //-----------------------------------------------------------------------------
 
+func idstring(err error, entries ...fmt.Stringer) string {
+	var retval string = ""
+	var filler string = ""
+	for _, entry := range entries {
+		retval += filler + entry.String()
+		filler = " "
+	}
+	if err != nil {
+		retval += filler + "err(" + err.Error() + ")"
+		filler = " "
+
+	}
+	return retval
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+
 var e2tSubReqTimeout time.Duration = 5 * time.Second
 var e2tSubDelReqTime time.Duration = 5 * time.Second
 var e2tMaxSubReqTryCount uint64 = 2    // Initial try + retry
@@ -43,12 +62,11 @@
 var e2tRecvMsgTimeout time.Duration = 5 * time.Second
 
 type Control struct {
-	e2ap         *E2ap
-	registry     *Registry
-	tracker      *Tracker
-	timerMap     *TimerMap
-	rmrSendMutex sync.Mutex
-	msgCounter   uint64
+	xapptweaks.XappWrapper
+	e2ap     *E2ap
+	registry *Registry
+	tracker  *Tracker
+	timerMap *TimerMap
 }
 
 type RMRMeid struct {
@@ -79,42 +97,28 @@
 	timerMap := new(TimerMap)
 	timerMap.Init()
 
-	return &Control{e2ap: new(E2ap),
-		registry:   registry,
-		tracker:    tracker,
-		timerMap:   timerMap,
-		msgCounter: 0,
+	c := &Control{e2ap: new(E2ap),
+		registry: registry,
+		tracker:  tracker,
+		timerMap: timerMap,
+	}
+	c.XappWrapper.Init("")
+	return c
+}
+
+func (c *Control) ReadyCB(data interface{}) {
+	if c.Rmr == nil {
+		c.Rmr = xapp.Rmr
 	}
 }
 
 func (c *Control) Run() {
+	xapp.SetReadyCB(c.ReadyCB, nil)
 	xapp.Run(c)
 }
 
-func (c *Control) rmrSendRaw(desc string, params *RMRParams) (err error) {
-
-	xapp.Logger.Info("%s: %s", desc, params.String())
-	status := false
-	i := 1
-	for ; i <= 10 && status == false; i++ {
-		c.rmrSendMutex.Lock()
-		status = xapp.Rmr.Send(params.RMRParams, false)
-		c.rmrSendMutex.Unlock()
-		if status == false {
-			xapp.Logger.Info("rmr.Send() failed. Retry count %d, %s", i, params.String())
-			time.Sleep(500 * time.Millisecond)
-		}
-	}
-	if status == false {
-		err = fmt.Errorf("rmr.Send() failed. Retry count %d, %s", i, params.String())
-		xapp.Logger.Error("%s: %s", desc, err.Error())
-		xapp.Rmr.Free(params.Mbuf)
-	}
-	return
-}
-
 func (c *Control) rmrSendToE2T(desc string, subs *Subscription, trans *TransactionSubs) (err error) {
-	params := &RMRParams{&xapp.RMRParams{}}
+	params := xapptweaks.NewParams(nil)
 	params.Mtype = trans.GetMtype()
 	params.SubId = int(subs.GetReqId().Seq)
 	params.Xid = ""
@@ -123,13 +127,13 @@
 	params.PayloadLen = len(trans.Payload.Buf)
 	params.Payload = trans.Payload.Buf
 	params.Mbuf = nil
-
-	return c.rmrSendRaw("MSG to E2T:"+desc+":"+trans.String(), params)
+	xapp.Logger.Info("MSG to E2T: %s %s %s", desc, trans.String(), params.String())
+	return c.RmrSend(params)
 }
 
 func (c *Control) rmrSendToXapp(desc string, subs *Subscription, trans *TransactionXapp) (err error) {
 
-	params := &RMRParams{&xapp.RMRParams{}}
+	params := xapptweaks.NewParams(nil)
 	params.Mtype = trans.GetMtype()
 	params.SubId = int(subs.GetReqId().Seq)
 	params.Xid = trans.GetXid()
@@ -138,15 +142,20 @@
 	params.PayloadLen = len(trans.Payload.Buf)
 	params.Payload = trans.Payload.Buf
 	params.Mbuf = nil
-
-	return c.rmrSendRaw("MSG to XAPP:"+desc+":"+trans.String(), params)
+	xapp.Logger.Info("MSG to XAPP: %s %s %s", desc, trans.String(), params.String())
+	return c.RmrSend(params)
 }
 
 func (c *Control) Consume(params *xapp.RMRParams) (err error) {
-	xapp.Rmr.Free(params.Mbuf)
-	params.Mbuf = nil
-	msg := &RMRParams{params}
-	c.msgCounter++
+	msg := xapptweaks.NewParams(params)
+	if c.Rmr == nil {
+		err = fmt.Errorf("Rmr object nil can handle %s", msg.String())
+		xapp.Logger.Error("%s", err.Error())
+		return
+	}
+	c.CntRecvMsg++
+
+	defer c.Rmr.Free(msg.Mbuf)
 
 	switch msg.Mtype {
 	case xapp.RICMessageTypes["RIC_SUB_REQ"]:
@@ -164,29 +173,13 @@
 	default:
 		xapp.Logger.Info("Unknown Message Type '%d', discarding", msg.Mtype)
 	}
-
-	return nil
-}
-
-func idstring(err error, entries ...fmt.Stringer) string {
-	var retval string = ""
-	var filler string = ""
-	for _, entry := range entries {
-		retval += filler + entry.String()
-		filler = " "
-	}
-	if err != nil {
-		retval += filler + "err(" + err.Error() + ")"
-		filler = " "
-
-	}
-	return retval
+	return
 }
 
 //-------------------------------------------------------------------
 // handle from XAPP Subscription Request
 //------------------------------------------------------------------
-func (c *Control) handleXAPPSubscriptionRequest(params *RMRParams) {
+func (c *Control) handleXAPPSubscriptionRequest(params *xapptweaks.RMRParams) {
 	xapp.Logger.Info("MSG from XAPP: %s", params.String())
 
 	subReqMsg, err := c.e2ap.UnpackSubscriptionRequest(params.Payload)
@@ -245,7 +238,7 @@
 //-------------------------------------------------------------------
 // handle from XAPP Subscription Delete Request
 //------------------------------------------------------------------
-func (c *Control) handleXAPPSubscriptionDeleteRequest(params *RMRParams) {
+func (c *Control) handleXAPPSubscriptionDeleteRequest(params *xapptweaks.RMRParams) {
 	xapp.Logger.Info("MSG from XAPP: %s", params.String())
 
 	subDelReqMsg, err := c.e2ap.UnpackSubscriptionDeleteRequest(params.Payload)
@@ -417,7 +410,7 @@
 //-------------------------------------------------------------------
 // handle from E2T Subscription Reponse
 //-------------------------------------------------------------------
-func (c *Control) handleE2TSubscriptionResponse(params *RMRParams) {
+func (c *Control) handleE2TSubscriptionResponse(params *xapptweaks.RMRParams) {
 	xapp.Logger.Info("MSG from E2T: %s", params.String())
 	subRespMsg, err := c.e2ap.UnpackSubscriptionResponse(params.Payload)
 	if err != nil {
@@ -446,7 +439,7 @@
 //-------------------------------------------------------------------
 // handle from E2T Subscription Failure
 //-------------------------------------------------------------------
-func (c *Control) handleE2TSubscriptionFailure(params *RMRParams) {
+func (c *Control) handleE2TSubscriptionFailure(params *xapptweaks.RMRParams) {
 	xapp.Logger.Info("MSG from E2T: %s", params.String())
 	subFailMsg, err := c.e2ap.UnpackSubscriptionFailure(params.Payload)
 	if err != nil {
@@ -475,7 +468,7 @@
 //-------------------------------------------------------------------
 // handle from E2T Subscription Delete Response
 //-------------------------------------------------------------------
-func (c *Control) handleE2TSubscriptionDeleteResponse(params *RMRParams) (err error) {
+func (c *Control) handleE2TSubscriptionDeleteResponse(params *xapptweaks.RMRParams) (err error) {
 	xapp.Logger.Info("MSG from E2T: %s", params.String())
 	subDelRespMsg, err := c.e2ap.UnpackSubscriptionDeleteResponse(params.Payload)
 	if err != nil {
@@ -504,7 +497,7 @@
 //-------------------------------------------------------------------
 // handle from E2T Subscription Delete Failure
 //-------------------------------------------------------------------
-func (c *Control) handleE2TSubscriptionDeleteFailure(params *RMRParams) {
+func (c *Control) handleE2TSubscriptionDeleteFailure(params *xapptweaks.RMRParams) {
 	xapp.Logger.Info("MSG from E2T: %s", params.String())
 	subDelFailMsg, err := c.e2ap.UnpackSubscriptionDeleteFailure(params.Payload)
 	if err != nil {
diff --git a/pkg/control/types.go b/pkg/control/types.go
index 4d318e0..ab62153 100644
--- a/pkg/control/types.go
+++ b/pkg/control/types.go
@@ -20,10 +20,7 @@
 package control
 
 import (
-	"bytes"
-	"fmt"
 	"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
-	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
 	"strconv"
 	"strings"
 )
@@ -149,16 +146,3 @@
 	}
 	return ep
 }
-
-//-----------------------------------------------------------------------------
-// To add own method for rmrparams
-//-----------------------------------------------------------------------------
-type RMRParams struct {
-	*xapp.RMRParams
-}
-
-func (params *RMRParams) String() string {
-	var b bytes.Buffer
-	fmt.Fprintf(&b, "params(Src=%s Mtype=%s(%d) SubId=%v Xid=%s Meid=%s)", params.Src, xapp.RicMessageTypeToName[params.Mtype], params.Mtype, params.SubId, params.Xid, params.Meid.RanName)
-	return b.String()
-}
diff --git a/pkg/control/types_test.go b/pkg/control/types_test.go
index 5e1cfac..424021b 100644
--- a/pkg/control/types_test.go
+++ b/pkg/control/types_test.go
@@ -20,11 +20,14 @@
 package control
 
 import (
+	"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
 	"testing"
 )
 
 func TestRmrEndpoint(t *testing.T) {
 
+	tent := teststub.NewTestWrapper("TestRmrEndpoint")
+
 	testEp := func(t *testing.T, val string, expect *RmrEndpoint) {
 		res := NewRmrEndpoint(val)
 
@@ -32,14 +35,14 @@
 			return
 		}
 		if res == nil {
-			testError(t, "Endpoint elems for value %s expected addr %s port %d got nil", val, expect.GetAddr(), expect.GetPort())
+			tent.TestError(t, "Endpoint elems for value %s expected addr %s port %d got nil", val, expect.GetAddr(), expect.GetPort())
 			return
 		}
 		if expect.GetAddr() != res.GetAddr() || expect.GetPort() != res.GetPort() {
-			testError(t, "Endpoint elems for value %s expected addr %s port %d got addr %s port %d", val, expect.GetAddr(), expect.GetPort(), res.GetAddr(), res.GetPort())
+			tent.TestError(t, "Endpoint elems for value %s expected addr %s port %d got addr %s port %d", val, expect.GetAddr(), expect.GetPort(), res.GetAddr(), res.GetPort())
 		}
 		if expect.String() != res.String() {
-			testError(t, "Endpoint string for value %s expected %s got %s", val, expect.String(), res.String())
+			tent.TestError(t, "Endpoint string for value %s expected %s got %s", val, expect.String(), res.String())
 		}
 
 	}
@@ -53,70 +56,73 @@
 }
 
 func TestRmrEndpointList(t *testing.T) {
+
+	tent := teststub.NewTestWrapper("TestRmrEndpointList")
+
 	epl := &RmrEndpointList{}
 
 	// Simple add / has / delete
 	if epl.AddEndpoint(NewRmrEndpoint("127.0.0.1:8080")) == false {
-		testError(t, "RmrEndpointList: 8080 add failed")
+		tent.TestError(t, "RmrEndpointList: 8080 add failed")
 	}
 	if epl.AddEndpoint(NewRmrEndpoint("127.0.0.1:8080")) == true {
-		testError(t, "RmrEndpointList: 8080 duplicate add success")
+		tent.TestError(t, "RmrEndpointList: 8080 duplicate add success")
 	}
 	if epl.AddEndpoint(NewRmrEndpoint("127.0.0.1:8081")) == false {
-		testError(t, "RmrEndpointList: 8081 add failed")
+		tent.TestError(t, "RmrEndpointList: 8081 add failed")
 	}
 	if epl.HasEndpoint(NewRmrEndpoint("127.0.0.1:8081")) == false {
-		testError(t, "RmrEndpointList: 8081 has failed")
+		tent.TestError(t, "RmrEndpointList: 8081 has failed")
 	}
 	if epl.DelEndpoint(NewRmrEndpoint("127.0.0.1:8081")) == false {
-		testError(t, "RmrEndpointList: 8081 del failed")
+		tent.TestError(t, "RmrEndpointList: 8081 del failed")
 	}
 	if epl.HasEndpoint(NewRmrEndpoint("127.0.0.1:8081")) == true {
-		testError(t, "RmrEndpointList: 8081 has non existing success")
+		tent.TestError(t, "RmrEndpointList: 8081 has non existing success")
 	}
 	if epl.DelEndpoint(NewRmrEndpoint("127.0.0.1:8081")) == true {
-		testError(t, "RmrEndpointList: 8081 del non existing success")
+		tent.TestError(t, "RmrEndpointList: 8081 del non existing success")
 	}
 	if epl.DelEndpoint(NewRmrEndpoint("127.0.0.1:8080")) == false {
-		testError(t, "RmrEndpointList: 8080 del failed")
+		tent.TestError(t, "RmrEndpointList: 8080 del failed")
 	}
 
 	// list delete
 	if epl.AddEndpoint(NewRmrEndpoint("127.0.0.1:8080")) == false {
-		testError(t, "RmrEndpointList: 8080 add failed")
+		tent.TestError(t, "RmrEndpointList: 8080 add failed")
 	}
 	if epl.AddEndpoint(NewRmrEndpoint("127.0.0.1:8081")) == false {
-		testError(t, "RmrEndpointList: 8081 add failed")
+		tent.TestError(t, "RmrEndpointList: 8081 add failed")
 	}
 	if epl.AddEndpoint(NewRmrEndpoint("127.0.0.1:8082")) == false {
-		testError(t, "RmrEndpointList: 8082 add failed")
+		tent.TestError(t, "RmrEndpointList: 8082 add failed")
 	}
 
 	epl2 := &RmrEndpointList{}
 	if epl2.AddEndpoint(NewRmrEndpoint("127.0.0.1:9080")) == false {
-		testError(t, "RmrEndpointList: othlist add 9080 failed")
+		tent.TestError(t, "RmrEndpointList: othlist add 9080 failed")
 	}
 
 	if epl.DelEndpoints(epl2) == true {
-		testError(t, "RmrEndpointList: delete list not existing successs")
+		tent.TestError(t, "RmrEndpointList: delete list not existing successs")
 	}
 
 	if epl2.AddEndpoint(NewRmrEndpoint("127.0.0.1:8080")) == false {
-		testError(t, "RmrEndpointList: othlist add 8080 failed")
+		tent.TestError(t, "RmrEndpointList: othlist add 8080 failed")
 	}
 	if epl.DelEndpoints(epl2) == false {
-		testError(t, "RmrEndpointList: delete list 8080,9080 failed")
+		tent.TestError(t, "RmrEndpointList: delete list 8080,9080 failed")
 	}
 
 	if epl2.AddEndpoint(NewRmrEndpoint("127.0.0.1:8081")) == false {
-		testError(t, "RmrEndpointList: othlist add 8081 failed")
+		tent.TestError(t, "RmrEndpointList: othlist add 8081 failed")
 	}
 	if epl2.AddEndpoint(NewRmrEndpoint("127.0.0.1:8082")) == false {
-		testError(t, "RmrEndpointList: othlist add 8082 failed")
+		tent.TestError(t, "RmrEndpointList: othlist add 8082 failed")
 	}
 
 	if epl.DelEndpoints(epl2) == false {
-		testError(t, "RmrEndpointList: delete list 8080,8081,8082,9080 failed")
+		tent.TestError(t, "RmrEndpointList: delete list 8080,8081,8082,9080 failed")
 	}
 
 }
diff --git a/pkg/control/ut_ctrl_submgr_test.go b/pkg/control/ut_ctrl_submgr_test.go
index 16da422..9fb852a 100644
--- a/pkg/control/ut_ctrl_submgr_test.go
+++ b/pkg/control/ut_ctrl_submgr_test.go
@@ -20,6 +20,7 @@
 package control
 
 import (
+	"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
 	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
 	"testing"
 	"time"
@@ -29,17 +30,18 @@
 //
 //-----------------------------------------------------------------------------
 type testingSubmgrControl struct {
-	testingRmrControl
+	teststub.RmrControl
 	c *Control
 }
 
-func createSubmgrControl(desc string, rtfile string, port string) *testingSubmgrControl {
+func createSubmgrControl(rtfile string, port string) *testingSubmgrControl {
 	mainCtrl = &testingSubmgrControl{}
-	mainCtrl.testingRmrControl.init(desc, rtfile, port)
+	mainCtrl.RmrControl.Init("SUBMGRCTL", rtfile, port)
 	mainCtrl.c = NewControl()
 	xapp.SetReadyCB(mainCtrl.ReadyCB, nil)
 	go xapp.RunWithParams(mainCtrl.c, false)
 	mainCtrl.WaitCB()
+	mainCtrl.c.ReadyCB(nil)
 	return mainCtrl
 }
 
@@ -53,7 +55,7 @@
 		}
 		time.Sleep(500 * time.Millisecond)
 	}
-	testError(t, "(general) no registry empty within %d secs: %d", secs, cnt)
+	mc.TestError(t, "(submgr) no registry empty within %d secs: %d", secs, cnt)
 	return false
 }
 
@@ -68,9 +70,9 @@
 		time.Sleep(500 * time.Millisecond)
 	}
 	if subs != nil {
-		testError(t, "(general) no clean within %d secs: %s", secs, subs.String())
+		mc.TestError(t, "(submgr) no clean within %d secs: %s", secs, subs.String())
 	} else {
-		testError(t, "(general) no clean within %d secs: subs(N/A)", secs)
+		mc.TestError(t, "(submgr) no clean within %d secs: subs(N/A)", secs)
 	}
 	return false
 }
@@ -90,9 +92,9 @@
 		time.Sleep(500 * time.Millisecond)
 	}
 	if trans != nil {
-		testError(t, "(general) no clean within %d secs: %s", secs, trans.String())
+		mc.TestError(t, "(submgr) no clean within %d secs: %s", secs, trans.String())
 	} else {
-		testError(t, "(general) no clean within %d secs: trans(N/A)", secs)
+		mc.TestError(t, "(submgr) no clean within %d secs: trans(N/A)", secs)
 	}
 	return false
 }
@@ -114,23 +116,23 @@
 		}
 		time.Sleep(500 * time.Millisecond)
 	}
-	testError(t, "(general) no subId change within %d secs", secs)
+	mc.TestError(t, "(submgr) no subId change within %d secs", secs)
 	return 0, false
 }
 
 func (mc *testingSubmgrControl) get_msgcounter(t *testing.T) uint64 {
-	return mc.c.msgCounter
+	return mc.c.CntRecvMsg
 }
 
 func (mc *testingSubmgrControl) wait_msgcounter_change(t *testing.T, orig uint64, secs int) (uint64, bool) {
 	i := 1
 	for ; i <= secs*2; i++ {
-		curr := mc.c.msgCounter
+		curr := mc.c.CntRecvMsg
 		if curr != orig {
 			return curr, true
 		}
 		time.Sleep(500 * time.Millisecond)
 	}
-	testError(t, "(general) no msg counter change within %d secs", secs)
+	mc.TestError(t, "(submgr) no msg counter change within %d secs", secs)
 	return 0, false
 }
diff --git a/pkg/control/ut_messaging_test.go b/pkg/control/ut_messaging_test.go
index 1bec316..3054999 100644
--- a/pkg/control/ut_messaging_test.go
+++ b/pkg/control/ut_messaging_test.go
@@ -20,7 +20,7 @@
 package control
 
 import (
-	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+	"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
 	"testing"
 )
 
@@ -48,19 +48,19 @@
 //-----------------------------------------------------------------------------
 
 func TestSubReqAndRouteNok(t *testing.T) {
-	xapp.Logger.Info("TestSubReqAndRouteNok")
+	CaseBegin("TestSubReqAndRouteNok")
 
 	waiter := rtmgrHttp.AllocNextEvent(false)
 	newSubsId := mainCtrl.get_subid(t)
-	xappConn1.handle_xapp_subs_req(t, nil, nil)
+	xappConn1.SendSubsReq(t, nil, nil)
 	waiter.WaitResult(t)
 
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, newSubsId, 10)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -99,29 +99,29 @@
 //
 //-----------------------------------------------------------------------------
 func TestSubReqAndSubDelOk(t *testing.T) {
-	xapp.Logger.Info("TestSubReqAndSubDelOk")
+	CaseBegin("TestSubReqAndSubDelOk")
 
 	waiter := rtmgrHttp.AllocNextEvent(true)
-	cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
+	cretrans := xappConn1.SendSubsReq(t, nil, nil)
 	waiter.WaitResult(t)
 
-	crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
-	e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
-	e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
-	deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
-	delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
+	crereq, cremsg := e2termConn.RecvSubsReq(t)
+	e2termConn.SendSubsResp(t, crereq, cremsg)
+	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
+	deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
+	delreq, delmsg := e2termConn.RecvSubsDelReq(t)
 
 	waiter = rtmgrHttp.AllocNextEvent(true)
-	e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg)
-	xappConn1.handle_xapp_subs_del_resp(t, deltrans)
+	e2termConn.SendSubsDelResp(t, delreq, delmsg)
+	xappConn1.RecvSubsDelResp(t, deltrans)
 	waiter.WaitResult(t)
 
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId, 10)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -154,31 +154,31 @@
 //
 //-----------------------------------------------------------------------------
 func TestSubReqRetransmission(t *testing.T) {
-	xapp.Logger.Info("TestSubReqRetransmission")
+	CaseBegin("TestSubReqRetransmission")
 
 	//Subs Create
-	cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
-	crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
+	cretrans := xappConn1.SendSubsReq(t, nil, nil)
+	crereq, cremsg := e2termConn.RecvSubsReq(t)
 
 	seqBef := mainCtrl.get_msgcounter(t)
-	xappConn1.handle_xapp_subs_req(t, nil, cretrans) //Retransmitted SubReq
+	xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
 	mainCtrl.wait_msgcounter_change(t, seqBef, 10)
 
-	e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
-	e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
+	e2termConn.SendSubsResp(t, crereq, cremsg)
+	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
 
 	//Subs Delete
-	deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
-	delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
-	e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg)
-	xappConn1.handle_xapp_subs_del_resp(t, deltrans)
+	deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
+	delreq, delmsg := e2termConn.RecvSubsDelReq(t)
+	e2termConn.SendSubsDelResp(t, delreq, delmsg)
+	xappConn1.RecvSubsDelResp(t, deltrans)
 
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId, 10)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -212,31 +212,31 @@
 //
 //-----------------------------------------------------------------------------
 func TestSubDelReqRetransmission(t *testing.T) {
-	xapp.Logger.Info("TestSubDelReqRetransmission")
+	CaseBegin("TestSubDelReqRetransmission")
 
 	//Subs Create
-	cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
-	crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
-	e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
-	e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
+	cretrans := xappConn1.SendSubsReq(t, nil, nil)
+	crereq, cremsg := e2termConn.RecvSubsReq(t)
+	e2termConn.SendSubsResp(t, crereq, cremsg)
+	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
 
 	//Subs Delete
-	deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
-	delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
+	deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
+	delreq, delmsg := e2termConn.RecvSubsDelReq(t)
 
 	seqBef := mainCtrl.get_msgcounter(t)
-	xappConn1.handle_xapp_subs_del_req(t, deltrans, e2SubsId) //Retransmitted SubDelReq
+	xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
 	mainCtrl.wait_msgcounter_change(t, seqBef, 10)
 
-	e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg)
-	xappConn1.handle_xapp_subs_del_resp(t, deltrans)
+	e2termConn.SendSubsDelResp(t, delreq, delmsg)
+	xappConn1.RecvSubsDelResp(t, deltrans)
 
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId, 10)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -274,37 +274,37 @@
 //-----------------------------------------------------------------------------
 
 func TestSubDelReqCollision(t *testing.T) {
-	xapp.Logger.Info("TestSubDelReqCollision")
+	CaseBegin("TestSubDelReqCollision")
 
 	//Subs Create
-	cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
-	crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
-	e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
-	e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
+	cretrans := xappConn1.SendSubsReq(t, nil, nil)
+	crereq, cremsg := e2termConn.RecvSubsReq(t)
+	e2termConn.SendSubsResp(t, crereq, cremsg)
+	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
 
 	//Subs Delete
-	xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
-	delreq1, delmsg1 := e2termConn.handle_e2term_subs_del_req(t)
+	xappConn1.SendSubsDelReq(t, nil, e2SubsId)
+	delreq1, delmsg1 := e2termConn.RecvSubsDelReq(t)
 
 	// Subs Delete colliding
 	seqBef := mainCtrl.get_msgcounter(t)
-	deltranscol2 := xappConn1.newXappTransaction("", "RAN_NAME_1")
-	xappConn1.handle_xapp_subs_del_req(t, deltranscol2, e2SubsId) //Colliding SubDelReq
+	deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
+	xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
 	mainCtrl.wait_msgcounter_change(t, seqBef, 10)
 
 	// Del resp for first and second
-	e2termConn.handle_e2term_subs_del_resp(t, delreq1, delmsg1)
+	e2termConn.SendSubsDelResp(t, delreq1, delmsg1)
 
 	// don't care in which order responses are received
-	xappConn1.handle_xapp_subs_del_resp(t, nil)
-	xappConn1.handle_xapp_subs_del_resp(t, nil)
+	xappConn1.RecvSubsDelResp(t, nil)
+	xappConn1.RecvSubsDelResp(t, nil)
 
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId, 10)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -347,49 +347,49 @@
 //
 //-----------------------------------------------------------------------------
 func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
-	xapp.Logger.Info("TestSubReqAndSubDelOkTwoParallel")
+	CaseBegin("TestSubReqAndSubDelOkTwoParallel")
 
 	//Req1
-	rparams1 := &test_subs_req_params{}
+	rparams1 := &teststube2ap.E2StubSubsReqParams{}
 	rparams1.Init()
-	rparams1.req.EventTriggerDefinition.ProcedureCode = 5
-	cretrans1 := xappConn1.handle_xapp_subs_req(t, rparams1, nil)
-	crereq1, cremsg1 := e2termConn.handle_e2term_subs_req(t)
+	rparams1.Req.EventTriggerDefinition.ProcedureCode = 5
+	cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
+	crereq1, cremsg1 := e2termConn.RecvSubsReq(t)
 
 	//Req2
-	rparams2 := &test_subs_req_params{}
+	rparams2 := &teststube2ap.E2StubSubsReqParams{}
 	rparams2.Init()
-	rparams2.req.EventTriggerDefinition.ProcedureCode = 28
-	cretrans2 := xappConn2.handle_xapp_subs_req(t, rparams2, nil)
-	crereq2, cremsg2 := e2termConn.handle_e2term_subs_req(t)
+	rparams2.Req.EventTriggerDefinition.ProcedureCode = 28
+	cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
+	crereq2, cremsg2 := e2termConn.RecvSubsReq(t)
 
 	//Resp1
-	e2termConn.handle_e2term_subs_resp(t, crereq1, cremsg1)
-	e2SubsId1 := xappConn1.handle_xapp_subs_resp(t, cretrans1)
+	e2termConn.SendSubsResp(t, crereq1, cremsg1)
+	e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
 
 	//Resp2
-	e2termConn.handle_e2term_subs_resp(t, crereq2, cremsg2)
-	e2SubsId2 := xappConn2.handle_xapp_subs_resp(t, cretrans2)
+	e2termConn.SendSubsResp(t, crereq2, cremsg2)
+	e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
 
 	//Del1
-	deltrans1 := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId1)
-	delreq1, delmsg1 := e2termConn.handle_e2term_subs_del_req(t)
-	e2termConn.handle_e2term_subs_del_resp(t, delreq1, delmsg1)
-	xappConn1.handle_xapp_subs_del_resp(t, deltrans1)
+	deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
+	delreq1, delmsg1 := e2termConn.RecvSubsDelReq(t)
+	e2termConn.SendSubsDelResp(t, delreq1, delmsg1)
+	xappConn1.RecvSubsDelResp(t, deltrans1)
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
 
 	//Del2
-	deltrans2 := xappConn2.handle_xapp_subs_del_req(t, nil, e2SubsId2)
-	delreq2, delmsg2 := e2termConn.handle_e2term_subs_del_req(t)
-	e2termConn.handle_e2term_subs_del_resp(t, delreq2, delmsg2)
-	xappConn2.handle_xapp_subs_del_resp(t, deltrans2)
+	deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
+	delreq2, delmsg2 := e2termConn.RecvSubsDelReq(t)
+	e2termConn.SendSubsDelResp(t, delreq2, delmsg2)
+	xappConn2.RecvSubsDelResp(t, deltrans2)
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -435,43 +435,43 @@
 //
 //-----------------------------------------------------------------------------
 func TestSameSubsDiffRan(t *testing.T) {
-	xapp.Logger.Info("TestSameSubsDiffRan")
+	CaseBegin("TestSameSubsDiffRan")
 
 	//Req1
-	cretrans1 := xappConn1.newXappTransaction("", "RAN_NAME_1")
-	xappConn1.handle_xapp_subs_req(t, nil, cretrans1)
-	crereq1, cremsg1 := e2termConn.handle_e2term_subs_req(t)
-	e2termConn.handle_e2term_subs_resp(t, crereq1, cremsg1)
-	e2SubsId1 := xappConn1.handle_xapp_subs_resp(t, cretrans1)
+	cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
+	xappConn1.SendSubsReq(t, nil, cretrans1)
+	crereq1, cremsg1 := e2termConn.RecvSubsReq(t)
+	e2termConn.SendSubsResp(t, crereq1, cremsg1)
+	e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
 
 	//Req2
-	cretrans2 := xappConn1.newXappTransaction("", "RAN_NAME_2")
-	xappConn1.handle_xapp_subs_req(t, nil, cretrans2)
-	crereq2, cremsg2 := e2termConn.handle_e2term_subs_req(t)
-	e2termConn.handle_e2term_subs_resp(t, crereq2, cremsg2)
-	e2SubsId2 := xappConn1.handle_xapp_subs_resp(t, cretrans2)
+	cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
+	xappConn1.SendSubsReq(t, nil, cretrans2)
+	crereq2, cremsg2 := e2termConn.RecvSubsReq(t)
+	e2termConn.SendSubsResp(t, crereq2, cremsg2)
+	e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
 
 	//Del1
-	deltrans1 := xappConn1.newXappTransaction("", "RAN_NAME_1")
-	xappConn1.handle_xapp_subs_del_req(t, deltrans1, e2SubsId1)
-	delreq1, delmsg1 := e2termConn.handle_e2term_subs_del_req(t)
-	e2termConn.handle_e2term_subs_del_resp(t, delreq1, delmsg1)
-	xappConn1.handle_xapp_subs_del_resp(t, deltrans1)
+	deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
+	xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
+	delreq1, delmsg1 := e2termConn.RecvSubsDelReq(t)
+	e2termConn.SendSubsDelResp(t, delreq1, delmsg1)
+	xappConn1.RecvSubsDelResp(t, deltrans1)
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
 
 	//Del2
-	deltrans2 := xappConn1.newXappTransaction("", "RAN_NAME_2")
-	xappConn1.handle_xapp_subs_del_req(t, deltrans2, e2SubsId2)
-	delreq2, delmsg2 := e2termConn.handle_e2term_subs_del_req(t)
-	e2termConn.handle_e2term_subs_del_resp(t, delreq2, delmsg2)
-	xappConn1.handle_xapp_subs_del_resp(t, deltrans2)
+	deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
+	xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
+	delreq2, delmsg2 := e2termConn.RecvSubsDelReq(t)
+	e2termConn.SendSubsDelResp(t, delreq2, delmsg2)
+	xappConn1.RecvSubsDelResp(t, deltrans2)
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -506,32 +506,32 @@
 
 func TestSubReqRetryInSubmgr(t *testing.T) {
 
-	xapp.Logger.Info("TestSubReqRetryInSubmgr start")
+	CaseBegin("TestSubReqRetryInSubmgr start")
 
 	// Xapp: Send SubsReq
-	cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
+	cretrans := xappConn1.SendSubsReq(t, nil, nil)
 
 	// E2t: Receive 1st SubsReq
-	e2termConn.handle_e2term_subs_req(t)
+	e2termConn.RecvSubsReq(t)
 
 	// E2t: Receive 2nd SubsReq and send SubsResp
-	crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
-	e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
+	crereq, cremsg := e2termConn.RecvSubsReq(t)
+	e2termConn.SendSubsResp(t, crereq, cremsg)
 
 	// Xapp: Receive SubsResp
-	e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
+	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
 
-	deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
-	delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
-	e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg)
-	xappConn1.handle_xapp_subs_del_resp(t, deltrans)
+	deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
+	delreq, delmsg := e2termConn.RecvSubsDelReq(t)
+	e2termConn.SendSubsDelResp(t, delreq, delmsg)
+	xappConn1.RecvSubsDelResp(t, deltrans)
 
 	// Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId, 10)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -569,27 +569,27 @@
 
 func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
 
-	xapp.Logger.Info("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
+	CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
 
 	// Xapp: Send SubsReq
-	xappConn1.handle_xapp_subs_req(t, nil, nil)
+	xappConn1.SendSubsReq(t, nil, nil)
 
 	// E2t: Receive 1st SubsReq
-	e2termConn.handle_e2term_subs_req(t)
+	e2termConn.RecvSubsReq(t)
 
 	// E2t: Receive 2nd SubsReq
-	e2termConn.handle_e2term_subs_req(t)
+	e2termConn.RecvSubsReq(t)
 
 	// E2t: Send receive SubsDelReq and send SubsResp
-	delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
-	e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg)
+	delreq, delmsg := e2termConn.RecvSubsDelReq(t)
+	e2termConn.SendSubsDelResp(t, delreq, delmsg)
 
 	// Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, delreq.RequestId.Seq, 10)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -624,29 +624,29 @@
 
 func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
 
-	xapp.Logger.Info("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
+	CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
 
 	// Xapp: Send SubsReq
-	xappConn1.handle_xapp_subs_req(t, nil, nil)
+	xappConn1.SendSubsReq(t, nil, nil)
 
 	// E2t: Receive 1st SubsReq
-	e2termConn.handle_e2term_subs_req(t)
+	e2termConn.RecvSubsReq(t)
 
 	// E2t: Receive 2nd SubsReq
-	e2termConn.handle_e2term_subs_req(t)
+	e2termConn.RecvSubsReq(t)
 
 	// E2t: Receive 1st SubsDelReq
-	e2termConn.handle_e2term_subs_del_req(t)
+	e2termConn.RecvSubsDelReq(t)
 
 	// E2t: Receive 2nd SubsDelReq
-	delreq, _ := e2termConn.handle_e2term_subs_del_req(t)
+	delreq, _ := e2termConn.RecvSubsDelReq(t)
 
 	// Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, delreq.RequestId.Seq, 15)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -675,26 +675,26 @@
 
 func TestSubReqSubFailRespInSubmgr(t *testing.T) {
 
-	xapp.Logger.Info("TestSubReqSubFailRespInSubmgr start")
+	CaseBegin("TestSubReqSubFailRespInSubmgr start")
 
 	// Xapp: Send SubsReq
-	cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
+	cretrans := xappConn1.SendSubsReq(t, nil, nil)
 
 	// E2t: Receive SubsReq and send SubsFail
-	crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
-	fparams := &test_subs_fail_params{}
+	crereq, cremsg := e2termConn.RecvSubsReq(t)
+	fparams := &teststube2ap.E2StubSubsFailParams{}
 	fparams.Set(crereq)
-	e2termConn.handle_e2term_subs_fail(t, fparams, cremsg)
+	e2termConn.SendSubsFail(t, fparams, cremsg)
 
 	// Xapp: Receive SubsFail
-	e2SubsId := xappConn1.handle_xapp_subs_fail(t, cretrans)
+	e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
 
 	// Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId, 10)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -728,34 +728,34 @@
 
 func TestSubDelReqRetryInSubmgr(t *testing.T) {
 
-	xapp.Logger.Info("TestSubDelReqRetryInSubmgr start")
+	CaseBegin("TestSubDelReqRetryInSubmgr start")
 
 	// Subs Create
-	cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
-	crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
-	e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
-	e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
+	cretrans := xappConn1.SendSubsReq(t, nil, nil)
+	crereq, cremsg := e2termConn.RecvSubsReq(t)
+	e2termConn.SendSubsResp(t, crereq, cremsg)
+	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
 
 	// Subs Delete
 	// Xapp: Send SubsDelReq
-	deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
+	deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
 
 	// E2t: Receive 1st SubsDelReq
-	e2termConn.handle_e2term_subs_del_req(t)
+	e2termConn.RecvSubsDelReq(t)
 
 	// E2t: Receive 2nd SubsDelReq and send SubsDelResp
-	delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
-	e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg)
+	delreq, delmsg := e2termConn.RecvSubsDelReq(t)
+	e2termConn.SendSubsDelResp(t, delreq, delmsg)
 
 	// Xapp: Receive SubsDelResp
-	xappConn1.handle_xapp_subs_del_resp(t, deltrans)
+	xappConn1.RecvSubsDelResp(t, deltrans)
 
 	// Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId, 10)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -787,33 +787,33 @@
 
 func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
 
-	xapp.Logger.Info("TestSubDelReTwoRetriesNoRespInSubmgr start")
+	CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
 
 	// Subs Create
-	cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
-	crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
-	e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
-	e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
+	cretrans := xappConn1.SendSubsReq(t, nil, nil)
+	crereq, cremsg := e2termConn.RecvSubsReq(t)
+	e2termConn.SendSubsResp(t, crereq, cremsg)
+	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
 
 	// Subs Delete
 	// Xapp: Send SubsDelReq
-	deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
+	deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
 
 	// E2t: Receive 1st SubsDelReq
-	e2termConn.handle_e2term_subs_del_req(t)
+	e2termConn.RecvSubsDelReq(t)
 
 	// E2t: Receive 2nd SubsDelReq
-	e2termConn.handle_e2term_subs_del_req(t)
+	e2termConn.RecvSubsDelReq(t)
 
 	// Xapp: Receive SubsDelResp
-	xappConn1.handle_xapp_subs_del_resp(t, deltrans)
+	xappConn1.RecvSubsDelResp(t, deltrans)
 
 	// Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId, 10)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -845,30 +845,30 @@
 
 func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
 
-	xapp.Logger.Info("TestSubReqSubDelFailRespInSubmgr start")
+	CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
 
 	// Subs Create
-	cretrans := xappConn1.handle_xapp_subs_req(t, nil, nil)
-	crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
-	e2termConn.handle_e2term_subs_resp(t, crereq, cremsg)
-	e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans)
+	cretrans := xappConn1.SendSubsReq(t, nil, nil)
+	crereq, cremsg := e2termConn.RecvSubsReq(t)
+	e2termConn.SendSubsResp(t, crereq, cremsg)
+	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
 
 	// Xapp: Send SubsDelReq
-	deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId)
+	deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
 
 	// E2t: Send receive SubsDelReq and send SubsDelFail
-	delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t)
-	e2termConn.handle_e2term_subs_del_fail(t, delreq, delmsg)
+	delreq, delmsg := e2termConn.RecvSubsDelReq(t)
+	e2termConn.SendSubsDelFail(t, delreq, delmsg)
 
 	// Xapp: Receive SubsDelResp
-	xappConn1.handle_xapp_subs_del_resp(t, deltrans)
+	xappConn1.RecvSubsDelResp(t, deltrans)
 
 	// Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId, 10)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -918,43 +918,43 @@
 //
 //-----------------------------------------------------------------------------
 func TestSubReqAndSubDelOkSameAction(t *testing.T) {
-	xapp.Logger.Info("TestSubReqAndSubDelOkSameAction")
+	CaseBegin("TestSubReqAndSubDelOkSameAction")
 
 	//Req1
-	rparams1 := &test_subs_req_params{}
+	rparams1 := &teststube2ap.E2StubSubsReqParams{}
 	rparams1.Init()
-	cretrans1 := xappConn1.handle_xapp_subs_req(t, rparams1, nil)
-	crereq1, cremsg1 := e2termConn.handle_e2term_subs_req(t)
-	e2termConn.handle_e2term_subs_resp(t, crereq1, cremsg1)
-	e2SubsId1 := xappConn1.handle_xapp_subs_resp(t, cretrans1)
+	cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
+	crereq1, cremsg1 := e2termConn.RecvSubsReq(t)
+	e2termConn.SendSubsResp(t, crereq1, cremsg1)
+	e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
 
 	//Req2
-	rparams2 := &test_subs_req_params{}
+	rparams2 := &teststube2ap.E2StubSubsReqParams{}
 	rparams2.Init()
-	cretrans2 := xappConn2.handle_xapp_subs_req(t, rparams2, nil)
-	//crereq2, cremsg2 := e2termConn.handle_e2term_subs_req(t)
-	//e2termConn.handle_e2term_subs_resp(t, crereq2, cremsg2)
-	e2SubsId2 := xappConn2.handle_xapp_subs_resp(t, cretrans2)
+	cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
+	//crereq2, cremsg2 := e2termConn.RecvSubsReq(t)
+	//e2termConn.SendSubsResp(t, crereq2, cremsg2)
+	e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
 
 	//Del1
-	deltrans1 := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId1)
-	//e2termConn.handle_e2term_subs_del_req(t)
-	//e2termConn.handle_e2term_subs_del_resp(t, delreq1, delmsg1)
-	xappConn1.handle_xapp_subs_del_resp(t, deltrans1)
+	deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
+	//e2termConn.RecvSubsDelReq(t)
+	//e2termConn.SendSubsDelResp(t, delreq1, delmsg1)
+	xappConn1.RecvSubsDelResp(t, deltrans1)
 	//Wait that subs is cleaned
 	//mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
 
 	//Del2
-	deltrans2 := xappConn2.handle_xapp_subs_del_req(t, nil, e2SubsId2)
-	delreq2, delmsg2 := e2termConn.handle_e2term_subs_del_req(t)
-	e2termConn.handle_e2term_subs_del_resp(t, delreq2, delmsg2)
-	xappConn2.handle_xapp_subs_del_resp(t, deltrans2)
+	deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
+	delreq2, delmsg2 := e2termConn.RecvSubsDelReq(t)
+	e2termConn.SendSubsDelResp(t, delreq2, delmsg2)
+	xappConn2.RecvSubsDelResp(t, deltrans2)
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -1003,42 +1003,42 @@
 //
 //-----------------------------------------------------------------------------
 func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
-	xapp.Logger.Info("TestSubReqAndSubDelOkSameActionParallel")
+	CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
 
 	//Req1
-	rparams1 := &test_subs_req_params{}
+	rparams1 := &teststube2ap.E2StubSubsReqParams{}
 	rparams1.Init()
-	cretrans1 := xappConn1.handle_xapp_subs_req(t, rparams1, nil)
-	crereq1, cremsg1 := e2termConn.handle_e2term_subs_req(t)
+	cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
+	crereq1, cremsg1 := e2termConn.RecvSubsReq(t)
 
 	//Req2
-	rparams2 := &test_subs_req_params{}
+	rparams2 := &teststube2ap.E2StubSubsReqParams{}
 	rparams2.Init()
-	cretrans2 := xappConn2.handle_xapp_subs_req(t, rparams2, nil)
+	cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
 
 	//Resp1
-	e2termConn.handle_e2term_subs_resp(t, crereq1, cremsg1)
-	e2SubsId1 := xappConn1.handle_xapp_subs_resp(t, cretrans1)
+	e2termConn.SendSubsResp(t, crereq1, cremsg1)
+	e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
 
 	//Resp2
-	e2SubsId2 := xappConn2.handle_xapp_subs_resp(t, cretrans2)
+	e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
 
 	//Del1
-	deltrans1 := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId1)
-	xappConn1.handle_xapp_subs_del_resp(t, deltrans1)
+	deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
+	xappConn1.RecvSubsDelResp(t, deltrans1)
 
 	//Del2
-	deltrans2 := xappConn2.handle_xapp_subs_del_req(t, nil, e2SubsId2)
-	delreq2, delmsg2 := e2termConn.handle_e2term_subs_del_req(t)
-	e2termConn.handle_e2term_subs_del_resp(t, delreq2, delmsg2)
-	xappConn2.handle_xapp_subs_del_resp(t, deltrans2)
+	deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
+	delreq2, delmsg2 := e2termConn.RecvSubsDelReq(t)
+	e2termConn.SendSubsDelResp(t, delreq2, delmsg2)
+	xappConn2.RecvSubsDelResp(t, deltrans2)
 
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -1069,37 +1069,37 @@
 //
 //-----------------------------------------------------------------------------
 func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
-	xapp.Logger.Info("TestSubReqAndSubDelNokSameActionParallel")
+	CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
 
 	//Req1
-	rparams1 := &test_subs_req_params{}
+	rparams1 := &teststube2ap.E2StubSubsReqParams{}
 	rparams1.Init()
-	cretrans1 := xappConn1.handle_xapp_subs_req(t, rparams1, nil)
-	crereq1, cremsg1 := e2termConn.handle_e2term_subs_req(t)
+	cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
+	crereq1, cremsg1 := e2termConn.RecvSubsReq(t)
 
 	//Req2
-	rparams2 := &test_subs_req_params{}
+	rparams2 := &teststube2ap.E2StubSubsReqParams{}
 	rparams2.Init()
 	seqBef2 := mainCtrl.get_msgcounter(t)
-	cretrans2 := xappConn2.handle_xapp_subs_req(t, rparams2, nil)
+	cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
 	mainCtrl.wait_msgcounter_change(t, seqBef2, 10)
 
 	//E2T Fail
-	fparams := &test_subs_fail_params{}
+	fparams := &teststube2ap.E2StubSubsFailParams{}
 	fparams.Set(crereq1)
-	e2termConn.handle_e2term_subs_fail(t, fparams, cremsg1)
+	e2termConn.SendSubsFail(t, fparams, cremsg1)
 
 	//Fail1
-	e2SubsId1 := xappConn1.handle_xapp_subs_fail(t, cretrans1)
+	e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
 	//Fail2
-	xappConn2.handle_xapp_subs_fail(t, cretrans2)
+	xappConn2.RecvSubsFail(t, cretrans2)
 
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -1133,33 +1133,33 @@
 //
 //-----------------------------------------------------------------------------
 func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
-	xapp.Logger.Info("TestSubReqAndSubDelNoAnswerSameActionParallel")
+	CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
 
 	//Req1
-	rparams1 := &test_subs_req_params{}
+	rparams1 := &teststube2ap.E2StubSubsReqParams{}
 	rparams1.Init()
-	xappConn1.handle_xapp_subs_req(t, rparams1, nil)
+	xappConn1.SendSubsReq(t, rparams1, nil)
 
-	e2termConn.handle_e2term_subs_req(t)
+	e2termConn.RecvSubsReq(t)
 
 	//Req2
-	rparams2 := &test_subs_req_params{}
+	rparams2 := &teststube2ap.E2StubSubsReqParams{}
 	rparams2.Init()
 	seqBef2 := mainCtrl.get_msgcounter(t)
-	xappConn2.handle_xapp_subs_req(t, rparams2, nil)
+	xappConn2.SendSubsReq(t, rparams2, nil)
 	mainCtrl.wait_msgcounter_change(t, seqBef2, 10)
 
 	//Req1 (retransmitted)
-	e2termConn.handle_e2term_subs_req(t)
+	e2termConn.RecvSubsReq(t)
 
-	delreq1, delmsg1 := e2termConn.handle_e2term_subs_del_req(t)
-	e2termConn.handle_e2term_subs_del_resp(t, delreq1, delmsg1)
+	delreq1, delmsg1 := e2termConn.RecvSubsDelReq(t)
+	e2termConn.SendSubsDelResp(t, delreq1, delmsg1)
 
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, delreq1.RequestId.Seq, 10)
 
-	xappConn1.TestMsgCnt(t)
-	xappConn2.TestMsgCnt(t)
-	e2termConn.TestMsgCnt(t)
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 15)
 }
diff --git a/pkg/control/ut_stub_e2term_test.go b/pkg/control/ut_stub_e2term_test.go
deleted file mode 100644
index f2392b9..0000000
--- a/pkg/control/ut_stub_e2term_test.go
+++ /dev/null
@@ -1,324 +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 control
-
-import (
-	"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
-	"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
-	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
-	"testing"
-	"time"
-)
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-var e2t_e2asnpacker e2ap.E2APPackerIf = e2ap_wrapper.NewAsn1E2Packer()
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-type testingE2termStub struct {
-	testingRmrStubControl
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-func createNewE2termStub(desc string, rtfile string, port string, stat string) *testingE2termStub {
-	e2termCtrl := &testingE2termStub{}
-	e2termCtrl.testingRmrStubControl.init(desc, rtfile, port, stat, e2termCtrl)
-	return e2termCtrl
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-func (tc *testingE2termStub) Consume(params *xapp.RMRParams) (err error) {
-	xapp.Rmr.Free(params.Mbuf)
-	params.Mbuf = nil
-	msg := &RMRParams{params}
-
-	if params.Mtype == 55555 {
-		xapp.Logger.Info("(%s) Testing message ignore %s", tc.GetDesc(), msg.String())
-		tc.active = true
-		return
-	}
-
-	xapp.Logger.Info("(%s) Consume %s", tc.GetDesc(), msg.String())
-	tc.rmrConChan <- msg
-	return
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-func (e2termConn *testingE2termStub) handle_e2term_subs_req(t *testing.T) (*e2ap.E2APSubscriptionRequest, *RMRParams) {
-	xapp.Logger.Info("(%s) handle_e2term_subs_req", e2termConn.GetDesc())
-	e2SubsReq := e2t_e2asnpacker.NewPackerSubscriptionRequest()
-
-	//---------------------------------
-	// e2term activity: Recv Subs Req
-	//---------------------------------
-	select {
-	case msg := <-e2termConn.rmrConChan:
-		e2termConn.DecMsgCnt()
-		if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_REQ"] {
-			testError(t, "(%s) Received wrong mtype expected %s got %s, error", e2termConn.GetDesc(), "RIC_SUB_REQ", xapp.RicMessageTypeToName[msg.Mtype])
-		} else {
-			xapp.Logger.Info("(%s) Recv Subs Req", e2termConn.GetDesc())
-			packedData := &e2ap.PackedData{}
-			packedData.Buf = msg.Payload
-			unpackerr, req := e2SubsReq.UnPack(packedData)
-			if unpackerr != nil {
-				testError(t, "(%s) RIC_SUB_REQ unpack failed err: %s", e2termConn.GetDesc(), unpackerr.Error())
-			}
-			return req, msg
-		}
-	case <-time.After(15 * time.Second):
-		testError(t, "(%s) Not Received RIC_SUB_REQ within 15 secs", e2termConn.GetDesc())
-	}
-	return nil, nil
-}
-
-func (e2termConn *testingE2termStub) handle_e2term_subs_resp(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *RMRParams) {
-	xapp.Logger.Info("(%s) handle_e2term_subs_resp", e2termConn.GetDesc())
-	e2SubsResp := e2t_e2asnpacker.NewPackerSubscriptionResponse()
-
-	//---------------------------------
-	// e2term activity: Send Subs Resp
-	//---------------------------------
-	xapp.Logger.Info("(%s) Send Subs Resp", e2termConn.GetDesc())
-
-	resp := &e2ap.E2APSubscriptionResponse{}
-
-	resp.RequestId.Id = req.RequestId.Id
-	resp.RequestId.Seq = req.RequestId.Seq
-	resp.FunctionId = req.FunctionId
-
-	resp.ActionAdmittedList.Items = make([]e2ap.ActionAdmittedItem, len(req.ActionSetups))
-	for index := int(0); index < len(req.ActionSetups); index++ {
-		resp.ActionAdmittedList.Items[index].ActionId = req.ActionSetups[index].ActionId
-	}
-
-	for index := uint64(0); index < 1; index++ {
-		item := e2ap.ActionNotAdmittedItem{}
-		item.ActionId = index
-		item.Cause.Content = 1
-		item.Cause.CauseVal = 1
-		resp.ActionNotAdmittedList.Items = append(resp.ActionNotAdmittedList.Items, item)
-	}
-
-	packerr, packedMsg := e2SubsResp.Pack(resp)
-	if packerr != nil {
-		testError(t, "(%s) pack NOK %s", e2termConn.GetDesc(), packerr.Error())
-	}
-	xapp.Logger.Debug("(%s) %s", e2termConn.GetDesc(), e2SubsResp.String())
-
-	params := &RMRParams{&xapp.RMRParams{}}
-	params.Mtype = xapp.RIC_SUB_RESP
-	//params.SubId = msg.SubId
-	params.SubId = -1
-	params.Payload = packedMsg.Buf
-	params.Meid = msg.Meid
-	//params.Xid = msg.Xid
-	params.Mbuf = nil
-
-	snderr := e2termConn.RmrSend(params)
-	if snderr != nil {
-		testError(t, "(%s) RMR SEND FAILED: %s", e2termConn.GetDesc(), snderr.Error())
-	}
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-type test_subs_fail_params struct {
-	req  *e2ap.E2APSubscriptionRequest
-	fail *e2ap.E2APSubscriptionFailure
-}
-
-func (p *test_subs_fail_params) Set(req *e2ap.E2APSubscriptionRequest) {
-	p.req = req
-
-	p.fail = &e2ap.E2APSubscriptionFailure{}
-	p.fail.RequestId.Id = p.req.RequestId.Id
-	p.fail.RequestId.Seq = p.req.RequestId.Seq
-	p.fail.FunctionId = p.req.FunctionId
-	p.fail.ActionNotAdmittedList.Items = make([]e2ap.ActionNotAdmittedItem, len(p.req.ActionSetups))
-	for index := int(0); index < len(p.fail.ActionNotAdmittedList.Items); index++ {
-		p.fail.ActionNotAdmittedList.Items[index].ActionId = p.req.ActionSetups[index].ActionId
-		p.SetCauseVal(index, 5, 1)
-	}
-}
-
-func (p *test_subs_fail_params) SetCauseVal(ind int, content uint8, causeval uint8) {
-
-	if ind < 0 {
-		for index := int(0); index < len(p.fail.ActionNotAdmittedList.Items); index++ {
-			p.fail.ActionNotAdmittedList.Items[index].Cause.Content = content
-			p.fail.ActionNotAdmittedList.Items[index].Cause.CauseVal = causeval
-		}
-		return
-	}
-	p.fail.ActionNotAdmittedList.Items[ind].Cause.Content = content
-	p.fail.ActionNotAdmittedList.Items[ind].Cause.CauseVal = causeval
-}
-
-func (e2termConn *testingE2termStub) handle_e2term_subs_fail(t *testing.T, fparams *test_subs_fail_params, msg *RMRParams) {
-	xapp.Logger.Info("(%s) handle_e2term_subs_fail", e2termConn.GetDesc())
-	e2SubsFail := e2t_e2asnpacker.NewPackerSubscriptionFailure()
-
-	//---------------------------------
-	// e2term activity: Send Subs Fail
-	//---------------------------------
-	xapp.Logger.Info("(%s) Send Subs Fail", e2termConn.GetDesc())
-
-	packerr, packedMsg := e2SubsFail.Pack(fparams.fail)
-	if packerr != nil {
-		testError(t, "(%s) pack NOK %s", e2termConn.GetDesc(), packerr.Error())
-	}
-	xapp.Logger.Debug("(%s) %s", e2termConn.GetDesc(), e2SubsFail.String())
-
-	params := &RMRParams{&xapp.RMRParams{}}
-	params.Mtype = xapp.RIC_SUB_FAILURE
-	params.SubId = msg.SubId
-	params.Payload = packedMsg.Buf
-	params.Meid = msg.Meid
-	params.Xid = msg.Xid
-	params.Mbuf = nil
-
-	snderr := e2termConn.RmrSend(params)
-	if snderr != nil {
-		testError(t, "(%s) RMR SEND FAILED: %s", e2termConn.GetDesc(), snderr.Error())
-	}
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-func (e2termConn *testingE2termStub) handle_e2term_subs_del_req(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequest, *RMRParams) {
-	xapp.Logger.Info("(%s) handle_e2term_subs_del_req", e2termConn.GetDesc())
-	e2SubsDelReq := e2t_e2asnpacker.NewPackerSubscriptionDeleteRequest()
-
-	//---------------------------------
-	// e2term activity: Recv Subs Del Req
-	//---------------------------------
-	select {
-	case msg := <-e2termConn.rmrConChan:
-		e2termConn.DecMsgCnt()
-		if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_REQ"] {
-			testError(t, "(%s) Received wrong mtype expected %s got %s, error", e2termConn.GetDesc(), "RIC_SUB_DEL_REQ", xapp.RicMessageTypeToName[msg.Mtype])
-		} else {
-			xapp.Logger.Info("(%s) Recv Subs Del Req", e2termConn.GetDesc())
-
-			packedData := &e2ap.PackedData{}
-			packedData.Buf = msg.Payload
-			unpackerr, req := e2SubsDelReq.UnPack(packedData)
-			if unpackerr != nil {
-				testError(t, "(%s) RIC_SUB_DEL_REQ unpack failed err: %s", e2termConn.GetDesc(), unpackerr.Error())
-			}
-			return req, msg
-		}
-	case <-time.After(15 * time.Second):
-		testError(t, "(%s) Not Received RIC_SUB_DEL_REQ within 15 secs", e2termConn.GetDesc())
-	}
-	return nil, nil
-}
-
-func handle_e2term_recv_empty() bool {
-	if len(e2termConn.rmrConChan) > 0 {
-		return false
-	}
-	return true
-}
-
-func (e2termConn *testingE2termStub) handle_e2term_subs_del_resp(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *RMRParams) {
-	xapp.Logger.Info("(%s) handle_e2term_subs_del_resp", e2termConn.GetDesc())
-	e2SubsDelResp := e2t_e2asnpacker.NewPackerSubscriptionDeleteResponse()
-
-	//---------------------------------
-	// e2term activity: Send Subs Del Resp
-	//---------------------------------
-	xapp.Logger.Info("(%s) Send Subs Del Resp", e2termConn.GetDesc())
-
-	resp := &e2ap.E2APSubscriptionDeleteResponse{}
-	resp.RequestId.Id = req.RequestId.Id
-	resp.RequestId.Seq = req.RequestId.Seq
-	resp.FunctionId = req.FunctionId
-
-	packerr, packedMsg := e2SubsDelResp.Pack(resp)
-	if packerr != nil {
-		testError(t, "(%s) pack NOK %s", e2termConn.GetDesc(), packerr.Error())
-	}
-	xapp.Logger.Debug("(%s) %s", e2termConn.GetDesc(), e2SubsDelResp.String())
-
-	params := &RMRParams{&xapp.RMRParams{}}
-	params.Mtype = xapp.RIC_SUB_DEL_RESP
-	params.SubId = msg.SubId
-	params.Payload = packedMsg.Buf
-	params.Meid = msg.Meid
-	params.Xid = msg.Xid
-	params.Mbuf = nil
-
-	snderr := e2termConn.RmrSend(params)
-	if snderr != nil {
-		testError(t, "(%s) RMR SEND FAILED: %s", e2termConn.GetDesc(), snderr.Error())
-	}
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-func (e2termConn *testingE2termStub) handle_e2term_subs_del_fail(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *RMRParams) {
-	xapp.Logger.Info("(%s) handle_e2term_del_subs_fail", e2termConn.GetDesc())
-	e2SubsDelFail := e2t_e2asnpacker.NewPackerSubscriptionDeleteFailure()
-
-	//---------------------------------
-	// e2term activity: Send Subs Del Fail
-	//---------------------------------
-	xapp.Logger.Info("(%s) Send Subs Del Fail", e2termConn.GetDesc())
-
-	resp := &e2ap.E2APSubscriptionDeleteFailure{}
-	resp.RequestId.Id = req.RequestId.Id
-	resp.RequestId.Seq = req.RequestId.Seq
-	resp.FunctionId = req.FunctionId
-	resp.Cause.Content = 3  // CauseMisc
-	resp.Cause.CauseVal = 4 // unspecified
-
-	packerr, packedMsg := e2SubsDelFail.Pack(resp)
-	if packerr != nil {
-		testError(t, "(%s) pack NOK %s", e2termConn.GetDesc(), packerr.Error())
-	}
-	xapp.Logger.Debug("(%s) %s", e2termConn.GetDesc(), e2SubsDelFail.String())
-
-	params := &RMRParams{&xapp.RMRParams{}}
-	params.Mtype = xapp.RIC_SUB_DEL_FAILURE
-	params.SubId = msg.SubId
-	params.Payload = packedMsg.Buf
-	params.Meid = msg.Meid
-	params.Xid = msg.Xid
-	params.Mbuf = nil
-
-	snderr := e2termConn.RmrSend(params)
-	if snderr != nil {
-		testError(t, "(%s) RMR SEND FAILED: %s", e2termConn.GetDesc(), snderr.Error())
-	}
-}
diff --git a/pkg/control/ut_stub_rtmgr_test.go b/pkg/control/ut_stub_rtmgr_test.go
index 59467dc..8546ad4 100644
--- a/pkg/control/ut_stub_rtmgr_test.go
+++ b/pkg/control/ut_stub_rtmgr_test.go
@@ -22,7 +22,7 @@
 import (
 	"encoding/json"
 	"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_models"
-	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+	"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
 	"net/http"
 	"sync"
 	"testing"
@@ -33,24 +33,25 @@
 //
 //-----------------------------------------------------------------------------
 
-type httpEventWaiter struct {
+type HttpEventWaiter struct {
+	teststub.TestWrapper
 	resultChan   chan bool
 	nextActionOk bool
 }
 
-func (msg *httpEventWaiter) SetResult(res bool) {
+func (msg *HttpEventWaiter) SetResult(res bool) {
 	msg.resultChan <- res
 }
 
-func (msg *httpEventWaiter) WaitResult(t *testing.T) bool {
+func (msg *HttpEventWaiter) WaitResult(t *testing.T) bool {
 	select {
 	case result := <-msg.resultChan:
 		return result
 	case <-time.After(15 * time.Second):
-		testError(t, "Waiter not received result status from case within 15 secs")
+		msg.TestError(t, "Waiter not received result status from case within 15 secs")
 		return false
 	}
-	testError(t, "Waiter error in default branch")
+	msg.TestError(t, "Waiter error in default branch")
 	return false
 }
 
@@ -59,68 +60,69 @@
 //-----------------------------------------------------------------------------
 type testingHttpRtmgrStub struct {
 	sync.Mutex
-	desc        string
+	teststub.TestWrapper
 	port        string
-	eventWaiter *httpEventWaiter
+	eventWaiter *HttpEventWaiter
 }
 
-func (hc *testingHttpRtmgrStub) NextEvent(eventWaiter *httpEventWaiter) {
-	hc.Lock()
-	defer hc.Unlock()
-	hc.eventWaiter = eventWaiter
+func (tc *testingHttpRtmgrStub) NextEvent(eventWaiter *HttpEventWaiter) {
+	tc.Lock()
+	defer tc.Unlock()
+	tc.eventWaiter = eventWaiter
 }
 
-func (hc *testingHttpRtmgrStub) AllocNextEvent(nextAction bool) *httpEventWaiter {
-	eventWaiter := &httpEventWaiter{
+func (tc *testingHttpRtmgrStub) AllocNextEvent(nextAction bool) *HttpEventWaiter {
+	eventWaiter := &HttpEventWaiter{
 		resultChan:   make(chan bool),
 		nextActionOk: nextAction,
 	}
-	hc.NextEvent(eventWaiter)
+	eventWaiter.TestWrapper.Init("localhost:" + tc.port)
+	tc.NextEvent(eventWaiter)
 	return eventWaiter
 }
 
-func (hc *testingHttpRtmgrStub) http_handler(w http.ResponseWriter, r *http.Request) {
+func (tc *testingHttpRtmgrStub) http_handler(w http.ResponseWriter, r *http.Request) {
 
-	hc.Lock()
-	defer hc.Unlock()
+	tc.Lock()
+	defer tc.Unlock()
 
 	if r.Method == http.MethodPost || r.Method == http.MethodDelete {
 		var req rtmgr_models.XappSubscriptionData
 		err := json.NewDecoder(r.Body).Decode(&req)
 		if err != nil {
-			xapp.Logger.Error("%s", err.Error())
+			tc.Logger.Error("%s", err.Error())
 		}
-		xapp.Logger.Info("(%s) handling SubscriptionID=%d Address=%s Port=%d", hc.desc, *req.SubscriptionID, *req.Address, *req.Port)
+		tc.Logger.Info("handling SubscriptionID=%d Address=%s Port=%d", *req.SubscriptionID, *req.Address, *req.Port)
 	}
 	if r.Method == http.MethodPut {
 		var req rtmgr_models.XappList
 		err := json.NewDecoder(r.Body).Decode(&req)
 		if err != nil {
-			xapp.Logger.Error("%s", err.Error())
+			tc.Logger.Error("%s", err.Error())
 		}
-		xapp.Logger.Info("(%s) handling put", hc.desc)
+		tc.Logger.Info("handling put")
 	}
 
 	var code int = 0
 	switch r.Method {
 	case http.MethodPost:
 		code = 201
-		if hc.eventWaiter != nil {
-			if hc.eventWaiter.nextActionOk == false {
+		if tc.eventWaiter != nil {
+			if tc.eventWaiter.nextActionOk == false {
 				code = 400
 			}
 		}
 	case http.MethodDelete:
 		code = 200
-		if hc.eventWaiter != nil {
-			if hc.eventWaiter.nextActionOk == false {
+		if tc.eventWaiter != nil {
+			if tc.eventWaiter.nextActionOk == false {
 				code = 400
 			}
 		}
 	case http.MethodPut:
 		code = 201
-		if hc.eventWaiter != nil {
-			if hc.eventWaiter.nextActionOk == false {
+		if tc.eventWaiter != nil {
+			if tc.eventWaiter.nextActionOk == false {
 				code = 400
 			}
 		}
@@ -128,24 +130,24 @@
 		code = 200
 	}
 
-	waiter := hc.eventWaiter
-	hc.eventWaiter = nil
+	waiter := tc.eventWaiter
+	tc.eventWaiter = nil
 	if waiter != nil {
 		waiter.SetResult(true)
 	}
-	xapp.Logger.Info("(%s) Method=%s Reply with code %d", hc.desc, r.Method, code)
+	tc.Logger.Info("Method=%s Reply with code %d", r.Method, code)
 	w.WriteHeader(code)
 
 }
 
-func (hc *testingHttpRtmgrStub) run() {
-	http.HandleFunc("/", hc.http_handler)
-	http.ListenAndServe("localhost:"+hc.port, nil)
+func (tc *testingHttpRtmgrStub) run() {
+	http.HandleFunc("/", tc.http_handler)
+	http.ListenAndServe("localhost:"+tc.port, nil)
 }
 
 func createNewHttpRtmgrStub(desc string, port string) *testingHttpRtmgrStub {
-	hc := &testingHttpRtmgrStub{}
-	hc.desc = desc
-	hc.port = port
-	return hc
+	tc := &testingHttpRtmgrStub{}
+	tc.port = port
+	tc.TestWrapper.Init(desc)
+	return tc
 }
diff --git a/pkg/control/ut_stub_xapp_test.go b/pkg/control/ut_stub_xapp_test.go
deleted file mode 100644
index ccd1eb6..0000000
--- a/pkg/control/ut_stub_xapp_test.go
+++ /dev/null
@@ -1,349 +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 control
-
-import (
-	"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
-	"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
-	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
-	"strconv"
-	"strings"
-	"testing"
-	"time"
-)
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-var xapp_e2asnpacker e2ap.E2APPackerIf = e2ap_wrapper.NewAsn1E2Packer()
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-type xappTransaction struct {
-	xid  string
-	meid *xapp.RMRMeid
-}
-
-func (trans *xappTransaction) String() string {
-	return "trans(" + trans.xid + "/" + trans.meid.RanName + ")"
-}
-
-type testingXappStub struct {
-	testingRmrStubControl
-	xid_seq uint64
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-func createNewXappStub(desc string, rtfile string, port string, stat string) *testingXappStub {
-	xappCtrl := &testingXappStub{}
-	xappCtrl.testingRmrStubControl.init(desc, rtfile, port, stat, xappCtrl)
-	xappCtrl.xid_seq = 1
-	return xappCtrl
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-func (tc *testingXappStub) newXappTransaction(xid string, ranname string) *xappTransaction {
-	trans := &xappTransaction{}
-	if len(xid) == 0 {
-		trans.xid = tc.GetDesc() + "_XID_" + strconv.FormatUint(uint64(tc.xid_seq), 10)
-		tc.xid_seq++
-	} else {
-		trans.xid = xid
-	}
-	trans.meid = &xapp.RMRMeid{RanName: ranname}
-	xapp.Logger.Info("(%s) New test %s", tc.GetDesc(), trans.String())
-	return trans
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-func (tc *testingXappStub) Consume(params *xapp.RMRParams) (err error) {
-	xapp.Rmr.Free(params.Mbuf)
-	params.Mbuf = nil
-	msg := &RMRParams{params}
-
-	if params.Mtype == 55555 {
-		xapp.Logger.Info("(%s) Testing message ignore %s", tc.GetDesc(), msg.String())
-		tc.active = true
-		return
-	}
-
-	if strings.Contains(msg.Xid, tc.GetDesc()) {
-		xapp.Logger.Info("(%s) Consume %s", tc.GetDesc(), msg.String())
-		tc.IncMsgCnt()
-		tc.rmrConChan <- msg
-	} else {
-		xapp.Logger.Info("(%s) Ignore %s", tc.GetDesc(), msg.String())
-	}
-	return
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-type test_subs_req_params struct {
-	req *e2ap.E2APSubscriptionRequest
-}
-
-func (p *test_subs_req_params) Init() {
-	p.req = &e2ap.E2APSubscriptionRequest{}
-
-	p.req.RequestId.Id = 1
-	p.req.RequestId.Seq = 0
-	p.req.FunctionId = 1
-
-	p.req.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present = true
-	p.req.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.StringPut("310150")
-	p.req.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Id = 123
-	p.req.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Bits = e2ap.E2AP_ENBIDHomeBits28
-
-	// gnb -> enb outgoing
-	// enb -> gnb incoming
-	// X2 36423-f40.doc
-	p.req.EventTriggerDefinition.InterfaceDirection = e2ap.E2AP_InterfaceDirectionIncoming
-	p.req.EventTriggerDefinition.ProcedureCode = 5 //28 35
-	p.req.EventTriggerDefinition.TypeOfMessage = e2ap.E2AP_InitiatingMessage
-
-	p.req.ActionSetups = make([]e2ap.ActionToBeSetupItem, 1)
-	p.req.ActionSetups[0].ActionId = 0
-	p.req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeReport
-	p.req.ActionSetups[0].ActionDefinition.Present = false
-	//p.req.ActionSetups[index].ActionDefinition.StyleId = 255
-	//p.req.ActionSetups[index].ActionDefinition.ParamId = 222
-	p.req.ActionSetups[0].SubsequentAction.Present = true
-	p.req.ActionSetups[0].SubsequentAction.Type = e2ap.E2AP_SubSeqActionTypeContinue
-	p.req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitZero
-
-}
-
-func (xappConn *testingXappStub) handle_xapp_subs_req(t *testing.T, rparams *test_subs_req_params, oldTrans *xappTransaction) *xappTransaction {
-
-	trans := oldTrans
-	if oldTrans == nil {
-		trans = xappConn.newXappTransaction("", "RAN_NAME_1")
-	}
-
-	xapp.Logger.Info("(%s) handle_xapp_subs_req %s", xappConn.GetDesc(), trans.String())
-	e2SubsReq := xapp_e2asnpacker.NewPackerSubscriptionRequest()
-
-	//---------------------------------
-	// xapp activity: Send Subs Req
-	//---------------------------------
-	xapp.Logger.Info("(%s) Send Subs Req %s", xappConn.GetDesc(), trans.String())
-
-	myparams := rparams
-
-	if myparams == nil {
-		myparams = &test_subs_req_params{}
-		myparams.Init()
-	}
-
-	err, packedMsg := e2SubsReq.Pack(myparams.req)
-	if err != nil {
-		testError(t, "(%s) pack NOK %s %s", xappConn.GetDesc(), trans.String(), err.Error())
-		return nil
-	}
-	xapp.Logger.Debug("(%s) %s %s", xappConn.GetDesc(), trans.String(), e2SubsReq.String())
-
-	params := &RMRParams{&xapp.RMRParams{}}
-	params.Mtype = xapp.RIC_SUB_REQ
-	params.SubId = -1
-	params.Payload = packedMsg.Buf
-	params.Meid = trans.meid
-	params.Xid = trans.xid
-	params.Mbuf = nil
-
-	snderr := xappConn.RmrSend(params)
-	if snderr != nil {
-		testError(t, "(%s) RMR SEND FAILED: %s %s", xappConn.GetDesc(), trans.String(), snderr.Error())
-		return nil
-	}
-	return trans
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-func (xappConn *testingXappStub) handle_xapp_subs_resp(t *testing.T, trans *xappTransaction) uint32 {
-	xapp.Logger.Info("(%s) handle_xapp_subs_resp", xappConn.GetDesc())
-	e2SubsResp := xapp_e2asnpacker.NewPackerSubscriptionResponse()
-	var e2SubsId uint32
-
-	//---------------------------------
-	// xapp activity: Recv Subs Resp
-	//---------------------------------
-	select {
-	case msg := <-xappConn.rmrConChan:
-		xappConn.DecMsgCnt()
-		if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_RESP"] {
-			testError(t, "(%s) Received RIC_SUB_RESP wrong mtype expected %s got %s, error", xappConn.GetDesc(), "RIC_SUB_RESP", xapp.RicMessageTypeToName[msg.Mtype])
-			return 0
-		} else if msg.Xid != trans.xid {
-			testError(t, "(%s) Received RIC_SUB_RESP wrong xid expected %s got %s, error", xappConn.GetDesc(), trans.xid, msg.Xid)
-			return 0
-		} else {
-			packedData := &e2ap.PackedData{}
-			packedData.Buf = msg.Payload
-			if msg.SubId > 0 {
-				e2SubsId = uint32(msg.SubId)
-			} else {
-				e2SubsId = 0
-			}
-			unpackerr, resp := e2SubsResp.UnPack(packedData)
-			if unpackerr != nil {
-				testError(t, "(%s) RIC_SUB_RESP unpack failed err: %s", xappConn.GetDesc(), unpackerr.Error())
-			}
-			xapp.Logger.Info("(%s) Recv Subs Resp rmr: xid=%s subid=%d, asn: seqnro=%d", xappConn.GetDesc(), msg.Xid, msg.SubId, resp.RequestId.Seq)
-			return e2SubsId
-		}
-	case <-time.After(15 * time.Second):
-		testError(t, "(%s) Not Received RIC_SUB_RESP within 15 secs", xappConn.GetDesc())
-		return 0
-	}
-	return 0
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-func (xappConn *testingXappStub) handle_xapp_subs_fail(t *testing.T, trans *xappTransaction) uint32 {
-	xapp.Logger.Info("(%s) handle_xapp_subs_fail", xappConn.GetDesc())
-	e2SubsFail := xapp_e2asnpacker.NewPackerSubscriptionFailure()
-	var e2SubsId uint32
-
-	//-------------------------------
-	// xapp activity: Recv Subs Fail
-	//-------------------------------
-	select {
-	case msg := <-xappConn.rmrConChan:
-		xappConn.DecMsgCnt()
-		if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_FAILURE"] {
-			testError(t, "(%s) Received RIC_SUB_FAILURE wrong mtype expected %s got %s, error", xappConn.GetDesc(), "RIC_SUB_FAILURE", xapp.RicMessageTypeToName[msg.Mtype])
-			return 0
-		} else if msg.Xid != trans.xid {
-			testError(t, "(%s) Received RIC_SUB_FAILURE wrong xid expected %s got %s, error", xappConn.GetDesc(), trans.xid, msg.Xid)
-			return 0
-		} else {
-			packedData := &e2ap.PackedData{}
-			packedData.Buf = msg.Payload
-			if msg.SubId > 0 {
-				e2SubsId = uint32(msg.SubId)
-			} else {
-				e2SubsId = 0
-			}
-			unpackerr, resp := e2SubsFail.UnPack(packedData)
-			if unpackerr != nil {
-				testError(t, "(%s) RIC_SUB_FAILURE unpack failed err: %s", xappConn.GetDesc(), unpackerr.Error())
-			}
-			xapp.Logger.Info("(%s) Recv Subs Fail rmr: xid=%s subid=%d, asn: seqnro=%d", xappConn.GetDesc(), msg.Xid, msg.SubId, resp.RequestId.Seq)
-			return e2SubsId
-		}
-	case <-time.After(15 * time.Second):
-		testError(t, "(%s) Not Received RIC_SUB_FAILURE within 15 secs", xappConn.GetDesc())
-		return 0
-	}
-	return 0
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-func (xappConn *testingXappStub) handle_xapp_subs_del_req(t *testing.T, oldTrans *xappTransaction, e2SubsId uint32) *xappTransaction {
-
-	trans := oldTrans
-	if oldTrans == nil {
-		trans = xappConn.newXappTransaction("", "RAN_NAME_1")
-	}
-
-	xapp.Logger.Info("(%s) handle_xapp_subs_del_req %s", xappConn.GetDesc(), trans.String())
-	e2SubsDelReq := xapp_e2asnpacker.NewPackerSubscriptionDeleteRequest()
-	//---------------------------------
-	// xapp activity: Send Subs Del Req
-	//---------------------------------
-	xapp.Logger.Info("(%s) Send Subs Del Req  %s", xappConn.GetDesc(), trans.String())
-
-	req := &e2ap.E2APSubscriptionDeleteRequest{}
-	req.RequestId.Id = 1
-	req.RequestId.Seq = e2SubsId
-	req.FunctionId = 1
-
-	err, packedMsg := e2SubsDelReq.Pack(req)
-	if err != nil {
-		testError(t, "(%s) pack NOK %s %s", xappConn.GetDesc(), trans.String(), err.Error())
-		return nil
-	}
-	xapp.Logger.Debug("(%s) %s %s", xappConn.GetDesc(), trans.String(), e2SubsDelReq.String())
-
-	params := &RMRParams{&xapp.RMRParams{}}
-	params.Mtype = xapp.RIC_SUB_DEL_REQ
-	params.SubId = int(e2SubsId)
-	params.Payload = packedMsg.Buf
-	params.Meid = trans.meid
-	params.Xid = trans.xid
-	params.Mbuf = nil
-
-	snderr := xappConn.RmrSend(params)
-
-	if snderr != nil {
-		testError(t, "(%s) RMR SEND FAILED: %s %s", xappConn.GetDesc(), trans.String(), snderr.Error())
-		return nil
-	}
-	return trans
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-func (xappConn *testingXappStub) handle_xapp_subs_del_resp(t *testing.T, trans *xappTransaction) {
-	xapp.Logger.Info("(%s) handle_xapp_subs_del_resp", xappConn.GetDesc())
-	e2SubsDelResp := xapp_e2asnpacker.NewPackerSubscriptionDeleteResponse()
-
-	//---------------------------------
-	// xapp activity: Recv Subs Del Resp
-	//---------------------------------
-	select {
-	case msg := <-xappConn.rmrConChan:
-		xappConn.DecMsgCnt()
-		if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_RESP"] {
-			testError(t, "(%s) Received RIC_SUB_DEL_RESP wrong mtype expected %s got %s, error", xappConn.GetDesc(), "RIC_SUB_DEL_RESP", xapp.RicMessageTypeToName[msg.Mtype])
-			return
-		} else if trans != nil && msg.Xid != trans.xid {
-			testError(t, "(%s) Received RIC_SUB_DEL_RESP wrong xid expected %s got %s, error", xappConn.GetDesc(), trans.xid, msg.Xid)
-			return
-		} else {
-			packedData := &e2ap.PackedData{}
-			packedData.Buf = msg.Payload
-			unpackerr, resp := e2SubsDelResp.UnPack(packedData)
-			if unpackerr != nil {
-				testError(t, "(%s) RIC_SUB_DEL_RESP unpack failed err: %s", xappConn.GetDesc(), unpackerr.Error())
-			}
-			xapp.Logger.Info("(%s) Recv Subs Del Resp rmr: xid=%s subid=%d, asn: seqnro=%d", xappConn.GetDesc(), msg.Xid, msg.SubId, resp.RequestId.Seq)
-			return
-		}
-	case <-time.After(15 * time.Second):
-		testError(t, "(%s) Not Received RIC_SUB_DEL_RESP within 15 secs", xappConn.GetDesc())
-	}
-}
diff --git a/pkg/control/ut_test.go b/pkg/control/ut_test.go
index 151619d..38bd322 100644
--- a/pkg/control/ut_test.go
+++ b/pkg/control/ut_test.go
@@ -20,160 +20,36 @@
 package control
 
 import (
-	"fmt"
-	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
-	"io/ioutil"
+	"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"
 	"os"
-	"strings"
-	"sync"
 	"testing"
-	"time"
 )
 
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-type testingRmrControl struct {
-	desc     string
-	mutex    sync.Mutex
-	syncChan chan struct{}
-}
-
-func (tc *testingRmrControl) Lock() {
-	tc.mutex.Lock()
-}
-
-func (tc *testingRmrControl) Unlock() {
-	tc.mutex.Unlock()
-}
-
-func (tc *testingRmrControl) GetDesc() string {
-	return tc.desc
-}
-
-func (tc *testingRmrControl) ReadyCB(data interface{}) {
-	xapp.Logger.Info("testingRmrControl(%s) ReadyCB", tc.GetDesc())
-	tc.syncChan <- struct{}{}
-	return
-}
-
-func (tc *testingRmrControl) WaitCB() {
-	<-tc.syncChan
-}
-
-func (tc *testingRmrControl) init(desc string, rtfile string, port string) {
-	os.Setenv("RMR_SEED_RT", rtfile)
-	os.Setenv("RMR_SRC_ID", "localhost:"+port)
-	xapp.Logger.Info("Using rt file %s", os.Getenv("RMR_SEED_RT"))
-	xapp.Logger.Info("Using src id  %s", os.Getenv("RMR_SRC_ID"))
-	tc.desc = strings.ToUpper(desc)
-	tc.syncChan = make(chan struct{})
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-type testingRmrStubControl struct {
-	testingRmrControl
-	rmrConChan    chan *RMRParams
-	rmrClientTest *xapp.RMRClient
-	active        bool
-	msgCnt        uint64
-}
-
-func (tc *testingRmrStubControl) GetMsgCnt() uint64 {
-	return tc.msgCnt
-}
-
-func (tc *testingRmrStubControl) IncMsgCnt() {
-	tc.msgCnt++
-}
-
-func (tc *testingRmrStubControl) DecMsgCnt() {
-	if tc.msgCnt > 0 {
-		tc.msgCnt--
-	}
-}
-
-func (tc *testingRmrStubControl) TestMsgCnt(t *testing.T) {
-	if tc.GetMsgCnt() > 0 {
-		testError(t, "(%s) message count expected 0 but is %d", tc.GetDesc(), tc.GetMsgCnt())
-	}
-}
-
-func (tc *testingRmrStubControl) RmrSend(params *RMRParams) (err error) {
-	//
-	//NOTE: Do this way until xapp-frame sending is improved
-	//
-	xapp.Logger.Info("(%s) RmrSend %s", tc.GetDesc(), params.String())
-	status := false
-	i := 1
-	for ; i <= 10 && status == false; i++ {
-		status = tc.rmrClientTest.SendMsg(params.RMRParams)
-		if status == false {
-			xapp.Logger.Info("(%s) RmrSend failed. Retry count %v, %s", tc.GetDesc(), i, params.String())
-			time.Sleep(500 * time.Millisecond)
-		}
-	}
-	if status == false {
-		err = fmt.Errorf("(%s) RmrSend failed. Retry count %v, %s", tc.GetDesc(), i, params.String())
-		xapp.Rmr.Free(params.Mbuf)
-	}
-	return
-}
-
-func (tc *testingRmrStubControl) init(desc string, rtfile string, port string, stat string, consumer xapp.MessageConsumer) {
-	tc.active = false
-	tc.testingRmrControl.init(desc, rtfile, port)
-	tc.rmrConChan = make(chan *RMRParams)
-	tc.rmrClientTest = xapp.NewRMRClientWithParams("tcp:"+port, 4096, 1, stat)
-	tc.rmrClientTest.SetReadyCB(tc.ReadyCB, nil)
-	go tc.rmrClientTest.Start(consumer)
-	tc.WaitCB()
-	allRmrStubs = append(allRmrStubs, tc)
-}
-
-var allRmrStubs []*testingRmrStubControl
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-
-func testError(t *testing.T, pattern string, args ...interface{}) {
-	xapp.Logger.Error(fmt.Sprintf(pattern, args...))
-	t.Errorf(fmt.Sprintf(pattern, args...))
-}
-
-func testLog(t *testing.T, pattern string, args ...interface{}) {
-	xapp.Logger.Info(fmt.Sprintf(pattern, args...))
-	t.Logf(fmt.Sprintf(pattern, args...))
-}
-
-func testCreateTmpFile(str string) (string, error) {
-	file, err := ioutil.TempFile("/tmp", "*.rt")
-	if err != nil {
-		return "", err
-	}
-	_, err = file.WriteString(str)
-	if err != nil {
-		file.Close()
-		return "", err
-	}
-	return file.Name(), nil
+func CaseBegin(desc string) *teststub.TestWrapper {
+	tent := teststub.NewTestWrapper(desc)
+	tent.Logger.Info(desc)
+	return tent
 }
 
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
 
-var xappConn1 *testingXappStub
-var xappConn2 *testingXappStub
-var e2termConn *testingE2termStub
+var xappConn1 *teststube2ap.E2Stub
+var xappConn2 *teststube2ap.E2Stub
+var e2termConn *teststube2ap.E2Stub
 var rtmgrHttp *testingHttpRtmgrStub
 var mainCtrl *testingSubmgrControl
 
+var dummystub *teststubdummy.RmrDummyStub
+
 func ut_test_init() {
-	xapp.Logger.Info("ut_test_init")
+	tent := CaseBegin("ut_test_init")
 
 	//---------------------------------
 	//
@@ -219,7 +95,7 @@
 	   defer os.Remove(cfgfilename)
 	   os.Setenv("CFG_FILE", cfgfilename)
 	*/
-	xapp.Logger.Info("Using cfg file %s", os.Getenv("CFG_FILE"))
+	tent.Logger.Info("Using cfg file %s", os.Getenv("CFG_FILE"))
 
 	//---------------------------------
 	// Static routetable for rmr
@@ -239,97 +115,61 @@
 	// 15560   e2term stub
 	// 13560   xapp1 stub
 	// 13660   xapp2 stub
+	// 16560   dummy stub
 	//
 	//---------------------------------
+	rt := &teststub.RmrRouteTable{}
+	rt.AddEntry(12010, "", -1, "localhost:14560")
+	rt.AddEntry(12010, "localhost:14560", -1, "localhost:15560")
+	rt.AddEntry(12011, "localhost:15560", -1, "localhost:14560")
+	rt.AddEntry(12012, "localhost:15560", -1, "localhost:14560")
+	rt.AddEntry(12011, "localhost:14560", -1, "localhost:13660;localhost:13560")
+	rt.AddEntry(12012, "localhost:14560", -1, "localhost:13660;localhost:13560")
+	rt.AddEntry(12020, "", -1, "localhost:14560")
+	rt.AddEntry(12020, "localhost:14560", -1, "localhost:15560")
+	rt.AddEntry(12021, "localhost:15560", -1, "localhost:14560")
+	rt.AddEntry(12022, "localhost:15560", -1, "localhost:14560")
+	rt.AddEntry(12021, "localhost:14560", -1, "localhost:13660;localhost:13560")
+	rt.AddEntry(12022, "localhost:14560", -1, "localhost:13660;localhost:13560")
+	rt.AddEntry(55555, "", -1, "localhost:13660;localhost:13560;localhost:15560;localhost:16560")
 
-	allrt := `newrt|start
-mse|12010|-1|localhost:14560
-mse|12010,localhost:14560|-1|localhost:15560
-mse|12011,localhost:15560|-1|localhost:14560
-mse|12012,localhost:15560|-1|localhost:14560
-mse|12011,localhost:14560|-1|localhost:13660;localhost:13560
-mse|12012,localhost:14560|-1|localhost:13660;localhost:13560
-mse|12020|-1|localhost:14560
-mse|12020,localhost:14560|-1|localhost:15560
-mse|12021,localhost:15560|-1|localhost:14560
-mse|12022,localhost:15560|-1|localhost:14560
-mse|12021,localhost:14560|-1|localhost:13660;localhost:13560
-mse|12022,localhost:14560|-1|localhost:13660;localhost:13560
-mse|55555|-1|localhost:13660;localhost:13560,localhost:15560
-newrt|end
-`
+	rtfilename, _ := teststub.CreateTmpFile(rt.GetRt())
+	defer os.Remove(rtfilename)
 
 	//---------------------------------
 	//
 	//---------------------------------
-	xapp.Logger.Info("### submgr ctrl run ###")
-	subsrt := allrt
-	subrtfilename, _ := testCreateTmpFile(subsrt)
-	defer os.Remove(subrtfilename)
-	mainCtrl = createSubmgrControl("main", subrtfilename, "14560")
+	tent.Logger.Info("### submgr ctrl run ###")
+	mainCtrl = createSubmgrControl(rtfilename, "14560")
 
 	//---------------------------------
 	//
 	//---------------------------------
-	xapp.Logger.Info("### xapp1 stub run ###")
-	xapprt1 := allrt
-	xapprtfilename1, _ := testCreateTmpFile(xapprt1)
-	defer os.Remove(xapprtfilename1)
-	xappConn1 = createNewXappStub("xappstub1", xapprtfilename1, "13560", "RMRXAPP1STUB")
+	tent.Logger.Info("### xapp1 stub run ###")
+	xappConn1 = teststube2ap.CreateNewE2Stub("xappstub1", rtfilename, "13560", "RMRXAPP1STUB", 55555)
 
 	//---------------------------------
 	//
 	//---------------------------------
-	xapp.Logger.Info("### xapp2 stub run ###")
-	xapprt2 := allrt
-	xapprtfilename2, _ := testCreateTmpFile(xapprt2)
-	defer os.Remove(xapprtfilename2)
-	xappConn2 = createNewXappStub("xappstub2", xapprtfilename2, "13660", "RMRXAPP2STUB")
+	tent.Logger.Info("### xapp2 stub run ###")
+	xappConn2 = teststube2ap.CreateNewE2Stub("xappstub2", rtfilename, "13660", "RMRXAPP2STUB", 55555)
 
 	//---------------------------------
 	//
 	//---------------------------------
-	xapp.Logger.Info("### e2term stub run ###")
-	e2termrt := allrt
-	e2termrtfilename, _ := testCreateTmpFile(e2termrt)
-	defer os.Remove(e2termrtfilename)
-	e2termConn = createNewE2termStub("e2termstub", e2termrtfilename, "15560", "RMRE2TERMSTUB")
+	tent.Logger.Info("### e2term stub run ###")
+	e2termConn = teststube2ap.CreateNewE2termStub("e2termstub", rtfilename, "15560", "RMRE2TERMSTUB", 55555)
+
+	//---------------------------------
+	// Just to test dummy stub
+	//---------------------------------
+	tent.Logger.Info("### dummy stub run ###")
+	dummystub = teststubdummy.CreateNewRmrDummyStub("dummystub", rtfilename, "16560", "DUMMYSTUB", 55555)
 
 	//---------------------------------
 	// Testing message sending
 	//---------------------------------
-	var dummyBuf []byte = make([]byte, 100)
-
-	params := &RMRParams{&xapp.RMRParams{}}
-	params.Mtype = 55555
-	params.SubId = -1
-	params.Payload = dummyBuf
-	params.PayloadLen = 100
-	params.Meid = &xapp.RMRMeid{RanName: "NONEXISTINGRAN"}
-	params.Xid = "THISISTESTFORSTUBS"
-	params.Mbuf = nil
-
-	status := false
-	i := 1
-	for ; i <= 10 && status == false; i++ {
-		xapp.Rmr.Send(params.RMRParams, false)
-
-		status = true
-		for _, val := range allRmrStubs {
-			if val.active == false {
-				status = false
-				break
-			}
-		}
-		if status == true {
-			break
-		}
-		xapp.Logger.Info("Sleep 0.5 secs and try routes again")
-		time.Sleep(500 * time.Millisecond)
-	}
-
-	if status == false {
-		xapp.Logger.Error("Could not initialize routes")
+	if teststub.RmrStubControlWaitAlive(10, 55555, mainCtrl.c) == false {
 		os.Exit(1)
 	}
 }
@@ -338,7 +178,7 @@
 //
 //-----------------------------------------------------------------------------
 func TestMain(m *testing.M) {
-	xapp.Logger.Info("TestMain start")
+	CaseBegin("TestMain start")
 	ut_test_init()
 	code := m.Run()
 	os.Exit(code)
diff --git a/pkg/teststub/controlRmr.go b/pkg/teststub/controlRmr.go
new file mode 100644
index 0000000..bcea500
--- /dev/null
+++ b/pkg/teststub/controlRmr.go
@@ -0,0 +1,62 @@
+/*
+==================================================================================
+  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 (
+	"fmt"
+	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+	"os"
+	"testing"
+)
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type RmrControl struct {
+	TestWrapper
+	syncChan chan struct{}
+}
+
+func (tc *RmrControl) ReadyCB(data interface{}) {
+	tc.syncChan <- struct{}{}
+	return
+}
+
+func (tc *RmrControl) WaitCB() {
+	<-tc.syncChan
+}
+
+func (tc *RmrControl) Init(desc string, rtfile string, port string) {
+	tc.TestWrapper.Init(desc)
+	os.Setenv("RMR_SEED_RT", rtfile)
+	os.Setenv("RMR_SRC_ID", "localhost:"+port)
+	xapp.Logger.Info("Using rt file %s", os.Getenv("RMR_SEED_RT"))
+	xapp.Logger.Info("Using src id  %s", os.Getenv("RMR_SRC_ID"))
+	tc.syncChan = make(chan struct{})
+}
+
+func (tc *RmrControl) TestError(t *testing.T, pattern string, args ...interface{}) {
+	tc.Logger.Error(fmt.Sprintf(pattern, args...))
+	t.Errorf(fmt.Sprintf(pattern, args...))
+}
+
+func (tc *RmrControl) TestLog(t *testing.T, pattern string, args ...interface{}) {
+	tc.Logger.Info(fmt.Sprintf(pattern, args...))
+	t.Logf(fmt.Sprintf(pattern, args...))
+}
diff --git a/pkg/teststub/controlRmrStub.go b/pkg/teststub/controlRmrStub.go
new file mode 100644
index 0000000..a8c861f
--- /dev/null
+++ b/pkg/teststub/controlRmrStub.go
@@ -0,0 +1,175 @@
+/*
+==================================================================================
+  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"
+	"strings"
+	"testing"
+	"time"
+)
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type RmrStubControl struct {
+	RmrControl
+	xapptweaks.RmrWrapper
+	RecvChan chan *xapptweaks.RMRParams
+	Active   bool
+	InitMsg  int
+	CheckXid bool
+}
+
+func (tc *RmrStubControl) SetActive() {
+	tc.Active = true
+}
+
+func (tc *RmrStubControl) IsActive() bool {
+	return tc.Active
+}
+
+func (tc *RmrStubControl) SetCheckXid(val bool) {
+	tc.CheckXid = val
+}
+
+func (tc *RmrStubControl) IsCheckXid() bool {
+	return tc.CheckXid
+}
+
+func (tc *RmrStubControl) IsChanEmpty() bool {
+	if len(tc.RecvChan) > 0 {
+		return false
+	}
+	return true
+}
+
+func (tc *RmrStubControl) TestMsgChanEmpty(t *testing.T) {
+	if tc.IsChanEmpty() == false {
+		tc.TestError(t, "message channel not empty")
+	}
+}
+
+func (tc *RmrStubControl) Init(desc string, rtfile string, port string, stat string, initMsg int) {
+	tc.InitMsg = initMsg
+	tc.Active = false
+	tc.RecvChan = make(chan *xapptweaks.RMRParams)
+	tc.RmrControl.Init(desc, rtfile, port)
+	tc.RmrWrapper.Init()
+
+	tc.Rmr = xapp.NewRMRClientWithParams("tcp:"+port, 4096, 1, stat)
+	tc.Rmr.SetReadyCB(tc.ReadyCB, nil)
+	go tc.Rmr.Start(tc)
+
+	tc.WaitCB()
+	allRmrStubs = append(allRmrStubs, tc)
+}
+
+func (tc *RmrStubControl) Consume(params *xapp.RMRParams) (err error) {
+	defer tc.Rmr.Free(params.Mbuf)
+	msg := xapptweaks.NewParams(params)
+	tc.CntRecvMsg++
+
+	if msg.Mtype == tc.InitMsg {
+		tc.Logger.Info("Testing message ignore %s", msg.String())
+		tc.SetActive()
+		return
+	}
+
+	if tc.IsCheckXid() == true && strings.Contains(msg.Xid, tc.GetDesc()) == false {
+		tc.Logger.Info("Ignore %s", msg.String())
+		return
+	}
+
+	tc.Logger.Info("Consume %s", msg.String())
+	tc.PushMsg(msg)
+	return
+}
+
+func (tc *RmrStubControl) PushMsg(msg *xapptweaks.RMRParams) {
+	tc.Logger.Debug("RmrStubControl PushMsg ... msg(%d) waiting", msg.Mtype)
+	tc.RecvChan <- msg
+	tc.Logger.Debug("RmrStubControl PushMsg ... done")
+}
+
+func (tc *RmrStubControl) WaitMsg(secs time.Duration) *xapptweaks.RMRParams {
+	tc.Logger.Debug("RmrStubControl WaitMsg ... waiting")
+	if secs == 0 {
+		msg := <-tc.RecvChan
+		tc.Logger.Debug("RmrStubControl WaitMsg ... msg(%d) done", msg.Mtype)
+		return msg
+	}
+	select {
+	case msg := <-tc.RecvChan:
+		tc.Logger.Debug("RmrStubControl WaitMsg ... msg(%d) done", msg.Mtype)
+		return msg
+	case <-time.After(secs * time.Second):
+		tc.Logger.Debug("RmrStubControl WaitMsg ... timeout")
+		return nil
+	}
+	tc.Logger.Debug("RmrStubControl WaitMsg ... error")
+	return nil
+}
+
+var allRmrStubs []*RmrStubControl
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+
+func RmrStubControlWaitAlive(seconds int, mtype int, rmr xapptweaks.XAppWrapperIf) bool {
+
+	var dummyBuf []byte = make([]byte, 100)
+
+	params := xapptweaks.NewParams(nil)
+	params.Mtype = mtype
+	params.SubId = -1
+	params.Payload = dummyBuf
+	params.PayloadLen = 100
+	params.Meid = &xapp.RMRMeid{RanName: "TESTPING"}
+	params.Xid = "TESTPING"
+	params.Mbuf = nil
+
+	status := false
+	i := 1
+	for ; i <= seconds*2 && status == false; i++ {
+
+		rmr.GetLogger().Info("SEND TESTPING: %s", params.String())
+		rmr.RmrSend(params)
+
+		status = true
+		for _, val := range allRmrStubs {
+			if val.IsActive() == false {
+				status = false
+				break
+			}
+		}
+		if status == true {
+			break
+		}
+		rmr.GetLogger().Info("Sleep 0.5 secs and try routes again")
+		time.Sleep(500 * time.Millisecond)
+	}
+
+	if status == false {
+		rmr.GetLogger().Error("Could not initialize routes")
+	}
+	return status
+}
diff --git a/pkg/teststub/rmrroutetable.go b/pkg/teststub/rmrroutetable.go
new file mode 100644
index 0000000..9ea2657
--- /dev/null
+++ b/pkg/teststub/rmrroutetable.go
@@ -0,0 +1,55 @@
+/*
+==================================================================================
+  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 {
+	lines []string
+}
+
+func (rrt *RmrRouteTable) AddEntry(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.lines = append(rrt.lines, line)
+}
+
+func (rrt *RmrRouteTable) GetRt() string {
+	allrt := "newrt|start\n"
+	for _, val := range rrt.lines {
+		allrt += val + "\n"
+	}
+	allrt += "newrt|end\n"
+	return allrt
+}
diff --git a/pkg/teststub/teststub.go b/pkg/teststub/teststub.go
new file mode 100644
index 0000000..963918a
--- /dev/null
+++ b/pkg/teststub/teststub.go
@@ -0,0 +1,39 @@
+/*
+==================================================================================
+  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 (
+	"io/ioutil"
+)
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func CreateTmpFile(str string) (string, error) {
+	file, err := ioutil.TempFile("/tmp", "*.rt")
+	if err != nil {
+		return "", err
+	}
+	_, err = file.WriteString(str)
+	if err != nil {
+		file.Close()
+		return "", err
+	}
+	return file.Name(), nil
+}
diff --git a/pkg/teststub/testwrapper.go b/pkg/teststub/testwrapper.go
new file mode 100644
index 0000000..f27392d
--- /dev/null
+++ b/pkg/teststub/testwrapper.go
@@ -0,0 +1,55 @@
+/*
+==================================================================================
+  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 (
+	"fmt"
+	"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
+	"testing"
+)
+
+type TestWrapper struct {
+	xapptweaks.LogWrapper
+}
+
+func (tw *TestWrapper) Init(desc string) {
+	tw.LogWrapper.Init(desc)
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tw *TestWrapper) TestError(t *testing.T, pattern string, args ...interface{}) {
+	tw.Logger.Error(fmt.Sprintf(pattern, args...))
+	t.Errorf(fmt.Sprintf(pattern, args...))
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tw *TestWrapper) TestLog(t *testing.T, pattern string, args ...interface{}) {
+	tw.Logger.Info(fmt.Sprintf(pattern, args...))
+	t.Logf(fmt.Sprintf(pattern, args...))
+}
+
+func NewTestWrapper(desc string) *TestWrapper {
+	tent := &TestWrapper{}
+	tent.Init(desc)
+	return tent
+}
diff --git a/pkg/teststubdummy/stubRmrDummy.go b/pkg/teststubdummy/stubRmrDummy.go
new file mode 100644
index 0000000..77e4b7d
--- /dev/null
+++ b/pkg/teststubdummy/stubRmrDummy.go
@@ -0,0 +1,114 @@
+/*
+==================================================================================
+  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.
+==================================================================================
+*/
+
+//
+// EXAMPLE HOW TO HAVE RMR STUB
+//
+
+package teststubdummy
+
+import (
+	"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
+	"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
+	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+	"testing"
+)
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type RmrDummyStub struct {
+	teststub.RmrStubControl
+	reqMsg  int
+	respMsg int
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func CreateNewRmrDummyStub(desc string, rtfile string, port string, stat string, mtypeseed int) *RmrDummyStub {
+	dummyStub := &RmrDummyStub{}
+	dummyStub.RmrStubControl.Init(desc, rtfile, port, stat, mtypeseed)
+	dummyStub.reqMsg = mtypeseed + 1
+	dummyStub.respMsg = mtypeseed + 2
+	return dummyStub
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+
+func (tc *RmrDummyStub) SendReq(t *testing.T) {
+	tc.Logger.Info("SendReq")
+	var dummyBuf []byte = make([]byte, 100)
+	params := xapptweaks.NewParams(nil)
+	params.Mtype = tc.reqMsg
+	params.SubId = -1
+	params.Payload = dummyBuf
+	params.PayloadLen = 100
+	params.Meid = &xapp.RMRMeid{RanName: "TEST"}
+	params.Xid = "TEST"
+	params.Mbuf = nil
+
+	snderr := tc.RmrSend(params)
+	if snderr != nil {
+		tc.TestError(t, "%s", snderr.Error())
+	}
+	return
+}
+
+func (tc *RmrDummyStub) RecvResp(t *testing.T) bool {
+	tc.Logger.Info("RecvResp")
+
+	msg := tc.WaitMsg(15)
+	if msg != nil {
+		if msg.Mtype != tc.respMsg {
+			tc.TestError(t, "Received wrong mtype expected %d got %d, error", tc.respMsg, msg.Mtype)
+			return false
+		}
+		return true
+	} else {
+		tc.TestError(t, "Not Received msg within %d secs", 15)
+	}
+	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)
+		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
new file mode 100644
index 0000000..c7c09ab
--- /dev/null
+++ b/pkg/teststube2ap/stubE2.go
@@ -0,0 +1,588 @@
+/*
+==================================================================================
+  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 teststube2ap
+
+import (
+	"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
+	"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
+	"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
+	"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
+	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+	"strconv"
+	"testing"
+)
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+var e2asnpacker e2ap.E2APPackerIf = e2ap_wrapper.NewAsn1E2Packer()
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type RmrTransactionId struct {
+	xid  string
+	meid *xapp.RMRMeid
+}
+
+func (trans *RmrTransactionId) String() string {
+	return "trans(" + trans.xid + "/" + trans.meid.RanName + ")"
+}
+
+type E2Stub struct {
+	teststub.RmrStubControl
+	xid_seq uint64
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func CreateNewE2Stub(desc string, rtfile string, port string, stat string, mtypeseed int) *E2Stub {
+	tc := &E2Stub{}
+	tc.RmrStubControl.Init(desc, rtfile, port, stat, mtypeseed)
+	tc.xid_seq = 1
+	tc.SetCheckXid(true)
+	return tc
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func CreateNewE2termStub(desc string, rtfile string, port string, stat string, mtypeseed int) *E2Stub {
+	tc := &E2Stub{}
+	tc.RmrStubControl.Init(desc, rtfile, port, stat, mtypeseed)
+	tc.xid_seq = 1
+	tc.SetCheckXid(false)
+	return tc
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) NewRmrTransactionId(xid string, ranname string) *RmrTransactionId {
+	trans := &RmrTransactionId{}
+	if len(xid) == 0 {
+		trans.xid = tc.GetDesc() + "_XID_" + strconv.FormatUint(uint64(tc.xid_seq), 10)
+		tc.xid_seq++
+	} else {
+		trans.xid = xid
+	}
+	trans.meid = &xapp.RMRMeid{RanName: ranname}
+	tc.Logger.Info("New test %s", trans.String())
+	return trans
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type E2StubSubsReqParams struct {
+	Req *e2ap.E2APSubscriptionRequest
+}
+
+func (p *E2StubSubsReqParams) Init() {
+	p.Req = &e2ap.E2APSubscriptionRequest{}
+
+	p.Req.RequestId.Id = 1
+	p.Req.RequestId.Seq = 0
+	p.Req.FunctionId = 1
+
+	p.Req.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present = true
+	p.Req.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.StringPut("310150")
+	p.Req.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Id = 123
+	p.Req.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Bits = e2ap.E2AP_ENBIDHomeBits28
+
+	// gnb -> enb outgoing
+	// enb -> gnb incoming
+	// X2 36423-f40.doc
+	p.Req.EventTriggerDefinition.InterfaceDirection = e2ap.E2AP_InterfaceDirectionIncoming
+	p.Req.EventTriggerDefinition.ProcedureCode = 5 //28 35
+	p.Req.EventTriggerDefinition.TypeOfMessage = e2ap.E2AP_InitiatingMessage
+
+	p.Req.ActionSetups = make([]e2ap.ActionToBeSetupItem, 1)
+	p.Req.ActionSetups[0].ActionId = 0
+	p.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeReport
+	p.Req.ActionSetups[0].ActionDefinition.Present = false
+	//p.Req.ActionSetups[index].ActionDefinition.StyleId = 255
+	//p.Req.ActionSetups[index].ActionDefinition.ParamId = 222
+	p.Req.ActionSetups[0].SubsequentAction.Present = true
+	p.Req.ActionSetups[0].SubsequentAction.Type = e2ap.E2AP_SubSeqActionTypeContinue
+	p.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitZero
+
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+
+type E2StubSubsFailParams struct {
+	Req  *e2ap.E2APSubscriptionRequest
+	Fail *e2ap.E2APSubscriptionFailure
+}
+
+func (p *E2StubSubsFailParams) Set(req *e2ap.E2APSubscriptionRequest) {
+	p.Req = req
+
+	p.Fail = &e2ap.E2APSubscriptionFailure{}
+	p.Fail.RequestId.Id = p.Req.RequestId.Id
+	p.Fail.RequestId.Seq = p.Req.RequestId.Seq
+	p.Fail.FunctionId = p.Req.FunctionId
+	p.Fail.ActionNotAdmittedList.Items = make([]e2ap.ActionNotAdmittedItem, len(p.Req.ActionSetups))
+	for index := int(0); index < len(p.Fail.ActionNotAdmittedList.Items); index++ {
+		p.Fail.ActionNotAdmittedList.Items[index].ActionId = p.Req.ActionSetups[index].ActionId
+		p.SetCauseVal(index, 5, 1)
+	}
+}
+
+func (p *E2StubSubsFailParams) SetCauseVal(ind int, content uint8, causeval uint8) {
+
+	if ind < 0 {
+		for index := int(0); index < len(p.Fail.ActionNotAdmittedList.Items); index++ {
+			p.Fail.ActionNotAdmittedList.Items[index].Cause.Content = content
+			p.Fail.ActionNotAdmittedList.Items[index].Cause.CauseVal = causeval
+		}
+		return
+	}
+	p.Fail.ActionNotAdmittedList.Items[ind].Cause.Content = content
+	p.Fail.ActionNotAdmittedList.Items[ind].Cause.CauseVal = causeval
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+
+func (tc *E2Stub) SendSubsReq(t *testing.T, rparams *E2StubSubsReqParams, oldTrans *RmrTransactionId) *RmrTransactionId {
+
+	trans := oldTrans
+	if oldTrans == nil {
+		trans = tc.NewRmrTransactionId("", "RAN_NAME_1")
+	}
+
+	tc.Logger.Info("SendSubsReq %s", trans.String())
+	e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest()
+
+	//---------------------------------
+	// xapp activity: Send Subs Req
+	//---------------------------------
+	myparams := rparams
+
+	if myparams == nil {
+		myparams = &E2StubSubsReqParams{}
+		myparams.Init()
+	}
+
+	err, packedMsg := e2SubsReq.Pack(myparams.Req)
+	if err != nil {
+		tc.TestError(t, "pack NOK %s %s", trans.String(), err.Error())
+		return nil
+	}
+	tc.Logger.Debug("%s %s", trans.String(), e2SubsReq.String())
+
+	params := xapptweaks.NewParams(nil)
+	params.Mtype = xapp.RIC_SUB_REQ
+	params.SubId = -1
+	params.Payload = packedMsg.Buf
+	params.Meid = trans.meid
+	params.Xid = trans.xid
+	params.Mbuf = nil
+
+	tc.Logger.Info("SEND SUB REQ: %s", params.String())
+	snderr := tc.RmrSend(params)
+	if snderr != nil {
+		tc.TestError(t, "RMR SEND FAILED: %s %s", trans.String(), snderr.Error())
+		return nil
+	}
+	return trans
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) RecvSubsReq(t *testing.T) (*e2ap.E2APSubscriptionRequest, *xapptweaks.RMRParams) {
+	tc.Logger.Info("RecvSubsReq")
+	e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest()
+
+	//---------------------------------
+	// e2term activity: Recv Subs Req
+	//---------------------------------
+	msg := tc.WaitMsg(15)
+	if msg != nil {
+		if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_REQ"] {
+			tc.TestError(t, "Received wrong mtype expected %s got %s, error", "RIC_SUB_REQ", xapp.RicMessageTypeToName[msg.Mtype])
+		} else {
+			tc.Logger.Info("Recv Subs Req")
+			packedData := &e2ap.PackedData{}
+			packedData.Buf = msg.Payload
+			unpackerr, req := e2SubsReq.UnPack(packedData)
+			if unpackerr != nil {
+				tc.TestError(t, "RIC_SUB_REQ unpack failed err: %s", unpackerr.Error())
+			}
+			return req, msg
+		}
+	} else {
+		tc.TestError(t, "Not Received msg within %d secs", 15)
+	}
+
+	return nil, nil
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *xapptweaks.RMRParams) {
+	tc.Logger.Info("SendSubsResp")
+	e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse()
+
+	//---------------------------------
+	// e2term activity: Send Subs Resp
+	//---------------------------------
+	resp := &e2ap.E2APSubscriptionResponse{}
+
+	resp.RequestId.Id = req.RequestId.Id
+	resp.RequestId.Seq = req.RequestId.Seq
+	resp.FunctionId = req.FunctionId
+
+	resp.ActionAdmittedList.Items = make([]e2ap.ActionAdmittedItem, len(req.ActionSetups))
+	for index := int(0); index < len(req.ActionSetups); index++ {
+		resp.ActionAdmittedList.Items[index].ActionId = req.ActionSetups[index].ActionId
+	}
+
+	for index := uint64(0); index < 1; index++ {
+		item := e2ap.ActionNotAdmittedItem{}
+		item.ActionId = index
+		item.Cause.Content = 1
+		item.Cause.CauseVal = 1
+		resp.ActionNotAdmittedList.Items = append(resp.ActionNotAdmittedList.Items, item)
+	}
+
+	packerr, packedMsg := e2SubsResp.Pack(resp)
+	if packerr != nil {
+		tc.TestError(t, "pack NOK %s", packerr.Error())
+	}
+	tc.Logger.Debug("%s", e2SubsResp.String())
+
+	params := xapptweaks.NewParams(nil)
+	params.Mtype = xapp.RIC_SUB_RESP
+	//params.SubId = msg.SubId
+	params.SubId = -1
+	params.Payload = packedMsg.Buf
+	params.Meid = msg.Meid
+	//params.Xid = msg.Xid
+	params.Mbuf = nil
+
+	tc.Logger.Info("SEND SUB RESP: %s", params.String())
+	snderr := tc.RmrSend(params)
+	if snderr != nil {
+		tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
+	}
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) RecvSubsResp(t *testing.T, trans *RmrTransactionId) uint32 {
+	tc.Logger.Info("RecvSubsResp")
+	e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse()
+	var e2SubsId uint32
+
+	//---------------------------------
+	// xapp activity: Recv Subs Resp
+	//---------------------------------
+	msg := tc.WaitMsg(15)
+	if msg != nil {
+		if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_RESP"] {
+			tc.TestError(t, "Received RIC_SUB_RESP wrong mtype expected %s got %s, error", "RIC_SUB_RESP", xapp.RicMessageTypeToName[msg.Mtype])
+			return 0
+		} else if msg.Xid != trans.xid {
+			tc.TestError(t, "Received RIC_SUB_RESP wrong xid expected %s got %s, error", trans.xid, msg.Xid)
+			return 0
+		} else {
+			packedData := &e2ap.PackedData{}
+			packedData.Buf = msg.Payload
+			if msg.SubId > 0 {
+				e2SubsId = uint32(msg.SubId)
+			} else {
+				e2SubsId = 0
+			}
+			unpackerr, resp := e2SubsResp.UnPack(packedData)
+			if unpackerr != nil {
+				tc.TestError(t, "RIC_SUB_RESP unpack failed err: %s", unpackerr.Error())
+			}
+			tc.Logger.Info("Recv Subs Resp rmr: xid=%s subid=%d, asn: seqnro=%d", msg.Xid, msg.SubId, resp.RequestId.Seq)
+			return e2SubsId
+		}
+	} else {
+		tc.TestError(t, "Not Received msg within %d secs", 15)
+	}
+	return 0
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+
+func (tc *E2Stub) SendSubsFail(t *testing.T, fparams *E2StubSubsFailParams, msg *xapptweaks.RMRParams) {
+	tc.Logger.Info("SendSubsFail")
+	e2SubsFail := e2asnpacker.NewPackerSubscriptionFailure()
+
+	//---------------------------------
+	// e2term activity: Send Subs Fail
+	//---------------------------------
+	packerr, packedMsg := e2SubsFail.Pack(fparams.Fail)
+	if packerr != nil {
+		tc.TestError(t, "pack NOK %s", packerr.Error())
+	}
+	tc.Logger.Debug("%s", e2SubsFail.String())
+
+	params := xapptweaks.NewParams(nil)
+	params.Mtype = xapp.RIC_SUB_FAILURE
+	params.SubId = msg.SubId
+	params.Payload = packedMsg.Buf
+	params.Meid = msg.Meid
+	params.Xid = msg.Xid
+	params.Mbuf = nil
+
+	tc.Logger.Info("SEND SUB FAIL: %s", params.String())
+	snderr := tc.RmrSend(params)
+	if snderr != nil {
+		tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
+	}
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) RecvSubsFail(t *testing.T, trans *RmrTransactionId) uint32 {
+	tc.Logger.Info("RecvSubsFail")
+	e2SubsFail := e2asnpacker.NewPackerSubscriptionFailure()
+	var e2SubsId uint32
+
+	//-------------------------------
+	// xapp activity: Recv Subs Fail
+	//-------------------------------
+	msg := tc.WaitMsg(15)
+	if msg != nil {
+		if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_FAILURE"] {
+			tc.TestError(t, "Received RIC_SUB_FAILURE wrong mtype expected %s got %s, error", "RIC_SUB_FAILURE", xapp.RicMessageTypeToName[msg.Mtype])
+			return 0
+		} else if msg.Xid != trans.xid {
+			tc.TestError(t, "Received RIC_SUB_FAILURE wrong xid expected %s got %s, error", trans.xid, msg.Xid)
+			return 0
+		} else {
+			packedData := &e2ap.PackedData{}
+			packedData.Buf = msg.Payload
+			if msg.SubId > 0 {
+				e2SubsId = uint32(msg.SubId)
+			} else {
+				e2SubsId = 0
+			}
+			unpackerr, resp := e2SubsFail.UnPack(packedData)
+			if unpackerr != nil {
+				tc.TestError(t, "RIC_SUB_FAILURE unpack failed err: %s", unpackerr.Error())
+			}
+			tc.Logger.Info("Recv Subs Fail rmr: xid=%s subid=%d, asn: seqnro=%d", msg.Xid, msg.SubId, resp.RequestId.Seq)
+			return e2SubsId
+		}
+	} else {
+		tc.TestError(t, "Not Received msg within %d secs", 15)
+	}
+	return 0
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) SendSubsDelReq(t *testing.T, oldTrans *RmrTransactionId, e2SubsId uint32) *RmrTransactionId {
+
+	trans := oldTrans
+	if oldTrans == nil {
+		trans = tc.NewRmrTransactionId("", "RAN_NAME_1")
+	}
+
+	tc.Logger.Info("SendSubsDelReq %s", trans.String())
+	e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest()
+	//---------------------------------
+	// xapp activity: Send Subs Del Req
+	//---------------------------------
+	req := &e2ap.E2APSubscriptionDeleteRequest{}
+	req.RequestId.Id = 1
+	req.RequestId.Seq = e2SubsId
+	req.FunctionId = 1
+
+	err, packedMsg := e2SubsDelReq.Pack(req)
+	if err != nil {
+		tc.TestError(t, "pack NOK %s %s", trans.String(), err.Error())
+		return nil
+	}
+	tc.Logger.Debug("%s %s", trans.String(), e2SubsDelReq.String())
+
+	params := xapptweaks.NewParams(nil)
+	params.Mtype = xapp.RIC_SUB_DEL_REQ
+	params.SubId = int(e2SubsId)
+	params.Payload = packedMsg.Buf
+	params.Meid = trans.meid
+	params.Xid = trans.xid
+	params.Mbuf = nil
+
+	tc.Logger.Info("SEND SUB DEL REQ: %s", params.String())
+	snderr := tc.RmrSend(params)
+	if snderr != nil {
+		tc.TestError(t, "RMR SEND FAILED: %s %s", trans.String(), snderr.Error())
+		return nil
+	}
+	return trans
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) RecvSubsDelReq(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequest, *xapptweaks.RMRParams) {
+	tc.Logger.Info("RecvSubsDelReq")
+	e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest()
+
+	//---------------------------------
+	// e2term activity: Recv Subs Del Req
+	//---------------------------------
+	msg := tc.WaitMsg(15)
+	if msg != nil {
+		if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_REQ"] {
+			tc.TestError(t, "Received wrong mtype expected %s got %s, error", "RIC_SUB_DEL_REQ", xapp.RicMessageTypeToName[msg.Mtype])
+		} else {
+			tc.Logger.Info("Recv Subs Del Req")
+
+			packedData := &e2ap.PackedData{}
+			packedData.Buf = msg.Payload
+			unpackerr, req := e2SubsDelReq.UnPack(packedData)
+			if unpackerr != nil {
+				tc.TestError(t, "RIC_SUB_DEL_REQ unpack failed err: %s", unpackerr.Error())
+			}
+			return req, msg
+		}
+	} else {
+		tc.TestError(t, "Not Received msg within %d secs", 15)
+	}
+	return nil, nil
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) SendSubsDelResp(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapptweaks.RMRParams) {
+	tc.Logger.Info("SendSubsDelResp")
+	e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse()
+
+	//---------------------------------
+	// e2term activity: Send Subs Del Resp
+	//---------------------------------
+	resp := &e2ap.E2APSubscriptionDeleteResponse{}
+	resp.RequestId.Id = req.RequestId.Id
+	resp.RequestId.Seq = req.RequestId.Seq
+	resp.FunctionId = req.FunctionId
+
+	packerr, packedMsg := e2SubsDelResp.Pack(resp)
+	if packerr != nil {
+		tc.TestError(t, "pack NOK %s", packerr.Error())
+	}
+	tc.Logger.Debug("%s", e2SubsDelResp.String())
+
+	params := xapptweaks.NewParams(nil)
+	params.Mtype = xapp.RIC_SUB_DEL_RESP
+	params.SubId = msg.SubId
+	params.Payload = packedMsg.Buf
+	params.Meid = msg.Meid
+	params.Xid = msg.Xid
+	params.Mbuf = nil
+
+	tc.Logger.Info("SEND SUB DEL RESP: %s", params.String())
+	snderr := tc.RmrSend(params)
+	if snderr != nil {
+		tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
+	}
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) RecvSubsDelResp(t *testing.T, trans *RmrTransactionId) {
+	tc.Logger.Info("RecvSubsDelResp")
+	e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse()
+
+	//---------------------------------
+	// xapp activity: Recv Subs Del Resp
+	//---------------------------------
+	msg := tc.WaitMsg(15)
+	if msg != nil {
+		if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_RESP"] {
+			tc.TestError(t, "Received RIC_SUB_DEL_RESP wrong mtype expected %s got %s, error", "RIC_SUB_DEL_RESP", xapp.RicMessageTypeToName[msg.Mtype])
+			return
+		} else if trans != nil && msg.Xid != trans.xid {
+			tc.TestError(t, "Received RIC_SUB_DEL_RESP wrong xid expected %s got %s, error", trans.xid, msg.Xid)
+			return
+		} else {
+			packedData := &e2ap.PackedData{}
+			packedData.Buf = msg.Payload
+			unpackerr, resp := e2SubsDelResp.UnPack(packedData)
+			if unpackerr != nil {
+				tc.TestError(t, "RIC_SUB_DEL_RESP unpack failed err: %s", unpackerr.Error())
+			}
+			tc.Logger.Info("Recv Subs Del Resp rmr: xid=%s subid=%d, asn: seqnro=%d", msg.Xid, msg.SubId, resp.RequestId.Seq)
+			return
+		}
+	} else {
+		tc.TestError(t, "Not Received msg within %d secs", 15)
+	}
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) SendSubsDelFail(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapptweaks.RMRParams) {
+	tc.Logger.Info("SendSubsDelFail")
+	e2SubsDelFail := e2asnpacker.NewPackerSubscriptionDeleteFailure()
+
+	//---------------------------------
+	// e2term activity: Send Subs Del Fail
+	//---------------------------------
+	resp := &e2ap.E2APSubscriptionDeleteFailure{}
+	resp.RequestId.Id = req.RequestId.Id
+	resp.RequestId.Seq = req.RequestId.Seq
+	resp.FunctionId = req.FunctionId
+	resp.Cause.Content = 3  // CauseMisc
+	resp.Cause.CauseVal = 4 // unspecified
+
+	packerr, packedMsg := e2SubsDelFail.Pack(resp)
+	if packerr != nil {
+		tc.TestError(t, "pack NOK %s", packerr.Error())
+	}
+	tc.Logger.Debug("%s", e2SubsDelFail.String())
+
+	params := xapptweaks.NewParams(nil)
+	params.Mtype = xapp.RIC_SUB_DEL_FAILURE
+	params.SubId = msg.SubId
+	params.Payload = packedMsg.Buf
+	params.Meid = msg.Meid
+	params.Xid = msg.Xid
+	params.Mbuf = nil
+
+	tc.Logger.Info("SEND SUB DEL FAIL: %s", params.String())
+	snderr := tc.RmrSend(params)
+	if snderr != nil {
+		tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
+	}
+}
diff --git a/pkg/xapptweaks/logwrapper.go b/pkg/xapptweaks/logwrapper.go
new file mode 100644
index 0000000..9b5388f
--- /dev/null
+++ b/pkg/xapptweaks/logwrapper.go
@@ -0,0 +1,50 @@
+/*
+==================================================================================
+  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 xapptweaks
+
+import (
+	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+	"strings"
+)
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type LogWrapper struct {
+	desc   string
+	Logger *xapp.Log
+}
+
+func (tc *LogWrapper) GetDesc() string {
+	return tc.desc
+}
+
+func (tc *LogWrapper) GetLogger() *xapp.Log {
+	return tc.Logger
+}
+
+func (tc *LogWrapper) Init(desc string) {
+	tc.desc = strings.ToUpper(desc)
+	if len(desc) == 0 {
+		tc.Logger = xapp.Logger
+	} else {
+		tc.Logger = xapp.NewLogger(tc.desc)
+	}
+}
diff --git a/pkg/xapptweaks/rmrparams.go b/pkg/xapptweaks/rmrparams.go
new file mode 100644
index 0000000..1b40466
--- /dev/null
+++ b/pkg/xapptweaks/rmrparams.go
@@ -0,0 +1,46 @@
+/*
+==================================================================================
+  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 xapptweaks
+
+import (
+	"bytes"
+	"fmt"
+	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+)
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type RMRParams struct {
+	*xapp.RMRParams
+}
+
+func (params *RMRParams) String() string {
+	var b bytes.Buffer
+	fmt.Fprintf(&b, "params(Src=%s Mtype=%d SubId=%d Xid=%s Meid=%s)", params.Src, params.Mtype, params.SubId, params.Xid, params.Meid.RanName)
+	return b.String()
+}
+
+func NewParams(params *xapp.RMRParams) *RMRParams {
+	if params != nil {
+		return &RMRParams{params}
+	}
+	return &RMRParams{&xapp.RMRParams{}}
+}
diff --git a/pkg/xapptweaks/rmrwrapper.go b/pkg/xapptweaks/rmrwrapper.go
new file mode 100644
index 0000000..ef633bd
--- /dev/null
+++ b/pkg/xapptweaks/rmrwrapper.go
@@ -0,0 +1,72 @@
+/*
+==================================================================================
+  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 xapptweaks
+
+import (
+	"fmt"
+	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+	"sync"
+	"time"
+)
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type RmrWrapper struct {
+	mtx        sync.Mutex
+	Rmr        *xapp.RMRClient
+	CntRecvMsg uint64
+	CntSentMsg uint64
+}
+
+func (tc *RmrWrapper) Lock() {
+	tc.mtx.Lock()
+}
+
+func (tc *RmrWrapper) Unlock() {
+	tc.mtx.Unlock()
+}
+
+func (tc *RmrWrapper) Init() {
+}
+
+func (tc *RmrWrapper) RmrSend(params *RMRParams) (err error) {
+	if tc.Rmr == nil {
+		err = fmt.Errorf("Failed rmr object nil for %s", params.String())
+		return
+	}
+	status := false
+	i := 1
+	for ; i <= 10 && status == false; i++ {
+		tc.Lock()
+		status = tc.Rmr.Send(params.RMRParams, false)
+		tc.Unlock()
+		if status == false {
+			time.Sleep(500 * time.Millisecond)
+		}
+	}
+	if status == false {
+		err = fmt.Errorf("Failed with retries(%d) %s", i, params.String())
+		tc.Rmr.Free(params.Mbuf)
+	} else {
+		tc.CntSentMsg++
+	}
+	return
+}
diff --git a/pkg/xapptweaks/xappwrapper.go b/pkg/xapptweaks/xappwrapper.go
new file mode 100644
index 0000000..8b7c91d
--- /dev/null
+++ b/pkg/xapptweaks/xappwrapper.go
@@ -0,0 +1,49 @@
+/*
+==================================================================================
+  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 xapptweaks
+
+import (
+	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+)
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type XAppWrapperIf interface {
+	RmrSend(params *RMRParams) (err error)
+	GetLogger() *xapp.Log
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type XappWrapper struct {
+	LogWrapper
+	RmrWrapper
+}
+
+func (tc *XappWrapper) GetDesc() string {
+	return tc.desc
+}
+
+func (tc *XappWrapper) Init(desc string) {
+	tc.LogWrapper.Init(desc)
+	tc.RmrWrapper.Init()
+}