You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2006/12/01 06:11:53 UTC

svn commit: r481159 [11/12] - in /incubator/qpid/trunk/qpid/cpp: ./ build-aux/ gen/ lib/ lib/broker/ lib/client/ lib/common/ lib/common/framing/ lib/common/sys/ lib/common/sys/apr/ lib/common/sys/posix/ m4/ src/ src/qpid/ src/qpid/apr/ src/qpid/broker/...

Added: incubator/qpid/trunk/qpid/cpp/lib/common/sys/posix/check.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/sys/posix/check.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/sys/posix/check.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/sys/posix/check.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,62 @@
+#ifndef _posix_check_h
+#define _posix_check_h
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <cerrno>
+#include <string>
+#include <QpidError.h>
+
+namespace qpid {
+namespace sys {
+
+/**
+ * Exception with message from errno.
+ */
+class PosixError : public qpid::QpidError
+{
+  public:
+    static std::string getMessage(int errNo);
+    
+    PosixError(int errNo, const qpid::SrcLine& location) throw();
+    
+    ~PosixError() throw() {}
+    
+    int getErrNo() { return errNo; }
+
+    Exception* clone() const throw() { return new PosixError(*this); }
+        
+    void throwSelf() { throw *this; }
+
+  private:
+    int errNo;
+};
+
+}}
+
+/** Create a PosixError for the current file/line and errno. */
+#define QPID_POSIX_ERROR(errNo) ::qpid::sys::PosixError(errNo, SRCLINE)
+
+/** Throw a posix error if errNo is non-zero */
+#define QPID_POSIX_THROW_IF(ERRNO)              \
+    if ((ERRNO) != 0) throw QPID_POSIX_ERROR((ERRNO))
+#endif  /*!_posix_check_h*/

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/sys/posix/check.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/sys/posix/check.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/m4/clock_time.m4
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/m4/clock_time.m4?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/m4/clock_time.m4 (added)
+++ incubator/qpid/trunk/qpid/cpp/m4/clock_time.m4 Thu Nov 30 21:11:45 2006
@@ -0,0 +1,30 @@
+# clock_time.m4 serial 8
+dnl Copyright (C) 2002-2006 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# Check for clock_gettime and clock_settime, and set LIB_CLOCK_GETTIME.
+# For a program named, say foo, you should add a line like the following
+# in the corresponding Makefile.am file:
+# foo_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
+
+AC_DEFUN([gl_CLOCK_TIME],
+[
+  dnl Persuade glibc and Solaris <time.h> to declare these functions.
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+  # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function.
+  # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
+
+  # Save and restore LIBS so e.g., -lrt, isn't added to it.  Otherwise, *all*
+  # programs in the package would end up linked with that potentially-shared
+  # library, inducing unnecessary run-time overhead.
+  gl_saved_libs=$LIBS
+    AC_SEARCH_LIBS(clock_gettime, [rt posix4],
+                   [test "$ac_cv_search_clock_gettime" = "none required" ||
+                    LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime])
+    AC_SUBST([LIB_CLOCK_GETTIME])
+    AC_CHECK_FUNCS(clock_gettime clock_settime)
+  LIBS=$gl_saved_libs
+])

Added: incubator/qpid/trunk/qpid/cpp/m4/compiler-flags.m4
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/m4/compiler-flags.m4?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/m4/compiler-flags.m4 (added)
+++ incubator/qpid/trunk/qpid/cpp/m4/compiler-flags.m4 Thu Nov 30 21:11:45 2006
@@ -0,0 +1,23 @@
+# serial 3
+# Find valid warning flags for the C Compiler.           -*-Autoconf-*-
+dnl Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl Written by Jesse Thilo.
+
+AC_DEFUN([gl_COMPILER_FLAGS],
+  [AC_MSG_CHECKING(whether compiler accepts $1)
+   AC_SUBST(COMPILER_FLAGS)
+   ac_save_CFLAGS="$CFLAGS"
+   CFLAGS="$CFLAGS $1"
+   ac_save_CXXFLAGS="$CXXFLAGS"
+   CXXFLAGS="$CXXFLAGS $1"
+   AC_TRY_COMPILE(,
+    [int x;],
+    COMPILER_FLAGS="$COMPILER_FLAGS $1"
+    AC_MSG_RESULT(yes),
+    AC_MSG_RESULT(no))
+  CFLAGS="$ac_save_CFLAGS"
+  CXXFLAGS="$ac_save_CXXFLAGS"
+ ])

