Ignore:
Timestamp:
27/08/2011 15:06:46 (9 months ago)
Author:
chris
Message:

Combine client and server protocols to make way for an offline/local protocol.

Rename ProtocolObject? to Message.

Location:
box/trunk/test/basicserver
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/test/basicserver/Makefile.extra

    r2598 r2983  
    22MAKEPROTOCOL = ../../lib/server/makeprotocol.pl 
    33 
    4 GEN_CMD_SRV = $(MAKEPROTOCOL) Server testprotocol.txt 
    5 GEN_CMD_CLI = $(MAKEPROTOCOL) Client testprotocol.txt 
     4GEN_CMD = $(MAKEPROTOCOL) testprotocol.txt 
    65 
    76# AUTOGEN SEEDING 
    8 autogen_TestProtocolServer.cpp: $(MAKEPROTOCOL) testprotocol.txt 
    9         $(_PERL) $(GEN_CMD_SRV) 
     7autogen_TestProtocol.cpp:       $(MAKEPROTOCOL) testprotocol.txt 
     8        $(_PERL) $(GEN_CMD) 
    109 
    1110autogen_TestProtocolServer.h:   $(MAKEPROTOCOL) testprotocol.txt 
    12         $(_PERL) $(GEN_CMD_SRV) 
     11        $(_PERL) $(GEN_CMD) 
    1312 
    14  
    15 # AUTOGEN SEEDING 
    16 autogen_TestProtocolClient.cpp: $(MAKEPROTOCOL) testprotocol.txt 
    17         $(_PERL) $(GEN_CMD_CLI) 
    18  
    19 autogen_TestProtocolClient.h:   $(MAKEPROTOCOL) testprotocol.txt 
    20         $(_PERL) $(GEN_CMD_CLI) 
    21  
  • box/trunk/test/basicserver/TestCommands.cpp

    r710 r2983  
    66#endif 
    77 
    8 #include "autogen_TestProtocolServer.h" 
     8#include "autogen_TestProtocol.h" 
    99#include "CollectInBufferStream.h" 
    1010 
     
    1212 
    1313 
    14 std::auto_ptr<ProtocolObject> TestProtocolServerHello::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) 
     14std::auto_ptr<TestProtocolMessage> TestProtocolHello::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 
    1515{ 
    1616        if(mNumber32 != 41 || mNumber16 != 87 || mNumber8 != 11 || mText != "pingu") 
    1717        { 
    18                 return std::auto_ptr<ProtocolObject>(new TestProtocolServerError(0, 0)); 
     18                return std::auto_ptr<TestProtocolMessage>(new TestProtocolError(0, 0)); 
    1919        } 
    20         return std::auto_ptr<ProtocolObject>(new TestProtocolServerHello(12,89,22,std::string("Hello world!"))); 
     20        return std::auto_ptr<TestProtocolMessage>(new TestProtocolHello(12,89,22,std::string("Hello world!"))); 
    2121} 
    2222 
    23 std::auto_ptr<ProtocolObject> TestProtocolServerLists::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) 
     23std::auto_ptr<TestProtocolMessage> TestProtocolLists::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 
    2424{ 
    25         return std::auto_ptr<ProtocolObject>(new TestProtocolServerListsReply(mLotsOfText.size())); 
     25        return std::auto_ptr<TestProtocolMessage>(new TestProtocolListsReply(mLotsOfText.size())); 
    2626} 
    2727 
    28 std::auto_ptr<ProtocolObject> TestProtocolServerQuit::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) 
     28std::auto_ptr<TestProtocolMessage> TestProtocolQuit::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 
    2929{ 
    30         return std::auto_ptr<ProtocolObject>(new TestProtocolServerQuit); 
     30        return std::auto_ptr<TestProtocolMessage>(new TestProtocolQuit); 
    3131} 
    3232 
    33 std::auto_ptr<ProtocolObject> TestProtocolServerSimple::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) 
     33std::auto_ptr<TestProtocolMessage> TestProtocolSimple::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 
    3434{ 
    35         return std::auto_ptr<ProtocolObject>(new TestProtocolServerSimpleReply(mValue+1)); 
     35        return std::auto_ptr<TestProtocolMessage>(new TestProtocolSimpleReply(mValue+1)); 
    3636} 
    3737 
     
    4646}; 
    4747 
    48 std::auto_ptr<ProtocolObject> TestProtocolServerGetStream::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) 
     48std::auto_ptr<TestProtocolMessage> TestProtocolGetStream::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 
    4949{ 
    5050        // make a new stream object 
     
    6969        rProtocol.SendStreamAfterCommand(pstream); 
    7070 
    71         return std::auto_ptr<ProtocolObject>(new TestProtocolServerGetStream(mStartingValue, mUncertainSize)); 
     71        return std::auto_ptr<TestProtocolMessage>(new TestProtocolGetStream(mStartingValue, mUncertainSize)); 
    7272} 
    7373 
    74 std::auto_ptr<ProtocolObject> TestProtocolServerSendStream::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) 
     74std::auto_ptr<TestProtocolMessage> TestProtocolSendStream::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 
    7575{ 
    7676        if(mValue != 0x73654353298ffLL) 
    7777        { 
    78                 return std::auto_ptr<ProtocolObject>(new TestProtocolServerError(0, 0)); 
     78                return std::auto_ptr<TestProtocolMessage>(new TestProtocolError(0, 0)); 
    7979        } 
    8080         
     
    9292 
    9393        // tell the caller how many bytes there were 
    94         return std::auto_ptr<ProtocolObject>(new TestProtocolServerGetStream(bytes, uncertain)); 
     94        return std::auto_ptr<TestProtocolMessage>(new TestProtocolGetStream(bytes, uncertain)); 
    9595} 
    9696 
    97 std::auto_ptr<ProtocolObject> TestProtocolServerString::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) 
     97std::auto_ptr<TestProtocolMessage> TestProtocolString::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 
    9898{ 
    99         return std::auto_ptr<ProtocolObject>(new TestProtocolServerString(mTest)); 
     99        return std::auto_ptr<TestProtocolMessage>(new TestProtocolString(mTest)); 
    100100} 
    101101 
  • box/trunk/test/basicserver/testbasicserver.cpp

    r2942 r2983  
    2727 
    2828#include "TestContext.h" 
    29 #include "autogen_TestProtocolClient.h" 
    30 #include "autogen_TestProtocolServer.h" 
     29#include "autogen_TestProtocol.h" 
    3130#include "ServerControl.h" 
    3231 
     
    394393void TestStreamReceive(TestProtocolClient &protocol, int value, bool uncertainstream) 
    395394{ 
    396         std::auto_ptr<TestProtocolClientGetStream> reply(protocol.QueryGetStream(value, uncertainstream)); 
     395        std::auto_ptr<TestProtocolGetStream> reply(protocol.QueryGetStream(value, uncertainstream)); 
    397396        TEST_THAT(reply->GetStartingValue() == value); 
    398397         
     
    705704                        // Simple query 
    706705                        { 
    707                                 std::auto_ptr<TestProtocolClientSimpleReply> reply(protocol.QuerySimple(41)); 
     706                                std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(41)); 
    708707                                TEST_THAT(reply->GetValuePlusOne() == 42); 
    709708                        } 
    710709                        { 
    711                                 std::auto_ptr<TestProtocolClientSimpleReply> reply(protocol.QuerySimple(809)); 
     710                                std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(809)); 
    712711                                TEST_THAT(reply->GetValuePlusOne() == 810); 
    713712                        } 
     
    725724                                s.Write(buf, sizeof(buf)); 
    726725                                s.SetForReading(); 
    727                                 std::auto_ptr<TestProtocolClientGetStream> reply(protocol.QuerySendStream(0x73654353298ffLL, s)); 
     726                                std::auto_ptr<TestProtocolGetStream> reply(protocol.QuerySendStream(0x73654353298ffLL, s)); 
    728727                                TEST_THAT(reply->GetStartingValue() == sizeof(buf)); 
    729728                        } 
     
    732731                        for(int q = 0; q < 514; q++) 
    733732                        { 
    734                                 std::auto_ptr<TestProtocolClientSimpleReply> reply(protocol.QuerySimple(q)); 
     733                                std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(q)); 
    735734                                TEST_THAT(reply->GetValuePlusOne() == (q+1)); 
    736735                        } 
     
    741740                                strings.push_back(std::string("test2")); 
    742741                                strings.push_back(std::string("test3")); 
    743                                 std::auto_ptr<TestProtocolClientListsReply> reply(protocol.QueryLists(strings)); 
     742                                std::auto_ptr<TestProtocolListsReply> reply(protocol.QueryLists(strings)); 
    744743                                TEST_THAT(reply->GetNumberOfStrings() == 3); 
    745744                        } 
     
    747746                        // And another 
    748747                        { 
    749                                 std::auto_ptr<TestProtocolClientHello> reply(protocol.QueryHello(41,87,11,std::string("pingu"))); 
     748                                std::auto_ptr<TestProtocolHello> reply(protocol.QueryHello(41,87,11,std::string("pingu"))); 
    750749                                TEST_THAT(reply->GetNumber32() == 12); 
    751750                                TEST_THAT(reply->GetNumber16() == 89); 
Note: See TracChangeset for help on using the changeset viewer.