summaryrefslogtreecommitdiff
path: root/cpp/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/tests')
-rw-r--r--cpp/src/tests/BrokerChannelTest.cpp24
-rw-r--r--cpp/src/tests/Cluster.cpp8
-rw-r--r--cpp/src/tests/Cluster.h2
-rw-r--r--cpp/src/tests/Cluster_child.cpp2
-rw-r--r--cpp/src/tests/FramingTest.cpp93
-rw-r--r--cpp/src/tests/InMemoryContentTest.cpp9
-rw-r--r--cpp/src/tests/InProcessBroker.h2
-rw-r--r--cpp/src/tests/LazyLoadedContentTest.cpp3
-rw-r--r--cpp/src/tests/Makefile.am5
-rw-r--r--cpp/src/tests/MessageBuilderTest.cpp46
-rw-r--r--cpp/src/tests/MessageTest.cpp17
-rw-r--r--cpp/src/tests/MockChannel.h11
-rw-r--r--cpp/src/tests/ReferenceTest.cpp22
-rw-r--r--cpp/src/tests/TxAckTest.cpp3
-rw-r--r--cpp/src/tests/TxPublishTest.cpp3
-rw-r--r--cpp/src/tests/Visitor.cpp58
16 files changed, 99 insertions, 209 deletions
diff --git a/cpp/src/tests/BrokerChannelTest.cpp b/cpp/src/tests/BrokerChannelTest.cpp
index eb67601875..6c9b910637 100644
--- a/cpp/src/tests/BrokerChannelTest.cpp
+++ b/cpp/src/tests/BrokerChannelTest.cpp
@@ -31,6 +31,7 @@
#include "MockChannel.h"
#include "qpid/broker/Connection.h"
#include "qpid/framing/ProtocolInitiation.h"
+#include "qpid/framing/ConnectionStartBody.h"
#include <vector>
using namespace boost;
@@ -233,18 +234,18 @@ class BrokerChannelTest : public CppUnit::TestCase
Queue::shared_ptr queue(new Queue("my_queue"));
exchange->bind(queue, "", 0);
- AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC));
+ AMQHeaderBody header(BASIC);
uint64_t contentSize(0);
for (int i = 0; i < 3; i++) {
contentSize += data[i].size();
}
- header->setContentSize(contentSize);
+ header.setContentSize(contentSize);
channel.handlePublish(msg);
- channel.handleHeader(header);
+ channel.handleHeader(&header);
for (int i = 0; i < 3; i++) {
- AMQContentBody::shared_ptr body(new AMQContentBody(data[i]));
- channel.handleContent(body);
+ AMQContentBody body(data[i]);
+ channel.handleContent(&body);
}
Message::shared_ptr msg2 = queue->dequeue();
CPPUNIT_ASSERT_EQUAL(msg, msg2.get());
@@ -312,8 +313,7 @@ class BrokerChannelTest : public CppUnit::TestCase
//there will always be a connection-start frame
CPPUNIT_ASSERT_EQUAL((size_t) 1, handler.frames.size());
CPPUNIT_ASSERT_EQUAL(ChannelId(0), handler.frames[0].getChannel());
- CPPUNIT_ASSERT(dynamic_cast<ConnectionStartBody*>(
- handler.frames[0].getBody().get()));
+ CPPUNIT_ASSERT(dynamic_cast<ConnectionStartBody*>(handler.frames[0].getBody()));
const string data("abcdefghijklmn");
@@ -340,17 +340,17 @@ class BrokerChannelTest : public CppUnit::TestCase
{
BasicMessage* msg = new BasicMessage(
0, exchange, routingKey, false, false);
- AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC));
- header->setContentSize(contentSize);
- msg->setHeader(header);
+ AMQHeaderBody header(BASIC);
+ header.setContentSize(contentSize);
+ msg->setHeader(&header);
msg->getHeaderProperties()->setMessageId(messageId);
return msg;
}
void addContent(Message::shared_ptr msg, const string& data)
{
- AMQContentBody::shared_ptr body(new AMQContentBody(data));
- msg->addContent(body);
+ AMQContentBody body(data);
+ msg->addContent(&body);
}
};
diff --git a/cpp/src/tests/Cluster.cpp b/cpp/src/tests/Cluster.cpp
index 811fc0133e..2d23b87627 100644
--- a/cpp/src/tests/Cluster.cpp
+++ b/cpp/src/tests/Cluster.cpp
@@ -33,7 +33,7 @@ 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(VER, 1, new SessionPingBody(VER));
+ AMQFrame send(VER, 1, SessionPingBody(VER));
cluster.handle(send);
AMQFrame received;
BOOST_REQUIRE(cluster.received.waitPop(received));
@@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE(testClusterTwo) {
BOOST_REQUIRE(cluster.waitFor(2)); // Myself and child.
// Exchange frames with child.
- AMQFrame send(VER, 1, new SessionPingBody(VER));
+ AMQFrame send(VER, 1, SessionPingBody(VER));
cluster.handle(send);
AMQFrame received;
BOOST_REQUIRE(cluster.received.waitPop(received));
@@ -90,8 +90,8 @@ struct CountHandler : public FrameHandler {
/** Test the ClassifierHandler */
BOOST_AUTO_TEST_CASE(testClassifierHandlerWiring) {
- AMQFrame queueDecl(VER, 0, new QueueDeclareBody(VER));
- AMQFrame messageTrans(VER, 0, new MessageTransferBody(VER));
+ AMQFrame queueDecl(VER, 0, QueueDeclareBody(VER));
+ AMQFrame messageTrans(VER, 0, MessageTransferBody(VER));
shared_ptr<CountHandler> wiring(new CountHandler());
shared_ptr<CountHandler> other(new CountHandler());
diff --git a/cpp/src/tests/Cluster.h b/cpp/src/tests/Cluster.h
index 510a788f7c..366ea92a8b 100644
--- a/cpp/src/tests/Cluster.h
+++ b/cpp/src/tests/Cluster.h
@@ -55,8 +55,6 @@ class TestHandler : public Handler<T&>, public ConcurrentQueue<T>
typedef TestHandler<AMQFrame> TestFrameHandler;
-void nullDeleter(void*) {}
-
struct TestCluster : public Cluster
{
TestCluster(string name, string url)
diff --git a/cpp/src/tests/Cluster_child.cpp b/cpp/src/tests/Cluster_child.cpp
index 7bea9d0490..62ccb9bd72 100644
--- a/cpp/src/tests/Cluster_child.cpp
+++ b/cpp/src/tests/Cluster_child.cpp
@@ -40,7 +40,7 @@ void clusterTwo() {
BOOST_CHECK_TYPEID_EQUAL(SessionPingBody, *frame.getBody());
BOOST_CHECK_EQUAL(2u, cluster.size()); // Me and parent
- AMQFrame send(VER, 1, new SessionPongBody(VER));
+ AMQFrame send(VER, 1, SessionPongBody(VER));
cluster.handle(send);
BOOST_REQUIRE(cluster.received.waitPop(frame));
BOOST_CHECK_TYPEID_EQUAL(SessionPongBody, *frame.getBody());
diff --git a/cpp/src/tests/FramingTest.cpp b/cpp/src/tests/FramingTest.cpp
index b0aeb9db6f..a0dd8d37f6 100644
--- a/cpp/src/tests/FramingTest.cpp
+++ b/cpp/src/tests/FramingTest.cpp
@@ -18,24 +18,27 @@
* under the License.
*
*/
+#include "InProcessBroker.h"
+#include "qpid/QpidError.h"
+#include "qpid/client/ClientExchange.h"
+#include "qpid/client/ClientQueue.h"
+#include "qpid/client/Connection.h"
+#include "qpid/client/Connector.h"
+#include "qpid/framing/AMQP_HighestVersion.h"
+#include "qpid/framing/BasicGetOkBody.h"
#include "qpid/framing/ConnectionRedirectBody.h"
#include "qpid/framing/ProtocolVersion.h"
+#include "qpid/framing/all_method_bodies.h"
#include "qpid/framing/amqp_framing.h"
-#include <iostream>
#include "qpid_test_plugin.h"
+
+#include <boost/bind.hpp>
+#include <boost/lexical_cast.hpp>
+#include <iostream>
+
+#include <memory>
#include <sstream>
#include <typeinfo>
-#include "qpid/QpidError.h"
-#include "qpid/framing/AMQP_HighestVersion.h"
-#include "InProcessBroker.h"
-#include "qpid/client/Connection.h"
-#include "qpid/client/Connector.h"
-#include "qpid/client/ClientExchange.h"
-#include "qpid/client/ClientQueue.h"
-#include "qpid/framing/BasicGetOkBody.h"
-#include <memory>
-#include <boost/lexical_cast.hpp>
-#include <boost/bind.hpp>
using namespace qpid;
using namespace qpid::framing;
@@ -62,13 +65,11 @@ class FramingTest : public CppUnit::TestCase
CPPUNIT_TEST(testInlineContent);
CPPUNIT_TEST(testContentReference);
CPPUNIT_TEST(testContentValidation);
- CPPUNIT_TEST(testRequestResponseRoundtrip);
CPPUNIT_TEST_SUITE_END();
private:
Buffer buffer;
ProtocolVersion version;
- AMQP_MethodVersionMap versionMap;
public:
@@ -77,10 +78,10 @@ class FramingTest : public CppUnit::TestCase
void testBasicQosBody()
{
BasicQosBody in(version, 0xCAFEBABE, 0xABBA, true);
- in.encodeContent(buffer);
+ in.encode(buffer);
buffer.flip();
BasicQosBody out(version);
- out.decodeContent(buffer);
+ out.decode(buffer);
CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
}
@@ -88,10 +89,10 @@ class FramingTest : public CppUnit::TestCase
{
std::string s = "security credential";
ConnectionSecureBody in(version, s);
- in.encodeContent(buffer);
+ in.encode(buffer);
buffer.flip();
ConnectionSecureBody out(version);
- out.decodeContent(buffer);
+ out.decode(buffer);
CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
}
@@ -100,10 +101,10 @@ class FramingTest : public CppUnit::TestCase
std::string a = "hostA";
std::string b = "hostB";
ConnectionRedirectBody in(version, a, b);
- in.encodeContent(buffer);
+ in.encode(buffer);
buffer.flip();
ConnectionRedirectBody out(version);
- out.decodeContent(buffer);
+ out.decode(buffer);
CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
}
@@ -111,10 +112,10 @@ class FramingTest : public CppUnit::TestCase
{
std::string s = "text";
AccessRequestBody in(version, s, true, false, true, false, true);
- in.encodeContent(buffer);
+ in.encode(buffer);
buffer.flip();
AccessRequestBody out(version);
- out.decodeContent(buffer);
+ out.decode(buffer);
CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
}
@@ -124,10 +125,10 @@ class FramingTest : public CppUnit::TestCase
std::string t = "tag";
BasicConsumeBody in(version, 0, q, t, false, true, false, false,
FieldTable());
- in.encodeContent(buffer);
+ in.encode(buffer);
buffer.flip();
BasicConsumeBody out(version);
- out.decodeContent(buffer);
+ out.decode(buffer);
CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
}
@@ -137,7 +138,7 @@ class FramingTest : public CppUnit::TestCase
std::string a = "hostA";
std::string b = "hostB";
AMQFrame in(version, 999,
- new ConnectionRedirectBody(version, a, b));
+ ConnectionRedirectBody(version, a, b));
in.encode(buffer);
buffer.flip();
AMQFrame out;
@@ -148,7 +149,7 @@ class FramingTest : public CppUnit::TestCase
void testBasicConsumeOkBodyFrame()
{
std::string s = "hostA";
- AMQFrame in(version, 999, new BasicConsumeOkBody(version, s));
+ AMQFrame in(version, 999, BasicConsumeOkBody(version, s));
in.encode(buffer);
buffer.flip();
AMQFrame out;
@@ -211,46 +212,6 @@ class FramingTest : public CppUnit::TestCase
}
- // expect may contain null chars so use string(ptr,size) constructor
- // Use sizeof(expect)-1 to strip the trailing null.
-#define ASSERT_FRAME(expect, frame) \
- CPPUNIT_ASSERT_EQUAL(string(expect, sizeof(expect)-1), boost::lexical_cast<string>(frame))
-
- void testRequestResponseRoundtrip() {
- boost::shared_ptr<broker::InProcessBroker> ibroker(new broker::InProcessBroker(version));
- client::Connection clientConnection(boost::static_pointer_cast<client::Connector>(ibroker));
- clientConnection.open("");
- client::Channel c;
- clientConnection.openChannel(c);
-
- client::Exchange exchange(
- "MyExchange", client::Exchange::TOPIC_EXCHANGE);
- client::Queue queue("MyQueue", true);
- c.declareExchange(exchange);
- c.declareQueue(queue);
- c.bind(exchange, queue, "MyTopic", framing::FieldTable());
- c.close();
- clientConnection.close();
- broker::InProcessBroker::Conversation::const_iterator i = ibroker->conversation.begin();
- ASSERT_FRAME("BROKER: Frame[channel=0; ConnectionStart: versionMajor=0; versionMinor=10; serverProperties={}; mechanisms=PLAIN; locales=en_US]", *i++);
- ASSERT_FRAME("CLIENT: Frame[channel=0; ConnectionStartOk: clientProperties={}; mechanism=PLAIN; response=\000guest\000guest; locale=en_US]", *i++);
- ASSERT_FRAME("BROKER: Frame[channel=0; ConnectionTune: channelMax=32767; frameMax=65536; heartbeat=0]", *i++);
- ASSERT_FRAME("CLIENT: Frame[channel=0; ConnectionTuneOk: channelMax=32767; frameMax=65536; heartbeat=0]", *i++);
- ASSERT_FRAME("CLIENT: Frame[channel=0; ConnectionOpen: virtualHost=/; capabilities=; insist=1]", *i++);
- ASSERT_FRAME("BROKER: Frame[channel=0; ConnectionOpenOk: knownHosts=]", *i++);
- ASSERT_FRAME("CLIENT: Frame[channel=1; ChannelOpen: outOfBand=]", *i++);
- ASSERT_FRAME("BROKER: Frame[channel=1; ChannelOpenOk: ]", *i++);
- ASSERT_FRAME("CLIENT: Frame[channel=1; ExchangeDeclare: ticket=0; exchange=MyExchange; type=topic; alternateExchange=; passive=0; durable=0; autoDelete=0; arguments={}]", *i++);
- ASSERT_FRAME("CLIENT: Frame[channel=1; ExecutionFlush: ]", *i++);
- ASSERT_FRAME("BROKER: Frame[channel=1; ExecutionComplete: cumulativeExecutionMark=1; rangedExecutionSet={}]", *i++);
- ASSERT_FRAME("CLIENT: Frame[channel=1; QueueDeclare: ticket=0; queue=MyQueue; alternateExchange=; passive=0; durable=0; exclusive=1; autoDelete=1; nowait=0; arguments={}]", *i++);
- ASSERT_FRAME("BROKER: Frame[channel=1; QueueDeclareOk: queue=MyQueue; messageCount=0; consumerCount=0]", *i++);
- ASSERT_FRAME("CLIENT: Frame[channel=1; ExecutionFlush: ]", *i++);
- ASSERT_FRAME("BROKER: Frame[channel=1; ExecutionComplete: cumulativeExecutionMark=2; rangedExecutionSet={}]", *i++);
- ASSERT_FRAME("CLIENT: Frame[channel=1; QueueBind: ticket=0; queue=MyQueue; exchange=MyExchange; routingKey=MyTopic; arguments={}]", *i++);
- ASSERT_FRAME("CLIENT: Frame[channel=1; ExecutionFlush: ]", *i++);
- ASSERT_FRAME("BROKER: Frame[channel=1; ExecutionComplete: cumulativeExecutionMark=3; rangedExecutionSet={}]", *i++);
- }
};
diff --git a/cpp/src/tests/InMemoryContentTest.cpp b/cpp/src/tests/InMemoryContentTest.cpp
index cb729f9930..bc95548d45 100644
--- a/cpp/src/tests/InMemoryContentTest.cpp
+++ b/cpp/src/tests/InMemoryContentTest.cpp
@@ -65,9 +65,8 @@ public:
CPPUNIT_ASSERT_EQUAL(outCount, channel.out.frames.size());
for (unsigned int i = 0; i < outCount; i++) {
- AMQContentBody::shared_ptr chunk(
- dynamic_pointer_cast<AMQContentBody>(
- channel.out.frames[i].getBody()));
+ AMQContentBody* chunk = dynamic_cast<AMQContentBody*>(
+ channel.out.frames[i].getBody());
CPPUNIT_ASSERT(chunk);
CPPUNIT_ASSERT_EQUAL(out[i], chunk->getData());
CPPUNIT_ASSERT_EQUAL(
@@ -78,8 +77,8 @@ public:
void addframes(InMemoryContent& content, size_t frameCount, string* frameData)
{
for (unsigned int i = 0; i < frameCount; i++) {
- AMQContentBody::shared_ptr frame(new AMQContentBody(frameData[i]));
- content.add(frame);
+ AMQContentBody frame(frameData[i]);
+ content.add(&frame);
}
}
diff --git a/cpp/src/tests/InProcessBroker.h b/cpp/src/tests/InProcessBroker.h
index 9f30ee584d..0e5f3895f9 100644
--- a/cpp/src/tests/InProcessBroker.h
+++ b/cpp/src/tests/InProcessBroker.h
@@ -54,7 +54,7 @@ class InProcessBroker : public client::Connector {
template <class MethodType>
MethodType* asMethod() {
- return dynamic_cast<MethodType*>(frame.getBody().get());
+ return dynamic_cast<MethodType*>(frame.getBody());
}
framing::AMQFrame frame;
Sender sender;
diff --git a/cpp/src/tests/LazyLoadedContentTest.cpp b/cpp/src/tests/LazyLoadedContentTest.cpp
index 7bac3613ad..df46f6b48e 100644
--- a/cpp/src/tests/LazyLoadedContentTest.cpp
+++ b/cpp/src/tests/LazyLoadedContentTest.cpp
@@ -97,7 +97,8 @@ public:
CPPUNIT_ASSERT_EQUAL(outCount, channel.out.frames.size());
for (unsigned int i = 0; i < outCount; i++) {
- AMQContentBody::shared_ptr chunk(dynamic_pointer_cast<AMQContentBody, AMQBody>(channel.out.frames[i].getBody()));
+ AMQContentBody* chunk(dynamic_cast<AMQContentBody*>(
+ channel.out.frames[i].getBody()));
CPPUNIT_ASSERT(chunk);
CPPUNIT_ASSERT_EQUAL(out[i], chunk->getData());
CPPUNIT_ASSERT_EQUAL(
diff --git a/cpp/src/tests/Makefile.am b/cpp/src/tests/Makefile.am
index 67b173af33..c9a08e6075 100644
--- a/cpp/src/tests/Makefile.am
+++ b/cpp/src/tests/Makefile.am
@@ -43,7 +43,6 @@ check_PROGRAMS+=Shlib
Shlib_SOURCES=Shlib.cpp
Shlib_LDADD=-lboost_unit_test_framework $(lib_common)
-
# TODO aconway 2007-08-07: Why aren't these tests run automatically?
check_PROGRAMS+=ConcurrentQueue
@@ -54,10 +53,6 @@ check_PROGRAMS+=Serializer
Serializer_SOURCES=Serializer.cpp
Serializer_LDADD=-lboost_unit_test_framework $(lib_common)
-check_PROGRAMS+=Visitor
-Visitor_SOURCES=Visitor.cpp
-Visitor_LDADD=-lboost_unit_test_framework
-
include cluster.mk
#
diff --git a/cpp/src/tests/MessageBuilderTest.cpp b/cpp/src/tests/MessageBuilderTest.cpp
index 3d2ee1aaea..a12fc603ce 100644
--- a/cpp/src/tests/MessageBuilderTest.cpp
+++ b/cpp/src/tests/MessageBuilderTest.cpp
@@ -119,12 +119,12 @@ class MessageBuilderTest : public CppUnit::TestCase
Message::shared_ptr message(
new BasicMessage(
0, "test", "my_routing_key", false, false));
- AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC));
- header->setContentSize(0);
+ AMQHeaderBody header(BASIC);
+ header.setContentSize(0);
builder.initialise(message);
CPPUNIT_ASSERT(!handler.msg);
- builder.setHeader(header);
+ builder.setHeader(&header);
CPPUNIT_ASSERT(handler.msg);
CPPUNIT_ASSERT_EQUAL(message, handler.msg);
}
@@ -137,15 +137,15 @@ class MessageBuilderTest : public CppUnit::TestCase
Message::shared_ptr message(
new BasicMessage(0, "test", "my_routing_key", false, false));
- AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC));
- header->setContentSize(7);
- AMQContentBody::shared_ptr part1(new AMQContentBody(data1));
+ AMQHeaderBody header(BASIC);
+ header.setContentSize(7);
+ AMQContentBody part1(data1);
builder.initialise(message);
CPPUNIT_ASSERT(!handler.msg);
- builder.setHeader(header);
+ builder.setHeader(&header);
CPPUNIT_ASSERT(!handler.msg);
- builder.addContent(part1);
+ builder.addContent(&part1);
CPPUNIT_ASSERT(handler.msg);
CPPUNIT_ASSERT_EQUAL(message, handler.msg);
}
@@ -159,18 +159,18 @@ class MessageBuilderTest : public CppUnit::TestCase
Message::shared_ptr message(
new BasicMessage(0, "test", "my_routing_key", false, false));
- AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC));
- header->setContentSize(14);
- AMQContentBody::shared_ptr part1(new AMQContentBody(data1));
- AMQContentBody::shared_ptr part2(new AMQContentBody(data2));
+ AMQHeaderBody header(BASIC);
+ header.setContentSize(14);
+ AMQContentBody part1(data1);
+ AMQContentBody part2(data2);
builder.initialise(message);
CPPUNIT_ASSERT(!handler.msg);
- builder.setHeader(header);
+ builder.setHeader(&header);
CPPUNIT_ASSERT(!handler.msg);
- builder.addContent(part1);
+ builder.addContent(&part1);
CPPUNIT_ASSERT(!handler.msg);
- builder.addContent(part2);
+ builder.addContent(&part2);
CPPUNIT_ASSERT(handler.msg);
CPPUNIT_ASSERT_EQUAL(message, handler.msg);
}
@@ -189,19 +189,19 @@ class MessageBuilderTest : public CppUnit::TestCase
Message::shared_ptr message(
new BasicMessage(0, "test", "my_routing_key", false, false));
- AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC));
- header->setContentSize(14);
- BasicHeaderProperties* properties = dynamic_cast<BasicHeaderProperties*>(header->getProperties());
+ AMQHeaderBody header(BASIC);
+ header.setContentSize(14);
+ BasicHeaderProperties* properties = dynamic_cast<BasicHeaderProperties*>(header.getProperties());
properties->setMessageId("MyMessage");
properties->getHeaders().setString("abc", "xyz");
- AMQContentBody::shared_ptr part1(new AMQContentBody(data1));
- AMQContentBody::shared_ptr part2(new AMQContentBody(data2));
+ AMQContentBody part1(data1);
+ AMQContentBody part2(data2);
builder.initialise(message);
- builder.setHeader(header);
- builder.addContent(part1);
- builder.addContent(part2);
+ builder.setHeader(&header);
+ builder.addContent(&part1);
+ builder.addContent(&part2);
CPPUNIT_ASSERT(handler.msg);
CPPUNIT_ASSERT_EQUAL(message, handler.msg);
diff --git a/cpp/src/tests/MessageTest.cpp b/cpp/src/tests/MessageTest.cpp
index 1e976312be..1fbb18b7d3 100644
--- a/cpp/src/tests/MessageTest.cpp
+++ b/cpp/src/tests/MessageTest.cpp
@@ -47,13 +47,13 @@ class MessageTest : public CppUnit::TestCase
BasicMessage::shared_ptr msg(
new BasicMessage(0, exchange, routingKey, false, false));
- AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC));
- header->setContentSize(14);
- AMQContentBody::shared_ptr part1(new AMQContentBody(data1));
- AMQContentBody::shared_ptr part2(new AMQContentBody(data2));
- msg->setHeader(header);
- msg->addContent(part1);
- msg->addContent(part2);
+ AMQHeaderBody header(BASIC);
+ header.setContentSize(14);
+ AMQContentBody part1(data1);
+ AMQContentBody part2(data2);
+ msg->setHeader(&header);
+ msg->addContent(&part1);
+ msg->addContent(&part2);
msg->getHeaderProperties()->setMessageId(messageId);
msg->getHeaderProperties()->setDeliveryMode(PERSISTENT);
@@ -75,7 +75,8 @@ class MessageTest : public CppUnit::TestCase
MockChannel channel(1);
msg->deliver(channel, "ignore", 0, 100);
CPPUNIT_ASSERT_EQUAL((size_t) 3, channel.out.frames.size());
- AMQContentBody::shared_ptr contentBody(dynamic_pointer_cast<AMQContentBody, AMQBody>(channel.out.frames[2].getBody()));
+ AMQContentBody* contentBody(
+ dynamic_cast<AMQContentBody*>(channel.out.frames[2].getBody()));
CPPUNIT_ASSERT(contentBody);
CPPUNIT_ASSERT_EQUAL(data1 + data2, contentBody->getData());
}
diff --git a/cpp/src/tests/MockChannel.h b/cpp/src/tests/MockChannel.h
index fb2de98d2a..b9a7c0a2a2 100644
--- a/cpp/src/tests/MockChannel.h
+++ b/cpp/src/tests/MockChannel.h
@@ -51,13 +51,10 @@ struct MockChannel : public qpid::framing::ChannelAdapter
bool isOpen() const { return true; }
- void handleHeader(
- boost::shared_ptr<qpid::framing::AMQHeaderBody> b) { send(b); }
- void handleContent(
- boost::shared_ptr<qpid::framing::AMQContentBody> b) { send(b); }
- void handleHeartbeat(
- boost::shared_ptr<qpid::framing::AMQHeartbeatBody> b) { send(b); }
- void handleMethod(boost::shared_ptr<qpid::framing::AMQMethodBody> method) { send(method); };
+ void handleHeader(qpid::framing::AMQHeaderBody* b) { send(*b); }
+ void handleContent(qpid::framing::AMQContentBody* b) { send(*b); }
+ void handleHeartbeat(qpid::framing::AMQHeartbeatBody* b) { send(*b); }
+ void handleMethod(qpid::framing::AMQMethodBody* b) { send(*b); };
};
diff --git a/cpp/src/tests/ReferenceTest.cpp b/cpp/src/tests/ReferenceTest.cpp
index b3dd44bf7d..411462564a 100644
--- a/cpp/src/tests/ReferenceTest.cpp
+++ b/cpp/src/tests/ReferenceTest.cpp
@@ -67,17 +67,17 @@ class ReferenceTest : public CppUnit::TestCase
Reference::shared_ptr r1(registry.open("bar"));
- MessageTransferBody::shared_ptr t1(new MessageTransferBody(v));
+ MessageTransferBody t1(v);
// TODO aconway 2007-04-03: hack around lack of generated setters. Clean this up.
- const_cast<framing::Content&>(t1->getBody()) = framing::Content(REFERENCE,"bar");
- MessageMessage::shared_ptr m1(new MessageMessage(0, t1, r1));
+ const_cast<framing::Content&>(t1.getBody()) = framing::Content(REFERENCE,"bar");
+ MessageMessage::shared_ptr m1(new MessageMessage(0, &t1, r1));
- MessageTransferBody::shared_ptr t2(new MessageTransferBody(v));
- const_cast<framing::Content&>(t2->getBody()) = framing::Content(REFERENCE,"bar");
- MessageMessage::shared_ptr m2(new MessageMessage(0, t2, r1));
+ MessageTransferBody t2(v);
+ const_cast<framing::Content&>(t2.getBody()) = framing::Content(REFERENCE,"bar");
+ MessageMessage::shared_ptr m2(new MessageMessage(0, &t2, r1));
- MessageAppendBody::shared_ptr a1(new MessageAppendBody(v));
- MessageAppendBody::shared_ptr a2(new MessageAppendBody(v));
+ MessageAppendBody a1(v);
+ MessageAppendBody a2(v);
r1->addMessage(m1);
r1->addMessage(m2);
@@ -86,12 +86,6 @@ class ReferenceTest : public CppUnit::TestCase
r1->append(a2);
CPPUNIT_ASSERT_EQUAL(size_t(2), r1->getAppends().size());
r1->close();
-
- CPPUNIT_ASSERT_EQUAL(m1->getReference()->getAppends()[0], a1);
- CPPUNIT_ASSERT_EQUAL(m1->getReference()->getAppends()[1], a2);
-
- CPPUNIT_ASSERT_EQUAL(m2->getReference()->getAppends()[0], a1);
- CPPUNIT_ASSERT_EQUAL(m2->getReference()->getAppends()[1], a2);
}
};
diff --git a/cpp/src/tests/TxAckTest.cpp b/cpp/src/tests/TxAckTest.cpp
index a5d9eb69a5..24e8aac701 100644
--- a/cpp/src/tests/TxAckTest.cpp
+++ b/cpp/src/tests/TxAckTest.cpp
@@ -70,7 +70,8 @@ public:
for(int i = 0; i < 10; i++){
Message::shared_ptr msg(
new BasicMessage(0, "exchange", "routing_key", false, false));
- msg->setHeader(AMQHeaderBody::shared_ptr(new AMQHeaderBody(BASIC)));
+ AMQHeaderBody body(BASIC);
+ msg->setHeader(&body);
msg->getHeaderProperties()->setDeliveryMode(PERSISTENT);
messages.push_back(msg);
deliveries.push_back(DeliveryRecord(msg, queue, "xyz", (i+1)));
diff --git a/cpp/src/tests/TxPublishTest.cpp b/cpp/src/tests/TxPublishTest.cpp
index 05c03754f9..3391be5128 100644
--- a/cpp/src/tests/TxPublishTest.cpp
+++ b/cpp/src/tests/TxPublishTest.cpp
@@ -72,7 +72,8 @@ public:
msg(new BasicMessage(0, "exchange", "routing_key", false, false)),
op(msg)
{
- msg->setHeader(AMQHeaderBody::shared_ptr(new AMQHeaderBody(BASIC)));
+ AMQHeaderBody body(BASIC);
+ msg->setHeader(&body);
msg->getHeaderProperties()->setDeliveryMode(PERSISTENT);
op.deliverTo(queue1);
op.deliverTo(queue2);
diff --git a/cpp/src/tests/Visitor.cpp b/cpp/src/tests/Visitor.cpp
deleted file mode 100644
index 0cb3cf15bb..0000000000
--- a/cpp/src/tests/Visitor.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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 "qpid/framing/Visitor.h"
-
-#define BOOST_AUTO_TEST_MAIN // Must come before #include<boost/test/*>
-#include <boost/test/auto_unit_test.hpp>
-#include <boost/tuple/tuple.hpp>
-
-using namespace std;
-using namespace qpid::framing;
-
-struct DummyA;
-struct DummyB;
-struct DummyC;
-
-QPID_VISITOR(DummyVisitor, (DummyA)(DummyB)(DummyC));
-
-struct DummyFrame : public VisitableRoot<DummyVisitor> {};
-
-struct DummyA : public Visitable<DummyA, DummyFrame> {};
-struct DummyB : public Visitable<DummyB, DummyFrame> {};
-struct DummyC : public Visitable<DummyC, DummyFrame> {};
-
-struct TestDummyVisitor : public DummyVisitor {
- boost::tuple<DummyA*, DummyB*, DummyC*> dummies;
- void visit(DummyA& a) { dummies.get<0>() = &a; }
- void visit(DummyB& b) { dummies.get<1>() = &b; }
- void visit(DummyC& c) { dummies.get<2>() = &c; }
-};
-
-BOOST_AUTO_TEST_CASE(Visitor_accept) {
- TestDummyVisitor v;
- DummyA a;
- DummyB b;
- DummyC c;
- a.accept(v);
- BOOST_CHECK_EQUAL(&a, v.dummies.get<0>());
- b.accept(v);
- BOOST_CHECK_EQUAL(&b, v.dummies.get<1>());
- c.accept(v);
- BOOST_CHECK_EQUAL(&c, v.dummies.get<2>());
-}