You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2008/05/30 10:13:22 UTC

svn commit: r661587 [2/2] - in /incubator/qpid/trunk/qpid/cpp: ./ src/tests/

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/QueueRegistryTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/QueueRegistryTest.cpp?rev=661587&r1=661586&r2=661587&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/QueueRegistryTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/QueueRegistryTest.cpp Fri May 30 01:13:21 2008
@@ -18,78 +18,77 @@
  */
 
 #include "qpid/broker/QueueRegistry.h"
-#include "qpid_test_plugin.h"
+#include "unit_test.h"
 #include <string>
 
 using namespace qpid::broker;
 
-class QueueRegistryTest : public CppUnit::TestCase 
+QPID_AUTO_TEST_SUITE(QueueRegistryTest)
+
+QPID_AUTO_TEST_CASE(testDeclare)
 {
-    CPPUNIT_TEST_SUITE(QueueRegistryTest);
-    CPPUNIT_TEST(testDeclare);
-    CPPUNIT_TEST(testDeclareTmp);
-    CPPUNIT_TEST(testFind);
-    CPPUNIT_TEST(testDestroy);
-    CPPUNIT_TEST_SUITE_END();
+    std::string foo("foo");
+    std::string bar("bar");
+    QueueRegistry reg;
+    std::pair<Queue::shared_ptr,  bool> qc;
 
-  private:
-    std::string foo, bar;
+    qc = reg.declare(foo, false, 0, 0);
+    Queue::shared_ptr q = qc.first;
+    BOOST_CHECK(q);
+    BOOST_CHECK(qc.second); // New queue
+    BOOST_CHECK_EQUAL(foo, q->getName());
+
+    qc = reg.declare(foo, false, 0, 0);
+    BOOST_CHECK_EQUAL(q, qc.first);
+    BOOST_CHECK(!qc.second);
+
+    qc = reg.declare(bar, false, 0, 0);
+    q = qc.first;
+    BOOST_CHECK(q);
+    BOOST_CHECK_EQUAL(true, qc.second);
+    BOOST_CHECK_EQUAL(bar, q->getName());
+}
+
+QPID_AUTO_TEST_CASE(testDeclareTmp) 
+{
     QueueRegistry reg;
     std::pair<Queue::shared_ptr,  bool> qc;
+
+    qc = reg.declare(std::string(), false, 0, 0);
+    BOOST_CHECK(qc.second);
+    BOOST_CHECK_EQUAL(std::string("tmp_1"), qc.first->getName());
+}
     
-  public:
-    void setUp() {
-        foo = "foo";
-        bar = "bar";
-    }
-    
-    void testDeclare() {
-        qc = reg.declare(foo, false, 0, 0);
-        Queue::shared_ptr q = qc.first;
-        CPPUNIT_ASSERT(q);
-        CPPUNIT_ASSERT(qc.second); // New queue
-        CPPUNIT_ASSERT_EQUAL(foo, q->getName());
-
-        qc = reg.declare(foo, false, 0, 0);
-        CPPUNIT_ASSERT_EQUAL(q, qc.first);
-        CPPUNIT_ASSERT(!qc.second);
-
-        qc = reg.declare(bar, false, 0, 0);
-        q = qc.first;
-        CPPUNIT_ASSERT(q);
-        CPPUNIT_ASSERT_EQUAL(true, qc.second);
-        CPPUNIT_ASSERT_EQUAL(bar, q->getName());
-    }
-
-    void testDeclareTmp() 
-    {
-        qc = reg.declare(std::string(), false, 0, 0);
-        CPPUNIT_ASSERT(qc.second);
-        CPPUNIT_ASSERT_EQUAL(std::string("tmp_1"), qc.first->getName());
-    }
-    
-    void testFind() {
-        CPPUNIT_ASSERT(reg.find(foo) == 0);
+QPID_AUTO_TEST_CASE(testFind) 
+{
+    std::string foo("foo");
+    std::string bar("bar");
+    QueueRegistry reg;
+    std::pair<Queue::shared_ptr,  bool> qc;
+
+    BOOST_CHECK(reg.find(foo) == 0);
+
+    reg.declare(foo, false, 0, 0);
+    reg.declare(bar, false, 0, 0);
+    Queue::shared_ptr q = reg.find(bar);
+    BOOST_CHECK(q);
+    BOOST_CHECK_EQUAL(bar, q->getName());
+}
+
+QPID_AUTO_TEST_CASE(testDestroy) 
+{
+    std::string foo("foo");
+    QueueRegistry reg;
+    std::pair<Queue::shared_ptr,  bool> qc;
+
+    qc = reg.declare(foo, false, 0, 0);
+    reg.destroy(foo);
+    // Queue is gone from the registry.
+    BOOST_CHECK(reg.find(foo) == 0);
+    // Queue is not actually destroyed till we drop our reference.
+    BOOST_CHECK_EQUAL(foo, qc.first->getName());
+    // We shoud be the only reference.
+    BOOST_CHECK_EQUAL(1L, qc.first.use_count());
+}
 
-        reg.declare(foo, false, 0, 0);
-        reg.declare(bar, false, 0, 0);
-        Queue::shared_ptr q = reg.find(bar);
-        CPPUNIT_ASSERT(q);
-        CPPUNIT_ASSERT_EQUAL(bar, q->getName());
-    }
-
-    void testDestroy() {
-        qc = reg.declare(foo, false, 0, 0);
-        reg.destroy(foo);
-        // Queue is gone from the registry.
-        CPPUNIT_ASSERT(reg.find(foo) == 0);
-        // Queue is not actually destroyed till we drop our reference.
-        CPPUNIT_ASSERT_EQUAL(foo, qc.first->getName());
-        // We shoud be the only reference.
-        CPPUNIT_ASSERT_EQUAL(1L, qc.first.use_count());
-    }
-};
-
-// Make this test suite a plugin.
-CPPUNIT_PLUGIN_IMPLEMENT();
-CPPUNIT_TEST_SUITE_REGISTRATION(QueueRegistryTest);
+QPID_AUTO_TEST_SUITE_END()

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/QueueTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/QueueTest.cpp?rev=661587&r1=661586&r2=661587&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/QueueTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/QueueTest.cpp Fri May 30 01:13:21 2008
@@ -18,13 +18,13 @@
  * under the License.
  *
  */
+#include "unit_test.h"
 #include "qpid/Exception.h"
 #include "qpid/broker/Queue.h"
 #include "qpid/broker/Deliverable.h"
 #include "qpid/broker/ExchangeRegistry.h"
 #include "qpid/broker/QueueRegistry.h"
 #include "qpid/framing/MessageTransferBody.h"
-#include "qpid_test_plugin.h"
 #include <iostream>
 #include "boost/format.hpp"
 
@@ -34,7 +34,6 @@
 using namespace qpid::framing;
 using namespace qpid::sys;
 
-
 class TestConsumer : public virtual Consumer{
 public:
     typedef boost::shared_ptr<TestConsumer> shared_ptr;            
@@ -63,200 +62,180 @@
     Message& getMessage() { return msg; }
 };
 
