From 9ecd69ebc88fb5d82a693e51eef0475c1a6b282e Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Mon, 2 Apr 2007 11:40:48 +0000 Subject: Fix for the most disruptive items in QPID-243. * All #include lines now use '""' rather than '<>' where appropriate. * #include lines within the qpid project use relative includes so that the same path will work in /usr/include when installed as part of the client libraries. * All the source code has now been rearranged to be under src in a directory analogous to the namespace of the classes in it. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@524769 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/HeaderTest.cpp | 141 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 qpid/cpp/src/tests/HeaderTest.cpp (limited to 'qpid/cpp/src/tests/HeaderTest.cpp') diff --git a/qpid/cpp/src/tests/HeaderTest.cpp b/qpid/cpp/src/tests/HeaderTest.cpp new file mode 100644 index 0000000000..29e2ddee3d --- /dev/null +++ b/qpid/cpp/src/tests/HeaderTest.cpp @@ -0,0 +1,141 @@ +/* + * + * 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 +#include "../framing/amqp_framing.h" +#include "qpid_test_plugin.h" + +using namespace qpid::framing; + +class HeaderTest : public CppUnit::TestCase +{ + CPPUNIT_TEST_SUITE(HeaderTest); + CPPUNIT_TEST(testGenericProperties); + CPPUNIT_TEST(testAllSpecificProperties); + CPPUNIT_TEST(testSomeSpecificProperties); + CPPUNIT_TEST_SUITE_END(); + +public: + + void testGenericProperties() + { + AMQHeaderBody body(BASIC); + dynamic_cast(body.getProperties())->getHeaders().setString("A", "BCDE"); + Buffer buffer(100); + + body.encode(buffer); + buffer.flip(); + AMQHeaderBody body2; + body2.decode(buffer, body.size()); + BasicHeaderProperties* props = + dynamic_cast(body2.getProperties()); + CPPUNIT_ASSERT_EQUAL(std::string("BCDE"), + props->getHeaders().getString("A")); + } + + void testAllSpecificProperties(){ + string contentType("text/html"); + string contentEncoding("UTF8"); + DeliveryMode deliveryMode(PERSISTENT); + uint8_t priority(3); + string correlationId("abc"); + string replyTo("no-address"); + string expiration("why is this a string?"); + string messageId("xyz"); + uint64_t timestamp(0xabcd); + string type("eh?"); + string userId("guest"); + string appId("just testing"); + string clusterId("no clustering required"); + + AMQHeaderBody body(BASIC); + BasicHeaderProperties* properties = + dynamic_cast(body.getProperties()); + properties->setContentType(contentType); + properties->getHeaders().setString("A", "BCDE"); + properties->setDeliveryMode(deliveryMode); + properties->setPriority(priority); + properties->setCorrelationId(correlationId); + properties->setReplyTo(replyTo); + properties->setExpiration(expiration); + properties->setMessageId(messageId); + properties->setTimestamp(timestamp); + properties->setType(type); + properties->setUserId(userId); + properties->setAppId(appId); + properties->setClusterId(clusterId); + + Buffer buffer(10000); + body.encode(buffer); + buffer.flip(); + AMQHeaderBody temp; + temp.decode(buffer, body.size()); + properties = dynamic_cast(temp.getProperties()); + + CPPUNIT_ASSERT_EQUAL(contentType, properties->getContentType()); + CPPUNIT_ASSERT_EQUAL(std::string("BCDE"), properties->getHeaders().getString("A")); + CPPUNIT_ASSERT_EQUAL(deliveryMode, properties->getDeliveryMode()); + CPPUNIT_ASSERT_EQUAL(priority, properties->getPriority()); + CPPUNIT_ASSERT_EQUAL(correlationId, properties->getCorrelationId()); + CPPUNIT_ASSERT_EQUAL(replyTo, properties->getReplyTo()); + CPPUNIT_ASSERT_EQUAL(expiration, properties->getExpiration()); + CPPUNIT_ASSERT_EQUAL(messageId, properties->getMessageId()); + CPPUNIT_ASSERT_EQUAL(timestamp, properties->getTimestamp()); + CPPUNIT_ASSERT_EQUAL(type, properties->getType()); + CPPUNIT_ASSERT_EQUAL(userId, properties->getUserId()); + CPPUNIT_ASSERT_EQUAL(appId, properties->getAppId()); + CPPUNIT_ASSERT_EQUAL(clusterId, properties->getClusterId()); + } + + void testSomeSpecificProperties(){ + string contentType("application/octet-stream"); + DeliveryMode deliveryMode(PERSISTENT); + uint8_t priority(6); + string expiration("Z"); + uint64_t timestamp(0xabe4a34a); + + AMQHeaderBody body(BASIC); + BasicHeaderProperties* properties = + dynamic_cast(body.getProperties()); + properties->setContentType(contentType); + properties->setDeliveryMode(deliveryMode); + properties->setPriority(priority); + properties->setExpiration(expiration); + properties->setTimestamp(timestamp); + + Buffer buffer(100); + body.encode(buffer); + buffer.flip(); + AMQHeaderBody temp; + temp.decode(buffer, body.size()); + properties = dynamic_cast(temp.getProperties()); + + CPPUNIT_ASSERT_EQUAL(contentType, properties->getContentType()); + CPPUNIT_ASSERT_EQUAL((int) deliveryMode, (int) properties->getDeliveryMode()); + CPPUNIT_ASSERT_EQUAL((int) priority, (int) properties->getPriority()); + CPPUNIT_ASSERT_EQUAL(expiration, properties->getExpiration()); + CPPUNIT_ASSERT_EQUAL(timestamp, properties->getTimestamp()); + } +}; + +// Make this test suite a plugin. +CPPUNIT_PLUGIN_IMPLEMENT(); +CPPUNIT_TEST_SUITE_REGISTRATION(HeaderTest); + -- cgit v1.2.1 From 26a723475dc6926bde883c8c7f983ee44d8deb01 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Fri, 13 Apr 2007 20:58:27 +0000 Subject: Moved src/ source code to src/qpid directory: - allows rhm package to build consistently against checked-out or installed qpid. - consistent correspondence between source paths and C++ namespaces. - consistent use of #include in source and by users. - allows header files to split over multiple directories, e.g. separating generated code, separating public API from private files. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@528668 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/HeaderTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/HeaderTest.cpp') diff --git a/qpid/cpp/src/tests/HeaderTest.cpp b/qpid/cpp/src/tests/HeaderTest.cpp index 29e2ddee3d..17381cc868 100644 --- a/qpid/cpp/src/tests/HeaderTest.cpp +++ b/qpid/cpp/src/tests/HeaderTest.cpp @@ -19,7 +19,7 @@ * */ #include -#include "../framing/amqp_framing.h" +#include "qpid/framing/amqp_framing.h" #include "qpid_test_plugin.h" using namespace qpid::framing; -- cgit v1.2.1 From b7b4a5407af61099567b8f1b3765cfada6150312 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 28 Aug 2007 19:38:17 +0000 Subject: Updated message.transfer encoding to use header and content segments (including new structs). Unified more between the basic and message classes messages. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@570538 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/HeaderTest.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'qpid/cpp/src/tests/HeaderTest.cpp') diff --git a/qpid/cpp/src/tests/HeaderTest.cpp b/qpid/cpp/src/tests/HeaderTest.cpp index 17381cc868..df2230342c 100644 --- a/qpid/cpp/src/tests/HeaderTest.cpp +++ b/qpid/cpp/src/tests/HeaderTest.cpp @@ -36,8 +36,8 @@ public: void testGenericProperties() { - AMQHeaderBody body(BASIC); - dynamic_cast(body.getProperties())->getHeaders().setString("A", "BCDE"); + AMQHeaderBody body; + body.get(true)->getHeaders().setString("A", "BCDE"); Buffer buffer(100); body.encode(buffer); @@ -45,7 +45,7 @@ public: AMQHeaderBody body2; body2.decode(buffer, body.size()); BasicHeaderProperties* props = - dynamic_cast(body2.getProperties()); + body2.get(true); CPPUNIT_ASSERT_EQUAL(std::string("BCDE"), props->getHeaders().getString("A")); } @@ -64,10 +64,11 @@ public: string userId("guest"); string appId("just testing"); string clusterId("no clustering required"); + uint64_t contentLength(54321); - AMQHeaderBody body(BASIC); + AMQFrame out(0, AMQHeaderBody()); BasicHeaderProperties* properties = - dynamic_cast(body.getProperties()); + out.castBody()->get(true); properties->setContentType(contentType); properties->getHeaders().setString("A", "BCDE"); properties->setDeliveryMode(deliveryMode); @@ -81,13 +82,14 @@ public: properties->setUserId(userId); properties->setAppId(appId); properties->setClusterId(clusterId); + properties->setContentLength(contentLength); Buffer buffer(10000); - body.encode(buffer); + out.encode(buffer); buffer.flip(); - AMQHeaderBody temp; - temp.decode(buffer, body.size()); - properties = dynamic_cast(temp.getProperties()); + AMQFrame in; + in.decode(buffer); + properties = in.castBody()->get(true); CPPUNIT_ASSERT_EQUAL(contentType, properties->getContentType()); CPPUNIT_ASSERT_EQUAL(std::string("BCDE"), properties->getHeaders().getString("A")); @@ -102,6 +104,7 @@ public: CPPUNIT_ASSERT_EQUAL(userId, properties->getUserId()); CPPUNIT_ASSERT_EQUAL(appId, properties->getAppId()); CPPUNIT_ASSERT_EQUAL(clusterId, properties->getClusterId()); + CPPUNIT_ASSERT_EQUAL(contentLength, properties->getContentLength()); } void testSomeSpecificProperties(){ @@ -111,9 +114,9 @@ public: string expiration("Z"); uint64_t timestamp(0xabe4a34a); - AMQHeaderBody body(BASIC); + AMQHeaderBody body; BasicHeaderProperties* properties = - dynamic_cast(body.getProperties()); + body.get(true); properties->setContentType(contentType); properties->setDeliveryMode(deliveryMode); properties->setPriority(priority); @@ -125,7 +128,7 @@ public: buffer.flip(); AMQHeaderBody temp; temp.decode(buffer, body.size()); - properties = dynamic_cast(temp.getProperties()); + properties = temp.get(true); CPPUNIT_ASSERT_EQUAL(contentType, properties->getContentType()); CPPUNIT_ASSERT_EQUAL((int) deliveryMode, (int) properties->getDeliveryMode()); -- cgit v1.2.1 From 0bc9a47a7c35f8cf67ef0e92cc53c91e66a6deec Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Fri, 31 Aug 2007 18:20:29 +0000 Subject: * Changes to make C++ client code use the asynchronous network IO * Fixed up the test for buffer changes * Removed unused buffer operations git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@571529 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/HeaderTest.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'qpid/cpp/src/tests/HeaderTest.cpp') diff --git a/qpid/cpp/src/tests/HeaderTest.cpp b/qpid/cpp/src/tests/HeaderTest.cpp index df2230342c..a883ccf300 100644 --- a/qpid/cpp/src/tests/HeaderTest.cpp +++ b/qpid/cpp/src/tests/HeaderTest.cpp @@ -38,12 +38,13 @@ public: { AMQHeaderBody body; body.get(true)->getHeaders().setString("A", "BCDE"); - Buffer buffer(100); + char buff[100]; + Buffer wbuffer(buff, 100); + body.encode(wbuffer); - body.encode(buffer); - buffer.flip(); + Buffer rbuffer(buff, 100); AMQHeaderBody body2; - body2.decode(buffer, body.size()); + body2.decode(rbuffer, body.size()); BasicHeaderProperties* props = body2.get(true); CPPUNIT_ASSERT_EQUAL(std::string("BCDE"), @@ -84,11 +85,13 @@ public: properties->setClusterId(clusterId); properties->setContentLength(contentLength); - Buffer buffer(10000); - out.encode(buffer); - buffer.flip(); + char buff[10000]; + Buffer wbuffer(buff, 10000); + out.encode(wbuffer); + + Buffer rbuffer(buff, 10000); AMQFrame in; - in.decode(buffer); + in.decode(rbuffer); properties = in.castBody()->get(true); CPPUNIT_ASSERT_EQUAL(contentType, properties->getContentType()); @@ -123,11 +126,13 @@ public: properties->setExpiration(expiration); properties->setTimestamp(timestamp); - Buffer buffer(100); - body.encode(buffer); - buffer.flip(); + char buff[100]; + Buffer wbuffer(buff, 100); + body.encode(wbuffer); + + Buffer rbuffer(buff, 100); AMQHeaderBody temp; - temp.decode(buffer, body.size()); + temp.decode(rbuffer, body.size()); properties = temp.get(true); CPPUNIT_ASSERT_EQUAL(contentType, properties->getContentType()); -- cgit v1.2.1 From 2e7a0f670684ccd696316666c6a1d61849f67e80 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Tue, 16 Oct 2007 10:21:20 +0000 Subject: Implementation of 0-10 field tables git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@585097 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/HeaderTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/src/tests/HeaderTest.cpp') diff --git a/qpid/cpp/src/tests/HeaderTest.cpp b/qpid/cpp/src/tests/HeaderTest.cpp index a883ccf300..1b21151b65 100644 --- a/qpid/cpp/src/tests/HeaderTest.cpp +++ b/qpid/cpp/src/tests/HeaderTest.cpp @@ -20,6 +20,7 @@ */ #include #include "qpid/framing/amqp_framing.h" +#include "qpid/framing/FieldValue.h" #include "qpid_test_plugin.h" using namespace qpid::framing; @@ -47,8 +48,7 @@ public: body2.decode(rbuffer, body.size()); BasicHeaderProperties* props = body2.get(true); - CPPUNIT_ASSERT_EQUAL(std::string("BCDE"), - props->getHeaders().getString("A")); + CPPUNIT_ASSERT(StringValue("BCDE") == *props->getHeaders().get("A")); } void testAllSpecificProperties(){ @@ -95,7 +95,7 @@ public: properties = in.castBody()->get(true); CPPUNIT_ASSERT_EQUAL(contentType, properties->getContentType()); - CPPUNIT_ASSERT_EQUAL(std::string("BCDE"), properties->getHeaders().getString("A")); + CPPUNIT_ASSERT(StringValue("BCDE") == *properties->getHeaders().get("A")); CPPUNIT_ASSERT_EQUAL(deliveryMode, properties->getDeliveryMode()); CPPUNIT_ASSERT_EQUAL(priority, properties->getPriority()); CPPUNIT_ASSERT_EQUAL(correlationId, properties->getCorrelationId()); -- cgit v1.2.1 From 48c509cc0e1461fdfb175b3b0a7733a3f991faaf Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Fri, 9 Nov 2007 23:30:59 +0000 Subject: Get rid of BasicHeaderProperties, dead code from 0-8 protocol. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@593692 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/HeaderTest.cpp | 141 ++++++++++++++++---------------------- 1 file changed, 59 insertions(+), 82 deletions(-) (limited to 'qpid/cpp/src/tests/HeaderTest.cpp') diff --git a/qpid/cpp/src/tests/HeaderTest.cpp b/qpid/cpp/src/tests/HeaderTest.cpp index 1b21151b65..21374e30e1 100644 --- a/qpid/cpp/src/tests/HeaderTest.cpp +++ b/qpid/cpp/src/tests/HeaderTest.cpp @@ -24,21 +24,23 @@ #include "qpid_test_plugin.h" using namespace qpid::framing; +using namespace std; class HeaderTest : public CppUnit::TestCase { CPPUNIT_TEST_SUITE(HeaderTest); CPPUNIT_TEST(testGenericProperties); - CPPUNIT_TEST(testAllSpecificProperties); - CPPUNIT_TEST(testSomeSpecificProperties); + CPPUNIT_TEST(testMessageProperties); + CPPUNIT_TEST(testDeliveryProperies); CPPUNIT_TEST_SUITE_END(); -public: + public: void testGenericProperties() { AMQHeaderBody body; - body.get(true)->getHeaders().setString("A", "BCDE"); + body.get(true)->getApplicationHeaders().setString( + "A", "BCDE"); char buff[100]; Buffer wbuffer(buff, 100); body.encode(wbuffer); @@ -46,44 +48,29 @@ public: Buffer rbuffer(buff, 100); AMQHeaderBody body2; body2.decode(rbuffer, body.size()); - BasicHeaderProperties* props = - body2.get(true); - CPPUNIT_ASSERT(StringValue("BCDE") == *props->getHeaders().get("A")); + MessageProperties* props = + body2.get(true); + CPPUNIT_ASSERT_EQUAL( + string("BCDE"), + props->getApplicationHeaders().get("A")->get()); } - void testAllSpecificProperties(){ - string contentType("text/html"); - string contentEncoding("UTF8"); - DeliveryMode deliveryMode(PERSISTENT); - uint8_t priority(3); - string correlationId("abc"); - string replyTo("no-address"); - string expiration("why is this a string?"); - string messageId("xyz"); - uint64_t timestamp(0xabcd); - string type("eh?"); - string userId("guest"); - string appId("just testing"); - string clusterId("no clustering required"); - uint64_t contentLength(54321); - + void testMessageProperties() { AMQFrame out(0, AMQHeaderBody()); - BasicHeaderProperties* properties = - out.castBody()->get(true); - properties->setContentType(contentType); - properties->getHeaders().setString("A", "BCDE"); - properties->setDeliveryMode(deliveryMode); - properties->setPriority(priority); - properties->setCorrelationId(correlationId); - properties->setReplyTo(replyTo); - properties->setExpiration(expiration); - properties->setMessageId(messageId); - properties->setTimestamp(timestamp); - properties->setType(type); - properties->setUserId(userId); - properties->setAppId(appId); - properties->setClusterId(clusterId); - properties->setContentLength(contentLength); + MessageProperties* props1 = + out.castBody()->get(true); + + props1->setContentLength(42); + props1->setMessageId("messageId"); + props1->setCorrelationId("correlationId"); + props1->setReplyTo(ReplyTo("ex","key")); + props1->setContentType("contentType"); + props1->setContentEncoding("contentEncoding"); + props1->setType("type"); + props1->setUserId("userId"); + props1->setAppId("appId"); + props1->setTransactionId("transactionId"); + props1->setSecurityToken("securityToken"); char buff[10000]; Buffer wbuffer(buff, 10000); @@ -92,55 +79,45 @@ public: Buffer rbuffer(buff, 10000); AMQFrame in; in.decode(rbuffer); - properties = in.castBody()->get(true); - - CPPUNIT_ASSERT_EQUAL(contentType, properties->getContentType()); - CPPUNIT_ASSERT(StringValue("BCDE") == *properties->getHeaders().get("A")); - CPPUNIT_ASSERT_EQUAL(deliveryMode, properties->getDeliveryMode()); - CPPUNIT_ASSERT_EQUAL(priority, properties->getPriority()); - CPPUNIT_ASSERT_EQUAL(correlationId, properties->getCorrelationId()); - CPPUNIT_ASSERT_EQUAL(replyTo, properties->getReplyTo()); - CPPUNIT_ASSERT_EQUAL(expiration, properties->getExpiration()); - CPPUNIT_ASSERT_EQUAL(messageId, properties->getMessageId()); - CPPUNIT_ASSERT_EQUAL(timestamp, properties->getTimestamp()); - CPPUNIT_ASSERT_EQUAL(type, properties->getType()); - CPPUNIT_ASSERT_EQUAL(userId, properties->getUserId()); - CPPUNIT_ASSERT_EQUAL(appId, properties->getAppId()); - CPPUNIT_ASSERT_EQUAL(clusterId, properties->getClusterId()); - CPPUNIT_ASSERT_EQUAL(contentLength, properties->getContentLength()); + MessageProperties* props2 = + in.castBody()->get(true); + + CPPUNIT_ASSERT_EQUAL(props1->getContentLength(), props2->getContentLength()); + CPPUNIT_ASSERT_EQUAL(props1->getMessageId(), props2->getMessageId()); + CPPUNIT_ASSERT_EQUAL(props1->getCorrelationId(), props2->getCorrelationId()); + CPPUNIT_ASSERT_EQUAL(props1->getContentType(), props2->getContentType()); + CPPUNIT_ASSERT_EQUAL(props1->getContentEncoding(), props2->getContentEncoding()); + CPPUNIT_ASSERT_EQUAL(props1->getType(), props2->getType()); + CPPUNIT_ASSERT_EQUAL(props1->getUserId(), props2->getUserId()); + CPPUNIT_ASSERT_EQUAL(props1->getAppId(), props2->getAppId()); + CPPUNIT_ASSERT_EQUAL(props1->getTransactionId(), props2->getTransactionId()); + CPPUNIT_ASSERT_EQUAL(props1->getSecurityToken(), props2->getSecurityToken()); + } - void testSomeSpecificProperties(){ - string contentType("application/octet-stream"); - DeliveryMode deliveryMode(PERSISTENT); - uint8_t priority(6); - string expiration("Z"); - uint64_t timestamp(0xabe4a34a); + void testDeliveryProperies() { + AMQFrame out(0, AMQHeaderBody()); + DeliveryProperties* props1 = + out.castBody()->get(true); - AMQHeaderBody body; - BasicHeaderProperties* properties = - body.get(true); - properties->setContentType(contentType); - properties->setDeliveryMode(deliveryMode); - properties->setPriority(priority); - properties->setExpiration(expiration); - properties->setTimestamp(timestamp); + props1->setDiscardUnroutable(true); + props1->setExchange("foo"); - char buff[100]; - Buffer wbuffer(buff, 100); - body.encode(wbuffer); + char buff[10000]; + Buffer wbuffer(buff, 10000); + out.encode(wbuffer); - Buffer rbuffer(buff, 100); - AMQHeaderBody temp; - temp.decode(rbuffer, body.size()); - properties = temp.get(true); - - CPPUNIT_ASSERT_EQUAL(contentType, properties->getContentType()); - CPPUNIT_ASSERT_EQUAL((int) deliveryMode, (int) properties->getDeliveryMode()); - CPPUNIT_ASSERT_EQUAL((int) priority, (int) properties->getPriority()); - CPPUNIT_ASSERT_EQUAL(expiration, properties->getExpiration()); - CPPUNIT_ASSERT_EQUAL(timestamp, properties->getTimestamp()); + Buffer rbuffer(buff, 10000); + AMQFrame in; + in.decode(rbuffer); + DeliveryProperties* props2 = + in.castBody()->get(true); + + CPPUNIT_ASSERT(props2->getDiscardUnroutable()); + CPPUNIT_ASSERT_EQUAL(string("foo"), props2->getExchange()); + CPPUNIT_ASSERT(!props2->hasTimestamp()); } + }; // Make this test suite a plugin. -- cgit v1.2.1 From 2e75ce2a7bc1a94c294def9f70789c49770c2470 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 22 Nov 2007 23:55:39 +0000 Subject: Added framing::BodyHolder: - Uniform holder for all body types, replaces MethodHolder. - Uses in_place constructors to avoid avoid body copy. framing::AMQFrame: - Holds body in heap-allocated intrusive_ptr - Uses in_place constructors to avoid avoid body copy. Removed/downgraded to TODO many redundant FIXME comments. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@597513 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/HeaderTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/src/tests/HeaderTest.cpp') diff --git a/qpid/cpp/src/tests/HeaderTest.cpp b/qpid/cpp/src/tests/HeaderTest.cpp index 21374e30e1..9e2bddb4de 100644 --- a/qpid/cpp/src/tests/HeaderTest.cpp +++ b/qpid/cpp/src/tests/HeaderTest.cpp @@ -56,7 +56,7 @@ class HeaderTest : public CppUnit::TestCase } void testMessageProperties() { - AMQFrame out(0, AMQHeaderBody()); + AMQFrame out(in_place()); MessageProperties* props1 = out.castBody()->get(true); @@ -96,7 +96,7 @@ class HeaderTest : public CppUnit::TestCase } void testDeliveryProperies() { - AMQFrame out(0, AMQHeaderBody()); + AMQFrame out(in_place()); DeliveryProperties* props1 = out.castBody()->get(true); -- cgit v1.2.1 From 4780580874e8d6a3e3590fa5fdf8a088310b20ae Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Sun, 20 Apr 2008 12:10:37 +0000 Subject: QPID-920: converted c++ client to use final 0-10 protocol * connection handler converted to using invoker & proxy and updated to final method defs * SessionCore & ExecutionHandler replace by SessionImpl * simplified handling of completion & results, removed handling of responses git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@649915 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/HeaderTest.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'qpid/cpp/src/tests/HeaderTest.cpp') diff --git a/qpid/cpp/src/tests/HeaderTest.cpp b/qpid/cpp/src/tests/HeaderTest.cpp index 9e2bddb4de..56be38a302 100644 --- a/qpid/cpp/src/tests/HeaderTest.cpp +++ b/qpid/cpp/src/tests/HeaderTest.cpp @@ -61,16 +61,13 @@ class HeaderTest : public CppUnit::TestCase out.castBody()->get(true); props1->setContentLength(42); - props1->setMessageId("messageId"); + props1->setMessageId(Uuid(true)); props1->setCorrelationId("correlationId"); props1->setReplyTo(ReplyTo("ex","key")); props1->setContentType("contentType"); props1->setContentEncoding("contentEncoding"); - props1->setType("type"); props1->setUserId("userId"); props1->setAppId("appId"); - props1->setTransactionId("transactionId"); - props1->setSecurityToken("securityToken"); char buff[10000]; Buffer wbuffer(buff, 10000); @@ -87,11 +84,8 @@ class HeaderTest : public CppUnit::TestCase CPPUNIT_ASSERT_EQUAL(props1->getCorrelationId(), props2->getCorrelationId()); CPPUNIT_ASSERT_EQUAL(props1->getContentType(), props2->getContentType()); CPPUNIT_ASSERT_EQUAL(props1->getContentEncoding(), props2->getContentEncoding()); - CPPUNIT_ASSERT_EQUAL(props1->getType(), props2->getType()); CPPUNIT_ASSERT_EQUAL(props1->getUserId(), props2->getUserId()); CPPUNIT_ASSERT_EQUAL(props1->getAppId(), props2->getAppId()); - CPPUNIT_ASSERT_EQUAL(props1->getTransactionId(), props2->getTransactionId()); - CPPUNIT_ASSERT_EQUAL(props1->getSecurityToken(), props2->getSecurityToken()); } -- cgit v1.2.1 From 0b1a16b3ef9e0b52aeb1ac2a6c73c150df3b46ee Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 30 May 2008 08:13:21 +0000 Subject: Convert remaining cppunit tests to boost test framework to reduce dependencies. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@661587 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/HeaderTest.cpp | 172 ++++++++++++++++++-------------------- 1 file changed, 81 insertions(+), 91 deletions(-) (limited to 'qpid/cpp/src/tests/HeaderTest.cpp') diff --git a/qpid/cpp/src/tests/HeaderTest.cpp b/qpid/cpp/src/tests/HeaderTest.cpp index 56be38a302..c3b64419ed 100644 --- a/qpid/cpp/src/tests/HeaderTest.cpp +++ b/qpid/cpp/src/tests/HeaderTest.cpp @@ -21,100 +21,90 @@ #include #include "qpid/framing/amqp_framing.h" #include "qpid/framing/FieldValue.h" -#include "qpid_test_plugin.h" +#include "unit_test.h" using namespace qpid::framing; using namespace std; -class HeaderTest : public CppUnit::TestCase +QPID_AUTO_TEST_SUITE(HeaderTestSuite) + +QPID_AUTO_TEST_CASE(testGenericProperties) +{ + AMQHeaderBody body; + body.get(true)->getApplicationHeaders().setString( + "A", "BCDE"); + char buff[100]; + Buffer wbuffer(buff, 100); + body.encode(wbuffer); + + Buffer rbuffer(buff, 100); + AMQHeaderBody body2; + body2.decode(rbuffer, body.size()); + MessageProperties* props = + body2.get(true); + BOOST_CHECK_EQUAL( + string("BCDE"), + props->getApplicationHeaders().get("A")->get()); +} + +QPID_AUTO_TEST_CASE(testMessageProperties) { - CPPUNIT_TEST_SUITE(HeaderTest); - CPPUNIT_TEST(testGenericProperties); - CPPUNIT_TEST(testMessageProperties); - CPPUNIT_TEST(testDeliveryProperies); - CPPUNIT_TEST_SUITE_END(); - - public: - - void testGenericProperties() - { - AMQHeaderBody body; - body.get(true)->getApplicationHeaders().setString( - "A", "BCDE"); - char buff[100]; - Buffer wbuffer(buff, 100); - body.encode(wbuffer); - - Buffer rbuffer(buff, 100); - AMQHeaderBody body2; - body2.decode(rbuffer, body.size()); - MessageProperties* props = - body2.get(true); - CPPUNIT_ASSERT_EQUAL( - string("BCDE"), - props->getApplicationHeaders().get("A")->get()); - } - - void testMessageProperties() { - AMQFrame out(in_place()); - MessageProperties* props1 = - out.castBody()->get(true); - - props1->setContentLength(42); - props1->setMessageId(Uuid(true)); - props1->setCorrelationId("correlationId"); - props1->setReplyTo(ReplyTo("ex","key")); - props1->setContentType("contentType"); - props1->setContentEncoding("contentEncoding"); - props1->setUserId("userId"); - props1->setAppId("appId"); - - char buff[10000]; - Buffer wbuffer(buff, 10000); - out.encode(wbuffer); - - Buffer rbuffer(buff, 10000); - AMQFrame in; - in.decode(rbuffer); - MessageProperties* props2 = - in.castBody()->get(true); - - CPPUNIT_ASSERT_EQUAL(props1->getContentLength(), props2->getContentLength()); - CPPUNIT_ASSERT_EQUAL(props1->getMessageId(), props2->getMessageId()); - CPPUNIT_ASSERT_EQUAL(props1->getCorrelationId(), props2->getCorrelationId()); - CPPUNIT_ASSERT_EQUAL(props1->getContentType(), props2->getContentType()); - CPPUNIT_ASSERT_EQUAL(props1->getContentEncoding(), props2->getContentEncoding()); - CPPUNIT_ASSERT_EQUAL(props1->getUserId(), props2->getUserId()); - CPPUNIT_ASSERT_EQUAL(props1->getAppId(), props2->getAppId()); - - } - - void testDeliveryProperies() { - AMQFrame out(in_place()); - DeliveryProperties* props1 = - out.castBody()->get(true); - - props1->setDiscardUnroutable(true); - props1->setExchange("foo"); - - char buff[10000]; - Buffer wbuffer(buff, 10000); - out.encode(wbuffer); - - Buffer rbuffer(buff, 10000); - AMQFrame in; - in.decode(rbuffer); - DeliveryProperties* props2 = - in.castBody()->get(true); - - CPPUNIT_ASSERT(props2->getDiscardUnroutable()); - CPPUNIT_ASSERT_EQUAL(string("foo"), props2->getExchange()); - CPPUNIT_ASSERT(!props2->hasTimestamp()); - } - -}; - -// Make this test suite a plugin. -CPPUNIT_PLUGIN_IMPLEMENT(); -CPPUNIT_TEST_SUITE_REGISTRATION(HeaderTest); + AMQFrame out(in_place()); + MessageProperties* props1 = + out.castBody()->get(true); + + props1->setContentLength(42); + props1->setMessageId(Uuid(true)); + props1->setCorrelationId("correlationId"); + props1->setReplyTo(ReplyTo("ex","key")); + props1->setContentType("contentType"); + props1->setContentEncoding("contentEncoding"); + props1->setUserId("userId"); + props1->setAppId("appId"); + + char buff[10000]; + Buffer wbuffer(buff, 10000); + out.encode(wbuffer); + + Buffer rbuffer(buff, 10000); + AMQFrame in; + in.decode(rbuffer); + MessageProperties* props2 = + in.castBody()->get(true); + + BOOST_CHECK_EQUAL(props1->getContentLength(), props2->getContentLength()); + BOOST_CHECK_EQUAL(props1->getMessageId(), props2->getMessageId()); + BOOST_CHECK_EQUAL(props1->getCorrelationId(), props2->getCorrelationId()); + BOOST_CHECK_EQUAL(props1->getContentType(), props2->getContentType()); + BOOST_CHECK_EQUAL(props1->getContentEncoding(), props2->getContentEncoding()); + BOOST_CHECK_EQUAL(props1->getUserId(), props2->getUserId()); + BOOST_CHECK_EQUAL(props1->getAppId(), props2->getAppId()); + +} + +QPID_AUTO_TEST_CASE(testDeliveryProperies) +{ + AMQFrame out(in_place()); + DeliveryProperties* props1 = + out.castBody()->get(true); + + props1->setDiscardUnroutable(true); + props1->setExchange("foo"); + + char buff[10000]; + Buffer wbuffer(buff, 10000); + out.encode(wbuffer); + + Buffer rbuffer(buff, 10000); + AMQFrame in; + in.decode(rbuffer); + DeliveryProperties* props2 = + in.castBody()->get(true); + + BOOST_CHECK(props2->getDiscardUnroutable()); + BOOST_CHECK_EQUAL(string("foo"), props2->getExchange()); + BOOST_CHECK(!props2->hasTimestamp()); +} + +QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 071fff099bd18bbbadbb90e344052ef877cefc32 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 7 Oct 2008 17:24:24 +0000 Subject: Rename size() to encodedSize() for encoded types to allow std collection interfaces for types like FieldTable and Array. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@702551 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/HeaderTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/HeaderTest.cpp') diff --git a/qpid/cpp/src/tests/HeaderTest.cpp b/qpid/cpp/src/tests/HeaderTest.cpp index c3b64419ed..33bf705e65 100644 --- a/qpid/cpp/src/tests/HeaderTest.cpp +++ b/qpid/cpp/src/tests/HeaderTest.cpp @@ -39,7 +39,7 @@ QPID_AUTO_TEST_CASE(testGenericProperties) Buffer rbuffer(buff, 100); AMQHeaderBody body2; - body2.decode(rbuffer, body.size()); + body2.decode(rbuffer, body.encodedSize()); MessageProperties* props = body2.get(true); BOOST_CHECK_EQUAL( -- cgit v1.2.1 From 3e26ae40844c3f9e612a0e3a2f98ba1576ee520c Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 22 Jan 2009 20:29:12 +0000 Subject: Removed BodyHolder: minor performance improvement, opens the way for more efficient memory management. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@736783 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/HeaderTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/src/tests/HeaderTest.cpp') diff --git a/qpid/cpp/src/tests/HeaderTest.cpp b/qpid/cpp/src/tests/HeaderTest.cpp index 33bf705e65..01e7c22ee6 100644 --- a/qpid/cpp/src/tests/HeaderTest.cpp +++ b/qpid/cpp/src/tests/HeaderTest.cpp @@ -49,7 +49,7 @@ QPID_AUTO_TEST_CASE(testGenericProperties) QPID_AUTO_TEST_CASE(testMessageProperties) { - AMQFrame out(in_place()); + AMQFrame out((AMQHeaderBody())); MessageProperties* props1 = out.castBody()->get(true); @@ -84,7 +84,7 @@ QPID_AUTO_TEST_CASE(testMessageProperties) QPID_AUTO_TEST_CASE(testDeliveryProperies) { - AMQFrame out(in_place()); + AMQFrame out((AMQHeaderBody())); DeliveryProperties* props1 = out.castBody()->get(true); -- cgit v1.2.1 From ffd20ee19a5fd027e0007c27a12dd402dbeca4f8 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 14 Jul 2009 14:32:39 +0000 Subject: Add directory to #include git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@793909 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/HeaderTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/HeaderTest.cpp') diff --git a/qpid/cpp/src/tests/HeaderTest.cpp b/qpid/cpp/src/tests/HeaderTest.cpp index 01e7c22ee6..ece842fe0e 100644 --- a/qpid/cpp/src/tests/HeaderTest.cpp +++ b/qpid/cpp/src/tests/HeaderTest.cpp @@ -21,7 +21,7 @@ #include #include "qpid/framing/amqp_framing.h" #include "qpid/framing/FieldValue.h" -#include "unit_test.h" +#include "tests/unit_test.h" using namespace qpid::framing; using namespace std; -- cgit v1.2.1 From 795b3bb9e5c033abf33635119694e21e7143fc0a Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 14 Jul 2009 14:41:22 +0000 Subject: Remove incorrect directory from #include git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@793912 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/HeaderTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/HeaderTest.cpp') diff --git a/qpid/cpp/src/tests/HeaderTest.cpp b/qpid/cpp/src/tests/HeaderTest.cpp index ece842fe0e..01e7c22ee6 100644 --- a/qpid/cpp/src/tests/HeaderTest.cpp +++ b/qpid/cpp/src/tests/HeaderTest.cpp @@ -21,7 +21,7 @@ #include #include "qpid/framing/amqp_framing.h" #include "qpid/framing/FieldValue.h" -#include "tests/unit_test.h" +#include "unit_test.h" using namespace qpid::framing; using namespace std; -- cgit v1.2.1 From 9259c46ecb8c5f3e98441080a26914bdea59bffe Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Wed, 9 Sep 2009 19:46:56 +0000 Subject: Tidied up namespace usage Miscelleneous whitespace fixes git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@813094 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/HeaderTest.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'qpid/cpp/src/tests/HeaderTest.cpp') diff --git a/qpid/cpp/src/tests/HeaderTest.cpp b/qpid/cpp/src/tests/HeaderTest.cpp index 01e7c22ee6..4b16f3c793 100644 --- a/qpid/cpp/src/tests/HeaderTest.cpp +++ b/qpid/cpp/src/tests/HeaderTest.cpp @@ -7,9 +7,9 @@ * 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 @@ -26,9 +26,12 @@ using namespace qpid::framing; using namespace std; +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(HeaderTestSuite) -QPID_AUTO_TEST_CASE(testGenericProperties) +QPID_AUTO_TEST_CASE(testGenericProperties) { AMQHeaderBody body; body.get(true)->getApplicationHeaders().setString( @@ -47,10 +50,10 @@ QPID_AUTO_TEST_CASE(testGenericProperties) props->getApplicationHeaders().get("A")->get()); } -QPID_AUTO_TEST_CASE(testMessageProperties) +QPID_AUTO_TEST_CASE(testMessageProperties) { AMQFrame out((AMQHeaderBody())); - MessageProperties* props1 = + MessageProperties* props1 = out.castBody()->get(true); props1->setContentLength(42); @@ -82,10 +85,10 @@ QPID_AUTO_TEST_CASE(testMessageProperties) } -QPID_AUTO_TEST_CASE(testDeliveryProperies) +QPID_AUTO_TEST_CASE(testDeliveryProperies) { AMQFrame out((AMQHeaderBody())); - DeliveryProperties* props1 = + DeliveryProperties* props1 = out.castBody()->get(true); props1->setDiscardUnroutable(true); @@ -108,3 +111,4 @@ QPID_AUTO_TEST_CASE(testDeliveryProperies) QPID_AUTO_TEST_SUITE_END() +}} // namespace qpid::tests -- cgit v1.2.1