Added: incubator/qpid/trunk/qpid/cpp/m4/extensions.m4
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/m4/extensions.m4?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/m4/extensions.m4 (added)
+++ incubator/qpid/trunk/qpid/cpp/m4/extensions.m4 Thu Nov 30 21:11:45 2006
@@ -0,0 +1,58 @@
+# serial 4  -*- Autoconf -*-
+# Enable extensions on systems that normally disable them.
+
+# Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS
+# Autoconf.  Perhaps we can remove this once we can assume Autoconf
+# 2.61 or later everywhere, but since CVS Autoconf mutates rapidly
+# enough in this area it's likely we'll need to redefine
+# AC_USE_SYSTEM_EXTENSIONS for quite some time.
+
+# AC_USE_SYSTEM_EXTENSIONS
+# ------------------------
+# Enable extensions on systems that normally disable them,
+# typically due to standards-conformance issues.
+AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS],
+[
+  AC_BEFORE([$0], [AC_COMPILE_IFELSE])
+  AC_BEFORE([$0], [AC_RUN_IFELSE])
+
+  AC_REQUIRE([AC_GNU_SOURCE])
+  AC_REQUIRE([AC_AIX])
+  AC_REQUIRE([AC_MINIX])
+
+  AH_VERBATIM([__EXTENSIONS__],
+[/* Enable extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif])
+  AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
+    [ac_cv_safe_to_define___extensions__],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM([
+#	  define __EXTENSIONS__ 1
+	  AC_INCLUDES_DEFAULT])],
+       [ac_cv_safe_to_define___extensions__=yes],
+       [ac_cv_safe_to_define___extensions__=no])])
+  test $ac_cv_safe_to_define___extensions__ = yes &&
+    AC_DEFINE([__EXTENSIONS__])
+  AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
+  AC_DEFINE([_TANDEM_SOURCE])
+])
+
+# gl_USE_SYSTEM_EXTENSIONS
+# ------------------------
+# Enable extensions on systems that normally disable them,
+# typically due to standards-conformance issues.
+AC_DEFUN([gl_USE_SYSTEM_EXTENSIONS],
+  [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])])

Added: incubator/qpid/trunk/qpid/cpp/src/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/Makefile.am?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/Makefile.am (added)
+++ incubator/qpid/trunk/qpid/cpp/src/Makefile.am Thu Nov 30 21:11:45 2006
@@ -0,0 +1,14 @@
+AM_CXXFLAGS = $(WARNING_CFLAGS)
+INCLUDES = \
+  -I$(top_srcdir)/gen \
+  -I$(top_srcdir)/lib/broker \
+  -I$(top_srcdir)/lib/common \
+  -I$(top_srcdir)/lib/common/framing \
+  -I$(top_srcdir)/lib/common/sys
+
+LDADD =				\
+  ../lib/broker/libbroker.la	\
+  ../lib/common/libcommon.la
+
+bin_PROGRAMS = qpidd
+qpidd_SOURCES = qpidd.cpp

Added: incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,54 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <Broker.h>
+#include <Configuration.h>
+// FIXME #include <sys/signal.h>
+#include <iostream>
+#include <memory>
+
+using namespace qpid::broker;
+using namespace qpid::sys;
+
+Broker::shared_ptr broker;
+
+void handle_signal(int /*signal*/){
+    std::cout << "Shutting down..." << std::endl;
+    broker->shutdown();
+}
+
+int main(int argc, char** argv)
+{
+    Configuration config;
+    try {
+        config.parse(argc, argv);
+        if(config.isHelp()){
+            config.usage();
+        }else{
+            broker = Broker::create(config);
+// FIXME             qpid::sys::signal(SIGINT, handle_signal);
+            broker->run();
+        }
+        return 0;
+    } catch(const std::exception& e) {
+        std::cout << e.what() << std::endl;
+    }
+    return 1;
+}

Added: incubator/qpid/trunk/qpid/cpp/tests/APRBaseTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/tests/APRBaseTest.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/tests/APRBaseTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/tests/APRBaseTest.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,47 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <apr/APRBase.h>
+#include <qpid_test_plugin.h>
+#include <iostream>
+
+using namespace qpid::sys;
+
+class APRBaseTest : public CppUnit::TestCase  
+{
+    CPPUNIT_TEST_SUITE(APRBaseTest);
+    CPPUNIT_TEST(testMe);
+    CPPUNIT_TEST_SUITE_END();
+
+  public:
+
+    void testMe() 
+    {
+        APRBase::increment();
+        APRBase::increment();
+        APRBase::decrement();
+        APRBase::decrement();
+    }
+};
+
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(APRBaseTest);
+

Propchange: incubator/qpid/trunk/qpid/cpp/tests/APRBaseTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/tests/APRBaseTest.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/tests/AccumulatedAckTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/tests/AccumulatedAckTest.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/tests/AccumulatedAckTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/tests/AccumulatedAckTest.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,85 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <AccumulatedAck.h>
+#include <qpid_test_plugin.h>
+#include <iostream>
+#include <list>
+
+using std::list;
+using namespace qpid::broker;
+
+class AccumulatedAckTest : public CppUnit::TestCase  
+{
+        CPPUNIT_TEST_SUITE(AccumulatedAckTest);
+        CPPUNIT_TEST(testCovers);
+        CPPUNIT_TEST(testUpdateAndConsolidate);
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+        void testCovers()
+        {
+            AccumulatedAck ack;
+            ack.range = 5;
+            ack.individual.push_back(7);
+            ack.individual.push_back(9);
+            
+            CPPUNIT_ASSERT(ack.covers(1));
+            CPPUNIT_ASSERT(ack.covers(2));
+            CPPUNIT_ASSERT(ack.covers(3));
+            CPPUNIT_ASSERT(ack.covers(4));
+            CPPUNIT_ASSERT(ack.covers(5));
+            CPPUNIT_ASSERT(ack.covers(7));
+            CPPUNIT_ASSERT(ack.covers(9));
+
+            CPPUNIT_ASSERT(!ack.covers(6));
+            CPPUNIT_ASSERT(!ack.covers(8));
+            CPPUNIT_ASSERT(!ack.covers(10));
+        }
+
+        void testUpdateAndConsolidate()
+        {
+            AccumulatedAck ack;
+            ack.clear();
+            ack.update(1, false);
+            ack.update(3, false);
+            ack.update(10, false);
+            ack.update(8, false);
+            ack.update(6, false);
+            ack.update(3, true);
+            ack.update(2, true);
+            ack.update(5, true);
+            ack.consolidate();
+            CPPUNIT_ASSERT_EQUAL((u_int64_t) 5, ack.range);
+            CPPUNIT_ASSERT_EQUAL((size_t) 3, ack.individual.size());
+            list<u_int64_t>::iterator i = ack.individual.begin();
+            CPPUNIT_ASSERT_EQUAL((u_int64_t) 6, *i);
+            i++;
+            CPPUNIT_ASSERT_EQUAL((u_int64_t) 8, *i);
+            i++;
+            CPPUNIT_ASSERT_EQUAL((u_int64_t) 10, *i);
+
+        }
+};
+
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(AccumulatedAckTest);
+

Propchange: incubator/qpid/trunk/qpid/cpp/tests/AccumulatedAckTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/tests/AccumulatedAckTest.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/tests/BodyHandlerTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/tests/BodyHandlerTest.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/tests/BodyHandlerTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/tests/BodyHandlerTest.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,109 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <iostream>
+#include <amqp_framing.h>
+#include <qpid_test_plugin.h>
+using namespace qpid::framing;
+
+class BodyHandlerTest : public CppUnit::TestCase  
+{
+    CPPUNIT_TEST_SUITE(BodyHandlerTest);
+    CPPUNIT_TEST(testMethod);
+    CPPUNIT_TEST(testHeader);
+    CPPUNIT_TEST(testContent);
+    CPPUNIT_TEST(testHeartbeat);
+    CPPUNIT_TEST_SUITE_END();
+private:
+
+    class TestBodyHandler : public BodyHandler{
+        AMQMethodBody* const method;
+        AMQHeaderBody* const header;
+        AMQContentBody* const content;
+        AMQHeartbeatBody* const heartbeat;        
+
+    public:
+
+        TestBodyHandler(AMQMethodBody* _method) : method(_method), header(0), content(0), heartbeat(0){}
+        TestBodyHandler(AMQHeaderBody* _header) : method(0), header(_header), content(0), heartbeat(0){}
+        TestBodyHandler(AMQContentBody* _content) : method(0), header(0), content(_content), heartbeat(0){}
+        TestBodyHandler(AMQHeartbeatBody* _heartbeat) : method(0), header(0), content(0), heartbeat(_heartbeat){}
+
+	virtual void handleMethod(AMQMethodBody::shared_ptr body){
+            CPPUNIT_ASSERT(method);
+            CPPUNIT_ASSERT_EQUAL(method, body.get());
+        }
+	virtual void handleHeader(AMQHeaderBody::shared_ptr body){
+            CPPUNIT_ASSERT(header);
+            CPPUNIT_ASSERT_EQUAL(header, body.get());
+        }
+	virtual void handleContent(AMQContentBody::shared_ptr body){
+            CPPUNIT_ASSERT(content);
+            CPPUNIT_ASSERT_EQUAL(content, body.get());
+        }
+	virtual void handleHeartbeat(AMQHeartbeatBody::shared_ptr body){
+            CPPUNIT_ASSERT(heartbeat);
+            CPPUNIT_ASSERT_EQUAL(heartbeat, body.get());
+        }
+    };
+  	ProtocolVersion v;
+
+public:
+        
+    BodyHandlerTest() : v(8, 0) {}
+
+    void testMethod() 
+    {
+        AMQMethodBody* method = new QueueDeclareBody(v);
+        AMQFrame frame(0, method);
+        TestBodyHandler handler(method);
+        handler.handleBody(frame.getBody());
+    }
+
+    void testHeader() 
+    {
+        AMQHeaderBody* header = new AMQHeaderBody();
+        AMQFrame frame(0, header);
+        TestBodyHandler handler(header);
+        handler.handleBody(frame.getBody());
+    }
+
+    void testContent() 
+    {
+        AMQContentBody* content = new AMQContentBody();
+        AMQFrame frame(0, content);
+        TestBodyHandler handler(content);
+        handler.handleBody(frame.getBody());
+    }
+
+    void testHeartbeat() 
+    {
+        AMQHeartbeatBody* heartbeat = new AMQHeartbeatBody();
+        AMQFrame frame(0, heartbeat);
+        TestBodyHandler handler(heartbeat);
+        handler.handleBody(frame.getBody());
+    }
+};
+
+
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(BodyHandlerTest);
+

Propchange: incubator/qpid/trunk/qpid/cpp/tests/BodyHandlerTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/tests/BodyHandlerTest.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/tests/ChannelTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/tests/ChannelTest.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/tests/ChannelTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/tests/ChannelTest.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,138 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <BrokerChannel.h>
+#include <BrokerMessage.h>
+#include <qpid_test_plugin.h>
+#include <iostream>
+#include <memory>
+
+using namespace boost;
+using namespace qpid::broker;
+using namespace qpid::framing;
+using namespace qpid::sys;
+
+struct DummyHandler : OutputHandler{
+    std::vector<AMQFrame*> frames; 
+
+    virtual void send(AMQFrame* frame){
+        frames.push_back(frame);
+    }
+};
+
+
+class ChannelTest : public CppUnit::TestCase  
+{
+    CPPUNIT_TEST_SUITE(ChannelTest);
+    CPPUNIT_TEST(testConsumerMgmt);
+    CPPUNIT_TEST(testDeliveryNoAck);
+    CPPUNIT_TEST_SUITE_END();
+
+  public:
+
+    void testConsumerMgmt(){
+        Queue::shared_ptr queue(new Queue("my_queue"));
+        Channel channel(0, 0, 0);
+        CPPUNIT_ASSERT(!channel.exists("my_consumer"));
+
+        ConnectionToken* owner = 0;
+        string tag("my_consumer");
+        channel.consume(tag, queue, false, false, owner);
+        string tagA;
+        string tagB;
+        channel.consume(tagA, queue, false, false, owner);
+        channel.consume(tagB, queue, false, false, owner);
+        CPPUNIT_ASSERT_EQUAL((u_int32_t) 3, queue->getConsumerCount());
+        CPPUNIT_ASSERT(channel.exists("my_consumer"));
+        CPPUNIT_ASSERT(channel.exists(tagA));
+        CPPUNIT_ASSERT(channel.exists(tagB));
+        channel.cancel(tagA);
+        CPPUNIT_ASSERT_EQUAL((u_int32_t) 2, queue->getConsumerCount());
+        CPPUNIT_ASSERT(channel.exists("my_consumer"));
+        CPPUNIT_ASSERT(!channel.exists(tagA));
+        CPPUNIT_ASSERT(channel.exists(tagB));
+        channel.close();
+        CPPUNIT_ASSERT_EQUAL((u_int32_t) 0, queue->getConsumerCount());        
+    }
+
+    void testDeliveryNoAck(){
+        DummyHandler handler;
+        Channel channel(&handler, 7, 10000);
+
+        Message::shared_ptr msg(new Message(0, "test", "my_routing_key", false, false));
+        AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC));
+        header->setContentSize(14);
+        msg->setHeader(header);
+        AMQContentBody::shared_ptr body(new AMQContentBody("abcdefghijklmn"));
+        msg->addContent(body);
+
+        Queue::shared_ptr queue(new Queue("my_queue"));
+        ConnectionToken* owner(0);
+        string tag("no_ack");
+        channel.consume(tag, queue, false, false, owner);
+
+        queue->deliver(msg);
+        CPPUNIT_ASSERT_EQUAL((size_t) 3, handler.frames.size());
+        CPPUNIT_ASSERT_EQUAL((u_int16_t) 7, handler.frames[0]->getChannel());        
+        CPPUNIT_ASSERT_EQUAL((u_int16_t) 7, handler.frames[1]->getChannel());        
+        CPPUNIT_ASSERT_EQUAL((u_int16_t) 7, handler.frames[2]->getChannel());
+        BasicDeliverBody::shared_ptr deliver(dynamic_pointer_cast<BasicDeliverBody, AMQBody>(handler.frames[0]->getBody()));
+        AMQHeaderBody::shared_ptr contentHeader(dynamic_pointer_cast<AMQHeaderBody, AMQBody>(handler.frames[1]->getBody()));
+        AMQContentBody::shared_ptr contentBody(dynamic_pointer_cast<AMQContentBody, AMQBody>(handler.frames[2]->getBody()));
+        CPPUNIT_ASSERT(deliver);
+        CPPUNIT_ASSERT(contentHeader);
+        CPPUNIT_ASSERT(contentBody);
+        CPPUNIT_ASSERT_EQUAL(string("abcdefghijklmn"), contentBody->getData());
+    }
+
+    void testDeliveryAndRecovery(){
+        DummyHandler handler;
+        Channel channel(&handler, 7, 10000);
+
+        Message::shared_ptr msg(new Message(0, "test", "my_routing_key", false, false));
+        AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC));
+        header->setContentSize(14);
+        msg->setHeader(header);
+        AMQContentBody::shared_ptr body(new AMQContentBody("abcdefghijklmn"));
+        msg->addContent(body);
+
+        Queue::shared_ptr queue(new Queue("my_queue"));
+        ConnectionToken* owner;
+        string tag("ack");
+        channel.consume(tag, queue, true, false, owner);
+
+        queue->deliver(msg);
+        CPPUNIT_ASSERT_EQUAL((size_t) 3, handler.frames.size());
+        CPPUNIT_ASSERT_EQUAL((u_int16_t) 7, handler.frames[0]->getChannel());        
+        CPPUNIT_ASSERT_EQUAL((u_int16_t) 7, handler.frames[1]->getChannel());        
+        CPPUNIT_ASSERT_EQUAL((u_int16_t) 7, handler.frames[2]->getChannel());
+        BasicDeliverBody::shared_ptr deliver(dynamic_pointer_cast<BasicDeliverBody, AMQBody>(handler.frames[0]->getBody()));
+        AMQHeaderBody::shared_ptr contentHeader(dynamic_pointer_cast<AMQHeaderBody, AMQBody>(handler.frames[1]->getBody()));
+        AMQContentBody::shared_ptr contentBody(dynamic_pointer_cast<AMQContentBody, AMQBody>(handler.frames[2]->getBody()));
+        CPPUNIT_ASSERT(deliver);
+        CPPUNIT_ASSERT(contentHeader);
+        CPPUNIT_ASSERT(contentBody);
+        CPPUNIT_ASSERT_EQUAL(string("abcdefghijklmn"), contentBody->getData());
+    }
+};
+
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(ChannelTest);