-class QueueTest : public CppUnit::TestCase  
-{
-    CPPUNIT_TEST_SUITE(QueueTest);
-    CPPUNIT_TEST(testConsumers);
-    CPPUNIT_TEST(testRegistry);
-    CPPUNIT_TEST(testDequeue);
-    CPPUNIT_TEST(testBound);
-    CPPUNIT_TEST(testAsyncMessage);
-    CPPUNIT_TEST(testAsyncMessageCount);
-    CPPUNIT_TEST_SUITE_END();
-
-
-  public:
-    intrusive_ptr<Message> message(std::string exchange, std::string routingKey) {
-        intrusive_ptr<Message> msg(new Message());
-        AMQFrame method(in_place<MessageTransferBody>(
-                            ProtocolVersion(), exchange, 0, 0));
-        AMQFrame header(in_place<AMQHeaderBody>());
-        msg->getFrames().append(method);
-        msg->getFrames().append(header);
-        msg->getFrames().getHeaders()->get<DeliveryProperties>(true)->setRoutingKey(routingKey);
-        return msg;
-    }
-    
-    
-    void testAsyncMessage(){
-    
-        Queue::shared_ptr queue(new Queue("my_test_queue", true));
-        intrusive_ptr<Message> received;
-	
-        TestConsumer c1;
-        queue->consume(c1);
-
-       
-        //Test basic delivery:
-        intrusive_ptr<Message> msg1 = message("e", "A");
-        msg1->enqueueAsync();//this is done on enqueue which is not called from process
-        queue->process(msg1);
-	sleep(2);
-
-        CPPUNIT_ASSERT(!c1.received);
- 	msg1->enqueueComplete();
-
-        received = queue->dequeue().payload;
-        CPPUNIT_ASSERT_EQUAL(msg1.get(), received.get());
- 	
-   
-    }
-    
-    
-    void testAsyncMessageCount(){
-        Queue::shared_ptr queue(new Queue("my_test_queue", true));
-        intrusive_ptr<Message> msg1 = message("e", "A");
-        msg1->enqueueAsync();//this is done on enqueue which is not called from process
-	
-        queue->process(msg1);
-	sleep(2);
-	uint32_t compval=0;
-        CPPUNIT_ASSERT_EQUAL(compval, queue->getMessageCount());
- 	msg1->enqueueComplete();
-	compval=1;
-        CPPUNIT_ASSERT_EQUAL(compval, queue->getMessageCount());
-    
-    }
-    
-    void testConsumers(){
-        Queue::shared_ptr queue(new Queue("my_queue", true));
-    
-        //Test adding consumers:
-        TestConsumer c1;
-        TestConsumer c2;
-        queue->consume(c1);
-        queue->consume(c2);
-
-        CPPUNIT_ASSERT_EQUAL(uint32_t(2), queue->getConsumerCount());
+intrusive_ptr<Message> message(std::string exchange, std::string routingKey) {
+    intrusive_ptr<Message> msg(new Message());
+    AMQFrame method(in_place<MessageTransferBody>(ProtocolVersion(), exchange, 0, 0));
+    AMQFrame header(in_place<AMQHeaderBody>());
+    msg->getFrames().append(method);
+    msg->getFrames().append(header);
+    msg->getFrames().getHeaders()->get<DeliveryProperties>(true)->setRoutingKey(routingKey);
+    return msg;
+}
+
+QPID_AUTO_TEST_SUITE(QueueTestSuite)
+
+QPID_AUTO_TEST_CASE(testAsyncMessage) {
+    Queue::shared_ptr queue(new Queue("my_test_queue", true));
+    intrusive_ptr<Message> received;
+    
+    TestConsumer c1;
+    queue->consume(c1);
+    
+    
+    //Test basic delivery:
+    intrusive_ptr<Message> msg1 = message("e", "A");
+    msg1->enqueueAsync();//this is done on enqueue which is not called from process
+    queue->process(msg1);
+    sleep(2);
+    
+    BOOST_CHECK(!c1.received);
+    msg1->enqueueComplete();
+    
+    received = queue->dequeue().payload;
+    BOOST_CHECK_EQUAL(msg1.get(), received.get());    
+}
+    
+    
+QPID_AUTO_TEST_CASE(testAsyncMessageCount){
+    Queue::shared_ptr queue(new Queue("my_test_queue", true));
+    intrusive_ptr<Message> msg1 = message("e", "A");
+    msg1->enqueueAsync();//this is done on enqueue which is not called from process
+    
+    queue->process(msg1);
+    sleep(2);
+    uint32_t compval=0;
+    BOOST_CHECK_EQUAL(compval, queue->getMessageCount());
+    msg1->enqueueComplete();
+    compval=1;
+    BOOST_CHECK_EQUAL(compval, queue->getMessageCount());    
+}
+
+QPID_AUTO_TEST_CASE(testConsumers){
+    Queue::shared_ptr queue(new Queue("my_queue", true));
+    
+    //Test adding consumers:
+    TestConsumer c1;
+    TestConsumer c2;
+    queue->consume(c1);
+    queue->consume(c2);
+    
+    BOOST_CHECK_EQUAL(uint32_t(2), queue->getConsumerCount());
+    
+    //Test basic delivery:
+    intrusive_ptr<Message> msg1 = message("e", "A");
+    intrusive_ptr<Message> msg2 = message("e", "B");
+    intrusive_ptr<Message> msg3 = message("e", "C");
+    
+    queue->deliver(msg1);
+    BOOST_CHECK(queue->dispatch(c1));
+    BOOST_CHECK_EQUAL(msg1.get(), c1.last.get());
+    
+    queue->deliver(msg2);
+    BOOST_CHECK(queue->dispatch(c2));
+    BOOST_CHECK_EQUAL(msg2.get(), c2.last.get());
+    
+    c1.received = false;
+    queue->deliver(msg3);
+    BOOST_CHECK(queue->dispatch(c1));
+    BOOST_CHECK_EQUAL(msg3.get(), c1.last.get());        
+    
+    //Test cancellation:
+    queue->cancel(c1);
+    BOOST_CHECK_EQUAL(uint32_t(1), queue->getConsumerCount());
+    queue->cancel(c2);
+    BOOST_CHECK_EQUAL(uint32_t(0), queue->getConsumerCount());
+}
+
+QPID_AUTO_TEST_CASE(testRegistry){
+    //Test use of queues in registry:
+    QueueRegistry registry;
+    registry.declare("queue1", true, true);
+    registry.declare("queue2", true, true);
+    registry.declare("queue3", true, true);
+    
+    BOOST_CHECK(registry.find("queue1"));
+    BOOST_CHECK(registry.find("queue2"));
+    BOOST_CHECK(registry.find("queue3"));
+    
+    registry.destroy("queue1");
+    registry.destroy("queue2");
+    registry.destroy("queue3");
+    
+    BOOST_CHECK(!registry.find("queue1"));
+    BOOST_CHECK(!registry.find("queue2"));
+    BOOST_CHECK(!registry.find("queue3"));
+}
+
+QPID_AUTO_TEST_CASE(testDequeue){
+    Queue::shared_ptr queue(new Queue("my_queue", true));
+    intrusive_ptr<Message> msg1 = message("e", "A");
+    intrusive_ptr<Message> msg2 = message("e", "B");
+    intrusive_ptr<Message> msg3 = message("e", "C");
+    intrusive_ptr<Message> received;
+    
+    queue->deliver(msg1);
+    queue->deliver(msg2);
+    queue->deliver(msg3);
+    
+    BOOST_CHECK_EQUAL(uint32_t(3), queue->getMessageCount());
+    
+    received = queue->dequeue().payload;
+    BOOST_CHECK_EQUAL(msg1.get(), received.get());
+    BOOST_CHECK_EQUAL(uint32_t(2), queue->getMessageCount());
+
+    received = queue->dequeue().payload;
+    BOOST_CHECK_EQUAL(msg2.get(), received.get());
+    BOOST_CHECK_EQUAL(uint32_t(1), queue->getMessageCount());
+
+    TestConsumer consumer;
+    queue->consume(consumer);
+    queue->dispatch(consumer);
+    if (!consumer.received)
+        sleep(2);
+
+    BOOST_CHECK_EQUAL(msg3.get(), consumer.last.get());
+    BOOST_CHECK_EQUAL(uint32_t(0), queue->getMessageCount());
+
+    received = queue->dequeue().payload;
+    BOOST_CHECK(!received);
+    BOOST_CHECK_EQUAL(uint32_t(0), queue->getMessageCount());
         
-        //Test basic delivery:
-        intrusive_ptr<Message> msg1 = message("e", "A");
-        intrusive_ptr<Message> msg2 = message("e", "B");
-        intrusive_ptr<Message> msg3 = message("e", "C");
-
-        queue->deliver(msg1);
-        CPPUNIT_ASSERT(queue->dispatch(c1));
-        CPPUNIT_ASSERT_EQUAL(msg1.get(), c1.last.get());
-
-        queue->deliver(msg2);
-        CPPUNIT_ASSERT(queue->dispatch(c2));
-        CPPUNIT_ASSERT_EQUAL(msg2.get(), c2.last.get());
-        
-	c1.received = false;
-        queue->deliver(msg3);
-        CPPUNIT_ASSERT(queue->dispatch(c1));
-        CPPUNIT_ASSERT_EQUAL(msg3.get(), c1.last.get());        
-    
-        //Test cancellation:
-        queue->cancel(c1);
-        CPPUNIT_ASSERT_EQUAL(uint32_t(1), queue->getConsumerCount());
-        queue->cancel(c2);
-        CPPUNIT_ASSERT_EQUAL(uint32_t(0), queue->getConsumerCount());
-    }
-
-    void testRegistry(){
-        //Test use of queues in registry:
-        QueueRegistry registry;
-        registry.declare("queue1", true, true);
-        registry.declare("queue2", true, true);
-        registry.declare("queue3", true, true);
-
-        CPPUNIT_ASSERT(registry.find("queue1"));
-        CPPUNIT_ASSERT(registry.find("queue2"));
-        CPPUNIT_ASSERT(registry.find("queue3"));
-        
-        registry.destroy("queue1");
-        registry.destroy("queue2");
-        registry.destroy("queue3");
-
-        CPPUNIT_ASSERT(!registry.find("queue1"));
-        CPPUNIT_ASSERT(!registry.find("queue2"));
-        CPPUNIT_ASSERT(!registry.find("queue3"));
-    }
-
-    void testDequeue(){
-        Queue::shared_ptr queue(new Queue("my_queue", true));
-        intrusive_ptr<Message> msg1 = message("e", "A");
-        intrusive_ptr<Message> msg2 = message("e", "B");
-        intrusive_ptr<Message> msg3 = message("e", "C");
-        intrusive_ptr<Message> received;
-
-        queue->deliver(msg1);
-        queue->deliver(msg2);
-        queue->deliver(msg3);
-
-        CPPUNIT_ASSERT_EQUAL(uint32_t(3), queue->getMessageCount());
-        
-        received = queue->dequeue().payload;
-        CPPUNIT_ASSERT_EQUAL(msg1.get(), received.get());
-        CPPUNIT_ASSERT_EQUAL(uint32_t(2), queue->getMessageCount());
-
-        received = queue->dequeue().payload;
-        CPPUNIT_ASSERT_EQUAL(msg2.get(), received.get());
-        CPPUNIT_ASSERT_EQUAL(uint32_t(1), queue->getMessageCount());
-
-        TestConsumer consumer;
-        queue->consume(consumer);
-        queue->dispatch(consumer);
-	if (!consumer.received)
-	    sleep(2);
-
-        CPPUNIT_ASSERT_EQUAL(msg3.get(), consumer.last.get());
-        CPPUNIT_ASSERT_EQUAL(uint32_t(0), queue->getMessageCount());
-
-        received = queue->dequeue().payload;
-        CPPUNIT_ASSERT(!received);
-        CPPUNIT_ASSERT_EQUAL(uint32_t(0), queue->getMessageCount());
-        
-    }
+}
 
-    void testBound()
-    {
-        //test the recording of bindings, and use of those to allow a queue to be unbound
-        string key("my-key");
-        FieldTable args;
-
-        Queue::shared_ptr queue(new Queue("my-queue", true));
-        ExchangeRegistry exchanges;
-        //establish bindings from exchange->queue and notify the queue as it is bound:
-        Exchange::shared_ptr exchange1 = exchanges.declare("my-exchange-1", "direct").first;
-        exchange1->bind(queue, key, &args);
-        queue->bound(exchange1->getName(), key, args);
-
-        Exchange::shared_ptr exchange2 = exchanges.declare("my-exchange-2", "fanout").first;
-        exchange2->bind(queue, key, &args);
-        queue->bound(exchange2->getName(), key, args);
-
-        Exchange::shared_ptr exchange3 = exchanges.declare("my-exchange-3", "topic").first;
-        exchange3->bind(queue, key, &args);
-        queue->bound(exchange3->getName(), key, args);
-
-        //delete one of the exchanges:
-        exchanges.destroy(exchange2->getName());
-        exchange2.reset();
-
-        //unbind the queue from all exchanges it knows it has been bound to:
-        queue->unbind(exchanges, queue);
-
-        //ensure the remaining exchanges don't still have the queue bound to them:
-        FailOnDeliver deliverable;        
-        exchange1->route(deliverable, key, &args);
-        exchange3->route(deliverable, key, &args);
-    }
-};
+QPID_AUTO_TEST_CASE(testBound)
+{
+    //test the recording of bindings, and use of those to allow a queue to be unbound
+    string key("my-key");
+    FieldTable args;
+
+    Queue::shared_ptr queue(new Queue("my-queue", true));
+    ExchangeRegistry exchanges;
+    //establish bindings from exchange->queue and notify the queue as it is bound:
+    Exchange::shared_ptr exchange1 = exchanges.declare("my-exchange-1", "direct").first;
+    exchange1->bind(queue, key, &args);
+    queue->bound(exchange1->getName(), key, args);
+
+    Exchange::shared_ptr exchange2 = exchanges.declare("my-exchange-2", "fanout").first;
+    exchange2->bind(queue, key, &args);
+    queue->bound(exchange2->getName(), key, args);
+
+    Exchange::shared_ptr exchange3 = exchanges.declare("my-exchange-3", "topic").first;
+    exchange3->bind(queue, key, &args);
+    queue->bound(exchange3->getName(), key, args);
+
+    //delete one of the exchanges:
+    exchanges.destroy(exchange2->getName());
+    exchange2.reset();
+
+    //unbind the queue from all exchanges it knows it has been bound to:
+    queue->unbind(exchanges, queue);
+
+    //ensure the remaining exchanges don't still have the queue bound to them:
+    FailOnDeliver deliverable;        
+    exchange1->route(deliverable, key, &args);
+    exchange3->route(deliverable, key, &args);
+}
 
