コード例 #1
0
ファイル: ShowdialogTest.cs プロジェクト: felix-tien/TechLab
        public void Requestdata_Test()
        {

            Thread.GetDomain().SetData(".appPath", AppDomain.CurrentDomain.BaseDirectory);
            Thread.GetDomain().SetData(".appVPath", "/");
            Thread.GetDomain().SetData(".appDomain", "*");
            TextWriter tw = new StringWriter();
            TestWorkerRequest wr = new TestWorkerRequest("/appinternals", "xhow=1&n=requestdata", tw);
            wr.SetRemoteAddress("127.0.0.1");


            Dictionary<string, string> header = new Dictionary<string, string>();
            header.Add("Tracing-RequestType", "Tracing-RequestType");

            wr.SetCustomRequestHeaders(header);
            HttpContext.Current = new HttpContext(wr);

            HttpContext.Current.Request.RequestContext.RouteData = new RouteData();

            HttpContext.Current.Request.RequestContext.RouteData.Values.Add("controller", "test");
            HttpContext.Current.Request.RequestContext.RouteData.Values.Add("action", "test");
            HttpContext.Current.Request.RequestContext.RouteData.DataTokens.Add("area", "area");


            ConfigBeanManager.Current.Register(new UrlTraceItems());
            object obj = new object();

            Showdialog showdialog = new Showdialog(HttpContext.Current);
            showdialog.IsOpen = true;
            HttpContext.Current.Items[obj] = showdialog;
            HttpContext.Current.Items[showdialog.Obj] = showdialog.ModelID;
            Freeway.Listening.LogListener.Instance.Callback += showdialog.TraceCallBack;


            UrlTracer.Start();

            UrlTracer.End();

            ShowdialogModel model;
            ShowdialogModelStore.Instance.TryGet(out model, HttpContext.Current);

            string requestId = model.RequestId;
            Dictionary<string,string> par=new Dictionary<string,string>();
            par.Add("requestId",requestId);

            TestWorkerRequest.SetQuery(HttpContext.Current, par);

            ResourceRouteHandler resourceRouteHandler = new ResourceRouteHandler();
            IHttpHandler httpHandler = resourceRouteHandler.GetHttpHandler(HttpContext.Current.Request.RequestContext);

            httpHandler.ProcessRequest(HttpContext.Current);

            Assert.IsTrue(tw.ToString().IndexOf("glimpse.data.initMetadata") > 0);

        }
コード例 #2
0
ファイル: TracingTest.cs プロジェクト: felix-tien/TechLab
        public void   UrlTracer_Test()
        {
            Thread.GetDomain().SetData(".appPath", AppDomain.CurrentDomain.BaseDirectory);
            Thread.GetDomain().SetData(".appVPath", "/");
            Thread.GetDomain().SetData(".appDomain", "*");
            TextWriter tw = new StringWriter();
            TestWorkerRequest wr = new TestWorkerRequest("/appinternals", "", tw);
            wr.SetRemoteAddress("127.0.0.1");

            Dictionary<string, string> header = new Dictionary<string, string>();
            header.Add("Tracing-RequestType", "Tracing-RequestType");

            wr.SetCustomRequestHeaders(header);
            HttpContext.Current = new HttpContext(wr);
            HttpContext.Current.Request.RequestContext.RouteData = new RouteData();


            HttpContext.Current.Request.RequestContext.RouteData.Values.Add("controller", "test");
            HttpContext.Current.Request.RequestContext.RouteData.Values.Add("action", "test");
            HttpContext.Current.Request.RequestContext.RouteData.DataTokens.Add("area", "area");


            ConfigBeanManager.Current.Register(new UrlTraceItems());

         //   var traceContext = UrlTraceContext.Create();



            //开始Trace
           // UrlTraceLogger.StartSpan(traceContext);

            //traceContext.TraceInfo = new UrlTraceInfo()
            //{

            //    ClientAppId = "12",
            //    ClientIP = "127.0.0l1",
            //    FilePath = "\\",
            //    HostAddress = "127.0.0.1",
            //    HttpMethod = "Get",
            //    RawUrl = "\appinternals",
            //    RequestCost = 12,
            //    RequestSize = 12,
            //    RequestType = "text\\html",
            //    ResponseSize = 100,
            //    ResponseStatus = 200,
            //    TraceItems = new UrlTraceItems()

            //};

            //UrlTraceLogger.Log(traceContext);

            //UrlTraceLogger.EndSpan(traceContext);

            UrlTracer.Start();
            UrlTracer.End();

            string key = typeof(UrlTraceContext).FullName;
            Assert.AreEqual(UrlTraceContext.Current, HttpContext.Current.Items[key]);


        }
コード例 #3
0
ファイル: ShowdialogTest.cs プロジェクト: felix-tien/TechLab
        public void Sdg_Test()
        {

            Thread.GetDomain().SetData(".appPath", AppDomain.CurrentDomain.BaseDirectory);
            Thread.GetDomain().SetData(".appVPath", "/");
            Thread.GetDomain().SetData(".appDomain", "*");
            TextWriter tw = new StringWriter();
            TestWorkerRequest wr = new TestWorkerRequest("/appinternals", "xhow=1&n=Sdg_sprite", tw);
            wr.SetRemoteAddress("127.0.0.1");

            Dictionary<string, string> header = new Dictionary<string, string>();
            header.Add("Tracing-RequestType", "Tracing-RequestType");

            wr.SetCustomRequestHeaders(header);
            HttpContext.Current = new HttpContext(wr);

            ResourceRouteHandler resourceRouteHandler = new ResourceRouteHandler();
            IHttpHandler httpHandler = resourceRouteHandler.GetHttpHandler(HttpContext.Current.Request.RequestContext);
            httpHandler.ProcessRequest(HttpContext.Current);
            Assert.IsTrue(tw.ToString().Length > 0);
        }
コード例 #4
0
ファイル: TracingTest.cs プロジェクト: felix-tien/TechLab
        public void UrlTraceCollector_Service_Test()
        {
            Thread.GetDomain().SetData(".appPath", AppDomain.CurrentDomain.BaseDirectory);
            Thread.GetDomain().SetData(".appVPath", "/");
            Thread.GetDomain().SetData(".appDomain", "*");
            TextWriter tw = new StringWriter();
            TestWorkerRequest wr = new TestWorkerRequest("/appinternals", "", tw);
            wr.SetRemoteAddress("127.0.0.1");

            Dictionary<string, string> header = new Dictionary<string, string>();
            header.Add("Tracing-RequestType", "Tracing-RequestType");

            wr.SetCustomRequestHeaders(header);
            HttpContext.Current = new HttpContext(wr);
            HttpContext.Current.Request.RequestContext.RouteData = new RouteData();


            HttpContext.Current.Request.RequestContext.RouteData.Values.Add("controller", "test");
            HttpContext.Current.Request.RequestContext.RouteData.Values.Add("action", "test");
            HttpContext.Current.Request.RequestContext.RouteData.DataTokens.Add("area", "area");


            ConfigBeanManager.Current.Register(new UrlTraceItems());

            var traceContext = UrlTraceContext.Create();



            //开始Trace
            UrlTraceLogger.StartSpan(traceContext);
            //开始数据收集
            UrlTraceCollector.StartCollect(traceContext);

            UrlTraceCollector.EndColloct(traceContext);

            Assert.AreEqual(traceContext.TraceInfo.RawUrl, "//appinternals");
            Assert.AreEqual(traceContext.TraceInfo.HttpMethod, "Get");



        }