Propchange: incubator/qpid/trunk/qpid/cpp/tests/ChannelTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/tests/ChannelTest.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/tests/ConfigurationTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/tests/ConfigurationTest.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/tests/ConfigurationTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/tests/ConfigurationTest.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,88 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <Configuration.h>
+#include <qpid_test_plugin.h>
+#include <iostream>
+
+using namespace std;
+using namespace qpid::broker;
+
+class ConfigurationTest : public CppUnit::TestCase  
+{
+    CPPUNIT_TEST_SUITE(ConfigurationTest);
+    CPPUNIT_TEST(testIsHelp);
+    CPPUNIT_TEST(testPortLongForm);
+    CPPUNIT_TEST(testPortShortForm);
+    CPPUNIT_TEST(testStore);
+    CPPUNIT_TEST(testVarious);
+    CPPUNIT_TEST_SUITE_END();
+
+  public:
+
+    void testIsHelp() 
+    {
+        Configuration conf;
+        char* argv[] = {"ignore", "--help"};
+        conf.parse(2, argv);
+        CPPUNIT_ASSERT(conf.isHelp());
+    }
+
+    void testPortLongForm() 
+    {
+        Configuration conf;
+        char* argv[] = {"ignore", "--port", "6789"};
+        conf.parse(3, argv);
+        CPPUNIT_ASSERT_EQUAL(6789, conf.getPort());
+    }
+
+    void testPortShortForm() 
+    {
+        Configuration conf;
+        char* argv[] = {"ignore", "-p", "6789"};
+        conf.parse(3, argv);
+        CPPUNIT_ASSERT_EQUAL(6789, conf.getPort());
+    }
+
+    void testStore() 
+    {
+        Configuration conf;
+        char* argv[] = {"ignore", "--store", "my-store-module.so"};
+        conf.parse(3, argv);
+        std::string expected("my-store-module.so");
+        CPPUNIT_ASSERT_EQUAL(expected, conf.getStore());
+    }
+
+    void testVarious() 
+    {        
+        Configuration conf;
+        char* argv[] = {"ignore", "-t", "--worker-threads", "10"};
+        conf.parse(4, argv);
+        CPPUNIT_ASSERT_EQUAL(5672, conf.getPort());//default
+        CPPUNIT_ASSERT_EQUAL(10, conf.getWorkerThreads());
+        CPPUNIT_ASSERT(conf.isTrace());
+        CPPUNIT_ASSERT(!conf.isHelp());
+    }
+};
+
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(ConfigurationTest);
+