-// Make this test suite a plugin.
-CPPUNIT_PLUGIN_IMPLEMENT();
-CPPUNIT_TEST_SUITE_REGISTRATION(QueueTest);
+QPID_AUTO_TEST_SUITE_END()
 
 

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/SequenceNumberTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/SequenceNumberTest.cpp?rev=661587&r1=661586&r2=661587&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/SequenceNumberTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/SequenceNumberTest.cpp Fri May 30 01:13:21 2008
@@ -19,202 +19,187 @@
  *
  */
 
-#include "qpid_test_plugin.h"
+#include "unit_test.h"
 #include <iostream>
 #include "qpid/framing/SequenceNumber.h"
 #include "qpid/framing/SequenceNumberSet.h"
 
 using namespace qpid::framing;
 
-class SequenceNumberTest : public CppUnit::TestCase
+
+void checkDifference(SequenceNumber& a, SequenceNumber& b, int gap)
+{
+    BOOST_CHECK_EQUAL(gap, a - b);
+    BOOST_CHECK_EQUAL(-gap, b - a);
+
+    //increment until b wraps around
+    for (int i = 0; i < (gap + 2); i++, ++a, ++b) {
+        BOOST_CHECK_EQUAL(gap, a - b);
+    }
+    //keep incrementing until a also wraps around
+    for (int i = 0; i < (gap + 2); i++, ++a, ++b) {
+        BOOST_CHECK_EQUAL(gap, a - b);
+    }
+    //let b catch up and overtake
+    for (int i = 0; i < (gap*2); i++, ++b) {
+        BOOST_CHECK_EQUAL(gap - i, a - b);
+        BOOST_CHECK_EQUAL(i - gap, b - a);
+    }
+}
+
+void checkComparison(SequenceNumber& a, SequenceNumber& b, int gap)
+{
+    //increment until b wraps around
+    for (int i = 0; i < (gap + 2); i++) {
+        BOOST_CHECK(++a < ++b);//test prefix
+    }
+    //keep incrementing until a also wraps around
+    for (int i = 0; i < (gap + 2); i++) {            
+        BOOST_CHECK(a++ < b++);//test postfix
+    }
+    //let a 'catch up'
+    for (int i = 0; i < gap; i++) {
+        a++;
+    }
+    BOOST_CHECK(a == b);
+    BOOST_CHECK(++a > b);
+}
+
+
+QPID_AUTO_TEST_SUITE(SequenceNumberTestSuite)
+
+QPID_AUTO_TEST_CASE(testIncrementPostfix)
+{
+    SequenceNumber a;
+    SequenceNumber b;
+    BOOST_CHECK(!(a > b));
+    BOOST_CHECK(!(b < a));
+    BOOST_CHECK(a == b);
+
+    SequenceNumber c = a++;
+    BOOST_CHECK(a > b);
+    BOOST_CHECK(b < a);
+    BOOST_CHECK(a != b);
+    BOOST_CHECK(c < a);
+    BOOST_CHECK(a != c);
+
+    b++;
+    BOOST_CHECK(!(a > b));
+    BOOST_CHECK(!(b < a));
+    BOOST_CHECK(a == b);
+    BOOST_CHECK(c < b);
+    BOOST_CHECK(b != c);
+}
+
+QPID_AUTO_TEST_CASE(testIncrementPrefix) 
+{
+    SequenceNumber a;
+    SequenceNumber b;
+    BOOST_CHECK(!(a > b));
+    BOOST_CHECK(!(b < a));
+    BOOST_CHECK(a == b);
+
+    SequenceNumber c = ++a;
+    BOOST_CHECK(a > b);
+    BOOST_CHECK(b < a);
+    BOOST_CHECK(a != b);
+    BOOST_CHECK(a == c);
+
+    ++b;
+    BOOST_CHECK(!(a > b));
+    BOOST_CHECK(!(b < a));
+    BOOST_CHECK(a == b);
+}
+
+QPID_AUTO_TEST_CASE(testWrapAround)
 {
-    CPPUNIT_TEST_SUITE(SequenceNumberTest);
-    CPPUNIT_TEST(testIncrementPostfix);
-    CPPUNIT_TEST(testIncrementPrefix);
-    CPPUNIT_TEST(testWrapAround);
-    CPPUNIT_TEST(testCondense);
-    CPPUNIT_TEST(testCondenseSingleRange);
-    CPPUNIT_TEST(testCondenseSingleItem);
-    CPPUNIT_TEST(testDifference);
-    CPPUNIT_TEST(testDifferenceWithWrapAround1);
-    CPPUNIT_TEST(testDifferenceWithWrapAround2);
-    CPPUNIT_TEST_SUITE_END();
-
-  public:
-
-    void testIncrementPostfix() 
-    {
-        SequenceNumber a;
-        SequenceNumber b;
-        CPPUNIT_ASSERT(!(a > b));
-        CPPUNIT_ASSERT(!(b < a));
-        CPPUNIT_ASSERT(a == b);
-
-        SequenceNumber c = a++;
-        CPPUNIT_ASSERT(a > b);
-        CPPUNIT_ASSERT(b < a);
-        CPPUNIT_ASSERT(a != b);
-        CPPUNIT_ASSERT(c < a);
-        CPPUNIT_ASSERT(a != c);
-
-        b++;
-        CPPUNIT_ASSERT(!(a > b));
-        CPPUNIT_ASSERT(!(b < a));
-        CPPUNIT_ASSERT(a == b);
-        CPPUNIT_ASSERT(c < b);
-        CPPUNIT_ASSERT(b != c);
-    }
-
-    void testIncrementPrefix() 
-    {
-        SequenceNumber a;
-        SequenceNumber b;
-        CPPUNIT_ASSERT(!(a > b));
-        CPPUNIT_ASSERT(!(b < a));
-        CPPUNIT_ASSERT(a == b);
-
-        SequenceNumber c = ++a;
-        CPPUNIT_ASSERT(a > b);
-        CPPUNIT_ASSERT(b < a);
-        CPPUNIT_ASSERT(a != b);
-        CPPUNIT_ASSERT(a == c);
-
-        ++b;
-        CPPUNIT_ASSERT(!(a > b));
-        CPPUNIT_ASSERT(!(b < a));
-        CPPUNIT_ASSERT(a == b);
-    }
-
-    void testWrapAround()
-    {
-        const uint32_t max = 0xFFFFFFFF;
-        SequenceNumber a(max - 10);
-        SequenceNumber b(max - 5);
-        checkComparison(a, b, 5);
-
-        const uint32_t max_signed = 0x7FFFFFFF;
-        SequenceNumber c(max_signed - 10);
-        SequenceNumber d(max_signed - 5);
-        checkComparison(c, d, 5);
-    }
-
-    void checkComparison(SequenceNumber& a, SequenceNumber& b, int gap)
-    {
-        //increment until b wraps around
-        for (int i = 0; i < (gap + 2); i++) {
-            CPPUNIT_ASSERT(++a < ++b);//test prefix
-        }
-        //keep incrementing until a also wraps around
-        for (int i = 0; i < (gap + 2); i++) {            
-            CPPUNIT_ASSERT(a++ < b++);//test postfix
-        }
-        //let a 'catch up'
-        for (int i = 0; i < gap; i++) {
-            a++;
-        }
-        CPPUNIT_ASSERT(a == b);
-        CPPUNIT_ASSERT(++a > b);
-    }
-
-    void testCondense()
-    {
-        SequenceNumberSet set;
-        for (uint i = 0; i < 6; i++) {
-            set.push_back(SequenceNumber(i));
-        }
-        set.push_back(SequenceNumber(7));
-        for (uint i = 9; i < 13; i++) {
-            set.push_back(SequenceNumber(i));
-        }
-        set.push_back(SequenceNumber(13));
-        SequenceNumberSet actual = set.condense();
-
-        SequenceNumberSet expected;
-        expected.addRange(SequenceNumber(0), SequenceNumber(5));
-        expected.addRange(SequenceNumber(7), SequenceNumber(7));
-        expected.addRange(SequenceNumber(9), SequenceNumber(13));
-        CPPUNIT_ASSERT_EQUAL(expected, actual);
-    }
-
-    void testCondenseSingleRange()
-    {
-        SequenceNumberSet set;
-        for (uint i = 0; i < 6; i++) {
-            set.push_back(SequenceNumber(i));
-        }
-        SequenceNumberSet actual = set.condense();
-
-        SequenceNumberSet expected;
-        expected.addRange(SequenceNumber(0), SequenceNumber(5));
-        CPPUNIT_ASSERT_EQUAL(expected, actual);
-    }
-
-    void testCondenseSingleItem()
-    {
-        SequenceNumberSet set;
-        set.push_back(SequenceNumber(1));
-        SequenceNumberSet actual = set.condense();
-
-        SequenceNumberSet expected;
-        expected.addRange(SequenceNumber(1), SequenceNumber(1));
-        CPPUNIT_ASSERT_EQUAL(expected, actual);
-    }
-
-    void testDifference()
-    {
-        SequenceNumber a;
-        SequenceNumber b;
-
-        for (int i = 0; i < 10; i++, ++a) {
-            CPPUNIT_ASSERT_EQUAL(i, a - b);
-            CPPUNIT_ASSERT_EQUAL(-i, b - a);
-        }
-
-        b = a;
-
-        for (int i = 0; i < 10; i++, ++b) {
-            CPPUNIT_ASSERT_EQUAL(-i, a - b);
-            CPPUNIT_ASSERT_EQUAL(i, b - a);
-        }
-    }
-
-    void testDifferenceWithWrapAround1()
-    {
-        const uint32_t max = 0xFFFFFFFF;
-        SequenceNumber a(max - 5);
-        SequenceNumber b(max - 10);
-        checkDifference(a, b, 5);
-    }
-
-    void testDifferenceWithWrapAround2()
-    {
-        const uint32_t max_signed = 0x7FFFFFFF;
-        SequenceNumber c(max_signed - 5);
-        SequenceNumber d(max_signed - 10);
-        checkDifference(c, d, 5);
-    }
-
-    void checkDifference(SequenceNumber& a, SequenceNumber& b, int gap)
-    {
-        CPPUNIT_ASSERT_EQUAL(gap, a - b);
-        CPPUNIT_ASSERT_EQUAL(-gap, b - a);
-
-        //increment until b wraps around
-        for (int i = 0; i < (gap + 2); i++, ++a, ++b) {
-            CPPUNIT_ASSERT_EQUAL(gap, a - b);
-        }
-        //keep incrementing until a also wraps around
-        for (int i = 0; i < (gap + 2); i++, ++a, ++b) {
-            CPPUNIT_ASSERT_EQUAL(gap, a - b);
-        }
-        //let b catch up and overtake
-        for (int i = 0; i < (gap*2); i++, ++b) {
-            CPPUNIT_ASSERT_EQUAL(gap - i, a - b);
-            CPPUNIT_ASSERT_EQUAL(i - gap, b - a);
-        }
-    }
-};
-    
-// Make this test suite a plugin.
-CPPUNIT_PLUGIN_IMPLEMENT();
-CPPUNIT_TEST_SUITE_REGISTRATION(SequenceNumberTest);
+    const uint32_t max = 0xFFFFFFFF;
+    SequenceNumber a(max - 10);
+    SequenceNumber b(max - 5);
+    checkComparison(a, b, 5);
+
+    const uint32_t max_signed = 0x7FFFFFFF;
+    SequenceNumber c(max_signed - 10);
+    SequenceNumber d(max_signed - 5);
+    checkComparison(c, d, 5);
+}
+
+QPID_AUTO_TEST_CASE(testCondense)
+{
+    SequenceNumberSet set;
+    for (uint i = 0; i < 6; i++) {
+        set.push_back(SequenceNumber(i));
+    }
+    set.push_back(SequenceNumber(7));
+    for (uint i = 9; i < 13; i++) {
+        set.push_back(SequenceNumber(i));
+    }
+    set.push_back(SequenceNumber(13));
+    SequenceNumberSet actual = set.condense();
+
+    SequenceNumberSet expected;
+    expected.addRange(SequenceNumber(0), SequenceNumber(5));
+    expected.addRange(SequenceNumber(7), SequenceNumber(7));
+    expected.addRange(SequenceNumber(9), SequenceNumber(13));
+    BOOST_CHECK_EQUAL(expected, actual);
+}
+
+QPID_AUTO_TEST_CASE(testCondenseSingleRange)
+{
+    SequenceNumberSet set;
+    for (uint i = 0; i < 6; i++) {
+        set.push_back(SequenceNumber(i));
+    }
+    SequenceNumberSet actual = set.condense();
+
+    SequenceNumberSet expected;
+    expected.addRange(SequenceNumber(0), SequenceNumber(5));
+    BOOST_CHECK_EQUAL(expected, actual);
+}
+
+QPID_AUTO_TEST_CASE(testCondenseSingleItem)
+{
+    SequenceNumberSet set;
+    set.push_back(SequenceNumber(1));
+    SequenceNumberSet actual = set.condense();
+
+    SequenceNumberSet expected;
+    expected.addRange(SequenceNumber(1), SequenceNumber(1));
+    BOOST_CHECK_EQUAL(expected, actual);
+}
+
+QPID_AUTO_TEST_CASE(testDifference)
+{
+    SequenceNumber a;
+    SequenceNumber b;
+
+    for (int i = 0; i < 10; i++, ++a) {
+        BOOST_CHECK_EQUAL(i, a - b);
+        BOOST_CHECK_EQUAL(-i, b - a);
+    }
+
+    b = a;
+
+    for (int i = 0; i < 10; i++, ++b) {
+        BOOST_CHECK_EQUAL(-i, a - b);
+        BOOST_CHECK_EQUAL(i, b - a);
+    }
+}
+
+QPID_AUTO_TEST_CASE(testDifferenceWithWrapAround1)
+{
+    const uint32_t max = 0xFFFFFFFF;
+    SequenceNumber a(max - 5);
+    SequenceNumber b(max - 10);
+    checkDifference(a, b, 5);
+}
+
+QPID_AUTO_TEST_CASE(testDifferenceWithWrapAround2)
+{
+    const uint32_t max_signed = 0x7FFFFFFF;
+    SequenceNumber c(max_signed - 5);
+    SequenceNumber d(max_signed - 10);
+    checkDifference(c, d, 5);
+}
+
+QPID_AUTO_TEST_SUITE_END()

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/TimerTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/TimerTest.cpp?rev=661587&r1=661586&r2=661587&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/TimerTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/TimerTest.cpp Fri May 30 01:13:21 2008
@@ -21,7 +21,7 @@
  */
 #include "qpid/broker/Timer.h"
 #include "qpid/sys/Monitor.h"
