From b90ceab30a9f2040a868e76c90af47f09b4cbbb2 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 16 Oct 2006 14:12:49 +0000 Subject: Renamed unit tests to follow naming conventions, fixed some #include inconsistencies. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@464503 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/test/unit/qpid/broker/ChannelTest.cpp | 4 +- cpp/test/unit/qpid/broker/ExchangeTest.cpp | 8 +- cpp/test/unit/qpid/broker/HeadersExchangeTest.cpp | 6 +- cpp/test/unit/qpid/broker/MessageTest.cpp | 4 +- cpp/test/unit/qpid/broker/QueueRegistryTest.cpp | 2 +- cpp/test/unit/qpid/broker/QueueTest.cpp | 4 +- cpp/test/unit/qpid/broker/RouterTest.cpp | 10 +- cpp/test/unit/qpid/broker/TopicExchangeTest.cpp | 2 +- cpp/test/unit/qpid/broker/ValueTest.cpp | 2 +- cpp/test/unit/qpid/framing/BodyHandlerTest.cpp | 2 +- cpp/test/unit/qpid/framing/FieldTableTest.cpp | 52 ++++++++ cpp/test/unit/qpid/framing/FramingTest.cpp | 144 ++++++++++++++++++++++ cpp/test/unit/qpid/framing/HeaderTest.cpp | 141 +++++++++++++++++++++ cpp/test/unit/qpid/framing/field_table_test.cpp | 52 -------- cpp/test/unit/qpid/framing/framing_test.cpp | 144 ---------------------- cpp/test/unit/qpid/framing/header_test.cpp | 141 --------------------- 16 files changed, 359 insertions(+), 359 deletions(-) create mode 100644 cpp/test/unit/qpid/framing/FieldTableTest.cpp create mode 100644 cpp/test/unit/qpid/framing/FramingTest.cpp create mode 100644 cpp/test/unit/qpid/framing/HeaderTest.cpp delete mode 100644 cpp/test/unit/qpid/framing/field_table_test.cpp delete mode 100644 cpp/test/unit/qpid/framing/framing_test.cpp delete mode 100644 cpp/test/unit/qpid/framing/header_test.cpp (limited to 'cpp/test/unit') diff --git a/cpp/test/unit/qpid/broker/ChannelTest.cpp b/cpp/test/unit/qpid/broker/ChannelTest.cpp index 8d54208f77..2197c1724a 100644 --- a/cpp/test/unit/qpid/broker/ChannelTest.cpp +++ b/cpp/test/unit/qpid/broker/ChannelTest.cpp @@ -15,8 +15,8 @@ * limitations under the License. * */ -#include "../../src/qpid/broker/Channel.h" -#include "../../src/qpid/broker/Message.h" +#include "qpid/broker/Channel.h" +#include "qpid/broker/Message.h" #include #include #include diff --git a/cpp/test/unit/qpid/broker/ExchangeTest.cpp b/cpp/test/unit/qpid/broker/ExchangeTest.cpp index 3d21cb66f0..adebc87422 100644 --- a/cpp/test/unit/qpid/broker/ExchangeTest.cpp +++ b/cpp/test/unit/qpid/broker/ExchangeTest.cpp @@ -16,10 +16,10 @@ * */ -#include "../../src/qpid/broker/DirectExchange.h" -#include "../../src/qpid/broker/Exchange.h" -#include "../../src/qpid/broker/Queue.h" -#include "../../src/qpid/broker/TopicExchange.h" +#include "qpid/broker/DirectExchange.h" +#include "qpid/broker/Exchange.h" +#include "qpid/broker/Queue.h" +#include "qpid/broker/TopicExchange.h" #include #include diff --git a/cpp/test/unit/qpid/broker/HeadersExchangeTest.cpp b/cpp/test/unit/qpid/broker/HeadersExchangeTest.cpp index d8fe71350e..a57c1d8800 100644 --- a/cpp/test/unit/qpid/broker/HeadersExchangeTest.cpp +++ b/cpp/test/unit/qpid/broker/HeadersExchangeTest.cpp @@ -16,9 +16,9 @@ * */ -#include "../../src/qpid/broker/HeadersExchange.h" -#include "../../src/qpid/framing/FieldTable.h" -#include "../../src/qpid/framing/Value.h" +#include "qpid/broker/HeadersExchange.h" +#include "qpid/framing/FieldTable.h" +#include "qpid/framing/Value.h" #include using namespace qpid::broker; diff --git a/cpp/test/unit/qpid/broker/MessageTest.cpp b/cpp/test/unit/qpid/broker/MessageTest.cpp index f6586f721a..210cd63934 100644 --- a/cpp/test/unit/qpid/broker/MessageTest.cpp +++ b/cpp/test/unit/qpid/broker/MessageTest.cpp @@ -15,8 +15,8 @@ * limitations under the License. * */ -#include "../../src/qpid/concurrent/APRBase.h" -#include "../../src/qpid/broker/Message.h" +#include "qpid/concurrent/APRBase.h" +#include "qpid/broker/Message.h" #include #include diff --git a/cpp/test/unit/qpid/broker/QueueRegistryTest.cpp b/cpp/test/unit/qpid/broker/QueueRegistryTest.cpp index 96fbc88069..59034fb7c8 100644 --- a/cpp/test/unit/qpid/broker/QueueRegistryTest.cpp +++ b/cpp/test/unit/qpid/broker/QueueRegistryTest.cpp @@ -1,4 +1,4 @@ -#include "../../src/qpid/broker/QueueRegistry.h" +#include "qpid/broker/QueueRegistry.h" #include #include diff --git a/cpp/test/unit/qpid/broker/QueueTest.cpp b/cpp/test/unit/qpid/broker/QueueTest.cpp index fa6344c265..5b06cb93ca 100644 --- a/cpp/test/unit/qpid/broker/QueueTest.cpp +++ b/cpp/test/unit/qpid/broker/QueueTest.cpp @@ -15,8 +15,8 @@ * limitations under the License. * */ -#include "../../src/qpid/broker/Queue.h" -#include "../../src/qpid/broker/QueueRegistry.h" +#include "qpid/broker/Queue.h" +#include "qpid/broker/QueueRegistry.h" #include #include diff --git a/cpp/test/unit/qpid/broker/RouterTest.cpp b/cpp/test/unit/qpid/broker/RouterTest.cpp index 7b77162905..f2c9f27abd 100644 --- a/cpp/test/unit/qpid/broker/RouterTest.cpp +++ b/cpp/test/unit/qpid/broker/RouterTest.cpp @@ -15,11 +15,11 @@ * limitations under the License. * */ -#include "../../src/qpid/broker/Channel.h" -#include "../../src/qpid/broker/Exchange.h" -#include "../../src/qpid/broker/ExchangeRegistry.h" -#include "../../src/qpid/broker/Message.h" -#include "../../src/qpid/broker/Router.h" +#include "qpid/broker/Channel.h" +#include "qpid/broker/Exchange.h" +#include "qpid/broker/ExchangeRegistry.h" +#include "qpid/broker/Message.h" +#include "qpid/broker/Router.h" #include #include #include diff --git a/cpp/test/unit/qpid/broker/TopicExchangeTest.cpp b/cpp/test/unit/qpid/broker/TopicExchangeTest.cpp index 4066a4709f..8d7903c4ac 100644 --- a/cpp/test/unit/qpid/broker/TopicExchangeTest.cpp +++ b/cpp/test/unit/qpid/broker/TopicExchangeTest.cpp @@ -1,4 +1,4 @@ -#include "../../src/qpid/broker/TopicExchange.h" +#include "qpid/broker/TopicExchange.h" #include using namespace qpid::broker; diff --git a/cpp/test/unit/qpid/broker/ValueTest.cpp b/cpp/test/unit/qpid/broker/ValueTest.cpp index 89444c38cf..2cb2563b46 100644 --- a/cpp/test/unit/qpid/broker/ValueTest.cpp +++ b/cpp/test/unit/qpid/broker/ValueTest.cpp @@ -1,4 +1,4 @@ -#include "../../src/qpid/framing/Value.h" +#include "qpid/framing/Value.h" #include using namespace qpid::framing; diff --git a/cpp/test/unit/qpid/framing/BodyHandlerTest.cpp b/cpp/test/unit/qpid/framing/BodyHandlerTest.cpp index 6b011743c0..d6edf37d51 100644 --- a/cpp/test/unit/qpid/framing/BodyHandlerTest.cpp +++ b/cpp/test/unit/qpid/framing/BodyHandlerTest.cpp @@ -16,7 +16,7 @@ * */ #include -#include "../../src/qpid/framing/amqp_framing.h" +#include "qpid/framing/amqp_framing.h" #include "qpid_test_plugin.h" using namespace qpid::framing; diff --git a/cpp/test/unit/qpid/framing/FieldTableTest.cpp b/cpp/test/unit/qpid/framing/FieldTableTest.cpp new file mode 100644 index 0000000000..b11addfd0e --- /dev/null +++ b/cpp/test/unit/qpid/framing/FieldTableTest.cpp @@ -0,0 +1,52 @@ +/* + * + * 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 +#include "qpid/framing/amqp_framing.h" +#include + +using namespace qpid::framing; + +class FieldTableTest : public CppUnit::TestCase +{ + CPPUNIT_TEST_SUITE(FieldTableTest); + CPPUNIT_TEST(testMe); + CPPUNIT_TEST_SUITE_END(); + + public: + + void testMe() + { + FieldTable ft; + ft.setString("A", "BCDE"); + CPPUNIT_ASSERT_EQUAL(std::string("BCDE"), ft.getString("A")); + + Buffer buffer(100); + buffer.putFieldTable(ft); + buffer.flip(); + FieldTable ft2; + buffer.getFieldTable(ft2); + CPPUNIT_ASSERT_EQUAL(std::string("BCDE"), ft2.getString("A")); + + } +}; + + +// Make this test suite a plugin. +CPPUNIT_PLUGIN_IMPLEMENT(); +CPPUNIT_TEST_SUITE_REGISTRATION(FieldTableTest); + diff --git a/cpp/test/unit/qpid/framing/FramingTest.cpp b/cpp/test/unit/qpid/framing/FramingTest.cpp new file mode 100644 index 0000000000..950d1e045a --- /dev/null +++ b/cpp/test/unit/qpid/framing/FramingTest.cpp @@ -0,0 +1,144 @@ +/* + * + * 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/amqp_framing.h" +#include "qpid/framing/ConnectionRedirectBody.h" +#include +#include +#include +#include + +using namespace qpid::framing; + +// TODO aconway 2006-09-12: Why do we need explicit qpid::framing:: below? + +template +std::string tostring(const T& x) +{ + std::ostringstream out; + out << x; + return out.str(); +} + +class FramingTest : public CppUnit::TestCase +{ + CPPUNIT_TEST_SUITE(FramingTest); + CPPUNIT_TEST(testBasicQosBody); + CPPUNIT_TEST(testConnectionSecureBody); + CPPUNIT_TEST(testConnectionRedirectBody); + CPPUNIT_TEST(testAccessRequestBody); + CPPUNIT_TEST(testBasicConsumeBody); + CPPUNIT_TEST(ConnectionRedirectBody); + CPPUNIT_TEST(BasicConsumeOkBody); + CPPUNIT_TEST_SUITE_END(); + + private: + Buffer buffer; + + public: + + FramingTest() : buffer(100) {} + + void testBasicQosBody() + { + BasicQosBody in(0xCAFEBABE, 0xABBA, true); + in.encodeContent(buffer); + buffer.flip(); + BasicQosBody out; + out.decodeContent(buffer); + CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out)); + } + + void testConnectionSecureBody() + { + std::string s = "security credential"; + ConnectionSecureBody in(s); + in.encodeContent(buffer); + buffer.flip(); + ConnectionSecureBody out; + out.decodeContent(buffer); + CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out)); + } + + void testConnectionRedirectBody() + { + std::string a = "hostA"; + std::string b = "hostB"; + qpid::framing::ConnectionRedirectBody in(a, b); + in.encodeContent(buffer); + buffer.flip(); + qpid::framing::ConnectionRedirectBody out; + out.decodeContent(buffer); + CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out)); + } + + void testAccessRequestBody() + { + std::string s = "text"; + AccessRequestBody in(s, true, false, true, false, true); + in.encodeContent(buffer); + buffer.flip(); + AccessRequestBody out; + out.decodeContent(buffer); + CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out)); + } + + void testBasicConsumeBody() + { + std::string q = "queue"; + std::string t = "tag"; + BasicConsumeBody in(0, q, t, false, true, false, false); + in.encodeContent(buffer); + buffer.flip(); + BasicConsumeBody out; + out.decodeContent(buffer); + CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out)); + } + + + void ConnectionRedirectBody() + { + std::string a = "hostA"; + std::string b = "hostB"; + AMQFrame in(999, new qpid::framing::ConnectionRedirectBody(a, b)); + in.encode(buffer); + buffer.flip(); + AMQFrame out; + out.decode(buffer); + CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out)); + } + + void BasicConsumeOkBody() + { + std::string s = "hostA"; + AMQFrame in(999, new qpid::framing::BasicConsumeOkBody(s)); + in.encode(buffer); + buffer.flip(); + AMQFrame out; + for(int i = 0; i < 5; i++){ + out.decode(buffer); + CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out)); + } + } +}; + +// Make this test suite a plugin. +CPPUNIT_PLUGIN_IMPLEMENT(); +CPPUNIT_TEST_SUITE_REGISTRATION(FramingTest); + + + diff --git a/cpp/test/unit/qpid/framing/HeaderTest.cpp b/cpp/test/unit/qpid/framing/HeaderTest.cpp new file mode 100644 index 0000000000..cf0d9fe5bd --- /dev/null +++ b/cpp/test/unit/qpid/framing/HeaderTest.cpp @@ -0,0 +1,141 @@ +/* + * + * 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 +#include "qpid/framing/amqp_framing.h" +#include + +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: + + // TODO aconway 2006-09-12: Need more detailed tests, + // need tests to assert something! + // + 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"); + u_int8_t deliveryMode(2); + u_int8_t priority(3); + string correlationId("abc"); + string replyTo("no-address"); + string expiration("why is this a string?"); + string messageId("xyz"); + u_int64_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"); + u_int8_t deliveryMode(5); + u_int8_t priority(6); + string expiration("Z"); + u_int64_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); + diff --git a/cpp/test/unit/qpid/framing/field_table_test.cpp b/cpp/test/unit/qpid/framing/field_table_test.cpp deleted file mode 100644 index 8f2fe61611..0000000000 --- a/cpp/test/unit/qpid/framing/field_table_test.cpp +++ /dev/null @@ -1,52 +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 -#include "../../src/qpid/framing/amqp_framing.h" -#include - -using namespace qpid::framing; - -class FieldTableTest : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(FieldTableTest); - CPPUNIT_TEST(testMe); - CPPUNIT_TEST_SUITE_END(); - - public: - - void testMe() - { - FieldTable ft; - ft.setString("A", "BCDE"); - CPPUNIT_ASSERT_EQUAL(std::string("BCDE"), ft.getString("A")); - - Buffer buffer(100); - buffer.putFieldTable(ft); - buffer.flip(); - FieldTable ft2; - buffer.getFieldTable(ft2); - CPPUNIT_ASSERT_EQUAL(std::string("BCDE"), ft2.getString("A")); - - } -}; - - -// Make this test suite a plugin. -CPPUNIT_PLUGIN_IMPLEMENT(); -CPPUNIT_TEST_SUITE_REGISTRATION(FieldTableTest); - diff --git a/cpp/test/unit/qpid/framing/framing_test.cpp b/cpp/test/unit/qpid/framing/framing_test.cpp deleted file mode 100644 index 40ce3d97ed..0000000000 --- a/cpp/test/unit/qpid/framing/framing_test.cpp +++ /dev/null @@ -1,144 +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 "../../src/qpid/framing/amqp_framing.h" -#include "ConnectionRedirectBody.h" -#include -#include -#include -#include - -using namespace qpid::framing; - -// TODO aconway 2006-09-12: Why do we need explicit qpid::framing:: below? - -template -std::string tostring(const T& x) -{ - std::ostringstream out; - out << x; - return out.str(); -} - -class FramingTest : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(FramingTest); - CPPUNIT_TEST(testBasicQosBody); - CPPUNIT_TEST(testConnectionSecureBody); - CPPUNIT_TEST(testConnectionRedirectBody); - CPPUNIT_TEST(testAccessRequestBody); - CPPUNIT_TEST(testBasicConsumeBody); - CPPUNIT_TEST(ConnectionRedirectBody); - CPPUNIT_TEST(BasicConsumeOkBody); - CPPUNIT_TEST_SUITE_END(); - - private: - Buffer buffer; - - public: - - FramingTest() : buffer(100) {} - - void testBasicQosBody() - { - BasicQosBody in(0xCAFEBABE, 0xABBA, true); - in.encodeContent(buffer); - buffer.flip(); - BasicQosBody out; - out.decodeContent(buffer); - CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out)); - } - - void testConnectionSecureBody() - { - std::string s = "security credential"; - ConnectionSecureBody in(s); - in.encodeContent(buffer); - buffer.flip(); - ConnectionSecureBody out; - out.decodeContent(buffer); - CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out)); - } - - void testConnectionRedirectBody() - { - std::string a = "hostA"; - std::string b = "hostB"; - qpid::framing::ConnectionRedirectBody in(a, b); - in.encodeContent(buffer); - buffer.flip(); - qpid::framing::ConnectionRedirectBody out; - out.decodeContent(buffer); - CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out)); - } - - void testAccessRequestBody() - { - std::string s = "text"; - AccessRequestBody in(s, true, false, true, false, true); - in.encodeContent(buffer); - buffer.flip(); - AccessRequestBody out; - out.decodeContent(buffer); - CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out)); - } - - void testBasicConsumeBody() - { - std::string q = "queue"; - std::string t = "tag"; - BasicConsumeBody in(0, q, t, false, true, false, false); - in.encodeContent(buffer); - buffer.flip(); - BasicConsumeBody out; - out.decodeContent(buffer); - CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out)); - } - - - void ConnectionRedirectBody() - { - std::string a = "hostA"; - std::string b = "hostB"; - AMQFrame in(999, new qpid::framing::ConnectionRedirectBody(a, b)); - in.encode(buffer); - buffer.flip(); - AMQFrame out; - out.decode(buffer); - CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out)); - } - - void BasicConsumeOkBody() - { - std::string s = "hostA"; - AMQFrame in(999, new qpid::framing::BasicConsumeOkBody(s)); - in.encode(buffer); - buffer.flip(); - AMQFrame out; - for(int i = 0; i < 5; i++){ - out.decode(buffer); - CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out)); - } - } -}; - -// Make this test suite a plugin. -CPPUNIT_PLUGIN_IMPLEMENT(); -CPPUNIT_TEST_SUITE_REGISTRATION(FramingTest); - - - diff --git a/cpp/test/unit/qpid/framing/header_test.cpp b/cpp/test/unit/qpid/framing/header_test.cpp deleted file mode 100644 index 9268c54272..0000000000 --- a/cpp/test/unit/qpid/framing/header_test.cpp +++ /dev/null @@ -1,141 +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 -#include "../../src/qpid/framing/amqp_framing.h" -#include - -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: - - // TODO aconway 2006-09-12: Need more detailed tests, - // need tests to assert something! - // - 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"); - u_int8_t deliveryMode(2); - u_int8_t priority(3); - string correlationId("abc"); - string replyTo("no-address"); - string expiration("why is this a string?"); - string messageId("xyz"); - u_int64_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"); - u_int8_t deliveryMode(5); - u_int8_t priority(6); - string expiration("Z"); - u_int64_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