Propchange: incubator/qpid/trunk/qpid/cpp/tests/ConfigurationTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/tests/ConfigurationTest.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/tests/EventChannelTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/tests/EventChannelTest.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/tests/EventChannelTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/tests/EventChannelTest.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,187 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <posix/EventChannel.h>
+#include <posix/check.h>
+#include <sys/Runnable.h>
+#include <sys/Socket.h>
+#include <sys/Thread.h>
+#include <qpid_test_plugin.h>
+
+#include <sys/socket.h>
+#include <signal.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <iostream>
+
+using namespace qpid::sys;
+
+
+const char hello[] = "hello";
+const size_t size = sizeof(hello);
+
+struct RunMe : public Runnable 
+{
+    bool ran;
+    RunMe() : ran(false) {}
+    void run() { ran = true; }
+};
+
+class EventChannelTest : public CppUnit::TestCase  
+{
+    CPPUNIT_TEST_SUITE(EventChannelTest);
+    CPPUNIT_TEST(testEvent);
+    CPPUNIT_TEST(testRead);
+    CPPUNIT_TEST(testFailedRead);
+    CPPUNIT_TEST(testWrite);
+    CPPUNIT_TEST(testFailedWrite);
+    CPPUNIT_TEST(testReadWrite);
+    CPPUNIT_TEST(testAccept);
+    CPPUNIT_TEST_SUITE_END();
+
+  private:
+    EventChannel::shared_ptr ec;
+    int pipe[2];
+    char readBuf[size];
+
+  public:
+
+    void setUp()
+    {
+        memset(readBuf, size, 0);
+        ec = EventChannel::create();
+        if (::pipe(pipe) != 0) throw QPID_POSIX_ERROR(errno);
+        // Ignore SIGPIPE, otherwise we will crash writing to broken pipe.
+        signal(SIGPIPE, SIG_IGN);
+    }
+
+    // Verify that calling getEvent returns event.
+    template <class T> bool isNextEvent(T& event)
+    {
+        return &event == dynamic_cast<T*>(ec->getEvent());
+    }
+
+    template <class T> bool isNextEventOk(T& event)
+    {
+        Event* next = ec->getEvent();
+        if (next) next->throwIfError();
+        return &event == next;
+    }
+        
+    void testEvent()
+    {
+        RunMe runMe;
+        CPPUNIT_ASSERT(!runMe.ran);
+        // Instances of Event just pass thru the channel immediately.
+        Event e(runMe.functor());
+        ec->postEvent(e);
+        CPPUNIT_ASSERT(isNextEventOk(e));
+        e.dispatch();
+        CPPUNIT_ASSERT(runMe.ran);
+    }
+
+    void testRead() {
+        ReadEvent re(pipe[0], readBuf, size);
+        ec->postEvent(re);
+        CPPUNIT_ASSERT_EQUAL(ssize_t(size), ::write(pipe[1], hello, size));
+        CPPUNIT_ASSERT(isNextEventOk(re));
+        CPPUNIT_ASSERT_EQUAL(size, re.getSize());
+        CPPUNIT_ASSERT_EQUAL(std::string(hello), std::string(readBuf));
+    }
+
+    void testFailedRead() 
+    {
+        ReadEvent re(pipe[0], readBuf, size);
+        ec->postEvent(re);
+
+        // EOF before all data read.
+        ::close(pipe[1]);
+        CPPUNIT_ASSERT(isNextEvent(re));
+        CPPUNIT_ASSERT(re.hasError());
+        try {
+            re.throwIfError();
+            CPPUNIT_FAIL("Expected QpidError.");
+        }
+        catch (const qpid::QpidError&) { }
+
+        //  Bad file descriptor. Note in this case we fail
+        //  in postEvent and throw immediately.
+        try {
+            ReadEvent bad;
+            ec->postEvent(bad);
+            CPPUNIT_FAIL("Expected QpidError.");
+        }
+        catch (const qpid::QpidError&) { }
+    }
+
+    void testWrite() {
+        WriteEvent wr(pipe[1], hello, size);
+        ec->postEvent(wr);
+        CPPUNIT_ASSERT(isNextEventOk(wr));
+        CPPUNIT_ASSERT_EQUAL(ssize_t(size), ::read(pipe[0], readBuf, size));;
+        CPPUNIT_ASSERT_EQUAL(std::string(hello), std::string(readBuf));
+    }
+
+    void testFailedWrite() {
+        WriteEvent wr(pipe[1], hello, size);
+        ::close(pipe[0]);
+        ec->postEvent(wr);
+        CPPUNIT_ASSERT(isNextEvent(wr));
+        CPPUNIT_ASSERT(wr.hasError());
+    }
+
+    void testReadWrite()
+    {
+        ReadEvent re(pipe[0], readBuf, size);
+        WriteEvent wr(pipe[1], hello, size);
+        ec->postEvent(re);
+        ec->postEvent(wr);
+        ec->getEvent();
+        ec->getEvent();
+        CPPUNIT_ASSERT_EQUAL(std::string(hello), std::string(readBuf));
+    }
+
+    void testAccept() {
+        Socket s = Socket::createTcp();
+        int port = s.listen(0, 10);
+        CPPUNIT_ASSERT(port != 0);
+
+        AcceptEvent ae(s.fd());
+        ec->postEvent(ae);
+        Socket client = Socket::createTcp();
+        client.connect("localhost", port);
+        CPPUNIT_ASSERT(isNextEvent(ae));
+        ae.dispatch();
+
+        // Verify client writes are read by the accepted descriptor.
+        char readBuf[size];
+        ReadEvent re(ae.getAcceptedDesscriptor(), readBuf, size);
+        ec->postEvent(re);
+        CPPUNIT_ASSERT_EQUAL(ssize_t(size), client.send(hello, sizeof(hello)));
+        CPPUNIT_ASSERT(isNextEvent(re));
+        re.dispatch();
+        CPPUNIT_ASSERT_EQUAL(std::string(hello), std::string(readBuf));
+    }
+};
+
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(EventChannelTest);
+

