public void ConnectTest_V4からV4へのプロキシ() { //setUp //ダミーWebサーバ const int webPort = 778; var webRoot = string.Format("{0}\\public_html", srcDir); var tsWeb = new TsWeb(webPort, webRoot);//Webサーバ起動 var cl = Inet.Connect(new Kernel(), new Ip(IpKind.V4Localhost), 8888, 10, null); cl.Send(Encoding.ASCII.GetBytes("GET http://127.0.0.1:778/index.html HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n")); //exercise var lines = Inet.RecvLines(cl, 3, this); //verify Assert.That(lines.Count, Is.EqualTo(9)); Assert.That(lines[0], Is.EqualTo("HTTP/1.1 200 OK")); Assert.That(lines[1], Is.EqualTo("Transfer-Encoding: chunked")); Assert.That(lines[2], Is.EqualTo("Server: Microsoft-HTTPAPI/2.0")); Assert.That(lines[4], Is.EqualTo("")); Assert.That(lines[5], Is.EqualTo("3")); Assert.That(lines[6], Is.EqualTo("123")); Assert.That(lines[7], Is.EqualTo("0")); Assert.That(lines[8], Is.EqualTo("")); //tearDown tsWeb.Dispose();//Webサーバ停止 }
//[TestCase(1000000000)] public void PerformanceTest(int count) { //ダミーWebサーバ const int webPort = 777; string webRoot = string.Format("{0}\\public_html", srcDir); //試験用ファイルの生成 var fileName = Path.GetRandomFileName(); var path = string.Format("{0}\\{1}", webRoot, fileName); var buf = new List <string>(); for (int i = 0; i < count; i++) { buf.Add("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"); } File.WriteAllLines(path, buf); var tsWeb = new TsWeb(webPort, webRoot);//Webサーバ起動 //試験用クライアント var cl = Inet.Connect(new Kernel(), new Ip(IpKind.V4Localhost), 8888, 10, null); //計測 var sw = new Stopwatch(); sw.Start(); cl.Send(Encoding.ASCII.GetBytes(string.Format("GET http://127.0.0.1:777/{0} HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n", fileName))); var lines = Inet.RecvLines(cl, 3, this); //計測終了 sw.Stop(); Console.Write("HTTPProxy Performance : {0}ms LINES:{1}\n", sw.ElapsedMilliseconds, count); //作業ファイル削除 File.Delete(path); if (lines != null) { Assert.AreEqual(lines[0], "HTTP/1.1 200 OK"); } else { Assert.AreEqual(null, "receive faild"); } cl.Close(); //試験用クライアント破棄 tsWeb.Dispose(); //Webサーバ停止 }
public void PerformanceTest(int count) { //ダミーWebサーバ const int webPort = 777; string webRoot = string.Format("{0}\\public_html", srcDir); //試験用ファイルの生成 var fileName = Path.GetRandomFileName(); var path = string.Format("{0}\\{1}", webRoot, fileName); var buf = new List<string>(); for (int i = 0; i < count; i++) { buf.Add("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"); } File.WriteAllLines(path,buf); var tsWeb = new TsWeb(webPort, webRoot);//Webサーバ起動 //試験用クライアント var cl = Inet.Connect(new Kernel(), new Ip(IpKind.V4Localhost), 8888, 10, null); //計測 var sw = new Stopwatch(); sw.Start(); cl.Send(Encoding.ASCII.GetBytes(string.Format("GET http://127.0.0.1:777/{0} HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n",fileName))); var lines = Inet.RecvLines(cl, 3, this); //計測終了 sw.Stop(); Console.Write("HTTPProxy Performance : {0}ms LINES:{1}\n",sw.ElapsedMilliseconds,count); //作業ファイル削除 File.Delete(path); if (lines != null) { Assert.AreEqual(lines[0], "HTTP/1.1 200 OK"); } else { Assert.AreEqual(null, "receive faild"); } cl.Close();//試験用クライアント破棄 tsWeb.Dispose();//Webサーバ停止 }