From 380e5b0d75fa8b4a663e39cfed69f81a10ec5980 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 19 Jan 2007 09:37:56 +0000 Subject: * tests/FramingTest.cpp - added test for validation of content data type * lib/broker/BrokerAdapter.cpp - initial unbind implementation * lib/common/framing/FramingContent.cpp - minor code cleanup git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9@497755 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/tests/FramingTest.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'cpp/tests') diff --git a/cpp/tests/FramingTest.cpp b/cpp/tests/FramingTest.cpp index b081b5822b..445d13e384 100644 --- a/cpp/tests/FramingTest.cpp +++ b/cpp/tests/FramingTest.cpp @@ -30,8 +30,10 @@ #include "AMQResponseBody.h" #include "Requester.h" #include "Responder.h" +#include using namespace qpid::framing; +using qpid::QpidError; template std::string tostring(const T& x) @@ -57,6 +59,7 @@ class FramingTest : public CppUnit::TestCase CPPUNIT_TEST(testResponder); CPPUNIT_TEST(testInlineContent); CPPUNIT_TEST(testContentReference); + CPPUNIT_TEST(testContentValidation); CPPUNIT_TEST_SUITE_END(); private: @@ -199,6 +202,37 @@ class FramingTest : public CppUnit::TestCase CPPUNIT_ASSERT_EQUAL(content.getValue(), recovered.getValue()); } + void testContentValidation() { + try { + Content content(REFERENCE, ""); + CPPUNIT_ASSERT(false);//fail, expected exception + } catch (QpidError& e) { + CPPUNIT_ASSERT_EQUAL(FRAMING_ERROR, e.code); + CPPUNIT_ASSERT_EQUAL(string("Reference cannot be empty"), e.msg); + } + + try { + Content content(2, "Blah"); + CPPUNIT_ASSERT(false);//fail, expected exception + } catch (QpidError& e) { + CPPUNIT_ASSERT_EQUAL(FRAMING_ERROR, e.code); + CPPUNIT_ASSERT_EQUAL(string("Invalid discriminator: 2"), e.msg); + } + + try { + buffer.putOctet(2); + buffer.putLongString("blah, blah"); + buffer.flip(); + Content content; + content.decode(buffer); + CPPUNIT_ASSERT(false);//fail, expected exception + } catch (QpidError& e) { + CPPUNIT_ASSERT_EQUAL(FRAMING_ERROR, e.code); + CPPUNIT_ASSERT_EQUAL(string("Invalid discriminator: 2"), e.msg); + } + + } + void testRequester() { Requester r; AMQRequestBody::Data q; -- cgit v1.2.1