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/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)
 }