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/ConnectionSettings.h"
00032 #include "qpid/client/MessageListener.h"
00033 #include "TestCase.h"
00034
00035
00036 namespace qpid {
00037
00038 using namespace qpid::client;
00039
00040 class SimpleTestCaseBase : public TestCase
00041 {
00042 protected:
00043 class Worker
00044 {
00045 protected:
00046 client::Connection connection;
00047 client::Channel channel;
00048 const int messages;
00049 int count;
00050
00051 public:
00052
00053 Worker(ConnectionSettings& options, const int messages);
00054 virtual ~Worker(){}
00055
00056 virtual void stop();
00057 virtual int getCount();
00058 virtual void init() = 0;
00059 virtual void start() = 0;
00060 };
00061
00062 class Sender : public Worker
00063 {
00064 const Exchange& exchange;
00065 const std::string key;
00066 public:
00067 Sender(ConnectionSettings& options,
00068 const Exchange& exchange,
00069 const std::string& key,
00070 const int messages);
00071 void init();
00072 void start();
00073 };
00074
00075 std::auto_ptr<Worker> worker;
00076
00077 public:
00078 virtual void assign(const std::string& role, framing::FieldTable& params, ConnectionSettings& options) = 0;
00079
00080 virtual ~SimpleTestCaseBase() {}
00081
00082 void start();
00083 void stop();
00084 void report(client::Message& report);
00085 };
00086
00087 }
00088
00089 #endif