summaryrefslogtreecommitdiff
path: root/cpp/src/tests
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2007-10-16 10:21:20 +0000
committerAndrew Stitcher <astitcher@apache.org>2007-10-16 10:21:20 +0000
commit5113fdd829e956b6836c102c13b83fb8105a7453 (patch)
tree600ada669c06d834c4509ea6c277deeaefc9effa /cpp/src/tests
parent0ae648d78f3970eb7fc96f000a5ba4f6444e4b6e (diff)
downloadqpid-python-5113fdd829e956b6836c102c13b83fb8105a7453.tar.gz
Implementation of 0-10 field tables
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@585097 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests')
-rw-r--r--cpp/src/tests/FieldTableTest.cpp30
-rw-r--r--cpp/src/tests/HeaderTest.cpp6
-rw-r--r--cpp/src/tests/HeadersExchangeTest.cpp18
-rw-r--r--cpp/src/tests/Makefile.am28
-rw-r--r--cpp/src/tests/MessageTest.cpp9
-rw-r--r--cpp/src/tests/topic_listener.cpp8
6 files changed, 54 insertions, 45 deletions
diff --git a/cpp/src/tests/FieldTableTest.cpp b/cpp/src/tests/FieldTableTest.cpp
index deb3655619..b2efb23954 100644
--- a/cpp/src/tests/FieldTableTest.cpp
+++ b/cpp/src/tests/FieldTableTest.cpp
@@ -19,7 +19,9 @@
*
*/
#include <iostream>
-#include "qpid/framing/amqp_framing.h"
+#include "qpid/framing/FieldTable.h"
+#include "qpid/framing/FieldValue.h"
+
#include "qpid_test_plugin.h"
using namespace qpid::framing;
@@ -37,16 +39,16 @@ class FieldTableTest : public CppUnit::TestCase
{
FieldTable ft;
ft.setString("A", "BCDE");
- CPPUNIT_ASSERT_EQUAL(std::string("BCDE"), ft.getString("A"));
+ CPPUNIT_ASSERT(StringValue("BCDE") == *ft.get("A"));
char buff[100];
Buffer wbuffer(buff, 100);
- wbuffer.putFieldTable(ft);
+ wbuffer.put(ft);
Buffer rbuffer(buff, 100);
FieldTable ft2;
- rbuffer.getFieldTable(ft2);
- CPPUNIT_ASSERT_EQUAL(std::string("BCDE"), ft2.getString("A"));
+ rbuffer.get(ft2);
+ CPPUNIT_ASSERT(StringValue("BCDE") == *ft2.get("A"));
}
@@ -60,10 +62,12 @@ class FieldTableTest : public CppUnit::TestCase
b = a;
a.setString("A", "CCCC");
- CPPUNIT_ASSERT_EQUAL(std::string("CCCC"), a.getString("A"));
- CPPUNIT_ASSERT_EQUAL(std::string("BBBB"), b.getString("A"));
+ CPPUNIT_ASSERT(StringValue("CCCC") == *a.get("A"));
+ CPPUNIT_ASSERT(StringValue("BBBB") == *b.get("A"));
CPPUNIT_ASSERT_EQUAL(1234, a.getInt("B"));
CPPUNIT_ASSERT_EQUAL(1234, b.getInt("B"));
+ CPPUNIT_ASSERT(IntegerValue(1234) == *a.get("B"));
+ CPPUNIT_ASSERT(IntegerValue(1234) == *b.get("B"));
FieldTable d;
{
@@ -72,16 +76,16 @@ class FieldTableTest : public CppUnit::TestCase
char* buff = static_cast<char*>(::alloca(c.size()));
Buffer wbuffer(buff, c.size());
- wbuffer.putFieldTable(c);
+ wbuffer.put(c);
Buffer rbuffer(buff, c.size());
- rbuffer.getFieldTable(d);
+ rbuffer.get(d);
CPPUNIT_ASSERT_EQUAL(c, d);
- CPPUNIT_ASSERT_EQUAL(std::string("CCCC"), c.getString("A"));
- CPPUNIT_ASSERT_EQUAL(1234, c.getInt("B"));
+ CPPUNIT_ASSERT(StringValue("CCCC") == *c.get("A"));
+ CPPUNIT_ASSERT(IntegerValue(1234) == *c.get("B"));
}
- CPPUNIT_ASSERT_EQUAL(std::string("CCCC"), d.getString("A"));
- CPPUNIT_ASSERT_EQUAL(1234, d.getInt("B"));
+ CPPUNIT_ASSERT(StringValue("CCCC") == *d.get("A"));
+ CPPUNIT_ASSERT(IntegerValue(1234) == *d.get("B"));
}
};
diff --git a/cpp/src/tests/HeaderTest.cpp b/cpp/src/tests/HeaderTest.cpp
index a883ccf300..1b21151b65 100644
--- a/cpp/src/tests/HeaderTest.cpp
+++ b/cpp/src/tests/HeaderTest.cpp
@@ -20,6 +20,7 @@
*/
#include <iostream>
#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<BasicHeaderProperties>(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<AMQHeaderBody>()->get<BasicHeaderProperties>(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());
diff --git a/cpp/src/tests/HeadersExchangeTest.cpp b/cpp/src/tests/HeadersExchangeTest.cpp
index a7a1001198..14c60449ec 100644
--- a/cpp/src/tests/HeadersExchangeTest.cpp
+++ b/cpp/src/tests/HeadersExchangeTest.cpp
@@ -21,7 +21,7 @@
#include "qpid/broker/HeadersExchange.h"
#include "qpid/framing/FieldTable.h"
-#include "qpid/framing/Value.h"
+#include "qpid/framing/FieldValue.h"
#include "qpid_test_plugin.h"
using namespace qpid::broker;
@@ -41,7 +41,7 @@ class HeadersExchangeTest : public CppUnit::TestCase
void testMatchAll()
{
- FieldTable b, m;
+ FieldTable b, m, n;
b.setString("x-match", "all");
b.setString("foo", "FOO");
b.setInt("n", 42);
@@ -58,20 +58,20 @@ class HeadersExchangeTest : public CppUnit::TestCase
CPPUNIT_ASSERT(!HeadersExchange::match(b, m));
// Fail mismatch, missing value
- m.erase("foo");
- CPPUNIT_ASSERT(!HeadersExchange::match(b, m));
+ n.setInt("n", 42);
+ n.setString("extra", "x");
+ CPPUNIT_ASSERT(!HeadersExchange::match(b, n));
}
void testMatchAny()
{
- FieldTable b, m;
+ FieldTable b, m, n;
b.setString("x-match", "any");
b.setString("foo", "FOO");
b.setInt("n", 42);
m.setString("foo", "FOO");
+ CPPUNIT_ASSERT(!HeadersExchange::match(b, n));
CPPUNIT_ASSERT(HeadersExchange::match(b, m));
- m.erase("foo");
- CPPUNIT_ASSERT(!HeadersExchange::match(b, m));
m.setInt("n", 42);
CPPUNIT_ASSERT(HeadersExchange::match(b, m));
}
@@ -80,8 +80,8 @@ class HeadersExchangeTest : public CppUnit::TestCase
{
FieldTable b, m;
b.setString("x-match", "all");
- b.getMap()["foo"] = FieldTable::ValuePtr(new EmptyValue());
- b.getMap()["n"] = FieldTable::ValuePtr(new EmptyValue());
+ b.set("foo", FieldTable::ValuePtr());
+ b.set("n", FieldTable::ValuePtr());
CPPUNIT_ASSERT(!HeadersExchange::match(b, m));
m.setString("foo", "blah");
m.setInt("n", 123);
diff --git a/cpp/src/tests/Makefile.am b/cpp/src/tests/Makefile.am
index b8622fc925..a1228f91b1 100644
--- a/cpp/src/tests/Makefile.am
+++ b/cpp/src/tests/Makefile.am
@@ -98,7 +98,6 @@ broker_unit_tests = \
TxAckTest \
TxBufferTest \
TxPublishTest \
- ValueTest \
MessageHandlerTest \
MessageBuilderTest \
ClientSessionTest
@@ -127,11 +126,12 @@ unit_tests = \
testprogs= \
client_test \
exception_test \
- echo_service \
topic_listener \
topic_publisher
+# echo_service
-check_PROGRAMS += $(testprogs) interop_runner
+#check_PROGRAMS += $(testprogs) interop_runner
+check_PROGRAMS += $(testprogs)
TESTS_ENVIRONMENT = VALGRIND=$(VALGRIND) srcdir=$(srcdir) $(srcdir)/run_test
@@ -192,14 +192,14 @@ all-am: .valgrind.supp .valgrindrc
CLEANFILES+=valgrind.out *.log *.vglog .valgrindrc .valgrind.supp dummy_test $(unit_wrappers)
MAINTAINERCLEANFILES=gen.mk
-interop_runner_SOURCES = \
- interop_runner.cpp \
- SimpleTestCaseBase.cpp \
- BasicP2PTest.cpp \
- BasicPubSubTest.cpp \
- SimpleTestCaseBase.h \
- BasicP2PTest.h \
- BasicPubSubTest.h \
- TestCase.h \
- TestOptions.h
-interop_runner_LDADD = $(lib_client) $(lib_common) $(extra_libs)
+#interop_runner_SOURCES = \
+# interop_runner.cpp \
+# SimpleTestCaseBase.cpp \
+# BasicP2PTest.cpp \
+# BasicPubSubTest.cpp \
+# SimpleTestCaseBase.h \
+# BasicP2PTest.h \
+# BasicPubSubTest.h \
+# TestCase.h \
+# TestOptions.h
+#interop_runner_LDADD = $(lib_client) $(lib_common) $(extra_libs)
diff --git a/cpp/src/tests/MessageTest.cpp b/cpp/src/tests/MessageTest.cpp
index 775d251349..f56d5e829e 100644
--- a/cpp/src/tests/MessageTest.cpp
+++ b/cpp/src/tests/MessageTest.cpp
@@ -19,12 +19,15 @@
*
*/
#include "qpid/broker/Message.h"
-#include "qpid_test_plugin.h"
-#include <iostream>
#include "qpid/framing/AMQP_HighestVersion.h"
#include "qpid/framing/AMQFrame.h"
+#include "qpid/framing/FieldValue.h"
#include "MockChannel.h"
+#include "qpid_test_plugin.h"
+
+#include <iostream>
+
using namespace boost;
using namespace qpid::broker;
using namespace qpid::framing;
@@ -81,7 +84,7 @@ class MessageTest : public CppUnit::TestCase
CPPUNIT_ASSERT_EQUAL((uint64_t) data1.size() + data2.size(), msg->contentSize());
CPPUNIT_ASSERT_EQUAL((uint64_t) data1.size() + data2.size(), msg->getProperties<MessageProperties>()->getContentLength());
CPPUNIT_ASSERT_EQUAL(messageId, msg->getProperties<MessageProperties>()->getMessageId());
- CPPUNIT_ASSERT_EQUAL(string("xyz"), msg->getProperties<MessageProperties>()->getApplicationHeaders().getString("abc"));
+ CPPUNIT_ASSERT(StringValue("xyz") == *msg->getProperties<MessageProperties>()->getApplicationHeaders().get("abc"));
CPPUNIT_ASSERT_EQUAL((uint8_t) PERSISTENT, msg->getProperties<DeliveryProperties>()->getDeliveryMode());
CPPUNIT_ASSERT(msg->isPersistent());
}
diff --git a/cpp/src/tests/topic_listener.cpp b/cpp/src/tests/topic_listener.cpp
index d19b8f8b19..9369b591a6 100644
--- a/cpp/src/tests/topic_listener.cpp
+++ b/cpp/src/tests/topic_listener.cpp
@@ -40,12 +40,14 @@
#include "qpid/client/MessageListener.h"
#include "qpid/client/Queue.h"
#include "qpid/sys/Time.h"
+#include "qpid/framing/FieldValue.h"
#include <iostream>
#include <sstream>
using namespace qpid;
using namespace qpid::client;
using namespace qpid::sys;
+using namespace qpid::framing;
using namespace std;
/**
@@ -134,11 +136,11 @@ void Listener::received(Message& message){
count = 0;
init = true;
}
- string type(message.getHeaders().getString("TYPE"));
+ FieldTable::ValuePtr type(message.getHeaders().get("TYPE"));
- if(type == "TERMINATION_REQUEST"){
+ if(!!type && StringValue("TERMINATION_REQUEST") == *type){
shutdown();
- }else if(type == "REPORT_REQUEST"){
+ }else if(!!type && StringValue("REPORT_REQUEST") == *type){
//send a report:
report();
init = false;