/*----< test Sender and Receiver classes >---------------------*/ public static bool testSndrRcvr() { TestUtilities.vbtitle("testing Sender & Receiver"); bool test = true; Receiver rcvr = new Receiver(); rcvr.start("http://localhost", 8080); Sender sndr = new Sender("http://localhost", 8080); CommMessage sndMsg = new CommMessage(CommMessage.MessageType.request); sndMsg.command = "show"; sndMsg.author = "Jim Fawcett"; sndMsg.to = "http://localhost:8080/IMessagePassingComm"; sndMsg.from = "http://localhost:8080/IMessagePassingComm"; sndr.postMessage(sndMsg); CommMessage rcvMsg; // get connection message rcvMsg = rcvr.getMessage(); if (ClientEnvironment.verbose) { rcvMsg.show(); } // get first info message rcvMsg = rcvr.getMessage(); if (ClientEnvironment.verbose) { rcvMsg.show(); } if (!compareMsgs(sndMsg, rcvMsg)) { test = false; } TestUtilities.checkResult(test, "sndMsg equals rcvMsg"); TestUtilities.putLine(); sndMsg.type = CommMessage.MessageType.closeReceiver; sndr.postMessage(sndMsg); rcvMsg = rcvr.getMessage(); if (ClientEnvironment.verbose) { rcvMsg.show(); } if (!compareMsgs(sndMsg, rcvMsg)) { test = false; } TestUtilities.checkResult(test, "Close Receiver"); TestUtilities.putLine(); sndMsg.type = CommMessage.MessageType.closeSender; if (ClientEnvironment.verbose) { sndMsg.show(); } sndr.postMessage(sndMsg); // rcvr.getMessage() would fail because server has shut down // no rcvMsg so no compare TestUtilities.putLine("last message received\n"); return(test); }
/*----< test Sender and Receiver classes >---------------------*/ public static bool testSndrRcvr() { bool test = true; Receiver rcvr = new Receiver(); rcvr.start("http://localhost", 8080); Sender sndr = new Sender("http://localhost", 8080); CommMessage sndMsg = new CommMessage(CommMessage.MessageType.request); sndMsg.command = "show"; sndMsg.author = "Jim Fawcett"; sndMsg.to = "http://localhost:8080/IPluggableComm"; sndMsg.from = "http://localhost:8080/IPluggableComm"; sndr.postMessage(sndMsg); CommMessage rcvMsg; // get connection message rcvMsg = rcvr.getMessage(); if (ClientEnvironment.verbose) { rcvMsg.show(); } // get first info message rcvMsg = rcvr.getMessage(); if (ClientEnvironment.verbose) { rcvMsg.show(); } if (!compareMsgs(sndMsg, rcvMsg)) { test = false; } sndMsg.type = CommMessage.MessageType.closeReceiver; sndr.postMessage(sndMsg); rcvMsg = rcvr.getMessage(); if (ClientEnvironment.verbose) { rcvMsg.show(); } if (!compareMsgs(sndMsg, rcvMsg)) { test = false; } sndMsg.type = CommMessage.MessageType.closeSender; if (ClientEnvironment.verbose) { sndMsg.show(); } sndr.postMessage(sndMsg); // rcvr.getMessage() would fail because server has shut down // no rcvMsg so no compare return(test); }
/*----< do the tests >-----------------------------------------*/ #if (TEST_MPCOMM) static void Main(string[] args) { ClientEnvironment.verbose = true; TestUtilities.vbtitle("testing Message-Passing Communication", '='); /*----< uncomment to see Sender & Receiver testing >---------*/ /* TestUtilities.checkResult(testSndrRcvr(), "Sender & Receiver"); * TestUtilities.putLine(); * * TestUtilities.checkResult(testComm(), "Comm"); * TestUtilities.putLine(); * * TestUtilities.putLine("Press key to quit\n"); */ Receiver crcvr = new Receiver(); crcvr.start("http://localhost", 8081); Sender child = new Sender("http://localhost", 8081); CommMessage cmsg = new CommMessage(CommMessage.MessageType.request); cmsg.command = "Xmsl"; cmsg.author = "Client"; cmsg.to = "http://localhost:8081/IPluggableComm"; cmsg.from = "Repo"; child.postMessage(cmsg); crcvr.getMessage(); bool transferSuccess = child.postFile("TestRequest1.xml", "../../../ChildBuilder", "../../../RepoStorage"); ClientEnvironment.verbose = true; TestUtilities.checkResult(transferSuccess, "transfer"); if (ClientEnvironment.verbose) { Console.ReadKey(); } }
/*----< post message to remote Comm >--------------------------*/ public void postMessage(CommMessage msg) { sndr.postMessage(msg); }
/*----< test Sender and Receiver classes >---------------------*/ public static bool testSndrRcvr() { TestPCommService testComService = new TestPCommService(); TestUtilities.vbtitle("testing Sender & Receiver"); bool test = true; Receiver rcvr = new Receiver(); rcvr.start("http://localhost", 8080); Sender sndr = new Sender("http://localhost", 8080); CommMessage sndMsg = new CommMessage(CommMessage.MessageType.request); sndMsg.command = "show"; sndMsg.author = "Jim Fawcett"; sndMsg.to = "http://localhost:8080/IPluggableComm"; sndMsg.from = "http://localhost:8080/IPluggableComm"; sndr.postMessage(sndMsg); CommMessage rcvMsg; // get connection message rcvMsg = rcvr.getMessage(); if (verbose) { rcvMsg.show(); } // get first info message rcvMsg = rcvr.getMessage(); if (verbose) { rcvMsg.show(); } if (!testComService.compareMsgs(sndMsg, rcvMsg)) { test = false; } TestUtilities.checkResult(test, "sndMsg equals rcvMsg"); TestUtilities.putLine(); sndMsg.type = CommMessage.MessageType.closeReceiver; sndr.postMessage(sndMsg); rcvMsg = rcvr.getMessage(); if (verbose) { rcvMsg.show(); } if (!testComService.compareMsgs(sndMsg, rcvMsg)) { test = false; } TestUtilities.checkResult(test, "Close Receiver"); TestUtilities.putLine(); sndMsg.type = CommMessage.MessageType.closeSender; if (verbose) { sndMsg.show(); } sndr.postMessage(sndMsg); TestUtilities.putLine("last message received\n"); return(test); }
static void Main(string[] args) { Sender sndr = new Sender("http://localhost", 8080); sndr.postMessage(sndMsg); }