summaryrefslogtreecommitdiff
path: root/cpp/tests/FramingTest.cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2007-01-19 09:37:56 +0000
committerGordon Sim <gsim@apache.org>2007-01-19 09:37:56 +0000
commit380e5b0d75fa8b4a663e39cfed69f81a10ec5980 (patch)
tree6dde5076bc62dd3f611ff1c1aed0b41a556cbd59 /cpp/tests/FramingTest.cpp
parente4410bd1c78aca7e05894e8822306b152ee70f78 (diff)
downloadqpid-python-380e5b0d75fa8b4a663e39cfed69f81a10ec5980.tar.gz
* 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
Diffstat (limited to 'cpp/tests/FramingTest.cpp')
-rw-r--r--cpp/tests/FramingTest.cpp34
1 files changed, 34 insertions, 0 deletions
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 <QpidError.h>
using namespace qpid::framing;
+using qpid::QpidError;
template <class T>
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;