diff options
Diffstat (limited to 'test/basicserver')
-rw-r--r-- | test/basicserver/Makefile.extra | 17 | ||||
-rw-r--r-- | test/basicserver/TestCommands.cpp | 34 | ||||
-rw-r--r-- | test/basicserver/testbasicserver.cpp | 17 |
3 files changed, 29 insertions, 39 deletions
diff --git a/test/basicserver/Makefile.extra b/test/basicserver/Makefile.extra index 50120136..e6a4675e 100644 --- a/test/basicserver/Makefile.extra +++ b/test/basicserver/Makefile.extra @@ -1,21 +1,12 @@ MAKEPROTOCOL = ../../lib/server/makeprotocol.pl -GEN_CMD_SRV = $(MAKEPROTOCOL) Server testprotocol.txt -GEN_CMD_CLI = $(MAKEPROTOCOL) Client testprotocol.txt +GEN_CMD = $(MAKEPROTOCOL) testprotocol.txt # AUTOGEN SEEDING -autogen_TestProtocolServer.cpp: $(MAKEPROTOCOL) testprotocol.txt - $(_PERL) $(GEN_CMD_SRV) +autogen_TestProtocol.cpp: $(MAKEPROTOCOL) testprotocol.txt + $(_PERL) $(GEN_CMD) autogen_TestProtocolServer.h: $(MAKEPROTOCOL) testprotocol.txt - $(_PERL) $(GEN_CMD_SRV) - - -# AUTOGEN SEEDING -autogen_TestProtocolClient.cpp: $(MAKEPROTOCOL) testprotocol.txt - $(_PERL) $(GEN_CMD_CLI) - -autogen_TestProtocolClient.h: $(MAKEPROTOCOL) testprotocol.txt - $(_PERL) $(GEN_CMD_CLI) + $(_PERL) $(GEN_CMD) diff --git a/test/basicserver/TestCommands.cpp b/test/basicserver/TestCommands.cpp index 657e79ea..5238819f 100644 --- a/test/basicserver/TestCommands.cpp +++ b/test/basicserver/TestCommands.cpp @@ -5,34 +5,34 @@ #include <syslog.h> #endif -#include "autogen_TestProtocolServer.h" +#include "autogen_TestProtocol.h" #include "CollectInBufferStream.h" #include "MemLeakFindOn.h" -std::auto_ptr<ProtocolObject> TestProtocolServerHello::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) +std::auto_ptr<TestProtocolMessage> TestProtocolHello::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const { if(mNumber32 != 41 || mNumber16 != 87 || mNumber8 != 11 || mText != "pingu") { - return std::auto_ptr<ProtocolObject>(new TestProtocolServerError(0, 0)); + return std::auto_ptr<TestProtocolMessage>(new TestProtocolError(0, 0)); } - return std::auto_ptr<ProtocolObject>(new TestProtocolServerHello(12,89,22,std::string("Hello world!"))); + return std::auto_ptr<TestProtocolMessage>(new TestProtocolHello(12,89,22,std::string("Hello world!"))); } -std::auto_ptr<ProtocolObject> TestProtocolServerLists::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) +std::auto_ptr<TestProtocolMessage> TestProtocolLists::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const { - return std::auto_ptr<ProtocolObject>(new TestProtocolServerListsReply(mLotsOfText.size())); + return std::auto_ptr<TestProtocolMessage>(new TestProtocolListsReply(mLotsOfText.size())); } -std::auto_ptr<ProtocolObject> TestProtocolServerQuit::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) +std::auto_ptr<TestProtocolMessage> TestProtocolQuit::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const { - return std::auto_ptr<ProtocolObject>(new TestProtocolServerQuit); + return std::auto_ptr<TestProtocolMessage>(new TestProtocolQuit); } -std::auto_ptr<ProtocolObject> TestProtocolServerSimple::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) +std::auto_ptr<TestProtocolMessage> TestProtocolSimple::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const { - return std::auto_ptr<ProtocolObject>(new TestProtocolServerSimpleReply(mValue+1)); + return std::auto_ptr<TestProtocolMessage>(new TestProtocolSimpleReply(mValue+1)); } class UncertainBufferStream : public CollectInBufferStream @@ -45,7 +45,7 @@ public: } }; -std::auto_ptr<ProtocolObject> TestProtocolServerGetStream::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) +std::auto_ptr<TestProtocolMessage> TestProtocolGetStream::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const { // make a new stream object CollectInBufferStream *pstream = mUncertainSize?(new UncertainBufferStream):(new CollectInBufferStream); @@ -68,14 +68,14 @@ std::auto_ptr<ProtocolObject> TestProtocolServerGetStream::DoCommand(TestProtoco // Get it to be sent rProtocol.SendStreamAfterCommand(pstream); - return std::auto_ptr<ProtocolObject>(new TestProtocolServerGetStream(mStartingValue, mUncertainSize)); + return std::auto_ptr<TestProtocolMessage>(new TestProtocolGetStream(mStartingValue, mUncertainSize)); } -std::auto_ptr<ProtocolObject> TestProtocolServerSendStream::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) +std::auto_ptr<TestProtocolMessage> TestProtocolSendStream::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const { if(mValue != 0x73654353298ffLL) { - return std::auto_ptr<ProtocolObject>(new TestProtocolServerError(0, 0)); + return std::auto_ptr<TestProtocolMessage>(new TestProtocolError(0, 0)); } // Get a stream @@ -91,11 +91,11 @@ std::auto_ptr<ProtocolObject> TestProtocolServerSendStream::DoCommand(TestProtoc } // tell the caller how many bytes there were - return std::auto_ptr<ProtocolObject>(new TestProtocolServerGetStream(bytes, uncertain)); + return std::auto_ptr<TestProtocolMessage>(new TestProtocolGetStream(bytes, uncertain)); } -std::auto_ptr<ProtocolObject> TestProtocolServerString::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) +std::auto_ptr<TestProtocolMessage> TestProtocolString::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const { - return std::auto_ptr<ProtocolObject>(new TestProtocolServerString(mTest)); + return std::auto_ptr<TestProtocolMessage>(new TestProtocolString(mTest)); } diff --git a/test/basicserver/testbasicserver.cpp b/test/basicserver/testbasicserver.cpp index 29bf8b6a..976bdd92 100644 --- a/test/basicserver/testbasicserver.cpp +++ b/test/basicserver/testbasicserver.cpp @@ -26,8 +26,7 @@ #include "CollectInBufferStream.h" #include "TestContext.h" -#include "autogen_TestProtocolClient.h" -#include "autogen_TestProtocolServer.h" +#include "autogen_TestProtocol.h" #include "ServerControl.h" #include "MemLeakFindOn.h" @@ -393,7 +392,7 @@ void Srv2TestConversations(const std::vector<IOStream *> &conns) void TestStreamReceive(TestProtocolClient &protocol, int value, bool uncertainstream) { - std::auto_ptr<TestProtocolClientGetStream> reply(protocol.QueryGetStream(value, uncertainstream)); + std::auto_ptr<TestProtocolGetStream> reply(protocol.QueryGetStream(value, uncertainstream)); TEST_THAT(reply->GetStartingValue() == value); // Get a stream @@ -704,11 +703,11 @@ int test(int argc, const char *argv[]) // Simple query { - std::auto_ptr<TestProtocolClientSimpleReply> reply(protocol.QuerySimple(41)); + std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(41)); TEST_THAT(reply->GetValuePlusOne() == 42); } { - std::auto_ptr<TestProtocolClientSimpleReply> reply(protocol.QuerySimple(809)); + std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(809)); TEST_THAT(reply->GetValuePlusOne() == 810); } @@ -724,14 +723,14 @@ int test(int argc, const char *argv[]) char buf[1663]; s.Write(buf, sizeof(buf)); s.SetForReading(); - std::auto_ptr<TestProtocolClientGetStream> reply(protocol.QuerySendStream(0x73654353298ffLL, s)); + std::auto_ptr<TestProtocolGetStream> reply(protocol.QuerySendStream(0x73654353298ffLL, s)); TEST_THAT(reply->GetStartingValue() == sizeof(buf)); } // Lots of simple queries for(int q = 0; q < 514; q++) { - std::auto_ptr<TestProtocolClientSimpleReply> reply(protocol.QuerySimple(q)); + std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(q)); TEST_THAT(reply->GetValuePlusOne() == (q+1)); } // Send a list of strings to it @@ -740,13 +739,13 @@ int test(int argc, const char *argv[]) strings.push_back(std::string("test1")); strings.push_back(std::string("test2")); strings.push_back(std::string("test3")); - std::auto_ptr<TestProtocolClientListsReply> reply(protocol.QueryLists(strings)); + std::auto_ptr<TestProtocolListsReply> reply(protocol.QueryLists(strings)); TEST_THAT(reply->GetNumberOfStrings() == 3); } // And another { - std::auto_ptr<TestProtocolClientHello> reply(protocol.QueryHello(41,87,11,std::string("pingu"))); + std::auto_ptr<TestProtocolHello> reply(protocol.QueryHello(41,87,11,std::string("pingu"))); TEST_THAT(reply->GetNumber32() == 12); TEST_THAT(reply->GetNumber16() == 89); TEST_THAT(reply->GetNumber8() == 22); |