diff options
author | Alan Conway <aconway@apache.org> | 2007-11-09 23:30:59 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2007-11-09 23:30:59 +0000 |
commit | e95499012b4663fdaa41a5b875be75492c1c8fb0 (patch) | |
tree | d0996eaa0bd4283431932fe085e6a8972d7598f1 /cpp/src/tests/HeaderTest.cpp | |
parent | b78af32f2bb9c725bacec590dbdeecaec9b2906c (diff) | |
download | qpid-python-e95499012b4663fdaa41a5b875be75492c1c8fb0.tar.gz |
Get rid of BasicHeaderProperties, dead code from 0-8 protocol.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@593692 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/HeaderTest.cpp')
-rw-r--r-- | cpp/src/tests/HeaderTest.cpp | 141 |
1 files changed, 59 insertions, 82 deletions
diff --git a/cpp/src/tests/HeaderTest.cpp b/cpp/src/tests/HeaderTest.cpp index 1b21151b65..21374e30e1 100644 --- a/cpp/src/tests/HeaderTest.cpp +++ b/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<BasicHeaderProperties>(true)->getHeaders().setString("A", "BCDE"); + body.get<MessageProperties>(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<BasicHeaderProperties>(true); - CPPUNIT_ASSERT(StringValue("BCDE") == *props->getHeaders().get("A")); + MessageProperties* props = + body2.get<MessageProperties>(true); + CPPUNIT_ASSERT_EQUAL( + string("BCDE"), + props->getApplicationHeaders().get("A")->get<string>()); } - 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<AMQHeaderBody>()->get<BasicHeaderProperties>(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<AMQHeaderBody>()->get<MessageProperties>(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<AMQHeaderBody>()->get<BasicHeaderProperties>(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<AMQHeaderBody>()->get<MessageProperties>(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<AMQHeaderBody>()->get<DeliveryProperties>(true); - AMQHeaderBody body; - BasicHeaderProperties* properties = - body.get<BasicHeaderProperties>(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<BasicHeaderProperties>(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<AMQHeaderBody>()->get<DeliveryProperties>(true); + + CPPUNIT_ASSERT(props2->getDiscardUnroutable()); + CPPUNIT_ASSERT_EQUAL(string("foo"), props2->getExchange()); + CPPUNIT_ASSERT(!props2->hasTimestamp()); } + }; // Make this test suite a plugin. |