/usr/share/cruisecontrol-bin-2.6.1/projects/qpid-trunk/cpp/src/tests/SimpleTestCaseBase.h

00001 #ifndef _SimpleTestCaseBase_
00002 #define _SimpleTestCaseBase_
00003 /*
00004  *
00005  * Licensed to the Apache Software Foundation (ASF) under one
00006  * or more contributor license agreements.  See the NOTICE file
00007  * distributed with this work for additional information
00008  * regarding copyright ownership.  The ASF licenses this file
00009  * to you under the Apache License, Version 2.0 (the
00010  * "License"); you may not use this file except in compliance
00011  * with the License.  You may obtain a copy of the License at
00012  * 
00013  *   http://www.apache.org/licenses/LICENSE-2.0
00014  * 
00015  * Unless required by applicable law or agreed to in writing,
00016  * software distributed under the License is distributed on an
00017  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00018  * KIND, either express or implied.  See the License for the
00019  * specific language governing permissions and limitations
00020  * under the License.
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

Generated on Thu Apr 10 11:08:18 2008 for Qpid by  doxygen 1.4.7