-#include "qpid_test_plugin.h"
+#include "unit_test.h"
 #include <math.h>
 #include <iostream>
 #include <memory>
@@ -33,98 +33,88 @@
 using boost::intrusive_ptr;
 using boost::dynamic_pointer_cast;
 
-class TimerTest : public CppUnit::TestCase  
+class Counter
 {
-    CPPUNIT_TEST_SUITE(TimerTest);
-    CPPUNIT_TEST(testGeneral);
-    CPPUNIT_TEST_SUITE_END();
-
-    class Counter
+    Mutex lock;
+    uint counter;
+  public:
+    Counter() : counter(0) {}
+    uint next()
     {
-        Mutex lock;
-        uint counter;
-    public:
-        Counter() : counter(0) {}
-        uint next()
-        {
-            Mutex::ScopedLock l(lock);
-            return ++counter;
-        }
-    };
+        Mutex::ScopedLock l(lock);
+        return ++counter;
+    }
+};
     
-    class TestTask : public TimerTask
-    {
-        const AbsTime start;
-        const Duration expected;
-        AbsTime end;
-        bool fired;
-        uint position;
-        Monitor monitor;
-        Counter& counter;
-
-    public:
-        TestTask(Duration timeout, Counter& _counter) 
-            : TimerTask(timeout), start(now()), expected(timeout), end(start), fired(false), counter(_counter) {}
-
-        void fire()
-        {
-            Monitor::ScopedLock l(monitor);
-            fired = true;
-            position = counter.next();
-            end = now();
-            monitor.notify();
-        }
-
-        void check(uint expected_position, uint64_t tolerance = 500 * TIME_MSEC)
-        {
-            Monitor::ScopedLock l(monitor);
-            CPPUNIT_ASSERT(fired);
-            CPPUNIT_ASSERT_EQUAL(expected_position, position);
-            Duration actual(start, end);
-            uint64_t difference = abs(expected - actual);
-            std::string msg(boost::lexical_cast<std::string>(boost::format("tolerance = %1%, difference = %2%") % tolerance % difference));
-            CPPUNIT_ASSERT_MESSAGE(msg, difference < tolerance);
-        }
-
-        void wait(Duration d)
-        {
-            Monitor::ScopedLock l(monitor);
-            monitor.wait(AbsTime(now(), d));
-        }
-    };
+class TestTask : public TimerTask
+{
+    const AbsTime start;
+    const Duration expected;
+    AbsTime end;
+    bool fired;
+    uint position;
+    Monitor monitor;
+    Counter& counter;
+
+  public:
+    TestTask(Duration timeout, Counter& _counter) 
+        : TimerTask(timeout), start(now()), expected(timeout), end(start), fired(false), counter(_counter) {}
 
-    class DummyRunner : public Runnable
+    void fire()
     {
-    public:
-        void run() {}
-    };
+        Monitor::ScopedLock l(monitor);
+        fired = true;
+        position = counter.next();
+        end = now();
+        monitor.notify();
+    }
 
-public:
+    void check(uint expected_position, uint64_t tolerance = 500 * TIME_MSEC)
+    {
+        Monitor::ScopedLock l(monitor);
+        BOOST_CHECK(fired);
+        BOOST_CHECK_EQUAL(expected_position, position);
+        Duration actual(start, end);
+        uint64_t difference = abs(expected - actual);
+        std::string msg(boost::lexical_cast<std::string>(boost::format("tolerance = %1%, difference = %2%") % tolerance % difference));
+        BOOST_CHECK_MESSAGE(difference < tolerance, msg);
+    }
 
