diff options
Diffstat (limited to 'cpp/src/tests')
-rw-r--r-- | cpp/src/tests/Blob.cpp | 2 | ||||
-rw-r--r-- | cpp/src/tests/BrokerChannelTest.cpp | 7 | ||||
-rw-r--r-- | cpp/src/tests/ClientSessionTest.cpp | 26 | ||||
-rw-r--r-- | cpp/src/tests/Cluster.cpp | 10 | ||||
-rw-r--r-- | cpp/src/tests/Cluster_child.cpp | 3 | ||||
-rw-r--r-- | cpp/src/tests/FramingTest.cpp | 6 | ||||
-rw-r--r-- | cpp/src/tests/HeaderTest.cpp | 4 | ||||
-rw-r--r-- | cpp/src/tests/Makefile.am | 1 | ||||
-rw-r--r-- | cpp/src/tests/MessageBuilderTest.cpp | 29 | ||||
-rw-r--r-- | cpp/src/tests/MessageHandlerTest.cpp | 57 | ||||
-rw-r--r-- | cpp/src/tests/MessageTest.cpp | 9 | ||||
-rw-r--r-- | cpp/src/tests/MessageUtils.h | 6 | ||||
-rw-r--r-- | cpp/src/tests/MockChannel.h | 6 | ||||
-rw-r--r-- | cpp/src/tests/QueueTest.cpp | 5 | ||||
-rw-r--r-- | cpp/src/tests/TxAckTest.cpp | 5 |
15 files changed, 50 insertions, 126 deletions
diff --git a/cpp/src/tests/Blob.cpp b/cpp/src/tests/Blob.cpp index 708f6771be..d10cbf20c0 100644 --- a/cpp/src/tests/Blob.cpp +++ b/cpp/src/tests/Blob.cpp @@ -95,7 +95,7 @@ BOOST_AUTO_TEST_CASE(testAssign) { BOOST_CHECK_EQUAL(1, Foo::instances); BOOST_CHECK_EQUAL(1, Bar::instances); - b2.construct(in_place<Foo>(4)); + b2 = in_place<Foo>(4); BOOST_CHECK_EQUAL(4, b2.get()->id); BOOST_CHECK_EQUAL(2, Foo::instances); BOOST_CHECK_EQUAL(0, Bar::instances); diff --git a/cpp/src/tests/BrokerChannelTest.cpp b/cpp/src/tests/BrokerChannelTest.cpp index 8752b8afeb..2f671a9e27 100644 --- a/cpp/src/tests/BrokerChannelTest.cpp +++ b/cpp/src/tests/BrokerChannelTest.cpp @@ -346,8 +346,9 @@ class BrokerChannelTest : public CppUnit::TestCase { intrusive_ptr<Message> msg(new Message()); - AMQFrame method(0, MessageTransferBody(ProtocolVersion(), 0, exchange, 0, 0)); - AMQFrame header(0, AMQHeaderBody()); + AMQFrame method(in_place<MessageTransferBody>( + ProtocolVersion(), 0, exchange, 0, 0)); + AMQFrame header(in_place<AMQHeaderBody>()); msg->getFrames().append(method); msg->getFrames().append(header); @@ -360,7 +361,7 @@ class BrokerChannelTest : public CppUnit::TestCase void addContent(intrusive_ptr<Message> msg, const string& data) { - AMQFrame content(0, AMQContentBody(data)); + AMQFrame content(in_place<AMQContentBody>(data)); msg->getFrames().append(content); } }; diff --git a/cpp/src/tests/ClientSessionTest.cpp b/cpp/src/tests/ClientSessionTest.cpp index 369477131c..5d87e1f76b 100644 --- a/cpp/src/tests/ClientSessionTest.cpp +++ b/cpp/src/tests/ClientSessionTest.cpp @@ -71,7 +71,6 @@ class ClientSessionTest : public CppUnit::TestCase CPPUNIT_TEST(testUseSuspendedError); CPPUNIT_TEST(testSuspendResume); CPPUNIT_TEST(testDisconnectResume); - CPPUNIT_TEST(testAutoDelete); CPPUNIT_TEST_SUITE_END(); shared_ptr<broker::Broker> broker; @@ -97,9 +96,7 @@ public: void declareSubscribe(const std::string& q="my-queue", const std::string& dest="my-dest") { - // FIXME aconway 2007-10-18: autoDelete queues are destroyed on channel close, not session. - // Fix & make all test queues exclusive, autoDelete - session.queueDeclare(queue=q); // FIXME aconway 2007-10-01: exclusive=true, autoDelete=true); + session.queueDeclare(queue=q); session.messageSubscribe(queue=q, destination=dest, acquireMode=1); session.messageFlow(destination=dest, unit=0, value=0xFFFFFFFF);//messages session.messageFlow(destination=dest, unit=1, value=0xFFFFFFFF);//bytes @@ -203,27 +200,6 @@ public: c2->resume(session); CPPUNIT_ASSERT(queueExists("after")); } - - void testAutoDelete() { - // Verify that autoDelete queues survive suspend/resume. - session = c->newSession(60); - session.queueDeclare(queue="my-queue", exclusive=true, autoDelete=true); - CPPUNIT_ASSERT(queueExists("my-queue")); - session.suspend(); - c->resume(session); - CPPUNIT_ASSERT(queueExists("my-queue")); - - // Verify they survive disconnect/resume on new Connection - c->disconnect(); - c2->resume(session); - - try { - // FIXME aconway 2007-10-23: Negative test, need to - // fix auto-delete queues to clean up with session, not channel. - CPPUNIT_ASSERT(queueExists("my-queue")); - CPPUNIT_FAIL("Negative test passed unexpectedly"); - } catch(const ChannelException&) {} - } }; // Make this test suite a plugin. diff --git a/cpp/src/tests/Cluster.cpp b/cpp/src/tests/Cluster.cpp index 80ff6d9544..635126053f 100644 --- a/cpp/src/tests/Cluster.cpp +++ b/cpp/src/tests/Cluster.cpp @@ -34,7 +34,8 @@ static const ProtocolVersion VER; /** Verify membership in a cluster with one member. */ BOOST_AUTO_TEST_CASE(testClusterOne) { TestCluster cluster("clusterOne", "amqp:one:1"); - AMQFrame send(1, SessionOpenBody(VER)); + AMQFrame send(in_place<SessionOpenBody>(VER)); + send.setChannel(1); cluster.handle(send); AMQFrame received = cluster.received.pop(); BOOST_CHECK_TYPEID_EQUAL(SessionOpenBody, *received.getBody()); @@ -59,7 +60,8 @@ BOOST_AUTO_TEST_CASE(testClusterTwo) { BOOST_REQUIRE(cluster.waitFor(2)); // Myself and child. // Exchange frames with child. - AMQFrame send(1, SessionOpenBody(VER)); + AMQFrame send(SessionOpenBody(VER)); + send.setChannel(1); cluster.handle(send); AMQFrame received = cluster.received.pop(); BOOST_CHECK_TYPEID_EQUAL(SessionOpenBody, *received.getBody()); @@ -89,8 +91,8 @@ struct CountHandler : public FrameHandler { /** Test the ClassifierHandler */ BOOST_AUTO_TEST_CASE(testClassifierHandlerWiring) { - AMQFrame queueDecl(0, QueueDeclareBody(VER)); - AMQFrame messageTrans(0, MessageTransferBody(VER)); + AMQFrame queueDecl(in_place<QueueDeclareBody>(VER)); + AMQFrame messageTrans(in_place<MessageTransferBody>(VER)); CountHandler wiring; CountHandler other; diff --git a/cpp/src/tests/Cluster_child.cpp b/cpp/src/tests/Cluster_child.cpp index 8d0682473b..75591bb68f 100644 --- a/cpp/src/tests/Cluster_child.cpp +++ b/cpp/src/tests/Cluster_child.cpp @@ -39,7 +39,8 @@ void clusterTwo() { BOOST_CHECK_TYPEID_EQUAL(SessionOpenBody, *frame.getBody()); BOOST_CHECK_EQUAL(2u, cluster.size()); // Me and parent - AMQFrame send(1, SessionAttachedBody(VER)); + AMQFrame send(in_place<SessionAttachedBody>(VER)); + send.setChannel(1); cluster.handle(send); BOOST_REQUIRE(cluster.received.waitPop(frame)); BOOST_CHECK_TYPEID_EQUAL(SessionAttachedBody, *frame.getBody()); diff --git a/cpp/src/tests/FramingTest.cpp b/cpp/src/tests/FramingTest.cpp index 9e82447ffa..0c7adb2af8 100644 --- a/cpp/src/tests/FramingTest.cpp +++ b/cpp/src/tests/FramingTest.cpp @@ -147,7 +147,8 @@ class FramingTest : public CppUnit::TestCase Buffer wbuff(buffer, sizeof(buffer)); std::string a = "hostA"; std::string b = "hostB"; - AMQFrame in(999, ConnectionRedirectBody(version, a, b)); + AMQFrame in(in_place<ConnectionRedirectBody>(version, a, b)); + in.setChannel(999); in.encode(wbuff); Buffer rbuff(buffer, sizeof(buffer)); @@ -160,7 +161,8 @@ class FramingTest : public CppUnit::TestCase { Buffer wbuff(buffer, sizeof(buffer)); std::string s = "hostA"; - AMQFrame in(999, BasicConsumeOkBody(version, s)); + AMQFrame in(in_place<BasicConsumeOkBody>(version, s)); + in.setChannel(999); in.encode(wbuff); Buffer rbuff(buffer, sizeof(buffer)); diff --git a/cpp/src/tests/HeaderTest.cpp b/cpp/src/tests/HeaderTest.cpp index 21374e30e1..9e2bddb4de 100644 --- a/cpp/src/tests/HeaderTest.cpp +++ b/cpp/src/tests/HeaderTest.cpp @@ -56,7 +56,7 @@ class HeaderTest : public CppUnit::TestCase } void testMessageProperties() { - AMQFrame out(0, AMQHeaderBody()); + AMQFrame out(in_place<AMQHeaderBody>()); MessageProperties* props1 = out.castBody<AMQHeaderBody>()->get<MessageProperties>(true); @@ -96,7 +96,7 @@ class HeaderTest : public CppUnit::TestCase } void testDeliveryProperies() { - AMQFrame out(0, AMQHeaderBody()); + AMQFrame out(in_place<AMQHeaderBody>()); DeliveryProperties* props1 = out.castBody<AMQHeaderBody>()->get<DeliveryProperties>(true); diff --git a/cpp/src/tests/Makefile.am b/cpp/src/tests/Makefile.am index 4dbc37d42a..5265411b54 100644 --- a/cpp/src/tests/Makefile.am +++ b/cpp/src/tests/Makefile.am @@ -66,7 +66,6 @@ broker_unit_tests = \ TxAckTest \ TxBufferTest \ TxPublishTest \ - MessageHandlerTest \ MessageBuilderTest \ ClientSessionTest diff --git a/cpp/src/tests/MessageBuilderTest.cpp b/cpp/src/tests/MessageBuilderTest.cpp index 8598f45d80..023aefc3fa 100644 --- a/cpp/src/tests/MessageBuilderTest.cpp +++ b/cpp/src/tests/MessageBuilderTest.cpp @@ -100,8 +100,9 @@ class MessageBuilderTest : public CppUnit::TestCase std::string exchange("builder-exchange"); std::string key("builder-exchange"); - AMQFrame method(0, MessageTransferBody(ProtocolVersion(), 0, exchange, 0, 0)); - AMQFrame header(0, AMQHeaderBody()); + AMQFrame method(in_place<MessageTransferBody>( + ProtocolVersion(), 0, exchange, 0, 0)); + AMQFrame header(in_place<AMQHeaderBody>()); header.castBody<AMQHeaderBody>()->get<MessageProperties>(true)->setContentLength(0); header.castBody<AMQHeaderBody>()->get<DeliveryProperties>(true)->setRoutingKey(key); @@ -123,9 +124,9 @@ class MessageBuilderTest : public CppUnit::TestCase std::string exchange("builder-exchange"); std::string key("builder-exchange"); - AMQFrame method(0, MessageTransferBody(ProtocolVersion(), 0, exchange, 0, 0)); - AMQFrame header(0, AMQHeaderBody()); - AMQFrame content(0, AMQContentBody(data)); + AMQFrame method(in_place<MessageTransferBody>(ProtocolVersion(), 0, exchange, 0, 0)); + AMQFrame header(in_place<AMQHeaderBody>()); + AMQFrame content(in_place<AMQContentBody>(data)); method.setEof(false); header.setBof(false); header.setEof(false); @@ -156,10 +157,11 @@ class MessageBuilderTest : public CppUnit::TestCase std::string exchange("builder-exchange"); std::string key("builder-exchange"); - AMQFrame method(0, MessageTransferBody(ProtocolVersion(), 0, exchange, 0, 0)); - AMQFrame header(0, AMQHeaderBody()); - AMQFrame content1(0, AMQContentBody(data1)); - AMQFrame content2(0, AMQContentBody(data2)); + AMQFrame method(in_place<MessageTransferBody>( + ProtocolVersion(), 0, exchange, 0, 0)); + AMQFrame header(in_place<AMQHeaderBody>()); + AMQFrame content1(in_place<AMQContentBody>(data1)); + AMQFrame content2(in_place<AMQContentBody>(data2)); method.setEof(false); header.setBof(false); header.setEof(false); @@ -191,10 +193,11 @@ class MessageBuilderTest : public CppUnit::TestCase std::string exchange("builder-exchange"); std::string key("builder-exchange"); - AMQFrame method(0, MessageTransferBody(ProtocolVersion(), 0, exchange, 0, 0)); - AMQFrame header(0, AMQHeaderBody()); - AMQFrame content1(0, AMQContentBody(data1)); - AMQFrame content2(0, AMQContentBody(data2)); + AMQFrame method(in_place<MessageTransferBody>( + ProtocolVersion(), 0, exchange, 0, 0)); + AMQFrame header(in_place<AMQHeaderBody>()); + AMQFrame content1(in_place<AMQContentBody>(data1)); + AMQFrame content2(in_place<AMQContentBody>(data2)); header.castBody<AMQHeaderBody>()->get<MessageProperties>(true)->setContentLength(data1.size() + data2.size()); header.castBody<AMQHeaderBody>()->get<DeliveryProperties>(true)->setRoutingKey(key); diff --git a/cpp/src/tests/MessageHandlerTest.cpp b/cpp/src/tests/MessageHandlerTest.cpp deleted file mode 100644 index 2650475f79..0000000000 --- a/cpp/src/tests/MessageHandlerTest.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -//#include <iostream> -//#include "qpid/framing/AMQP_HighestVersion.h> -#include "qpid/framing/amqp_framing.h" -#include "qpid_test_plugin.h" - -#include "qpid/broker/BrokerAdapter.h" - -using namespace qpid::framing; -using namespace qpid::broker; - -class MessageHandlerTest : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(MessageHandlerTest); - CPPUNIT_TEST(testOpenMethod); - CPPUNIT_TEST_SUITE_END(); -private: - -public: - - MessageHandlerTest() - { - } - - void testOpenMethod() - { - //AMQFrame frame(highestProtocolVersion, 0, method); - //TestBodyHandler handler(method); - //handler.handleBody(frame.getBody()); - } - -}; - - -// Make this test suite a plugin. -CPPUNIT_PLUGIN_IMPLEMENT(); -CPPUNIT_TEST_SUITE_REGISTRATION(MessageHandlerTest); - diff --git a/cpp/src/tests/MessageTest.cpp b/cpp/src/tests/MessageTest.cpp index f5239165b0..f683eaad68 100644 --- a/cpp/src/tests/MessageTest.cpp +++ b/cpp/src/tests/MessageTest.cpp @@ -51,10 +51,11 @@ class MessageTest : public CppUnit::TestCase intrusive_ptr<Message> msg(new Message()); - AMQFrame method(0, MessageTransferBody(ProtocolVersion(), 0, exchange, 0, 0)); - AMQFrame header(0, AMQHeaderBody()); - AMQFrame content1(0, AMQContentBody(data1)); - AMQFrame content2(0, AMQContentBody(data2)); + AMQFrame method(in_place<MessageTransferBody>( + ProtocolVersion(), 0, exchange, 0, 0)); + AMQFrame header(in_place<AMQHeaderBody>()); + AMQFrame content1(in_place<AMQContentBody>(data1)); + AMQFrame content2(in_place<AMQContentBody>(data2)); msg->getFrames().append(method); msg->getFrames().append(header); diff --git a/cpp/src/tests/MessageUtils.h b/cpp/src/tests/MessageUtils.h index cf0f130fa6..117473bb5e 100644 --- a/cpp/src/tests/MessageUtils.h +++ b/cpp/src/tests/MessageUtils.h @@ -34,8 +34,8 @@ struct MessageUtils { intrusive_ptr<Message> msg(new Message()); - AMQFrame method(0, MessageTransferBody(ProtocolVersion(), 0, exchange, 0, 0)); - AMQFrame header(0, AMQHeaderBody()); + AMQFrame method(in_place<MessageTransferBody>(ProtocolVersion(), 0, exchange, 0, 0)); + AMQFrame header(in_place<AMQHeaderBody>()); msg->getFrames().append(method); msg->getFrames().append(header); @@ -48,7 +48,7 @@ struct MessageUtils static void addContent(intrusive_ptr<Message> msg, const string& data) { - AMQFrame content(0, AMQContentBody(data)); + AMQFrame content(in_place<AMQContentBody>(data)); msg->getFrames().append(content); } }; diff --git a/cpp/src/tests/MockChannel.h b/cpp/src/tests/MockChannel.h index b9a7c0a2a2..0c06daab2c 100644 --- a/cpp/src/tests/MockChannel.h +++ b/cpp/src/tests/MockChannel.h @@ -37,12 +37,6 @@ struct MockOutputHandler : public qpid::framing::OutputHandler { */ struct MockChannel : public qpid::framing::ChannelAdapter { - typedef qpid::framing::BasicGetBody Body; - static Body::shared_ptr basicGetBody() { - return Body::shared_ptr( - new Body(qpid::framing::ProtocolVersion())); - } - MockOutputHandler out; MockChannel(qpid::framing::ChannelId id) { diff --git a/cpp/src/tests/QueueTest.cpp b/cpp/src/tests/QueueTest.cpp index 2d84d23b6f..4714a998f6 100644 --- a/cpp/src/tests/QueueTest.cpp +++ b/cpp/src/tests/QueueTest.cpp @@ -73,8 +73,9 @@ class QueueTest : public CppUnit::TestCase public: intrusive_ptr<Message> message(std::string exchange, std::string routingKey) { intrusive_ptr<Message> msg(new Message()); - AMQFrame method(0, MessageTransferBody(ProtocolVersion(), 0, exchange, 0, 0)); - AMQFrame header(0, AMQHeaderBody()); + AMQFrame method(in_place<MessageTransferBody>( + ProtocolVersion(), 0, exchange, 0, 0)); + AMQFrame header(in_place<AMQHeaderBody>()); msg->getFrames().append(method); msg->getFrames().append(header); msg->getFrames().getHeaders()->get<DeliveryProperties>(true)->setRoutingKey(routingKey); diff --git a/cpp/src/tests/TxAckTest.cpp b/cpp/src/tests/TxAckTest.cpp index 495b8b550e..bcf422e706 100644 --- a/cpp/src/tests/TxAckTest.cpp +++ b/cpp/src/tests/TxAckTest.cpp @@ -70,8 +70,9 @@ public: { for(int i = 0; i < 10; i++){ intrusive_ptr<Message> msg(new Message()); - AMQFrame method(0, MessageTransferBody(ProtocolVersion(), 0, "exchange", 0, 0)); - AMQFrame header(0, AMQHeaderBody()); + AMQFrame method(in_place<MessageTransferBody>( + ProtocolVersion(), 0, "exchange", 0, 0)); + AMQFrame header(in_place<AMQHeaderBody>()); msg->getFrames().append(method); msg->getFrames().append(header); msg->getProperties<DeliveryProperties>()->setDeliveryMode(PERSISTENT); |