Propchange: incubator/qpid/trunk/qpid/cpp/tests/EventChannelTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/tests/EventChannelTest.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/tests/EventChannelThreadsTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/tests/EventChannelThreadsTest.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/tests/EventChannelThreadsTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/tests/EventChannelThreadsTest.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,247 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <iostream>
+#include <boost/bind.hpp>
+
+#include <sys/Socket.h>
+#include <posix/EventChannelThreads.h>
+#include <qpid_test_plugin.h>
+
+
+using namespace std;
+
+using namespace qpid::sys;
+
+const int nConnections = 5;
+const int nMessages = 10; // Messages read/written per connection.
+
+
+// Accepts + reads + writes.
+const int totalEvents = nConnections+2*nConnections*nMessages;
+
+/**
+ * Messages are numbered 0..nMessages.
+ * We count the total number of events, and the
+ * number of reads and writes for each message number.
+ */
+class TestResults : public Monitor {
+  public:
+    TestResults() : isShutdown(false), nEventsRemaining(totalEvents) {}
+
+    void countEvent() {
+        if (--nEventsRemaining == 0)
+            shutdown();
+    }
+
+    void countRead(int messageNo) {
+        ++reads[messageNo];
+        countEvent();
+    }
+
+    void countWrite(int messageNo) {
+        ++writes[messageNo];
+        countEvent();
+    }
+
+    void shutdown(const std::string& exceptionMsg = std::string()) {
+        ScopedLock lock(*this);
+        exception = exceptionMsg;
+        isShutdown = true;
+        notifyAll();
+    }
+    
+    void wait() {
+        ScopedLock lock(*this);
+        Time deadline = now() + 10*TIME_SEC; 
+        while (!isShutdown) {
+            CPPUNIT_ASSERT(Monitor::wait(deadline));
+        }
+    }
+
+    bool isShutdown;
+    std::string exception;
+    AtomicCount reads[nMessages];
+    AtomicCount writes[nMessages];
+    AtomicCount nEventsRemaining;
+};
+
+TestResults results;
+
+EventChannelThreads::shared_ptr threads;
+
+// Functor to wrap callbacks in try/catch.
+class SafeCallback {
+  public:
+    SafeCallback(Runnable& r) : callback(r.functor()) {}
+    SafeCallback(Event::Callback cb) : callback(cb) {}
+    
+    void operator()() {
+        std::string exception;
+        try {
+            callback();
+            return;
+        }
+        catch (const std::exception& e) {
+            exception = e.what();
+        }
+        catch (...) {
+            exception = "Unknown exception.";
+        }
+        results.shutdown(exception);
+    }
+
+  private:
+    Event::Callback callback;
+};
+
+/** Repost an event N times. */
+class Repost {
+  public:
+    Repost(int n) : count (n) {}
+    virtual ~Repost() {}
+    
+    void repost(Event* event) {
+        if (--count==0) {
+            delete event;
+        } else {
+            threads->postEvent(event);
+        }
+    }
+  private:
+    int count;
+};
+    
+            
+
+/** Repeating read event. */
+class TestReadEvent : public ReadEvent, public Runnable, private Repost {
+  public:
+    explicit TestReadEvent(int fd=-1) :
+        ReadEvent(fd, &value, sizeof(value), SafeCallback(*this)),
+        Repost(nMessages)
+    {}
+    
+    void run() {
+        CPPUNIT_ASSERT_EQUAL(sizeof(value), getSize());
+        CPPUNIT_ASSERT(0 <= value);
+        CPPUNIT_ASSERT(value < nMessages);
+        results.countRead(value);
+        repost(this);
+    }
+    
+  private:
+    int value;
+    ReadEvent original;
+};
+
+
+/** Fire and forget write event */
+class TestWriteEvent : public WriteEvent, public Runnable, private Repost {
+  public:
+    TestWriteEvent(int fd=-1) :
+        WriteEvent(fd, &value, sizeof(value), SafeCallback(*this)),
+        Repost(nMessages),
+        value(0)
+    {}
+    
+    void run() {
+        CPPUNIT_ASSERT_EQUAL(sizeof(int), getSize());
+        results.countWrite(value++);
+        repost(this);
+    }
+
+  private:
+    int value;
+};
+
+/** Fire-and-forget Accept event, posts reads on the accepted connection. */
+class TestAcceptEvent : public AcceptEvent, public Runnable, private Repost {
+  public:
+    TestAcceptEvent(int fd=-1) :
+        AcceptEvent(fd, SafeCallback(*this)),
+        Repost(nConnections)
+    {}
+    
+    void run() {
+        threads->postEvent(new TestReadEvent(getAcceptedDesscriptor()));
+        results.countEvent();
+        repost(this);
+    }
+};
+
+class EventChannelThreadsTest : public CppUnit::TestCase
+{
+    CPPUNIT_TEST_SUITE(EventChannelThreadsTest);
+    CPPUNIT_TEST(testThreads);
+    CPPUNIT_TEST_SUITE_END();
+
+  public:
+
+    void setUp() {
+        threads = EventChannelThreads::create(EventChannel::create());
+    }
+
+    void tearDown() {
+        threads.reset();
+    }
+
+    void testThreads()
+    {
+        Socket listener = Socket::createTcp();
+        int port = listener.listen();
+
+        // Post looping accept events, will repost nConnections times.
+        // The accept event will automatically post read events.
+        threads->postEvent(new TestAcceptEvent(listener.fd()));
+
+        // Make connections.
+        Socket connections[nConnections];
+        for (int i = 0; i < nConnections; ++i) {
+            connections[i] = Socket::createTcp();
+            connections[i].connect("localhost", port);
+        }
+
+        // Post looping write events.
+        for (int i = 0; i < nConnections; ++i) {
+            threads->postEvent(new TestWriteEvent(connections[i].fd()));
+        }
+
+        // Wait for all events to be dispatched.
+        results.wait();
+
+        if (!results.exception.empty()) CPPUNIT_FAIL(results.exception);
+        CPPUNIT_ASSERT_EQUAL(0, int(results.nEventsRemaining));
+
+        // Expect a read and write for each messageNo from each connection.
+        for (int messageNo = 0; messageNo < nMessages; ++messageNo) {
+            CPPUNIT_ASSERT_EQUAL(nConnections, int(results.reads[messageNo]));
+            CPPUNIT_ASSERT_EQUAL(nConnections, int(results.writes[messageNo]));
+        }
+
+        threads->shutdown();
+        threads->join();
+    }
+};
+
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(EventChannelThreadsTest);
+

Propchange: incubator/qpid/trunk/qpid/cpp/tests/EventChannelThreadsTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/tests/EventChannelThreadsTest.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/tests/ExceptionTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/tests/ExceptionTest.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/tests/ExceptionTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/tests/ExceptionTest.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <Exception.h>
+#include <qpid_test_plugin.h>
+
+using namespace qpid;
+
+struct CountDestroyedException : public Exception {
+    int& count;
+    static int staticCount;
+    CountDestroyedException() : count(staticCount) { }
+    CountDestroyedException(int& n) : count(n) {}
+    ~CountDestroyedException() throw() { count++; }
+    void throwSelf() const { throw *this; }
+};
+
+int CountDestroyedException::staticCount = 0;
+         
+        
+class ExceptionTest : public CppUnit::TestCase 
+{
+    CPPUNIT_TEST_SUITE(ExceptionTest);
+    CPPUNIT_TEST(testHeapException);
+    CPPUNIT_TEST_SUITE_END();
+  public:
+    // Verify proper memory management for heap-allocated exceptions.
+    void testHeapException() {
+        int count = 0;
+        try {
+            std::auto_ptr<Exception> p(
+                new CountDestroyedException(count));
+            p.release()->throwSelf();
+            CPPUNIT_FAIL("Expected CountDestroyedException.");
+        } catch (const CountDestroyedException& e) {
+            CPPUNIT_ASSERT(&e.count == &count);
+        }
+        CPPUNIT_ASSERT_EQUAL(1, count);
+    }
+};
+
+    
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(ExceptionTest);
+

Propchange: incubator/qpid/trunk/qpid/cpp/tests/ExceptionTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/tests/ExceptionTest.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/tests/ExchangeTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/tests/ExchangeTest.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/tests/ExchangeTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/tests/ExchangeTest.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,67 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <DeliverableMessage.h>
+#include <DirectExchange.h>
+#include <BrokerExchange.h>
+#include <BrokerQueue.h>
+#include <TopicExchange.h>
+#include <qpid_test_plugin.h>
+#include <iostream>
+
+using namespace qpid::broker;
+using namespace qpid::sys;
+
+class ExchangeTest : public CppUnit::TestCase
+{
+    CPPUNIT_TEST_SUITE(ExchangeTest);
+    CPPUNIT_TEST(testMe);
+    CPPUNIT_TEST_SUITE_END();
+
+  public:
+
+    void testMe() 
+    {
+        Queue::shared_ptr queue(new Queue("queue", true));
+        Queue::shared_ptr queue2(new Queue("queue2", true));
+
+        TopicExchange topic("topic");
+        topic.bind(queue, "abc", 0);
+        topic.bind(queue2, "abc", 0);
+
+        DirectExchange direct("direct");
+        direct.bind(queue, "abc", 0);
+        direct.bind(queue2, "abc", 0);
+
+        queue.reset();
+        queue2.reset();
+
+        Message::shared_ptr msgPtr(new Message(0, "e", "A", true, true));
+        DeliverableMessage msg(msgPtr);
+        topic.route(msg, "abc", 0);
+        direct.route(msg, "abc", 0);
+
+    }
+};
+    
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(ExchangeTest);

Propchange: incubator/qpid/trunk/qpid/cpp/tests/ExchangeTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/tests/ExchangeTest.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/tests/FieldTableTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/tests/FieldTableTest.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/tests/FieldTableTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/tests/FieldTableTest.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,55 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <iostream>
+#include <amqp_framing.h>
+#include <qpid_test_plugin.h>
+
+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);
+