-    void testGeneral()
+    void wait(Duration d)
     {
-        Counter counter;
-        Timer timer;
-        intrusive_ptr<TestTask> task1(new TestTask(Duration(3 * TIME_SEC), counter));
-        intrusive_ptr<TestTask> task2(new TestTask(Duration(1 * TIME_SEC), counter));
-        intrusive_ptr<TestTask> task3(new TestTask(Duration(4 * TIME_SEC), counter));
-        intrusive_ptr<TestTask> task4(new TestTask(Duration(2 * TIME_SEC), counter));
-        
-        timer.add(task1);
-        timer.add(task2);
-        timer.add(task3);
-        timer.add(task4);
-        
-        dynamic_pointer_cast<TestTask>(task3)->wait(Duration(6 * TIME_SEC));
-        
-        dynamic_pointer_cast<TestTask>(task1)->check(3);
-        dynamic_pointer_cast<TestTask>(task2)->check(1);
-        dynamic_pointer_cast<TestTask>(task3)->check(4);
-        dynamic_pointer_cast<TestTask>(task4)->check(2);
+        Monitor::ScopedLock l(monitor);
+        monitor.wait(AbsTime(now(), d));
     }
 };
 
-// Make this test suite a plugin.
-CPPUNIT_PLUGIN_IMPLEMENT();
-CPPUNIT_TEST_SUITE_REGISTRATION(TimerTest);
+class DummyRunner : public Runnable
+{
+  public:
+    void run() {}
+};
+
+QPID_AUTO_TEST_SUITE(TimerTestSuite)
+
+QPID_AUTO_TEST_CASE(testGeneral)
+{
+    Counter counter;
+    Timer timer;
+    intrusive_ptr<TestTask> task1(new TestTask(Duration(3 * TIME_SEC), counter));
+    intrusive_ptr<TestTask> task2(new TestTask(Duration(1 * TIME_SEC), counter));
+    intrusive_ptr<TestTask> task3(new TestTask(Duration(4 * TIME_SEC), counter));
+    intrusive_ptr<TestTask> task4(new TestTask(Duration(2 * TIME_SEC), counter));
+        
+    timer.add(task1);
+    timer.add(task2);
+    timer.add(task3);
+    timer.add(task4);
+        
+    dynamic_pointer_cast<TestTask>(task3)->wait(Duration(6 * TIME_SEC));
+        
+    dynamic_pointer_cast<TestTask>(task1)->check(3);
+    dynamic_pointer_cast<TestTask>(task2)->check(1);
+    dynamic_pointer_cast<TestTask>(task3)->check(4);
+    dynamic_pointer_cast<TestTask>(task4)->check(2);
+}
 
+QPID_AUTO_TEST_SUITE_END()

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/TopicExchangeTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/TopicExchangeTest.cpp?rev=661587&r1=661586&r2=661587&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/TopicExchangeTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/TopicExchangeTest.cpp Fri May 30 01:13:21 2008
@@ -17,7 +17,8 @@
  * under the License.
  */
 #include "qpid/broker/TopicExchange.h"
-#include "qpid_test_plugin.h"
+#include "unit_test.h"
+#include "test_tools.h"
 
 using namespace qpid::broker;
 
@@ -34,167 +35,133 @@
 // Convert array to token vector
 #define TOKENS(a) makeTokens(a, a + LEN(a))
 
-// Allow CPPUNIT_EQUALS to print a Tokens.
-CppUnit::OStringStream& operator <<(CppUnit::OStringStream& out, const Tokens& v)
-{
-    out << "[ ";
-    for (Tokens::const_iterator i = v.begin();
-         i != v.end(); ++i)
-    {
-        out << '"' << *i << '"' << (i+1 == v.end() ? "]" : ", ");
-    }
-    return out;
-}
+#define ASSERT_NORMALIZED(expect, pattern)                              \
+    BOOST_CHECK_EQUAL(Tokens(expect), static_cast<Tokens>(TopicPattern(pattern)))
 
 
-class TokensTest : public CppUnit::TestCase
-{
-    CPPUNIT_TEST_SUITE(TokensTest);
-    CPPUNIT_TEST(testTokens);
-    CPPUNIT_TEST_SUITE_END();
-
-  public:
-    void testTokens() 
-    {
-        Tokens tokens("hello.world");
-        const char* expect[] = {"hello", "world"};
-        CPPUNIT_ASSERT_EQUAL(TOKENS(expect), tokens);
+QPID_AUTO_TEST_SUITE(TopicExchangeTestSuite)
+
+QPID_AUTO_TEST_CASE(testTokens) 
+{
+    Tokens tokens("hello.world");
+    const char* expect[] = {"hello", "world"};
+    BOOST_CHECK_EQUAL(TOKENS(expect), tokens);
         
-        tokens = "a.b.c";
-        const char* expect2[] = { "a", "b", "c" };
-        CPPUNIT_ASSERT_EQUAL(TOKENS(expect2), tokens);
-
-        tokens = "";
-        CPPUNIT_ASSERT(tokens.empty());
-
-        tokens = "x";
-        const char* expect3[] = { "x" };
-        CPPUNIT_ASSERT_EQUAL(TOKENS(expect3), tokens);
-
-        tokens = (".x");
-        const char* expect4[] = { "", "x" };
-        CPPUNIT_ASSERT_EQUAL(TOKENS(expect4), tokens);
-
-        tokens = ("x.");
-        const char* expect5[] = { "x", "" };
-        CPPUNIT_ASSERT_EQUAL(TOKENS(expect5), tokens);
-
-        tokens = (".");
-        const char* expect6[] = { "", "" };
-        CPPUNIT_ASSERT_EQUAL(TOKENS(expect6), tokens);        
-
-        tokens = ("..");
-        const char* expect7[] = { "", "", "" };
-        CPPUNIT_ASSERT_EQUAL(TOKENS(expect7), tokens);        
-    }
-    
-};
+    tokens = "a.b.c";
+    const char* expect2[] = { "a", "b", "c" };
+    BOOST_CHECK_EQUAL(TOKENS(expect2), tokens);
+
+    tokens = "";
+    BOOST_CHECK(tokens.empty());
+
+    tokens = "x";
+    const char* expect3[] = { "x" };
+    BOOST_CHECK_EQUAL(TOKENS(expect3), tokens);
+
+    tokens = (".x");
+    const char* expect4[] = { "", "x" };
+    BOOST_CHECK_EQUAL(TOKENS(expect4), tokens);
+
+    tokens = ("x.");
+    const char* expect5[] = { "x", "" };
+    BOOST_CHECK_EQUAL(TOKENS(expect5), tokens);
+
+    tokens = (".");
+    const char* expect6[] = { "", "" };
+    BOOST_CHECK_EQUAL(TOKENS(expect6), tokens);        
+
+    tokens = ("..");
+    const char* expect7[] = { "", "", "" };
+    BOOST_CHECK_EQUAL(TOKENS(expect7), tokens);        
+}
 
