// forming the test message and uploading files and sending test request private void start_test(object sender, RoutedEventArgs e) { if (testname != "" && fileList.Count > 0 && author != "") { cc.comm.sndr.channel = Sender.CreateServiceChannel("http://localhost:8082/StreamService"); foreach (string file in fileList) { //uploading files cc.comm.sndr.uploadFile(System.IO.Path.GetFileName(file)); } string to = Comm <Client2> .makeEndPoint("http://localhost", 8080); string from = Comm <Client2> .makeEndPoint("http://localhost", 8084); Message msg = cc.makeMessage(author, from, to); //forming test request msg.body = MessageTest.makeTestRequestUI(testname, testcode, testdriver); //sending request cc.comm.sndr.PostMessage(msg); } else { MessageBox.Show("enter author and testname"); return; } }
//----< save results and logs in Repository >-------------------- bool saveResultsAndLogs(ITestResults testResults) { string logName = testResults.testKey + ".txt"; System.IO.StreamWriter sr = null; try { sr = new System.IO.StreamWriter(System.IO.Path.Combine(repoPath_, logName)); sr.WriteLine(logName); foreach (ITestResult test in testResults.testResults) { sr.WriteLine("-----------------------------"); sr.WriteLine(test.testName); sr.WriteLine(test.testResult); sr.WriteLine(test.testLog); } sr.WriteLine("-----------------------------"); } catch (Exception message) { Console.WriteLine("Error message", message); sr.Close(); return(false); } sr.Close(); this.comm.sndr.channel = Sender.CreateServiceChannel("http://localhost:8082/StreamService"); this.comm.sndr.uploadFile(logName); //sending log to repository Console.WriteLine("\n**********************************************************************"); Console.WriteLine("\nDemonstrating requirement 7 ,saving logs to Repository"); return(true); }
//----< run client demo >---------------------------------------- static void Main(string[] args) { Console.Title = "Client 1 Console"; Console.Write("\n Testing Client Demo"); Console.Write("\n =====================\n"); Client clnt = new Client(); clnt.comm.sndr.channel = Sender.CreateServiceChannel("http://localhost:8082/StreamService"); HiResTimer hrt = new HiResTimer(); hrt.Start(); clnt.comm.sndr.uploadFile("TestDriver.dll"); clnt.comm.sndr.uploadFile("TestedCode.dll"); hrt.Stop(); Console.WriteLine("\n**********************************************************************"); Console.WriteLine("\nDemonstrating requirement 12 latency"); Console.Write( "\n\n total elapsed time for uploading = {0} microsec.\n", hrt.ElapsedMicroseconds ); Message msg = clnt.makeMessage("Brahma", clnt.endPoint, clnt.endPoint); msg.type = "TestRequest"; msg = clnt.makeMessage("Brahma", clnt.endPoint, clnt.endPoint); msg.body = MessageTest.makeTestRequest(); Console.WriteLine("\n**********************************************************************"); Console.WriteLine("\n Demonstrating requirement 2 : XML messages"); msg.showMsg(); string remoteEndPoint = Comm <Client> .makeEndPoint("http://localhost", 8080); msg = msg.copy(); msg.to = remoteEndPoint; clnt.comm.sndr.PostMessage(msg); string repository = Comm <Client> .makeEndPoint("http://localhost", 8082); msg = clnt.makeMessage("Brahma", clnt.endPoint, repository); msg.type = "testlogs"; msg.body = "brahma"; clnt.comm.sndr.PostMessage(msg); Console.Write("\n press key to exit: "); Console.ReadKey(); msg.body = "quit"; clnt.comm.sndr.PostMessage(msg); msg.showMsg(); Console.Write("\n\n Press key to terminate client"); Console.ReadKey(); Console.Write("\n\n"); clnt.wait(); ((IChannel)clnt.comm.sndr).Close(); Console.Write("\n\n"); }
//----< create local directory and load from Repository >-------- RequestInfo processRequestAndLoadFiles(Message testRequest) { HiResTimer hrt = new HiResTimer(); string localDir_ = ""; RequestInfo rqi = new RequestInfo(); rqi.requestInfo = extractTests(testRequest); List <string> files = extractCode(rqi.requestInfo); localDir_ = makeKey(testRequest.author); Console.WriteLine(" \n Key :", localDir_); Console.WriteLine("\n**********************************************************************"); Console.WriteLine("\nDemonstrating requirement 8 ,unique key"); // name of temporary dir to hold test files rqi.tempDirName = localDir_; lock (sync_) { filePath_ = System.IO.Path.GetFullPath(localDir_); // LoadAndTest will use this path TLS[Thread.CurrentThread.ManagedThreadId] = filePath_; } Console.Write("\n creating local test directory \"" + localDir_ + "\""); System.IO.Directory.CreateDirectory(localDir_); //for file streaming to download files this.comm.sndr.channel = Sender.CreateServiceChannel("http://localhost:8082/StreamService"); Console.Write("\n loading code from Repository"); foreach (string file in files) { hrt.Start(); try { string name = System.IO.Path.GetFileName(file); this.comm.sndr.changepath(System.IO.Path.GetFullPath(localDir_)); this.comm.sndr.download(file); } catch (Exception message) { Console.Write("Exception of file", message); Console.Write("\n TID" + Thread.CurrentThread.ManagedThreadId + ": could not retrieve file \"" + file + "\""); } hrt.Stop(); Console.Write( "\n\n Total elapsed time for downloading = {0}", hrt.ElapsedMicroseconds); Console.Write("\n TID" + Thread.CurrentThread.ManagedThreadId + ": retrieved file \"" + file + "\""); } Console.WriteLine(); return(rqi); }