/*----< test Comm instance >-----------------------------------*/ public static bool testComm() { bool test = true; Comm comm = new Comm("http://localhost", 8081); CommMessage csndMsg = new CommMessage(CommMessage.MessageType.request); csndMsg.command = "show"; csndMsg.author = "Jim Fawcett"; csndMsg.to = "http://localhost:8081/IPluggableComm"; csndMsg.from = "http://localhost:8081/IPluggableComm"; comm.postMessage(csndMsg); CommMessage crcvMsg = comm.getMessage(); if (ClientEnvironment.verbose) { crcvMsg.show(); } crcvMsg = comm.getMessage(); if (ClientEnvironment.verbose) { crcvMsg.show(); } if (!compareMsgs(csndMsg, crcvMsg)) { test = false; } bool testFileTransfer = true; List <string> names = getClientFileList(); foreach (string name in names) { bool transferSuccess = comm.postFile(ClientEnvironment.fileStorage, ServiceEnvironment.fileStorage, name); } foreach (string name in names) { if (!compareFileBytes(name)) { testFileTransfer = false; break; } } csndMsg.type = CommMessage.MessageType.closeReceiver; comm.postMessage(csndMsg); crcvMsg = comm.getMessage(); if (ClientEnvironment.verbose) { crcvMsg.show(); } if (!compareMsgs(csndMsg, crcvMsg)) { test = false; } csndMsg.type = CommMessage.MessageType.closeSender; comm.postMessage(csndMsg); if (ClientEnvironment.verbose) { csndMsg.show(); } return(test && testFileTransfer); }
public static bool testComm1(Comm comm, CommMessage csndMsg, bool test) { comm.postMessage(csndMsg); CommMessage crcvMsg = comm.getMessage(); if (ClientEnvironment.verbose) { crcvMsg.show(); } if (!compareMsgs(csndMsg, crcvMsg)) { test = false; } TestUtilities.checkResult(test, "csndMsg equals crcvMsg"); TestUtilities.putLine(comm.size().ToString() + " messages left in queue"); TestUtilities.putLine(); TestUtilities.vbtitle("testing connect to new EndPoint"); csndMsg.to = "http://DESKTOP-J98AUHN:8081/IMessagePassingComm"; comm.postMessage(csndMsg); crcvMsg = comm.getMessage(); if (ClientEnvironment.verbose) { crcvMsg.show(); } if (!compareMsgs(csndMsg, crcvMsg)) { test = false; } TestUtilities.checkResult(test, "csndMsg equals crcvMsg"); TestUtilities.putLine(comm.size().ToString() + " messages left in queue"); TestUtilities.putLine(); return(test); }
/*----< test Comm instance >-----------------------------------*/ public static bool testComm() { TestUtilities.vbtitle("testing Comm"); bool test = true; Comm comm = new Comm("http://localhost", 8081); CommMessage csndMsg = new CommMessage(CommMessage.MessageType.request); csndMsg.command = "show"; csndMsg.author = "Jim Fawcett"; csndMsg.to = "http://localhost:8081/IMessagePassingComm"; csndMsg.from = "http://localhost:8081/IMessagePassingComm"; comm.postMessage(csndMsg); CommMessage crcvMsg = comm.getMessage(); crcvMsg.show(); if (!compareMsgs(csndMsg, crcvMsg)) { test = false; } TestUtilities.checkResult(test, "csndMsg equals crcvMsg"); TestUtilities.putLine(); TestUtilities.vbtitle("testing file transfer"); bool testFileTransfer = true; List <string> names = getClientFileList(); foreach (string name in names) { TestUtilities.putLine(string.Format("transferring file \"{0}\"", name)); bool transferSuccess = comm.postFile(name, ""); TestUtilities.checkResult(transferSuccess, "transfer"); } foreach (string name in names) { if (!compareFileBytes(name)) { testFileTransfer = false; break; } } TestUtilities.checkResult(testFileTransfer, "file transfers"); TestUtilities.vbtitle("test receiver close"); csndMsg.type = CommMessage.MessageType.closeReceiver; comm.postMessage(csndMsg); crcvMsg = comm.getMessage(); if (ClientEnvironment.verbose) { crcvMsg.show(); } if (!compareMsgs(csndMsg, crcvMsg)) { test = false; } TestUtilities.checkResult(test, "closeReceiver"); TestUtilities.putLine(); csndMsg.type = CommMessage.MessageType.closeSender; comm.postMessage(csndMsg); csndMsg.show(); return(test && testFileTransfer); }
//----------------<Close all relevent thread gracefully>----------- public void shutDown() { Msg msg = new Msg(Msg.MessageType.closeReceiver); msg.to = autoClientAdd_; msg.from = autoClientAdd_; comm_.postMessage(msg); msg.type = Msg.MessageType.closeSender; comm_.postMessage(msg); }
/*----< compare binary file's bytes >--------------------------*/ /*----< test Comm instance >-----------------------------------*/ public static bool testComm() { TestUtilities.title("testing Comm"); bool test = true; Comm comm = new Comm("http://localhost", 8081, "../../clientFolder"); CommMessage csndMsg = new CommMessage(CommMessage.MessageType.request); csndMsg.command = "show"; csndMsg.author = "Jim Fawcett"; csndMsg.to = "http://localhost:8081/IMessagePassingComm"; csndMsg.from = "http://localhost:8081/IMessagePassingComm"; comm.postMessage(csndMsg); CommMessage crcvMsg = comm.getMessage(); //if (localEnvironment.verbose) crcvMsg.show(); crcvMsg = comm.getMessage(); //if (localEnvironment.verbose) crcvMsg.show(); if (!compareMsgs(csndMsg, crcvMsg)) { test = false; } TestUtilities.checkResult(test, "csndMsg equals crcvMsg"); TestUtilities.putLine(); TestUtilities.title("testing file transfer"); TestUtilities.title("test receiver close"); csndMsg.type = CommMessage.MessageType.closeReceiver; comm.postMessage(csndMsg); crcvMsg = comm.getMessage(); //if (localEnvironment.verbose) crcvMsg.show(); //if (!compareMsgs(csndMsg, crcvMsg)) test = false; TestUtilities.checkResult(test, "closeReceiver"); TestUtilities.putLine(); csndMsg.type = CommMessage.MessageType.closeSender; comm.postMessage(csndMsg); //if(localEnvironment.verbose) csndMsg.show(); // comm.getMessage() would fail because server has shut down // no rcvMsg so no compare TestUtilities.putLine("last message received\n"); return(test); }
public static bool testComm3(Comm comm, CommMessage csndMsg, bool test) { TestUtilities.vbtitle("test receiver close"); csndMsg.type = CommMessage.MessageType.closeReceiver; if (ClientEnvironment.verbose) { csndMsg.show(); } comm.postMessage(csndMsg); CommMessage crcvMsg = comm.getMessage(); if (ClientEnvironment.verbose) { crcvMsg.show(); } if (!compareMsgs(csndMsg, crcvMsg)) { test = false; } TestUtilities.checkResult(test, "closeReceiver"); TestUtilities.putLine(comm.size().ToString() + " messages left in queue"); TestUtilities.putLine(); csndMsg.type = CommMessage.MessageType.closeSender; comm.postMessage(csndMsg); if (ClientEnvironment.verbose) { csndMsg.show(); } TestUtilities.putLine(comm.size().ToString() + " messages left in queue"); // comm.getMessage() would fail because server has shut down // no rcvMsg so no compare TestUtilities.putLine("last message received\n"); TestUtilities.putLine("Test comm.restart on same port - expected to fail"); if (comm.restart(8081)) { CommMessage newerMsg = new CommMessage(CommMessage.MessageType.request); newerMsg.to = ClientEnvironment.endPoint; newerMsg.from = ClientEnvironment.endPoint; comm.postMessage(newerMsg); CommMessage newReply = comm.getMessage(); newReply.show(); } else { Console.Write("\n can't restart but won't fail test"); } return(test); }
//quit message handler which sends quit messages to all availabel child Testharnesses and also self kills. private void handleQuitMessage(CommMessage tempCommMessage) { Console.WriteLine("\n REQUIREMENT 7: quit command recieved from client with address: {0}", tempCommMessage.from); //this is to enable the GUI to command mother testHarness to shutdown its processes. foreach (string childTestHarness in _addressesOfTestHarnesses) { Console.WriteLine("\n REQUIREMENT 7: quit command sending to child TestHarness"); quitMessageTochildTestHarness.to = childTestHarness; quitMessageTochildTestHarness.command = "quit"; wcfMediator.postMessage(quitMessageTochildTestHarness); Console.WriteLine("quit message sent to child testHarness with address: {0}", childTestHarness); Thread.Sleep(250); } Console.WriteLine("mother testHarness quits itself after asking the child testHarnesses to close. Press Enter to exit"); Process.GetCurrentProcess().Kill(); }
/*----< test Comm instance >-----------------------------------*/ public void transferFiles(string req) { ClientEnvironment.verbose = true; TestUtilities.vbtitle("testing Message-Passing Communication", '='); TestUtilities.vbtitle("testing Comm"); Comm comm = new Comm("http://localhost", 8081); CommMessage csndMsg = new CommMessage(CommMessage.MessageType.connect); csndMsg.command = "show"; csndMsg.author = "Dinesh"; csndMsg.to = "http://localhost:8081/IPluggableComm"; csndMsg.from = "http://localhost:8081/IPluggableComm"; comm.postMessage(csndMsg); TestUtilities.vbtitle("testing file transfer"); List <string> names = getClientFileList(); foreach (string name in names) { TestUtilities.putLine(string.Format("transferring file \"{0}\"", name)); bool transferSuccess = comm.postFile(name, "", ""); TestUtilities.checkResult(transferSuccess, "transfer"); } }
public void start_builder(int ch_proc) { generate_xml(); Console.WriteLine("Mthr Builder started"); // start listening the br and rdQ thread // br_thread = new Thread(build_req_thread); br_thread.Start(); ///start listening the mb thread // build_thread = new Thread(listen_builder_thread); build_thread.Start(); //initiate child process// Console.WriteLine("after this"); int count = ch_proc; for (int i = 1; i <= count; ++i) { if (createProcess(i)) { Console.Write(" - succeeded"); } else { Console.Write(" - failed"); } } // send msg to repo for file request // CommMessage sndMsg_to_repo = new CommMessage(CommMessage.MessageType.request); sndMsg_to_repo.command = "Get_Files_From_Repo"; sndMsg_to_repo.author = "Salim Zhulkhrni"; sndMsg_to_repo.to = "http://localhost:8092/IPluggableComm"; sndMsg_to_repo.from = "http://localhost:8091/IMessagePassingComm"; sndMsg_to_repo.msg_body = "8091"; sndMsg_to_repo.port_number = 8091; comm.postMessage(sndMsg_to_repo); Console.WriteLine("Requested for files from Repo"); //Console.ReadLine(); sndMsg_to_repo.show(); }
public static bool testComm2(Comm comm, CommMessage csndMsg, bool test) { string localEndPoint = "http://localhost:8081/IMessagePassingComm"; TestUtilities.vbtitle("testing file transfer"); bool testFileTransfer = true; List <string> names = getClientFileList(); foreach (string name in names) { TestUtilities.putLine(string.Format("transferring file \"{0}\"", name)); bool transferSuccess = comm.postFile(name); TestUtilities.checkResult(transferSuccess, "transfer"); } foreach (string name in names) { if (!compareFileBytes(name)) { testFileTransfer = false; break; } } TestUtilities.checkResult(testFileTransfer, "file transfers"); TestUtilities.putLine(comm.size().ToString() + " messages left in queue"); TestUtilities.putLine(); TestUtilities.vbtitle("test closeConnection then postMessage"); comm.closeConnection(); CommMessage newMsg = new CommMessage(CommMessage.MessageType.request); newMsg.to = localEndPoint; newMsg.from = localEndPoint; comm.postMessage(newMsg); CommMessage reply = comm.getMessage(); reply.show(); // if we get here, test passed TestUtilities.checkResult(true, "closeSenderConnenction then PostMessage"); TestUtilities.putLine(comm.size().ToString() + " messages left in queue"); TestUtilities.putLine(); return(testFileTransfer); }
/*----< test Comm instance >-----------------------------------*/ /* * - Note: change every occurance of string "Odin" to your machine name * */ public static bool testComm() { TestUtilities.vbtitle("testing Comm"); bool test = true; Comm comm = new Comm("http://localhost", 8081); CommMessage csndMsg = new CommMessage(CommMessage.MessageType.request); csndMsg.command = "show"; csndMsg.author = "Jim Fawcett"; string localEndPoint = "http://localhost:8081/IMessagePassingComm"; csndMsg.to = localEndPoint; csndMsg.from = localEndPoint; comm.postMessage(csndMsg); CommMessage crcvMsg = comm.getMessage(); if (ClientEnvironment.verbose) { crcvMsg.show(); } if (!compareMsgs(csndMsg, crcvMsg)) { test = false; } TestUtilities.checkResult(test, "csndMsg equals crcvMsg"); TestUtilities.putLine(comm.size().ToString() + " messages left in queue"); TestUtilities.putLine(); TestUtilities.vbtitle("testing connect to new EndPoint"); csndMsg.to = "http://Odin:8081/IMessagePassingComm"; comm.postMessage(csndMsg); crcvMsg = comm.getMessage(); if (ClientEnvironment.verbose) { crcvMsg.show(); } if (!compareMsgs(csndMsg, crcvMsg)) { test = false; } TestUtilities.checkResult(test, "csndMsg equals crcvMsg"); TestUtilities.putLine(comm.size().ToString() + " messages left in queue"); TestUtilities.putLine(); TestUtilities.vbtitle("testing file transfer"); bool testFileTransfer = true; List <string> names = getClientFileList(); foreach (string name in names) { TestUtilities.putLine(string.Format("transferring file \"{0}\"", name)); bool transferSuccess = comm.postFile(name); TestUtilities.checkResult(transferSuccess, "transfer"); } foreach (string name in names) { if (!compareFileBytes(name)) { testFileTransfer = false; break; } } TestUtilities.checkResult(testFileTransfer, "file transfers"); TestUtilities.putLine(comm.size().ToString() + " messages left in queue"); TestUtilities.putLine(); TestUtilities.vbtitle("test closeConnection then postMessage"); comm.closeConnection(); CommMessage newMsg = new CommMessage(CommMessage.MessageType.request); newMsg.to = localEndPoint; newMsg.from = localEndPoint; comm.postMessage(newMsg); CommMessage reply = comm.getMessage(); reply.show(); // if we get here, test passed TestUtilities.checkResult(true, "closeSenderConnenction then PostMessage"); TestUtilities.putLine(comm.size().ToString() + " messages left in queue"); TestUtilities.putLine(); TestUtilities.vbtitle("test receiver close"); csndMsg.type = CommMessage.MessageType.closeReceiver; if (ClientEnvironment.verbose) { csndMsg.show(); } comm.postMessage(csndMsg); crcvMsg = comm.getMessage(); if (ClientEnvironment.verbose) { crcvMsg.show(); } if (!compareMsgs(csndMsg, crcvMsg)) { test = false; } TestUtilities.checkResult(test, "closeReceiver"); TestUtilities.putLine(comm.size().ToString() + " messages left in queue"); TestUtilities.putLine(); csndMsg.type = CommMessage.MessageType.closeSender; comm.postMessage(csndMsg); if (ClientEnvironment.verbose) { csndMsg.show(); } TestUtilities.putLine(comm.size().ToString() + " messages left in queue"); // comm.getMessage() would fail because server has shut down // no rcvMsg so no compare TestUtilities.putLine("last message received\n"); TestUtilities.putLine("Test comm.restart on same port - expected to fail"); if (comm.restart(8081)) { CommMessage newerMsg = new CommMessage(CommMessage.MessageType.request); newerMsg.to = ClientEnvironment.endPoint; newerMsg.from = ClientEnvironment.endPoint; comm.postMessage(newerMsg); CommMessage newReply = comm.getMessage(); newReply.show(); } else { Console.Write("\n can't restart but won't fail test"); } return(test && testFileTransfer); }
/*----< test Comm instance >-----------------------------------*/ public static bool testComm() { TestUtilities.vbtitle("testing Comm"); bool test = true; Comm comm = new Comm("http://localhost", 8081); CommMessage csndMsg = new CommMessage(CommMessage.MessageType.request); csndMsg.command = Msg.Command.show; csndMsg.author = "Jim Fawcett"; csndMsg.to = "http://localhost:8081/IPluggableComm"; csndMsg.from = "http://localhost:8081/IPluggableComm"; comm.postMessage(csndMsg); CommMessage crcvMsg = comm.getMessage(); if (ClientEnvironment.verbose) { crcvMsg.show(); } crcvMsg = comm.getMessage(); if (ClientEnvironment.verbose) { crcvMsg.show(); } if (!compareMsgs(csndMsg, crcvMsg)) { test = false; } TestUtilities.checkResult(test, "csndMsg equals crcvMsg"); TestUtilities.putLine(); bool testFileTransferResult = testFileTransfer(comm, csndMsg); TestUtilities.vbtitle("test receiver close"); csndMsg.type = CommMessage.MessageType.closeReceiver; comm.postMessage(csndMsg); crcvMsg = comm.getMessage(); if (ClientEnvironment.verbose) { crcvMsg.show(); } if (!compareMsgs(csndMsg, crcvMsg)) { test = false; } TestUtilities.checkResult(test, "closeReceiver"); TestUtilities.putLine(); csndMsg.type = CommMessage.MessageType.closeSender; comm.postMessage(csndMsg); if (ClientEnvironment.verbose) { csndMsg.show(); } // comm.getMessage() would fail because server has shut down // no rcvMsg so no compare TestUtilities.putLine("last message received\n"); return(test && testFileTransferResult); }