-#define ASSERT_NORMALIZED(expect, pattern) \
-    CPPUNIT_ASSERT_EQUAL(Tokens(expect), static_cast<Tokens>(TopicPattern(pattern)))
-class TopicPatternTest : public CppUnit::TestCase 
-{
-    CPPUNIT_TEST_SUITE(TopicPatternTest);
-    CPPUNIT_TEST(testNormalize);
-    CPPUNIT_TEST(testPlain);
-    CPPUNIT_TEST(testStar);
-    CPPUNIT_TEST(testHash);
-    CPPUNIT_TEST(testMixed);
-    CPPUNIT_TEST(testCombo);
-    CPPUNIT_TEST_SUITE_END();
-
-  public:
-
-    void testNormalize() 
-    {
-        CPPUNIT_ASSERT(TopicPattern("").empty());
-        ASSERT_NORMALIZED("a.b.c", "a.b.c");
-        ASSERT_NORMALIZED("a.*.c", "a.*.c");
-        ASSERT_NORMALIZED("#", "#");
-        ASSERT_NORMALIZED("#", "#.#.#.#");
-        ASSERT_NORMALIZED("*.*.*.#", "#.*.#.*.#.#.*");
-        ASSERT_NORMALIZED("a.*.*.*.#", "a.*.#.*.#.*.#");
-        ASSERT_NORMALIZED("a.*.*.*.#", "a.*.#.*.#.*");
-    }
+QPID_AUTO_TEST_CASE(testNormalize) 
+{
+    BOOST_CHECK(TopicPattern("").empty());
+    ASSERT_NORMALIZED("a.b.c", "a.b.c");
+    ASSERT_NORMALIZED("a.*.c", "a.*.c");
+    ASSERT_NORMALIZED("#", "#");
+    ASSERT_NORMALIZED("#", "#.#.#.#");
+    ASSERT_NORMALIZED("*.*.*.#", "#.*.#.*.#.#.*");
+    ASSERT_NORMALIZED("a.*.*.*.#", "a.*.#.*.#.*.#");
+    ASSERT_NORMALIZED("a.*.*.*.#", "a.*.#.*.#.*");
+}
     
-    void testPlain() {
-        TopicPattern p("ab.cd.e");
-        CPPUNIT_ASSERT(p.match("ab.cd.e"));
-        CPPUNIT_ASSERT(!p.match("abx.cd.e"));
-        CPPUNIT_ASSERT(!p.match("ab.cd"));
-        CPPUNIT_ASSERT(!p.match("ab.cd..e."));
-        CPPUNIT_ASSERT(!p.match("ab.cd.e."));
-        CPPUNIT_ASSERT(!p.match(".ab.cd.e"));
-
-        p = "";
-        CPPUNIT_ASSERT(p.match(""));
-
-        p = ".";
-        CPPUNIT_ASSERT(p.match("."));
-    }
-
-
-    void testStar() 
-    {
-        TopicPattern p("a.*.b");
-        CPPUNIT_ASSERT(p.match("a.xx.b"));
-        CPPUNIT_ASSERT(!p.match("a.b"));
-
-        p = "*.x";
-        CPPUNIT_ASSERT(p.match("y.x"));
-        CPPUNIT_ASSERT(p.match(".x"));
-        CPPUNIT_ASSERT(!p.match("x"));
-
-        p = "x.x.*";
-        CPPUNIT_ASSERT(p.match("x.x.y"));
-        CPPUNIT_ASSERT(p.match("x.x."));
-        CPPUNIT_ASSERT(!p.match("x.x"));
-        CPPUNIT_ASSERT(!p.match("q.x.y"));
-    }
-
-    void testHash() 
-    {
-        TopicPattern p("a.#.b");
-        CPPUNIT_ASSERT(p.match("a.b"));
-        CPPUNIT_ASSERT(p.match("a.x.b"));
-        CPPUNIT_ASSERT(p.match("a..x.y.zz.b"));
-        CPPUNIT_ASSERT(!p.match("a.b."));
-        CPPUNIT_ASSERT(!p.match("q.x.b"));
-
-        p = "a.#";
-        CPPUNIT_ASSERT(p.match("a"));
-        CPPUNIT_ASSERT(p.match("a.b"));
-        CPPUNIT_ASSERT(p.match("a.b.c"));
-
-        p = "#.a";
-        CPPUNIT_ASSERT(p.match("a"));
-        CPPUNIT_ASSERT(p.match("x.y.a"));
-    }
-
-    void testMixed() 
-    {
-        TopicPattern p("*.x.#.y");
-        CPPUNIT_ASSERT(p.match("a.x.y"));
-        CPPUNIT_ASSERT(p.match("a.x.p.qq.y"));
-        CPPUNIT_ASSERT(!p.match("a.a.x.y"));
-        CPPUNIT_ASSERT(!p.match("aa.x.b.c"));
-
-        p = "a.#.b.*";
-        CPPUNIT_ASSERT(p.match("a.b.x"));
-        CPPUNIT_ASSERT(p.match("a.x.x.x.b.x"));
-    }
-
-    void testCombo() {
-        TopicPattern p("*.#.#.*.*.#");
-        CPPUNIT_ASSERT(p.match("x.y.z"));
-        CPPUNIT_ASSERT(p.match("x.y.z.a.b.c"));
-        CPPUNIT_ASSERT(!p.match("x.y"));
-        CPPUNIT_ASSERT(!p.match("x"));
-    }
-};
+QPID_AUTO_TEST_CASE(testPlain) 
+{
+    TopicPattern p("ab.cd.e");
+    BOOST_CHECK(p.match("ab.cd.e"));
+    BOOST_CHECK(!p.match("abx.cd.e"));
+    BOOST_CHECK(!p.match("ab.cd"));
+    BOOST_CHECK(!p.match("ab.cd..e."));
+    BOOST_CHECK(!p.match("ab.cd.e."));
+    BOOST_CHECK(!p.match(".ab.cd.e"));
 
-    
-// Make this test suite a plugin.
-CPPUNIT_PLUGIN_IMPLEMENT();
-CPPUNIT_TEST_SUITE_REGISTRATION(TopicPatternTest);
-CPPUNIT_TEST_SUITE_REGISTRATION(TokensTest);
+    p = "";
+    BOOST_CHECK(p.match(""));
+
+    p = ".";
+    BOOST_CHECK(p.match("."));
+}
+
+
+QPID_AUTO_TEST_CASE(testStar) 
+{
+    TopicPattern p("a.*.b");
+    BOOST_CHECK(p.match("a.xx.b"));
+    BOOST_CHECK(!p.match("a.b"));
+
+    p = "*.x";
+    BOOST_CHECK(p.match("y.x"));
+    BOOST_CHECK(p.match(".x"));
+    BOOST_CHECK(!p.match("x"));
+
+    p = "x.x.*";
+    BOOST_CHECK(p.match("x.x.y"));
+    BOOST_CHECK(p.match("x.x."));
+    BOOST_CHECK(!p.match("x.x"));
+    BOOST_CHECK(!p.match("q.x.y"));
+}
+
+QPID_AUTO_TEST_CASE(testHash) 
+{
+    TopicPattern p("a.#.b");
+    BOOST_CHECK(p.match("a.b"));
+    BOOST_CHECK(p.match("a.x.b"));
+    BOOST_CHECK(p.match("a..x.y.zz.b"));
+    BOOST_CHECK(!p.match("a.b."));
+    BOOST_CHECK(!p.match("q.x.b"));
+
+    p = "a.#";
+    BOOST_CHECK(p.match("a"));
+    BOOST_CHECK(p.match("a.b"));
+    BOOST_CHECK(p.match("a.b.c"));
+
+    p = "#.a";
+    BOOST_CHECK(p.match("a"));
+    BOOST_CHECK(p.match("x.y.a"));
+}
+
+QPID_AUTO_TEST_CASE(testMixed) 
+{
+    TopicPattern p("*.x.#.y");
+    BOOST_CHECK(p.match("a.x.y"));
+    BOOST_CHECK(p.match("a.x.p.qq.y"));
+    BOOST_CHECK(!p.match("a.a.x.y"));
+    BOOST_CHECK(!p.match("aa.x.b.c"));
+
+    p = "a.#.b.*";
+    BOOST_CHECK(p.match("a.b.x"));
+    BOOST_CHECK(p.match("a.x.x.x.b.x"));
+}
+
+QPID_AUTO_TEST_CASE(testCombo) 
+{
+    TopicPattern p("*.#.#.*.*.#");
+    BOOST_CHECK(p.match("x.y.z"));
+    BOOST_CHECK(p.match("x.y.z.a.b.c"));
+    BOOST_CHECK(!p.match("x.y"));
+    BOOST_CHECK(!p.match("x"));
+}
+
+QPID_AUTO_TEST_SUITE_END()

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/TxAckTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/TxAckTest.cpp?rev=661587&r1=661586&r2=661587&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/TxAckTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/TxAckTest.cpp Fri May 30 01:13:21 2008
@@ -22,7 +22,7 @@
 #include "qpid/broker/NullMessageStore.h"
 #include "qpid/broker/RecoveryManager.h"
 #include "qpid/broker/TxAck.h"
-#include "qpid_test_plugin.h"
+#include "unit_test.h"
 #include <iostream>
 #include <list>
 #include <vector>
@@ -34,29 +34,23 @@
 using namespace qpid::broker;
 using namespace qpid::framing;
 
-class TxAckTest : public CppUnit::TestCase  
-{
 
-    class TestMessageStore : public NullMessageStore
+class TestMessageStore : public NullMessageStore
+{
+  public:
+    vector<intrusive_ptr<PersistableMessage> > dequeued;
+    
+    void dequeue(TransactionContext*, intrusive_ptr<PersistableMessage>& msg, const PersistableQueue& /*queue*/)
     {
-    public:
-        vector<intrusive_ptr<PersistableMessage> > dequeued;
-
-        void dequeue(TransactionContext*, intrusive_ptr<PersistableMessage>& msg, const PersistableQueue& /*queue*/)
-        {
-            dequeued.push_back(msg);
-        }
-
-        TestMessageStore() : NullMessageStore() {}
-        ~TestMessageStore(){}
-    };
-
-    CPPUNIT_TEST_SUITE(TxAckTest);
-    CPPUNIT_TEST(testPrepare);
-    CPPUNIT_TEST(testCommit);
-    CPPUNIT_TEST_SUITE_END();
+        dequeued.push_back(msg);
+    }
 
+    TestMessageStore() : NullMessageStore() {}
+    ~TestMessageStore(){}
+};
 