Propchange: incubator/qpid/trunk/qpid/cpp/tests/FieldTableTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/tests/FieldTableTest.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/tests/FramingTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/tests/FramingTest.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/tests/FramingTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/tests/FramingTest.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,149 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <ConnectionRedirectBody.h>
+#include <ProtocolVersion.h>
+#include <amqp_framing.h>
+#include <iostream>
+#include <qpid_test_plugin.h>
+#include <sstream>
+#include <typeinfo>
+
+using namespace qpid::framing;
+
+template <class T>
+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(testConnectionRedirectBodyFrame);
+    CPPUNIT_TEST(testBasicConsumeOkBodyFrame);
+    CPPUNIT_TEST_SUITE_END();
+
+  private:
+    Buffer buffer;
+  	ProtocolVersion v;
+
+  public:
+
+// AMQP version management change - kpvdr 2006-11-17
+// TODO: Make this class version-aware and link these hard-wired numbers to that version
+    FramingTest() : buffer(100), v(8, 0) {}
+
+    void testBasicQosBody() 
+    {
+        BasicQosBody in(v, 0xCAFEBABE, 0xABBA, true);
+        in.encodeContent(buffer);
+        buffer.flip(); 
+        BasicQosBody out(v);
+        out.decodeContent(buffer);
+        CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
+    }
+    
+    void testConnectionSecureBody() 
+    {
+        std::string s = "security credential";
+        ConnectionSecureBody in(v, s);
+        in.encodeContent(buffer);
+        buffer.flip(); 
+        ConnectionSecureBody out(v);
+        out.decodeContent(buffer);
+        CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
+    }
+
+    void testConnectionRedirectBody()
+    {
+        std::string a = "hostA";
+        std::string b = "hostB";
+        ConnectionRedirectBody in(v, a, b);
+        in.encodeContent(buffer);
+        buffer.flip(); 
+        ConnectionRedirectBody out(v);
+        out.decodeContent(buffer);
+        CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
+    }
+
+    void testAccessRequestBody()
+    {
+        std::string s = "text";
+        AccessRequestBody in(v, s, true, false, true, false, true);
+        in.encodeContent(buffer);
+        buffer.flip(); 
+        AccessRequestBody out(v);
+        out.decodeContent(buffer);
+        CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
+    }
+
+    void testBasicConsumeBody()
+    {
+        std::string q = "queue";
+        std::string t = "tag";
+        BasicConsumeBody in(v, 0, q, t, false, true, false, false);
+        in.encodeContent(buffer);
+        buffer.flip(); 
+        BasicConsumeBody out(v);
+        out.decodeContent(buffer);
+        CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
+    }
+    
+
+    void testConnectionRedirectBodyFrame()
+    {
+        std::string a = "hostA";
+        std::string b = "hostB";
+        AMQFrame in(999, new ConnectionRedirectBody(v, a, b));
+        in.encode(buffer);
+        buffer.flip(); 
+        AMQFrame out;
+        out.decode(buffer);
+        CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
+    }
+
+    void testBasicConsumeOkBodyFrame()
+    {
+        std::string s = "hostA";
+        AMQFrame in(999, new BasicConsumeOkBody(v, 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);
+
+
+

Propchange: incubator/qpid/trunk/qpid/cpp/tests/FramingTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/tests/FramingTest.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/tests/HeaderTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/tests/HeaderTest.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/tests/HeaderTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/tests/HeaderTest.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,141 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <iostream>
+#include <amqp_framing.h>
+#include <qpid_test_plugin.h>
+
+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:
+
+    void testGenericProperties() 
+    {
+        AMQHeaderBody body(BASIC);
+        dynamic_cast<BasicHeaderProperties*>(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<BasicHeaderProperties*>(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<BasicHeaderProperties*>(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<BasicHeaderProperties*>(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<BasicHeaderProperties*>(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<BasicHeaderProperties*>(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);
+

Propchange: incubator/qpid/trunk/qpid/cpp/tests/HeaderTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/tests/HeaderTest.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/tests/HeadersExchangeTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/tests/HeadersExchangeTest.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/tests/HeadersExchangeTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/tests/HeadersExchangeTest.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,115 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <HeadersExchange.h>
+#include <FieldTable.h>
+#include <Value.h>
+#include <qpid_test_plugin.h>
+
+using namespace qpid::broker;
+using namespace qpid::framing;
+
+class HeadersExchangeTest : public CppUnit::TestCase
+{
+    CPPUNIT_TEST_SUITE(HeadersExchangeTest);
+    CPPUNIT_TEST(testMatchAll);
+    CPPUNIT_TEST(testMatchAny);
+    CPPUNIT_TEST(testMatchEmptyValue);
+    CPPUNIT_TEST(testMatchEmptyArgs);
+    CPPUNIT_TEST(testMatchNoXMatch);
+    CPPUNIT_TEST_SUITE_END();
+
+  public:
+
+    void testMatchAll() 
+    {
+        FieldTable b, m;
+        b.setString("x-match", "all");
+        b.setString("foo", "FOO");
+        b.setInt("n", 42);
+        m.setString("foo", "FOO");
+        m.setInt("n", 42);
+        CPPUNIT_ASSERT(HeadersExchange::match(b, m));
+
+        // Ignore extras.
+        m.setString("extra", "x");
+        CPPUNIT_ASSERT(HeadersExchange::match(b, m));
+        
+        // Fail mismatch, wrong value.
+        m.setString("foo", "NotFoo");
+        CPPUNIT_ASSERT(!HeadersExchange::match(b, m));
+
+        // Fail mismatch, missing value
+        m.erase("foo");
+        CPPUNIT_ASSERT(!HeadersExchange::match(b, m));
+    }
+
+    void testMatchAny() 
+    {
+        FieldTable b, m;
+        b.setString("x-match", "any");
+        b.setString("foo", "FOO");
+        b.setInt("n", 42);
+        m.setString("foo", "FOO");
+        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));
+    }
+
+    void testMatchEmptyValue() 
+    {
+        FieldTable b, m;
+        b.setString("x-match", "all");
+        b.getMap()["foo"] = FieldTable::ValuePtr(new EmptyValue());
+        b.getMap()["n"] = FieldTable::ValuePtr(new EmptyValue());
+        CPPUNIT_ASSERT(!HeadersExchange::match(b, m));
+        m.setString("foo", "blah");
+        m.setInt("n", 123);
+    }
+
+    void testMatchEmptyArgs()
+    {
+        FieldTable b, m;
+        m.setString("foo", "FOO");
+        
+        b.setString("x-match", "all");
+        CPPUNIT_ASSERT(HeadersExchange::match(b, m));
+        b.setString("x-match", "any");
+        CPPUNIT_ASSERT(!HeadersExchange::match(b, m));
+    }
+    
+
+    void testMatchNoXMatch() 
+    {
+        FieldTable b, m;
+        b.setString("foo", "FOO");
+        m.setString("foo", "FOO");
+        CPPUNIT_ASSERT(!HeadersExchange::match(b, m));
+    }
+    
+    
+};
+    
+// make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(HeadersExchangeTest);

Propchange: incubator/qpid/trunk/qpid/cpp/tests/HeadersExchangeTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/tests/HeadersExchangeTest.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/tests/InMemoryContentTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/tests/InMemoryContentTest.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/tests/InMemoryContentTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/tests/InMemoryContentTest.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,97 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <InMemoryContent.h>
+#include <qpid_test_plugin.h>
+#include <iostream>
+#include <list>
+
+using std::list;
+using std::string;
+using boost::dynamic_pointer_cast;
+using namespace qpid::broker;
+using namespace qpid::framing;
+
+struct DummyHandler : OutputHandler{
+    std::vector<AMQFrame*> frames; 
+
+    virtual void send(AMQFrame* frame){
+        frames.push_back(frame);
+    }
+};
+
+class InMemoryContentTest : public CppUnit::TestCase  
+{
+        CPPUNIT_TEST_SUITE(InMemoryContentTest);
+        CPPUNIT_TEST(testRefragmentation);
+        CPPUNIT_TEST_SUITE_END();
+
+public:
+    void testRefragmentation()
+    {
+        {//no remainder
+            string out[] = {"abcde", "fghij", "klmno", "pqrst"};
+            string in[] = {out[0] + out[1], out[2] + out[3]};        
+            refragment(2, in, 4, out);
+        }
+        {//remainder for last frame
+            string out[] = {"abcde", "fghij", "klmno", "pqrst", "uvw"};
+            string in[] = {out[0] + out[1], out[2] + out[3] + out[4]};        
+            refragment(2, in, 5, out);
+        }
+    }
+
+
+    void refragment(size_t inCount, string* in, size_t outCount, string* out, u_int32_t framesize = 5)
+    {
+        InMemoryContent content;
+        DummyHandler handler;
+        u_int16_t channel = 3;
+
+        addframes(content, inCount, in);
+        content.send(&handler, channel, framesize);         
+        check(handler, channel, outCount, out);
+    }
+
+    void addframes(InMemoryContent& content, size_t frameCount, string* frameData)
+    {
+        for (unsigned int i = 0; i < frameCount; i++) {
+            AMQContentBody::shared_ptr frame(new AMQContentBody(frameData[i]));
+            content.add(frame);
+        }
+    }
+
+    void check(DummyHandler& handler, u_int16_t channel, size_t expectedChunkCount, string* expectedChunks)
+    {
+        CPPUNIT_ASSERT_EQUAL(expectedChunkCount, handler.frames.size());
+
+        for (unsigned int i = 0; i < expectedChunkCount; i++) {
+            AMQContentBody::shared_ptr chunk(dynamic_pointer_cast<AMQContentBody, AMQBody>(handler.frames[i]->getBody()));
+            CPPUNIT_ASSERT(chunk);
+            CPPUNIT_ASSERT_EQUAL(expectedChunks[i], chunk->getData());
+            CPPUNIT_ASSERT_EQUAL(channel, handler.frames[i]->getChannel());
+        }
+    }
+};
+
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(InMemoryContentTest);
+

Propchange: incubator/qpid/trunk/qpid/cpp/tests/InMemoryContentTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/tests/InMemoryContentTest.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/tests/LazyLoadedContentTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/tests/LazyLoadedContentTest.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/tests/LazyLoadedContentTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/tests/LazyLoadedContentTest.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,122 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <LazyLoadedContent.h>
+#include <NullMessageStore.h>
+#include <qpid_test_plugin.h>
+#include <iostream>
+#include <list>
+#include <sstream>
+
+using std::list;
+using std::string;
+using boost::dynamic_pointer_cast;
+using namespace qpid::broker;
+using namespace qpid::framing;
+
+struct DummyHandler : OutputHandler{
+    std::vector<AMQFrame*> frames; 
+
+    virtual void send(AMQFrame* frame){
+        frames.push_back(frame);
+    }
+};
+
+
+class LazyLoadedContentTest : public CppUnit::TestCase  
+{
+        CPPUNIT_TEST_SUITE(LazyLoadedContentTest);
+        CPPUNIT_TEST(testFragmented);
+        CPPUNIT_TEST(testWhole);
+        CPPUNIT_TEST(testHalved);
+        CPPUNIT_TEST_SUITE_END();
+
+    class TestMessageStore : public NullMessageStore
+    {
+        const string content;
+        
+    public:
+        TestMessageStore(const string& _content) : content(_content) {}
+
+        void loadContent(Message* const, string& data, u_int64_t offset, u_int32_t length)
+        {
+            if (offset + length <= content.size()) {
+                data = content.substr(offset, length);
+            } else{
+                std::stringstream error;
+                error << "Invalid segment: offset=" << offset << ", length=" << length << ", content_length=" << content.size();
+                throw qpid::Exception(error.str());
+            }
+        }
+    };
+
+
+public:
+    void testFragmented()
+    {
+        string data = "abcdefghijklmnopqrstuvwxyz";
+        u_int32_t framesize = 5;
+        string out[] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z"};
+        load(data, 6, out, framesize);
+    }
+
+    void testWhole()
+    {
+        string data = "abcdefghijklmnopqrstuvwxyz";
+        u_int32_t framesize = 50;
+        string out[] = {data};
+        load(data, 1, out, framesize);
+    }
+
+    void testHalved()
+    {
+        string data = "abcdefghijklmnopqrstuvwxyz";
+        u_int32_t framesize = 13;
+        string out[] = {"abcdefghijklm", "nopqrstuvwxyz"};
+        load(data, 2, out, framesize);
+    }
+
+    void load(string& in, size_t outCount, string* out, u_int32_t framesize)
+    {
+        TestMessageStore store(in);
+        LazyLoadedContent content(&store, 0, in.size());
+        DummyHandler handler;
+        u_int16_t channel = 3;
+        content.send(&handler, channel, framesize);         
+        check(handler, channel, outCount, out);
+    }
+
+    void check(DummyHandler& handler, u_int16_t channel, size_t expectedChunkCount, string* expectedChunks)
+    {
+        CPPUNIT_ASSERT_EQUAL(expectedChunkCount, handler.frames.size());
+
+        for (unsigned int i = 0; i < expectedChunkCount; i++) {
+            AMQContentBody::shared_ptr chunk(dynamic_pointer_cast<AMQContentBody, AMQBody>(handler.frames[i]->getBody()));
+            CPPUNIT_ASSERT(chunk);
+            CPPUNIT_ASSERT_EQUAL(expectedChunks[i], chunk->getData());
+            CPPUNIT_ASSERT_EQUAL(channel, handler.frames[i]->getChannel());
+        }
+    }
+};
+
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(LazyLoadedContentTest);
+

Propchange: incubator/qpid/trunk/qpid/cpp/tests/LazyLoadedContentTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/tests/LazyLoadedContentTest.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/tests/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/tests/Makefile.am?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/tests/Makefile.am (added)
+++ incubator/qpid/trunk/qpid/cpp/tests/Makefile.am Thu Nov 30 21:11:45 2006
@@ -0,0 +1,100 @@
+# TODO aconway 2006-11-30: nasty hack, should be done by automake?
+abs_builddir = @abs_builddir@
+
+AM_CXXFLAGS = $(WARNING_CFLAGS)
+INCLUDES = \
+  -I$(top_srcdir)/gen \
+  -I$(top_srcdir)/lib \
+  -I$(top_srcdir)/lib/client \
+  -I$(top_srcdir)/lib/broker \
+  -I$(top_srcdir)/lib/common \
+  -I$(top_srcdir)/lib/common/sys \
+  -I$(top_srcdir)/lib/common/framing
+
+# FIXME: -lcppunit must come from autoconf
+
+# FIXME: have e.g., topicall, run as part of "make check"?
+EXTRA_DIST =		\
+  env			\
+  broker		\
+  topicall		\
+  topictest		\
+  qpid_test_plugin.h	\
+  APRBaseTest.cpp
+
+client_tests =		\
+  client_test		\
+  echo_service		\
+  topic_listener	\
+  topic_publisher
+
+broker_tests =		\
+  AccumulatedAckTest	\
+  ChannelTest		\
+  ConfigurationTest	\
+  ExchangeTest		\
+  HeadersExchangeTest	\
+  InMemoryContentTest	\
+  LazyLoadedContentTest	\
+  MessageBuilderTest	\
+  MessageTest		\
+  QueueRegistryTest	\
+  QueueTest		\
+  TopicExchangeTest	\
+  TxAckTest		\
+  TxBufferTest		\
+  TxPublishTest		\
+  ValueTest
+
+framing_tests =		\
+  BodyHandlerTest	\
+  FieldTableTest	\
+  FramingTest		\
+  HeaderTest
+
+misc_tests =		\
+  ExceptionTest
+
+posix_tests =		\
+  EventChannelTest	\
+  EventChannelThreadsTest
+
+unit_tests =		\
+  $(broker_tests)	\
+  $(framing_tests)	\
+  $(misc_tests)		\
+  $(posix_tests)
+
+noinst_PROGRAMS = $(client_tests)
+
+check: run-unit-tests
+
+.PHONY: run-unit-tests
+run-unit-tests: $(check_LTLIBRARIES)
+	DllPlugInTester -c -b .libs/*.so
+
+include gen.mk
+
+extra_libs = -lcppunit
+lib_client = ../lib/client/libclient.la
+lib_common = ../lib/common/libcommon.la
+lib_broker = ../lib/broker/libbroker.la
+
+gen.mk: Makefile.am
+	(					\
+	  for i in $(client_tests); do		\
+	    echo $${i}_SOURCES = $$i.cpp;	\
+	    echo $${i}_LDADD = '$$(lib_client) $$(lib_common) $$(extra_libs)'; \
+	  done;					\
+	  libs=;				\
+	  for i in $(unit_tests); do		\
+	    libs="$$libs $${i}.la";		\
+	    echo $${i}_la_SOURCES = $$i.cpp;	\
+	    echo $${i}_la_LIBADD = '$$(lib_common)';			\
+	    echo $${i}_la_LIBADD += '$$(lib_broker) $$(extra_libs)';	\
+	    echo $${i}_la_LDFLAGS = '-module -rpath $$(abs_builddir)';	\
+	  done;					\
+	  echo "check_LTLIBRARIES =$$libs";	\
+	)					\
+	> $@-t
+	mv $@-t $@

Added: incubator/qpid/trunk/qpid/cpp/tests/MessageBuilderTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/tests/MessageBuilderTest.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/tests/MessageBuilderTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/tests/MessageBuilderTest.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,203 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <Exception.h>
+#include <BrokerMessage.h>
+#include <MessageBuilder.h>
+#include <NullMessageStore.h>
+#include <Buffer.h>
+#include <qpid_test_plugin.h>
+#include <iostream>
+#include <memory>
+
+using namespace boost;
+using namespace qpid::broker;
+using namespace qpid::framing;
+using namespace qpid::sys;
+
+class MessageBuilderTest : public CppUnit::TestCase  
+{
+    struct DummyHandler : MessageBuilder::CompletionHandler{
+        Message::shared_ptr msg;
+        
+        virtual void complete(Message::shared_ptr& _msg){
+            msg = _msg;
+        }
+    };
+
+    class TestMessageStore : public NullMessageStore
+    {
+        Buffer* header;
+        Buffer* content;
+        const u_int32_t contentBufferSize;
+        
+    public:
+
+        void stage(Message::shared_ptr& msg)
+        {
+            if (msg->getPersistenceId() == 0) {
+                header = new Buffer(msg->encodedHeaderSize());
+                msg->encodeHeader(*header);                
+                content = new Buffer(contentBufferSize);
+                msg->setPersistenceId(1);
+            } else {
+                throw qpid::Exception("Message already staged!");
+            }
+        }
+
+        void appendContent(u_int64_t msgId, const string& data)
+        {
+            if (msgId == 1) {
+                content->putRawData(data);
+            } else {
+                throw qpid::Exception("Invalid message id!");
+            }
+        }
+
+        Message::shared_ptr getRestoredMessage()
+        {
+            Message::shared_ptr msg(new Message());
+            if (header) {
+                header->flip();
+                msg->decodeHeader(*header);
+                delete header;
+                header = 0; 
+                if (content) {
+                    content->flip();
+                    msg->decodeContent(*content);
+                    delete content;
+                    content = 0;
+                }
+            }
+            return msg;
+        }
+        
+        //dont care about any of the other methods:
+        TestMessageStore(u_int32_t _contentBufferSize) : NullMessageStore(false), header(0), content(0), 
+                                                         contentBufferSize(_contentBufferSize) {}
+        ~TestMessageStore(){}
+    };
+
+    CPPUNIT_TEST_SUITE(MessageBuilderTest);
+    CPPUNIT_TEST(testHeaderOnly);
+    CPPUNIT_TEST(test1ContentFrame);
+    CPPUNIT_TEST(test2ContentFrames);
+    CPPUNIT_TEST(testStaging);
+    CPPUNIT_TEST_SUITE_END();
+
+  public:
+
+    void testHeaderOnly(){
+        DummyHandler handler;
+        MessageBuilder builder(&handler);
+
+        Message::shared_ptr message(new Message(0, "test", "my_routing_key", false, false));
+        AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC));
+        header->setContentSize(0);
+        
+        builder.initialise(message);
+        CPPUNIT_ASSERT(!handler.msg);
+        builder.setHeader(header);
+        CPPUNIT_ASSERT(handler.msg);
+        CPPUNIT_ASSERT_EQUAL(message, handler.msg);
+    }
+
+    void test1ContentFrame(){
+        DummyHandler handler;
+        MessageBuilder builder(&handler);
+
+        string data1("abcdefg");
+
+        Message::shared_ptr message(new Message(0, "test", "my_routing_key", false, false));
+        AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC));
+        header->setContentSize(7);
+        AMQContentBody::shared_ptr part1(new AMQContentBody(data1));
+        
+        builder.initialise(message);
+        CPPUNIT_ASSERT(!handler.msg);
+        builder.setHeader(header);
+        CPPUNIT_ASSERT(!handler.msg);
+        builder.addContent(part1);
+        CPPUNIT_ASSERT(handler.msg);
+        CPPUNIT_ASSERT_EQUAL(message, handler.msg);
+    }
+
+    void test2ContentFrames(){
+        DummyHandler handler;
+        MessageBuilder builder(&handler);
+
+        string data1("abcdefg");
+        string data2("hijklmn");
+
+        Message::shared_ptr message(new Message(0, "test", "my_routing_key", false, false));
+        AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC));
+        header->setContentSize(14);
+        AMQContentBody::shared_ptr part1(new AMQContentBody(data1));
+        AMQContentBody::shared_ptr part2(new AMQContentBody(data2));        
+        
+        builder.initialise(message);
+        CPPUNIT_ASSERT(!handler.msg);
+        builder.setHeader(header);
+        CPPUNIT_ASSERT(!handler.msg);
+        builder.addContent(part1);
+        CPPUNIT_ASSERT(!handler.msg);
+        builder.addContent(part2);
+        CPPUNIT_ASSERT(handler.msg);
+        CPPUNIT_ASSERT_EQUAL(message, handler.msg);
+    }
+
+    void testStaging(){
+        DummyHandler handler;
+        TestMessageStore store(14);
+        MessageBuilder builder(&handler, &store, 5);
+
+        string data1("abcdefg");
+        string data2("hijklmn");
+
+        Message::shared_ptr message(new Message(0, "test", "my_routing_key", false, false));
+        AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC));
+        header->setContentSize(14);
+        BasicHeaderProperties* properties = dynamic_cast<BasicHeaderProperties*>(header->getProperties());
+        properties->setMessageId("MyMessage");
+        properties->getHeaders().setString("abc", "xyz");
+
+        AMQContentBody::shared_ptr part1(new AMQContentBody(data1));
+        AMQContentBody::shared_ptr part2(new AMQContentBody(data2));        
+        
+        builder.initialise(message);
+        builder.setHeader(header);
+        builder.addContent(part1);
+        builder.addContent(part2);
+        CPPUNIT_ASSERT(handler.msg);
+        CPPUNIT_ASSERT_EQUAL(message, handler.msg);
+
+        Message::shared_ptr restored = store.getRestoredMessage();
+        CPPUNIT_ASSERT_EQUAL(message->getExchange(), restored->getExchange());
+        CPPUNIT_ASSERT_EQUAL(message->getRoutingKey(), restored->getRoutingKey());
+        CPPUNIT_ASSERT_EQUAL(message->getHeaderProperties()->getMessageId(), restored->getHeaderProperties()->getMessageId());
+        CPPUNIT_ASSERT_EQUAL(message->getHeaderProperties()->getHeaders().getString("abc"), 
+                             restored->getHeaderProperties()->getHeaders().getString("abc"));
+        CPPUNIT_ASSERT_EQUAL((u_int64_t) 14, restored->contentSize());
+    }
+};
+
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(MessageBuilderTest);

Propchange: incubator/qpid/trunk/qpid/cpp/tests/MessageBuilderTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/tests/MessageBuilderTest.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date