+
+type httpRtmgrMsg struct {
+ msg *rtmgr_models.XappSubscriptionData
+ w http.ResponseWriter
+ r *http.Request
+}
+
+func (msg *httpRtmgrMsg) RetOk() {
+ msg.w.WriteHeader(200)
+}
+
+type testingHttpRtmgrControl struct {
+ desc string
+ port string
+ useChannel bool
+ msgChan chan *httpRtmgrMsg
+}
+
+func (hc *testingHttpRtmgrControl) UseChannel(flag bool) {
+ hc.useChannel = flag
+}
+
+func (hc *testingHttpRtmgrControl) WaitReq(t *testing.T) *httpRtmgrMsg {
+ xapp.Logger.Info("(%s) handle_rtmgr_req", hc.desc)
+ select {
+ case msg := <-hc.msgChan:
+ return msg
+ case <-time.After(15 * time.Second):
+ testError(t, "(%s) Not Received RTMGR Subscription message within 15 secs", hc.desc)
+ return nil
+ }
+ return nil
+}
+
+func (hc *testingHttpRtmgrControl) http_handler(w http.ResponseWriter, r *http.Request) {
+ var req rtmgr_models.XappSubscriptionData
+ err := json.NewDecoder(r.Body).Decode(&req)
+ if err != nil {
+ xapp.Logger.Error("%s", err.Error())
+ }
+ xapp.Logger.Info("(%s) handling Address=%s Port=%d SubscriptionID=%d", hc.desc, *req.Address, *req.Port, *req.SubscriptionID)
+ msg := &httpRtmgrMsg{
+ msg: &req,
+ w: w,
+ r: r,
+ }
+ if hc.useChannel {
+ hc.msgChan <- msg
+ } else {
+ msg.RetOk()
+ }
+}
+
+func (hc *testingHttpRtmgrControl) run() {
+ http.HandleFunc("/", hc.http_handler)
+ http.ListenAndServe("localhost:"+hc.port, nil)
+}
+
+func initTestingHttpRtmgrControl(desc string, port string) *testingHttpRtmgrControl {
+ hc := &testingHttpRtmgrControl{}
+ hc.desc = desc
+ hc.port = port
+ hc.useChannel = false
+ hc.msgChan = make(chan *httpRtmgrMsg)
+ return hc
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type testingRmrControl struct {