+struct TxAckTest
+{
     AccumulatedAck acked;
     TestMessageStore store;
     Queue::shared_ptr queue;
@@ -64,9 +58,6 @@
     list<DeliveryRecord> deliveries;
     TxAck op;
 
-
-public:
-
     TxAckTest() : acked(0), queue(new Queue("my_queue", false, &store, 0)), op(acked, deliveries)
     {
         for(int i = 0; i < 10; i++){
@@ -84,31 +75,35 @@
         acked.update(9, 9);
     }      
 
-    void testPrepare()
-    {
-        //ensure acked messages are discarded, i.e. dequeued from store
-        op.prepare(0);
-        CPPUNIT_ASSERT_EQUAL((size_t) 7, store.dequeued.size());
-        CPPUNIT_ASSERT_EQUAL((size_t) 10, deliveries.size());
-        int dequeued[] = {0, 1, 2, 3, 4, 6, 8};
-        for (int i = 0; i < 7; i++) {
-            CPPUNIT_ASSERT_EQUAL(static_pointer_cast<PersistableMessage>(messages[dequeued[i]]), store.dequeued[i]);
-        }
-    }
+};
 
-    void testCommit()
-    {
-        //emsure acked messages are removed from list
-        op.commit();
-        CPPUNIT_ASSERT_EQUAL((size_t) 3, deliveries.size());
-        list<DeliveryRecord>::iterator i = deliveries.begin();
-        CPPUNIT_ASSERT(i->matches(6));//msg 6
-        CPPUNIT_ASSERT((++i)->matches(8));//msg 8
-        CPPUNIT_ASSERT((++i)->matches(10));//msg 10
+QPID_AUTO_TEST_SUITE(TxAckTestSuite)
+
+QPID_AUTO_TEST_CASE(testPrepare)
+{
+    TxAckTest t;
+
+    //ensure acked messages are discarded, i.e. dequeued from store
+    t.op.prepare(0);
+    BOOST_CHECK_EQUAL((size_t) 7, t.store.dequeued.size());
+    BOOST_CHECK_EQUAL((size_t) 10, t.deliveries.size());
+    int dequeued[] = {0, 1, 2, 3, 4, 6, 8};
+    for (int i = 0; i < 7; i++) {
+        BOOST_CHECK_EQUAL(static_pointer_cast<PersistableMessage>(t.messages[dequeued[i]]), t.store.dequeued[i]);
     }
-};
+}
+
+QPID_AUTO_TEST_CASE(testCommit)
+{
+    TxAckTest t;
 
-// Make this test suite a plugin.
-CPPUNIT_PLUGIN_IMPLEMENT();
-CPPUNIT_TEST_SUITE_REGISTRATION(TxAckTest);
+    //ensure acked messages are removed from list
+    t.op.commit();
+    BOOST_CHECK_EQUAL((size_t) 3, t.deliveries.size());
+    list<DeliveryRecord>::iterator i = t.deliveries.begin();
+    BOOST_CHECK(i->matches(6));//msg 6
+    BOOST_CHECK((++i)->matches(8));//msg 8
+    BOOST_CHECK((++i)->matches(10));//msg 10
+}
 
+QPID_AUTO_TEST_SUITE_END()

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/TxBufferTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/TxBufferTest.cpp?rev=661587&r1=661586&r2=661587&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/TxBufferTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/TxBufferTest.cpp Fri May 30 01:13:21 2008
@@ -19,7 +19,7 @@
  *
  */
 #include "qpid/broker/TxBuffer.h"
-#include "qpid_test_plugin.h"
+#include "unit_test.h"
 #include <iostream>
 #include <vector>
 #include "TxMocks.h"
@@ -27,159 +27,150 @@
 using namespace qpid::broker;
 using boost::static_pointer_cast;
 
-class TxBufferTest : public CppUnit::TestCase  
+QPID_AUTO_TEST_SUITE(TxBufferTestSuite)
+
+QPID_AUTO_TEST_CASE(testCommitLocal)
+{
+    MockTransactionalStore store;
+    store.expectBegin().expectCommit();
+
+    MockTxOp::shared_ptr opA(new MockTxOp());
+    opA->expectPrepare().expectCommit();
+    MockTxOp::shared_ptr opB(new MockTxOp());
+    opB->expectPrepare().expectPrepare().expectCommit().expectCommit();//opB enlisted twice to test relative order
+    MockTxOp::shared_ptr opC(new MockTxOp());
+    opC->expectPrepare().expectCommit();
+
+    TxBuffer buffer;
+    buffer.enlist(static_pointer_cast<TxOp>(opA));
+    buffer.enlist(static_pointer_cast<TxOp>(opB));
+    buffer.enlist(static_pointer_cast<TxOp>(opB));//opB enlisted twice
+    buffer.enlist(static_pointer_cast<TxOp>(opC));
+
+    BOOST_CHECK(buffer.commitLocal(&store));
+    store.check();
+    BOOST_CHECK(store.isCommitted());
+    opA->check();
+    opB->check();
+    opC->check();
+}
+
+QPID_AUTO_TEST_CASE(testFailOnCommitLocal)
+{
+    MockTransactionalStore store;
+    store.expectBegin().expectAbort();
+
+    MockTxOp::shared_ptr opA(new MockTxOp());
+    opA->expectPrepare().expectRollback();
+    MockTxOp::shared_ptr opB(new MockTxOp(true));
+    opB->expectPrepare().expectRollback();
+    MockTxOp::shared_ptr opC(new MockTxOp());//will never get prepare as b will fail
+    opC->expectRollback();
+
+    TxBuffer buffer;
+    buffer.enlist(static_pointer_cast<TxOp>(opA));
+    buffer.enlist(static_pointer_cast<TxOp>(opB));
+    buffer.enlist(static_pointer_cast<TxOp>(opC));
+
+    BOOST_CHECK(!buffer.commitLocal(&store));
+    BOOST_CHECK(store.isAborted());
+    store.check();
+    opA->check();
+    opB->check();
+    opC->check();
+}
+
+QPID_AUTO_TEST_CASE(testPrepare)
+{
+    MockTxOp::shared_ptr opA(new MockTxOp());
+    opA->expectPrepare();
+    MockTxOp::shared_ptr opB(new MockTxOp());
+    opB->expectPrepare();
+    MockTxOp::shared_ptr opC(new MockTxOp());
+    opC->expectPrepare();
+
+    TxBuffer buffer;
+    buffer.enlist(static_pointer_cast<TxOp>(opA));
+    buffer.enlist(static_pointer_cast<TxOp>(opB));
+    buffer.enlist(static_pointer_cast<TxOp>(opC));
+
+    BOOST_CHECK(buffer.prepare(0));
+    opA->check();
+    opB->check();
+    opC->check();
+}
+
+QPID_AUTO_TEST_CASE(testFailOnPrepare)
+{
+    MockTxOp::shared_ptr opA(new MockTxOp());
+    opA->expectPrepare();
+    MockTxOp::shared_ptr opB(new MockTxOp(true));
+    opB->expectPrepare();
+    MockTxOp::shared_ptr opC(new MockTxOp());//will never get prepare as b will fail
+
+    TxBuffer buffer;
+    buffer.enlist(static_pointer_cast<TxOp>(opA));
+    buffer.enlist(static_pointer_cast<TxOp>(opB));
+    buffer.enlist(static_pointer_cast<TxOp>(opC));
+
+    BOOST_CHECK(!buffer.prepare(0));
+    opA->check();
+    opB->check();
+    opC->check();
+}
+
+QPID_AUTO_TEST_CASE(testRollback)
+{
+    MockTxOp::shared_ptr opA(new MockTxOp());
+    opA->expectRollback();
+    MockTxOp::shared_ptr opB(new MockTxOp(true));
+    opB->expectRollback();
+    MockTxOp::shared_ptr opC(new MockTxOp());
+    opC->expectRollback();
+
+    TxBuffer buffer;
+    buffer.enlist(static_pointer_cast<TxOp>(opA));
+    buffer.enlist(static_pointer_cast<TxOp>(opB));
+    buffer.enlist(static_pointer_cast<TxOp>(opC));
+
+    buffer.rollback();
+    opA->check();
+    opB->check();
+    opC->check();
+}
+
+QPID_AUTO_TEST_CASE(testBufferIsClearedAfterRollback)
+{
+    MockTxOp::shared_ptr opA(new MockTxOp());
+    opA->expectRollback();
+    MockTxOp::shared_ptr opB(new MockTxOp());
+    opB->expectRollback();
+
+    TxBuffer buffer;
+    buffer.enlist(static_pointer_cast<TxOp>(opA));
+    buffer.enlist(static_pointer_cast<TxOp>(opB));
+
+    buffer.rollback();
+    buffer.commit();//second call should not reach ops
+    opA->check();
+    opB->check();
+}
+
+QPID_AUTO_TEST_CASE(testBufferIsClearedAfterCommit)
 {
-    CPPUNIT_TEST_SUITE(TxBufferTest);
-    CPPUNIT_TEST(testCommitLocal);
-    CPPUNIT_TEST(testFailOnCommitLocal);
-    CPPUNIT_TEST(testPrepare);
-    CPPUNIT_TEST(testFailOnPrepare);
-    CPPUNIT_TEST(testRollback);
-    CPPUNIT_TEST(testBufferIsClearedAfterRollback);
-    CPPUNIT_TEST(testBufferIsClearedAfterCommit);
-    CPPUNIT_TEST_SUITE_END();
-
-  public:
-
-    void testCommitLocal(){
-        MockTransactionalStore store;
-        store.expectBegin().expectCommit();
-
-        MockTxOp::shared_ptr opA(new MockTxOp());
-        opA->expectPrepare().expectCommit();
-        MockTxOp::shared_ptr opB(new MockTxOp());
-        opB->expectPrepare().expectPrepare().expectCommit().expectCommit();//opB enlisted twice to test relative order
-        MockTxOp::shared_ptr opC(new MockTxOp());
-        opC->expectPrepare().expectCommit();
-
-        TxBuffer buffer;
-        buffer.enlist(static_pointer_cast<TxOp>(opA));
-        buffer.enlist(static_pointer_cast<TxOp>(opB));
-        buffer.enlist(static_pointer_cast<TxOp>(opB));//opB enlisted twice
-        buffer.enlist(static_pointer_cast<TxOp>(opC));
-
-        CPPUNIT_ASSERT(buffer.commitLocal(&store));
-        store.check();
-        CPPUNIT_ASSERT(store.isCommitted());
-        opA->check();
-        opB->check();
-        opC->check();
-    }
-
-    void testFailOnCommitLocal(){
-        MockTransactionalStore store;
-        store.expectBegin().expectAbort();
-
-        MockTxOp::shared_ptr opA(new MockTxOp());
-        opA->expectPrepare().expectRollback();
-        MockTxOp::shared_ptr opB(new MockTxOp(true));
-        opB->expectPrepare().expectRollback();
-        MockTxOp::shared_ptr opC(new MockTxOp());//will never get prepare as b will fail
-        opC->expectRollback();
-
-        TxBuffer buffer;
-        buffer.enlist(static_pointer_cast<TxOp>(opA));
-        buffer.enlist(static_pointer_cast<TxOp>(opB));
-        buffer.enlist(static_pointer_cast<TxOp>(opC));
-
-        CPPUNIT_ASSERT(!buffer.commitLocal(&store));
-        CPPUNIT_ASSERT(store.isAborted());
-        store.check();
-        opA->check();
-        opB->check();
-        opC->check();
-    }
-
-    void testPrepare(){
-        MockTxOp::shared_ptr opA(new MockTxOp());
-        opA->expectPrepare();
-        MockTxOp::shared_ptr opB(new MockTxOp());
-        opB->expectPrepare();
-        MockTxOp::shared_ptr opC(new MockTxOp());
-        opC->expectPrepare();
-
-        TxBuffer buffer;
-        buffer.enlist(static_pointer_cast<TxOp>(opA));
-        buffer.enlist(static_pointer_cast<TxOp>(opB));
-        buffer.enlist(static_pointer_cast<TxOp>(opC));
-
-        CPPUNIT_ASSERT(buffer.prepare(0));
-        opA->check();
-        opB->check();
-        opC->check();
-    }
-
-    void testFailOnPrepare(){
-        MockTxOp::shared_ptr opA(new MockTxOp());
-        opA->expectPrepare();
-        MockTxOp::shared_ptr opB(new MockTxOp(true));
-        opB->expectPrepare();
-        MockTxOp::shared_ptr opC(new MockTxOp());//will never get prepare as b will fail
-
-        TxBuffer buffer;
-        buffer.enlist(static_pointer_cast<TxOp>(opA));
-        buffer.enlist(static_pointer_cast<TxOp>(opB));
-        buffer.enlist(static_pointer_cast<TxOp>(opC));
-
-        CPPUNIT_ASSERT(!buffer.prepare(0));
-        opA->check();
-        opB->check();
-        opC->check();
-    }
-
-    void testRollback(){
-        MockTxOp::shared_ptr opA(new MockTxOp());
-        opA->expectRollback();
-        MockTxOp::shared_ptr opB(new MockTxOp(true));
-        opB->expectRollback();
-        MockTxOp::shared_ptr opC(new MockTxOp());
-        opC->expectRollback();
-
-        TxBuffer buffer;
-        buffer.enlist(static_pointer_cast<TxOp>(opA));
-        buffer.enlist(static_pointer_cast<TxOp>(opB));
-        buffer.enlist(static_pointer_cast<TxOp>(opC));
-
-        buffer.rollback();
-        opA->check();
-        opB->check();
-        opC->check();
-    }
-
-    void testBufferIsClearedAfterRollback(){
-        MockTxOp::shared_ptr opA(new MockTxOp());
-        opA->expectRollback();
-        MockTxOp::shared_ptr opB(new MockTxOp());
-        opB->expectRollback();
-
-        TxBuffer buffer;
-        buffer.enlist(static_pointer_cast<TxOp>(opA));
-        buffer.enlist(static_pointer_cast<TxOp>(opB));
-
-        buffer.rollback();
-        buffer.commit();//second call should not reach ops
-        opA->check();
-        opB->check();
-    }
-
-    void testBufferIsClearedAfterCommit(){
-        MockTxOp::shared_ptr opA(new MockTxOp());
-        opA->expectCommit();
-        MockTxOp::shared_ptr opB(new MockTxOp());
-        opB->expectCommit();
-
-        TxBuffer buffer;
-        buffer.enlist(static_pointer_cast<TxOp>(opA));
-        buffer.enlist(static_pointer_cast<TxOp>(opB));
-
-        buffer.commit();
-        buffer.rollback();//second call should not reach ops
-        opA->check();
-        opB->check();
-    }
-};
-
-// Make this test suite a plugin.
-CPPUNIT_PLUGIN_IMPLEMENT();
-CPPUNIT_TEST_SUITE_REGISTRATION(TxBufferTest);
+    MockTxOp::shared_ptr opA(new MockTxOp());
+    opA->expectCommit();
+    MockTxOp::shared_ptr opB(new MockTxOp());
+    opB->expectCommit();
+
+    TxBuffer buffer;
+    buffer.enlist(static_pointer_cast<TxOp>(opA));
+    buffer.enlist(static_pointer_cast<TxOp>(opB));
+
+    buffer.commit();
+    buffer.rollback();//second call should not reach ops
+    opA->check();
+    opB->check();
+}
 
