00001 #ifndef _SimpleTestCaseBase_
00002 #define _SimpleTestCaseBase_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <memory>
00025 #include <sstream>
00026
00027 #include "qpid/Exception.h"
00028 #include "qpid/client/Channel.h"
00029 #include "qpid/client/Message.h"
00030 #include "qpid/client/Connection.h"
00031 #include "qpid/client/MessageListener.h"
00032 #include "TestCase.h"
00033
00034
00035 namespace qpid {
00036
00037 using namespace qpid::client;
00038
00039 class SimpleTestCaseBase : public TestCase
00040 {
00041 protected:
00042 class Worker
00043 {
00044 protected:
00045 client::Connection connection;
00046 client::Channel channel;
00047 const int messages;
00048 int count;
00049
00050 public:
00051
00052 Worker(TestOptions& options, const int messages);
00053 virtual ~Worker(){}
00054
00055 virtual void stop();
00056 virtual int getCount();
00057 virtual void init() = 0;
00058 virtual void start() = 0;
00059 };
00060
00061 class Sender : public Worker
00062 {
00063 const Exchange& exchange;
00064 const std::string key;
00065 public:
00066 Sender(TestOptions& options,
00067 const Exchange& exchange,
00068 const std::string& key,
00069 const int messages);
00070 void init();
00071 void start();
00072 };
00073
00074 std::auto_ptr<Worker> worker;
00075
00076 public:
00077 virtual void assign(const std::string& role, framing::FieldTable& params, TestOptions& options) = 0;
00078
00079 virtual ~SimpleTestCaseBase() {}
00080
00081 void start();
00082 void stop();
00083 void report(client::Message& report);
00084 };
00085
00086 }
00087
00088 #endif