コード例 #1
0
        public void ThreadDumpEndpointMiddleware_PathAndVerbMatching_ReturnsExpected()
        {
            var actOptions = new ActuatorManagementOptions()
            {
                Path     = "/",
                Exposure = new Exposure {
                    Include = new List <string> {
                        "*"
                    }
                }
            };

            var opts = new ThreadDumpEndpointOptions();

            actOptions.EndpointOptions.Add(opts);
            ThreadDumper obs    = new ThreadDumper(opts);
            var          ep     = new ThreadDumpEndpoint(opts, obs);
            var          middle = new ThreadDumpEndpointMiddleware(null, ep, new List <IManagementOptions> {
                actOptions
            });

            Assert.True(middle.RequestVerbAndPathMatch("GET", "/dump"));
            Assert.False(middle.RequestVerbAndPathMatch("PUT", "/dump"));
            Assert.False(middle.RequestVerbAndPathMatch("GET", "/badpath"));
        }
コード例 #2
0
        public void ThreadDumpEndpointMiddleware_PathAndVerbMatching_ReturnsExpected()
        {
            var          opts   = new ThreadDumpOptions();
            ThreadDumper obs    = new ThreadDumper(opts);
            var          ep     = new ThreadDumpEndpoint(opts, obs);
            var          middle = new ThreadDumpEndpointMiddleware(null, ep);

            Assert.True(middle.RequestVerbAndPathMatch("GET", "/dump"));
            Assert.False(middle.RequestVerbAndPathMatch("PUT", "/dump"));
            Assert.False(middle.RequestVerbAndPathMatch("GET", "/badpath"));
        }
コード例 #3
0
        public void IsDumpRequest_ReturnsExpected()
        {
            var opts = new ThreadDumpOptions();

            ThreadDumper obs     = new ThreadDumper(opts);
            var          ep      = new ThreadDumpEndpoint(opts, obs);
            var          middle  = new ThreadDumpEndpointMiddleware(null, ep);
            var          context = CreateRequest("GET", "/dump");

            Assert.True(middle.IsThreadDumpRequest(context));
            var context2 = CreateRequest("PUT", "/dump");

            Assert.False(middle.IsThreadDumpRequest(context2));
            var context3 = CreateRequest("GET", "/badpath");

            Assert.False(middle.IsThreadDumpRequest(context3));
        }
コード例 #4
0
        public async void HandleThreadDumpRequestAsync_ReturnsExpected()
        {
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                var opts = new ThreadDumpOptions();

                ThreadDumper obs     = new ThreadDumper(opts);
                var          ep      = new ThreadDumpEndpoint(opts, obs);
                var          middle  = new ThreadDumpEndpointMiddleware(null, ep);
                var          context = CreateRequest("GET", "/dump");
                await middle.HandleThreadDumpRequestAsync(context);

                context.Response.Body.Seek(0, SeekOrigin.Begin);
                StreamReader rdr  = new StreamReader(context.Response.Body);
                string       json = await rdr.ReadToEndAsync();

                Assert.StartsWith("[", json);
                Assert.EndsWith("]", json);
            }
        }
コード例 #5
0
        public async void HandleThreadDumpRequestAsync_ReturnsExpected()
        {
            if (Platform.IsWindows)
            {
                var opts = new ThreadDumpEndpointOptions();

                var mgmtOptions = new ActuatorManagementOptions();
                mgmtOptions.EndpointOptions.Add(opts);

                ThreadDumper obs     = new ThreadDumper(opts);
                var          ep      = new ThreadDumpEndpoint(opts, obs);
                var          middle  = new ThreadDumpEndpointMiddleware(null, ep, mgmtOptions);
                var          context = CreateRequest("GET", "/dump");
                await middle.HandleThreadDumpRequestAsync(context);

                context.Response.Body.Seek(0, SeekOrigin.Begin);
                var rdr  = new StreamReader(context.Response.Body);
                var json = await rdr.ReadToEndAsync();

                Assert.StartsWith("[", json);
                Assert.EndsWith("]", json);
            }
        }