+QPID_AUTO_TEST_SUITE_END()

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/TxMocks.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/TxMocks.h?rev=661587&r1=661586&r2=661587&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/TxMocks.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/TxMocks.h Fri May 30 01:13:21 2008
@@ -35,7 +35,7 @@
 template <class T> void assertEqualVector(std::vector<T>& expected, std::vector<T>& actual){
     unsigned int i = 0;
     while(i < expected.size() && i < actual.size()){
-        CPPUNIT_ASSERT_EQUAL(expected[i], actual[i]);
+        BOOST_CHECK_EQUAL(expected[i], actual[i]);
         i++;
     }
     if (i < expected.size()) {
@@ -43,7 +43,7 @@
     } else if (i < actual.size()) {
         throw qpid::Exception(QPID_MSG("Extra " << actual[i]));
     }
-    CPPUNIT_ASSERT_EQUAL(expected.size(), actual.size());
+    BOOST_CHECK_EQUAL(expected.size(), actual.size());
 }
 
 class TxOpConstants{

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/TxPublishTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/TxPublishTest.cpp?rev=661587&r1=661586&r2=661587&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/TxPublishTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/TxPublishTest.cpp Fri May 30 01:13:21 2008
@@ -21,7 +21,7 @@
 #include "qpid/broker/NullMessageStore.h"
 #include "qpid/broker/RecoveryManager.h"
 #include "qpid/broker/TxPublish.h"
-#include "qpid_test_plugin.h"
+#include "unit_test.h"
 #include <iostream>
 #include <list>
 #include <vector>
@@ -34,31 +34,26 @@
 using namespace qpid::broker;
 using namespace qpid::framing;
 
-class TxPublishTest : public CppUnit::TestCase  
-{
-    typedef std::pair<string, intrusive_ptr<PersistableMessage> > msg_queue_pair;
+typedef std::pair<string, intrusive_ptr<PersistableMessage> > msg_queue_pair;
 
-    class TestMessageStore : public NullMessageStore
-    {
-    public:
-        vector<msg_queue_pair> enqueued;
+class TestMessageStore : public NullMessageStore
+{
+  public:
+    vector<msg_queue_pair> enqueued;
         
-        void enqueue(TransactionContext*, intrusive_ptr<PersistableMessage>& msg, const PersistableQueue& queue)
-        {
-            msg->enqueueComplete(); 
- 	        enqueued.push_back(msg_queue_pair(queue.getName(), msg));
-        }
+    void enqueue(TransactionContext*, intrusive_ptr<PersistableMessage>& msg, const PersistableQueue& queue)
+    {
+        msg->enqueueComplete(); 
+        enqueued.push_back(msg_queue_pair(queue.getName(), msg));
+    }
         
-        //dont care about any of the other methods:
-        TestMessageStore() : NullMessageStore(false) {}
-        ~TestMessageStore(){}
-    };
-    
-    CPPUNIT_TEST_SUITE(TxPublishTest);
-    CPPUNIT_TEST(testPrepare);
-    CPPUNIT_TEST(testCommit);
-    CPPUNIT_TEST_SUITE_END();
-    
+    //dont care about any of the other methods:
+    TestMessageStore() : NullMessageStore(false) {}
+    ~TestMessageStore(){}
+};
+
+struct TxPublishTest
+{
     
     TestMessageStore store;
     Queue::shared_ptr queue1;
@@ -66,8 +61,6 @@
     intrusive_ptr<Message> msg;
     TxPublish op;
     
-public:
-    
     TxPublishTest() :
         queue1(new Queue("queue1", false, &store, 0)), 
         queue2(new Queue("queue2", false, &store, 0)), 
@@ -78,37 +71,41 @@
         op.deliverTo(queue1);
         op.deliverTo(queue2);
     }      
+};
 
-    void testPrepare()
-    {
-        intrusive_ptr<PersistableMessage> pmsg = static_pointer_cast<PersistableMessage>(msg);
-        //ensure messages are enqueued in store
-        op.prepare(0);
-        CPPUNIT_ASSERT_EQUAL((size_t) 2, store.enqueued.size());
-        CPPUNIT_ASSERT_EQUAL(string("queue1"), store.enqueued[0].first);
-        CPPUNIT_ASSERT_EQUAL(pmsg, store.enqueued[0].second);
-        CPPUNIT_ASSERT_EQUAL(string("queue2"), store.enqueued[1].first);
-        CPPUNIT_ASSERT_EQUAL(pmsg, store.enqueued[1].second);
-	    CPPUNIT_ASSERT_EQUAL( true, ( static_pointer_cast<PersistableMessage>(msg))->isEnqueueComplete());
-    }
 
-    void testCommit()
-    {
-        //ensure messages are delivered to queue
-        op.prepare(0);
-        op.commit();
-        CPPUNIT_ASSERT_EQUAL((uint32_t) 1, queue1->getMessageCount());
-	intrusive_ptr<Message> msg_dequeue = queue1->dequeue().payload;
+QPID_AUTO_TEST_SUITE(TxPublishTestSuite)
+    
+QPID_AUTO_TEST_CASE(testPrepare)
+{
+    TxPublishTest t;
 
- 	CPPUNIT_ASSERT_EQUAL( true, (static_pointer_cast<PersistableMessage>(msg_dequeue))->isEnqueueComplete());
-        CPPUNIT_ASSERT_EQUAL(msg, msg_dequeue);
+    intrusive_ptr<PersistableMessage> pmsg = static_pointer_cast<PersistableMessage>(t.msg);
+    //ensure messages are enqueued in store
+    t.op.prepare(0);
+    BOOST_CHECK_EQUAL((size_t) 2, t.store.enqueued.size());
+    BOOST_CHECK_EQUAL(string("queue1"), t.store.enqueued[0].first);
+    BOOST_CHECK_EQUAL(pmsg, t.store.enqueued[0].second);
+    BOOST_CHECK_EQUAL(string("queue2"), t.store.enqueued[1].first);
+    BOOST_CHECK_EQUAL(pmsg, t.store.enqueued[1].second);
+    BOOST_CHECK_EQUAL( true, ( static_pointer_cast<PersistableMessage>(t.msg))->isEnqueueComplete());
+}
 
-        CPPUNIT_ASSERT_EQUAL((uint32_t) 1, queue2->getMessageCount());
-        CPPUNIT_ASSERT_EQUAL(msg, queue2->dequeue().payload);            
-    }
-};
+QPID_AUTO_TEST_CASE(testCommit)
+{
+    TxPublishTest t;
 
-// Make this test suite a plugin.
-CPPUNIT_PLUGIN_IMPLEMENT();
-CPPUNIT_TEST_SUITE_REGISTRATION(TxPublishTest);
+    //ensure messages are delivered to queue
+    t.op.prepare(0);
+    t.op.commit();
+    BOOST_CHECK_EQUAL((uint32_t) 1, t.queue1->getMessageCount());
+    intrusive_ptr<Message> msg_dequeue = t.queue1->dequeue().payload;
+
+    BOOST_CHECK_EQUAL( true, (static_pointer_cast<PersistableMessage>(msg_dequeue))->isEnqueueComplete());
+    BOOST_CHECK_EQUAL(t.msg, msg_dequeue);
+
+    BOOST_CHECK_EQUAL((uint32_t) 1, t.queue2->getMessageCount());
+    BOOST_CHECK_EQUAL(t.msg, t.queue2->dequeue().payload);            
+}
 
+QPID_AUTO_TEST_SUITE_END()