[rhmessaging-commits] rhmessaging commits: r1570 - in store/trunk/cpp: lib and 2 other directories.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Fri Jan 18 09:14:22 EST 2008


Author: kpvdr
Date: 2008-01-18 09:14:21 -0500 (Fri, 18 Jan 2008)
New Revision: 1570

Added:
   store/trunk/cpp/tests/jrnl/_ut_enq_map.cpp
   store/trunk/cpp/tests/jrnl/_ut_jdir.cpp
   store/trunk/cpp/tests/jrnl/_ut_jerrno.cpp
   store/trunk/cpp/tests/jrnl/_ut_jexception.cpp
   store/trunk/cpp/tests/jrnl/_ut_jinf.cpp
   store/trunk/cpp/tests/jrnl/_ut_rec_hdr.cpp
   store/trunk/cpp/tests/jrnl/_ut_txn_map.cpp
   store/trunk/cpp/tests/jrnl/jhexdump
Removed:
   store/trunk/cpp/tests/jrnl/unit_test_enq_map.cpp
   store/trunk/cpp/tests/jrnl/unit_test_jdir.cpp
   store/trunk/cpp/tests/jrnl/unit_test_jerrno.cpp
   store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp
   store/trunk/cpp/tests/jrnl/unit_test_jinf.cpp
   store/trunk/cpp/tests/jrnl/unit_test_rec_hdr.cpp
   store/trunk/cpp/tests/jrnl/unit_test_txn_map.cpp
Modified:
   store/trunk/cpp/bootstrap
   store/trunk/cpp/configure.ac
   store/trunk/cpp/lib/JournalImpl.cpp
   store/trunk/cpp/lib/JournalImpl.h
   store/trunk/cpp/lib/jrnl/aio_cb.hpp
   store/trunk/cpp/lib/jrnl/data_tok.cpp
   store/trunk/cpp/lib/jrnl/deq_rec.cpp
   store/trunk/cpp/lib/jrnl/enq_map.cpp
   store/trunk/cpp/lib/jrnl/enq_rec.cpp
   store/trunk/cpp/lib/jrnl/enq_rec.hpp
   store/trunk/cpp/lib/jrnl/jcntl.cpp
   store/trunk/cpp/lib/jrnl/jcntl.hpp
   store/trunk/cpp/lib/jrnl/jdir.cpp
   store/trunk/cpp/lib/jrnl/jexception.hpp
   store/trunk/cpp/lib/jrnl/jinf.cpp
   store/trunk/cpp/lib/jrnl/nlfh.cpp
   store/trunk/cpp/lib/jrnl/nlfh.hpp
   store/trunk/cpp/lib/jrnl/pmgr.cpp
   store/trunk/cpp/lib/jrnl/pmgr.hpp
   store/trunk/cpp/lib/jrnl/rmgr.cpp
   store/trunk/cpp/lib/jrnl/rmgr.hpp
   store/trunk/cpp/lib/jrnl/rrfc.cpp
   store/trunk/cpp/lib/jrnl/slock.hpp
   store/trunk/cpp/lib/jrnl/txn_map.cpp
   store/trunk/cpp/lib/jrnl/txn_rec.cpp
   store/trunk/cpp/lib/jrnl/wmgr.cpp
   store/trunk/cpp/lib/jrnl/wmgr.hpp
   store/trunk/cpp/lib/jrnl/wrfc.cpp
   store/trunk/cpp/lib/jrnl/wrfc.hpp
   store/trunk/cpp/tests/jrnl/
   store/trunk/cpp/tests/jrnl/JournalSystemTests.cpp
   store/trunk/cpp/tests/jrnl/JournalSystemTests.hpp
   store/trunk/cpp/tests/jrnl/Makefile.am
Log:
Bugfixes and tidy-up

Modified: store/trunk/cpp/bootstrap
===================================================================
--- store/trunk/cpp/bootstrap	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/bootstrap	2008-01-18 14:14:21 UTC (rev 1570)
@@ -1,4 +1,26 @@
 #!/bin/sh
+
+# Copyright (C) 2007, 2008 Red Hat Inc.
+#
+# This file is part of Red Hat Messaging.
+#
+# Red Hat Messaging is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+# USA
+#
+# The GNU Lesser General Public License is available in the file COPYING.
+
 set -e
 aclocal -I m4
 autoheader
@@ -11,3 +33,5 @@
 
 automake --add-missing
 autoconf
+
+# cd tests/jrnl/jtt && ./bootstrap

Modified: store/trunk/cpp/configure.ac
===================================================================
--- store/trunk/cpp/configure.ac	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/configure.ac	2008-01-18 14:14:21 UTC (rev 1570)
@@ -1,14 +1,27 @@
+dnl # Copyright (C) 2007, 2008 Red Hat Inc.
+dnl #
+dnl # This file is part of Red Hat Messaging.
+dnl #
+dnl # Red Hat Messaging is free software; you can redistribute it and/or
+dnl # modify it under the terms of the GNU Lesser General Public
+dnl # License as published by the Free Software Foundation; either
+dnl # version 2.1 of the License, or (at your option) any later version.
+dnl #
+dnl # This library is distributed in the hope that it will be useful,
+dnl # but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl # Lesser General Public License for more details.
+dnl #
+dnl # You should have received a copy of the GNU Lesser General Public
+dnl # License along with this library; if not, write to the Free Software
+dnl # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+dnl # USA
+dnl #
+dnl # The GNU Lesser General Public License is available in the file COPYING.
+dnl 
 dnl Process this file with autoconf to produce a configure script.
-dnl
-dnl This file is free software; as a special exception the author gives
-dnl unlimited permission to copy and/or distribute it, with or without
-dnl modifications, as long as this notice is preserved.
-dnl
-dnl This program is distributed in the hope that it will be useful, but
-dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
-dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
-AC_INIT([rhm], [0.2], [rhm-users at redhat.com])
+AC_INIT([MRG Store Module], [0.9], [rhm-users at redhat.com])
 AC_CONFIG_AUX_DIR([build-aux])
 AM_INIT_AUTOMAKE([dist-bzip2])
 
@@ -177,4 +190,6 @@
   docs/Makefile
   ])
 
+dnl AC_CONFIG_SUBDIRS([tests/jrnl/jtt])
+
 AC_OUTPUT

Modified: store/trunk/cpp/lib/JournalImpl.cpp
===================================================================
--- store/trunk/cpp/lib/JournalImpl.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/JournalImpl.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2007 Red Hat Software
+    Copyright (C) 2007, 2008 Red Hat Software
 
     This file is part of Red Hat Messaging.
     
@@ -80,8 +80,7 @@
 }
 
 void
-JournalImpl::recover(std::deque<data_tok*>* rd_dtokl, const aio_cb rd_cb,
-        std::deque<data_tok*>* wr_dtokl, const aio_cb wr_cb,
+JournalImpl::recover(const aio_cb rd_cb, const aio_cb wr_cb,
         boost::ptr_list<bdbstore::PreparedTransaction>& prep_tx_list, u_int64_t& highest_rid,
         u_int64_t queue_id)
 {
@@ -92,7 +91,7 @@
         prep_xid_list.push_back(i->xid);
     }
 
-    jcntl::recover(rd_dtokl, rd_cb, wr_dtokl, wr_cb, prep_xid_list, highest_rid);
+    jcntl::recover(rd_cb, wr_cb, prep_xid_list, highest_rid);
         
     // Populate PreparedTransaction lists from _tmap
     for (bdbstore::PreparedTransaction::list::iterator i = prep_tx_list.begin();
@@ -313,62 +312,49 @@
     }
 }
 
+// static AIO callback fns
+
 void
-JournalImpl::aio_wr_callback(jcntl* journal, u_int32_t num_dtoks)
+JournalImpl::aio_wr_callback(jcntl* journal, std::vector<data_tok*>& dtokl)
 {
-    JournalImpl* jip = static_cast<JournalImpl*>(journal);
-//kpvdr TODO -- this list needs to be mutexed...???
-    std::deque<rhm::journal::data_tok*> this_dtok_list(jip->_aio_wr_cmpl_dtok_list.begin(),
-            jip->_aio_wr_cmpl_dtok_list.end());
-	    
-    jip->_aio_wr_cmpl_dtok_list.clear();
-    for (u_int32_t i=0; i<num_dtoks; i++)
+    for (std::vector<data_tok*>::const_iterator i=dtokl.begin(); i!=dtokl.end(); i++)
     {
-        DataTokenImpl* dtokp = static_cast<DataTokenImpl*>(this_dtok_list.front());
-		if (!journal->is_stopped() && dtokp->getSourceMessage())
-		{
-			switch (dtokp->wstate())
-			{
- 				case data_tok::ENQ:
-     	         	dtokp->getSourceMessage()->enqueueComplete();
- 					break;
-				case data_tok::DEQ:
+        DataTokenImpl* dtokp = static_cast<DataTokenImpl*>(*i);
+	    if (!journal->is_stopped() && dtokp->getSourceMessage())
+	    {
+		    switch (dtokp->wstate())
+		    {
+ 			    case data_tok::ENQ:
+             	    dtokp->getSourceMessage()->enqueueComplete();
+ 				    break;
+			    case data_tok::DEQ:
 /* Don't need to signal until we have a way to ack completion of dequeue in AMQP
-     	        	dtokp->getSourceMessage()->dequeueComplete();
-		     		if ( dtokp->getSourceMessage()->isDequeueComplete()  ) // clear id after last dequeue
-		         		dtokp->getSourceMessage()->setPersistenceId(0);
+                    dtokp->getSourceMessage()->dequeueComplete();
+                    if ( dtokp->getSourceMessage()->isDequeueComplete()  ) // clear id after last dequeue
+                        dtokp->getSourceMessage()->setPersistenceId(0);
 */
-					break;
-				default:
-					;
-			}
-		}
-		dtokp->release();
-        this_dtok_list.pop_front();
+				    break;
+			    default:
+				    ;
+		    }
+	    }
+	    dtokp->release();
     }
 }
 
 void
-JournalImpl::aio_rd_callback(jcntl*  journal, u_int32_t num_dtoks)
+JournalImpl::aio_rd_callback(jcntl* journal, std::vector<data_tok*>& dtokl)
 {
-    JournalImpl* jip = static_cast<JournalImpl*>(journal);
-//kpvdr TODO -- can we get rid of the copy???
-    std::deque<rhm::journal::data_tok*> this_dtok_list(jip->_aio_rd_cmpl_dtok_list.begin(),
-            jip->_aio_rd_cmpl_dtok_list.end());
-    jip->_aio_rd_cmpl_dtok_list.clear();
-    for (u_int32_t i=0; i<num_dtoks; i++)
-    {
-        DataTokenImpl* dtokp = static_cast<DataTokenImpl*>(this_dtok_list.front());
-		if (!journal->is_stopped() && dtokp->getSourceMessage())
-		{
-        	if (dtokp->wstate() == data_tok::ENQ && dtokp->rstate() == data_tok::READ)
-         	{
-                // cct call the recovery manager. / lazyload.. 
-        	}
-		}
-	    dtokp->release();
-        this_dtok_list.pop_front();
-    }
-    
+        for (std::vector<data_tok*>::const_iterator i=dtokl.begin(); i!=dtokl.end(); i++)
+        {
+            DataTokenImpl* dtokp = static_cast<DataTokenImpl*>(*i);
+		    if (!journal->is_stopped() && dtokp->getSourceMessage())
+		    {
+                if (dtokp->wstate() == data_tok::ENQ && dtokp->rstate() == data_tok::READ)
+                {
+                    // cct call the recovery manager. / lazyload.. 
+                }
+            }
+            dtokp->release();
+        }
 }
-

Modified: store/trunk/cpp/lib/JournalImpl.h
===================================================================
--- store/trunk/cpp/lib/JournalImpl.h	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/JournalImpl.h	2008-01-18 14:14:21 UTC (rev 1570)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2007 Red Hat Software
+    Copyright (C) 2007, 2008 Red Hat Software
 
     This file is part of Red Hat Messaging.
     
@@ -82,9 +82,6 @@
             journal::data_tok _dtok;
             bool _external;
 
-            std::deque<rhm::journal::data_tok*> _aio_rd_cmpl_dtok_list; ///< Internally mamanged deque
-            std::deque<rhm::journal::data_tok*> _aio_wr_cmpl_dtok_list; ///< Internally mamanged deque
-
         public:
             JournalImpl(const std::string& journalId,
                         const std::string& journalDirectory,
@@ -95,20 +92,15 @@
                         const qpid::sys::Duration flushTimeout);
             virtual ~JournalImpl();
 
-            inline void initialize() {
-	            jcntl::initialize(&_aio_rd_cmpl_dtok_list, &aio_rd_callback, &_aio_wr_cmpl_dtok_list,
-                        &aio_wr_callback );
-	        } 
+            inline void initialize() { jcntl::initialize(&aio_rd_callback, &aio_wr_callback); } 
 
-            void recover(std::deque<journal::data_tok*>* rd_dtokl, const journal::aio_cb rd_cb,
-			        std::deque<journal::data_tok*>* wr_dtokl, const journal::aio_cb wr_cb,
+            void recover(const journal::aio_cb rd_cb, const journal::aio_cb wr_cb,
                     boost::ptr_list<bdbstore::PreparedTransaction>& prep_tx_list,
                     u_int64_t& highest_rid, u_int64_t queue_id);
 
             inline void recover(boost::ptr_list<bdbstore::PreparedTransaction>& prep_tx_list,
                     u_int64_t& highest_rid, u_int64_t queue_id) {
-                recover(&_aio_rd_cmpl_dtok_list, &aio_rd_callback, &_aio_wr_cmpl_dtok_list,
-                    &aio_wr_callback, prep_tx_list, highest_rid, queue_id);
+                recover(&aio_rd_callback,  &aio_wr_callback, prep_tx_list, highest_rid, queue_id);
             }
             
             // Temporary fn to read and save last msg read from journal so it can be assigned
@@ -151,8 +143,8 @@
 
         private:
             void handleIoResult(const journal::iores r);
-            static void aio_wr_callback(jcntl* journal, u_int32_t num_dtoks);
-            static void aio_rd_callback(jcntl* journal, u_int32_t num_dtoks);
+            static void aio_wr_callback(jcntl* journal, std::vector<journal::data_tok*>& dtokl);
+            static void aio_rd_callback(jcntl* journal, std::vector<journal::data_tok*>& dtokl);
         }; // class JournalImpl
 
     } // namespace bdbstore

Modified: store/trunk/cpp/lib/jrnl/aio_cb.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/aio_cb.hpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/aio_cb.hpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * This file contains the definition for the AIO callback function
 * pointer.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -33,17 +31,20 @@
 #ifndef rhm_journal_aio_cb_hpp
 #define rhm_journal_aio_cb_hpp
 
+#include <vector>
+
 namespace rhm
 {
 namespace journal
 {
     
     class jcntl;
+    class data_tok;
     
     /**
     * \brief Callback function pointer to be called when AIO events arrive.
     */
-    typedef void (*aio_cb)(jcntl* journal, u_int32_t num_dtoks);
+    typedef void (*aio_cb)(jcntl* journal, std::vector<data_tok*>& dtokl);
 }
 }
 

Modified: store/trunk/cpp/lib/jrnl/data_tok.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/data_tok.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/data_tok.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * File containing code for class rhm::journal::data_tok (data block token).
 * See comments in file data_tok.hpp for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -55,7 +53,7 @@
     _xid(),
     _external_rid(false)
 {
-    pthread_mutex_init(&_mutex, NULL);
+    pthread_mutex_init(&_mutex, 0);
     pthread_mutex_lock(&_mutex);
     _icnt = _cnt++;
     pthread_mutex_unlock(&_mutex);
@@ -148,7 +146,7 @@
         std::ostringstream oss;
         oss << "Attempted to change read state to " << rstate_str(rstate);
         oss << " while write state is not enqueued (wstate ENQ); wstate=" << wstate_str() << ".";
-        throw new jexception(jerrno::JERR_DTOK_ILLEGALSTATE, oss.str(), "data_tok",
+        throw jexception(jerrno::JERR_DTOK_ILLEGALSTATE, oss.str(), "data_tok",
                 "set_rstate");
     }
     _rstate = rstate;

Modified: store/trunk/cpp/lib/jrnl/deq_rec.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/deq_rec.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/deq_rec.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * This file contains the code for the rhm::journal::deq_rec (journal dequeue
 * record) class. See comments in file deq_rec.hpp for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -46,8 +44,8 @@
 
 deq_rec::deq_rec():
         _deq_hdr(RHM_JDAT_DEQ_MAGIC, RHM_JDAT_VERSION, 0, 0, 0, false),
-        _xidp(NULL),
-        _buff(NULL),
+        _xidp(0),
+        _buff(0),
         _deq_tail(_deq_hdr)
 {}
 
@@ -55,7 +53,7 @@
         const size_t xidlen, const bool owi):
         _deq_hdr(RHM_JDAT_DEQ_MAGIC, RHM_JDAT_VERSION, rid, drid, xidlen, owi),
         _xidp(xidp),
-        _buff(NULL),
+        _buff(0),
         _deq_tail(_deq_hdr)
 {}
 
@@ -71,8 +69,8 @@
     _deq_hdr._deq_rid = 0;
     _deq_hdr._xidsize = 0;
     _deq_tail._rid = 0;
-    _xidp = NULL;
-    _buff = NULL;
+    _xidp = 0;
+    _buff = 0;
 }
 
 void
@@ -85,15 +83,15 @@
     _deq_hdr._xidsize = xidlen;
     _deq_tail._rid = rid;
     _xidp = xidp;
-    _buff = NULL;
+    _buff = 0;
 }
 
 const u_int32_t
 deq_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
 {
-    assert(wptr != NULL);
+    assert(wptr != 0);
     assert(max_size_dblks > 0);
-    if (_xidp == NULL)
+    if (_xidp == 0)
         assert(_deq_hdr._xidsize == 0);
 
     size_t rec_offs = rec_offs_dblks * JRNL_DBLK_SIZE;
@@ -203,7 +201,7 @@
 const u_int32_t
 deq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
 {
-    assert(rptr != NULL);
+    assert(rptr != 0);
     assert(max_size_dblks > 0);
 
     size_t rd_cnt = 0;
@@ -376,7 +374,7 @@
 {
     if (!_buff)
     {
-        *xidpp = NULL;
+        *xidpp = 0;
         return 0;
     }
     *xidpp = _buff;

Modified: store/trunk/cpp/lib/jrnl/enq_map.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/enq_map.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/enq_map.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * File containing code for class rhm::journal::enq_map (enqueue map). See
 * comments in file enq_map.hpp for details.
 *
-* \author Kim van der Riet
+* Copyright (C) 2007, 2008 Red Hat Inc.
 *
-* Copyright (C) 2007 Red Hat Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -36,6 +34,7 @@
 #include <sstream>
 #include <jrnl/jerrno.hpp>
 
+
 namespace rhm
 {
 namespace journal
@@ -44,7 +43,7 @@
 enq_map::enq_map():
         _map()
 {
-    pthread_mutex_init(&_mutex, NULL);
+    pthread_mutex_init(&_mutex, 0);
 }
 
 enq_map::~enq_map()

Modified: store/trunk/cpp/lib/jrnl/enq_rec.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/enq_rec.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/enq_rec.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * This file contains the code for the rhm::journal::enq_rec (journal enqueue
 * record) class. See comments in file enq_rec.hpp for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -48,9 +46,9 @@
 enq_rec::enq_rec():
         jrec(), // superclass
         _enq_hdr(RHM_JDAT_ENQ_MAGIC, RHM_JDAT_VERSION, 0, 0, 0, false, false),
-        _xidp(NULL),
-        _data(NULL),
-        _buff(NULL),
+        _xidp(0),
+        _data(0),
+        _buff(0),
         _enq_tail(_enq_hdr)
 {}
 
@@ -61,7 +59,7 @@
         _enq_hdr(RHM_JDAT_ENQ_MAGIC, RHM_JDAT_VERSION, rid, xidlen, dlen, owi, transient),
         _xidp(xidp),
         _data(dbuf),
-        _buff(NULL),
+        _buff(0),
         _enq_tail(_enq_hdr)
 {}
 
@@ -80,9 +78,9 @@
     _enq_hdr.set_transient(false);
     _enq_hdr._xidsize = 0;
     _enq_hdr._dsize = 0;
-    _xidp = NULL;
-    _data = NULL;
-    _buff = NULL;
+    _xidp = 0;
+    _data = 0;
+    _buff = 0;
     _enq_tail._rid = 0;
 }
 
@@ -101,16 +99,16 @@
     _enq_hdr._dsize = dlen;
     _xidp = xidp;
     _data = dbuf;
-    _buff = NULL;
+    _buff = 0;
     _enq_tail._rid = rid;
 }
 
 const u_int32_t
 enq_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
 {
-    assert(wptr != NULL);
+    assert(wptr != 0);
     assert(max_size_dblks > 0);
-    if (_xidp == NULL)
+    if (_xidp == 0)
         assert(_enq_hdr._xidsize == 0);
 
     size_t rec_offs = rec_offs_dblks * JRNL_DBLK_SIZE;
@@ -253,7 +251,7 @@
 const u_int32_t
 enq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
 {
-    assert(rptr != NULL);
+    assert(rptr != 0);
     assert(max_size_dblks > 0);
 
     size_t rd_cnt = 0;
@@ -474,7 +472,7 @@
     }
     if (!_enq_hdr.is_external())
     {
-        if (rec_offs < sizeof(rec_hdr) + _enq_hdr._xidsize +  _enq_hdr._dsize)
+        if (rec_offs < sizeof(_enq_hdr) + _enq_hdr._xidsize +  _enq_hdr._dsize)
         {
             // Ignore data (or continue ignoring data)
             size_t offs = rec_offs - sizeof(_enq_hdr) - _enq_hdr._xidsize;
@@ -514,7 +512,7 @@
 {
     if (!_buff)
     {
-        *xidpp = NULL;
+        *xidpp = 0;
         return 0;
     }
     *xidpp = _buff;
@@ -526,11 +524,11 @@
 {
     if (!_buff)
     {
-        *datapp = NULL;
+        *datapp = 0;
         return 0;
     }
     if (_enq_hdr.is_external())
-        *datapp = NULL;
+        *datapp = 0;
     else
         *datapp = (void*)((char*)_buff + _enq_hdr._xidsize);
     return _enq_hdr._dsize;
@@ -551,18 +549,6 @@
 }
 
 const size_t
-enq_rec::data_size() const
-{
-    return _enq_hdr._dsize;
-}
-
-const size_t
-enq_rec::xid_size() const
-{
-    return _enq_hdr._xidsize;
-}
-
-const size_t
 enq_rec::rec_size() const
 {
     return rec_size(_enq_hdr._xidsize, _enq_hdr._dsize, _enq_hdr.is_external());

Modified: store/trunk/cpp/lib/jrnl/enq_rec.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/enq_rec.hpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/enq_rec.hpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * This file contains the code for the rhm::journal::enq_rec (journal enqueue
 * record) class. See class documentation for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -97,8 +95,8 @@
         inline const bool is_transient() const { return _enq_hdr.is_transient(); }
         inline const bool is_external() const { return _enq_hdr.is_external(); }
         std::string& str(std::string& str) const;
-        const size_t data_size() const;
-        const size_t xid_size() const;
+        inline const size_t data_size() const { return _enq_hdr._dsize; }
+        inline const size_t xid_size() const { return _enq_hdr._xidsize; }
         const size_t rec_size() const;
         static const size_t rec_size(const size_t xidsize, const size_t dsize, const bool external);
         inline const u_int64_t rid() const { return _enq_hdr._rid; }

Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * Messaging journal top-level control and interface class
 * rhm::journal::jcntl.  See comments in file jcntl.hpp for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -64,7 +62,7 @@
     _autostop(true),
     _num_jfiles(num_jfiles > JRNL_MIN_NUM_FILES ? num_jfiles : JRNL_MIN_NUM_FILES),
     _jfsize_sblks(jfsize_sblks > JRNL_MIN_FILE_SIZE ? jfsize_sblks :JRNL_MIN_FILE_SIZE),
-    _datafh(NULL),
+    _datafh(0),
     _emap(),
     _tmap(),
     _rrfc(),
@@ -73,8 +71,8 @@
     _wmgr(this, _emap, _tmap, _wrfc),
     _rcvdat(_num_jfiles)
 {
-    pthread_mutex_init(&_wr_mutex, NULL);
-    pthread_mutex_init(&_gev_mutex, NULL);
+    pthread_mutex_init(&_wr_mutex, 0);
+    pthread_mutex_init(&_gev_mutex, 0);
 }
 
 jcntl::~jcntl()
@@ -85,17 +83,15 @@
     if (_datafh)
     {
         for (u_int32_t i=0; i<_num_jfiles; i++)
-            if (_datafh[i])
-                ::delete _datafh[i];
-        ::delete[] _datafh;
+            delete _datafh[i];
+        delete[] _datafh;
     }
     pthread_mutex_destroy(&_gev_mutex);
     pthread_mutex_destroy(&_wr_mutex);
 }
 
 void
-jcntl::initialize(std::deque<data_tok*>* rdtoklp, const aio_cb rd_cb,
-        std::deque<data_tok*>* wdtoklp, const aio_cb wr_cb)
+jcntl::initialize(const aio_cb rd_cb, const aio_cb wr_cb)
 {
     _init_flag = false;
     _stop_flag = false;
@@ -105,23 +101,22 @@
     _jdir.clear_dir();
     _emap.clear();
 
-    // TODO - place this in a finalize() fn? - see ~jcntl()...
+    // TODO - place this in a finalize() fn? - see ~jcntl() & recover()...
     if (_datafh)
     {
         for (u_int32_t i=0; i<_num_jfiles; i++)
-            if (_datafh[i])
-                ::delete _datafh[i];
-        ::delete[] _datafh;
+            delete _datafh[i];
+        delete[] _datafh;
     }
 
-    _datafh = ::new lfh*[_num_jfiles];
-    // NULL the pointer array first because new() can throw exceptions
+    _datafh = new lfh*[_num_jfiles];
+    // Zero the pointer array first because new() can throw exceptions
     ::memset(_datafh, 0, sizeof(lfh*) * _num_jfiles);
     for (u_int16_t i=0; i<_num_jfiles; i++)
     {
         std::ostringstream oss;
         oss << _jdir << "/" << _base_filename;
-        _datafh[i] = ::new lfh(oss.str(), i, _jfsize_sblks, NULL);
+        _datafh[i] = new lfh(oss.str(), i, _jfsize_sblks, 0);
     }
 
     // TODO: Check the following comment/note (may be obsolete):
@@ -130,8 +125,8 @@
     // constrains read activity (i.e. one can't read what has not yet been written).
     _wrfc.initialize(_num_jfiles, _jfsize_sblks, (nlfh**)_datafh);
     _rrfc.initialize(_num_jfiles, (nlfh**)_datafh);
-    _rmgr.initialize(rdtoklp, rd_cb, 0);
-    _wmgr.initialize(wdtoklp, wr_cb, JRNL_WMGR_MAXDTOKPP, JRNL_WMGR_MAXWAITUS);
+    _rmgr.initialize(rd_cb, 0);
+    _wmgr.initialize(wr_cb, JRNL_WMGR_MAXDTOKPP, JRNL_WMGR_MAXWAITUS);
 
     // Write info file (<basename>.jinf) to disk
     write_infofile();
@@ -140,8 +135,8 @@
 }
 
 void
-jcntl::recover(std::deque<data_tok*>* rdtoklp, const aio_cb rd_cb, std::deque<data_tok*>* wdtoklp,
-        const aio_cb wr_cb, const std::vector<std::string>& prep_txn_list, u_int64_t& highest_rid)
+jcntl::recover(const aio_cb rd_cb, const aio_cb wr_cb,
+        const std::vector<std::string>& prep_txn_list, u_int64_t& highest_rid)
 {
     _init_flag = false;
     _stop_flag = false;
@@ -161,22 +156,22 @@
     // Debug info; should be sent to log file
     // std::cout << _rcvdat.to_string(_jid) << std::endl << std::flush;
 
+    // TODO - place this in a finalize() fn? - see ~jcntl() & initialize()...
     if (_datafh)
     {
         for (u_int32_t i=0; i<_num_jfiles; i++)
-            if (_datafh[i])
-                ::delete _datafh[i];
-        ::delete[] _datafh;
+            delete _datafh[i];
+        delete[] _datafh;
     }
 
-    _datafh = ::new lfh*[_num_jfiles];
-    // NULL the pointer array first because new() can throw exceptions
+    _datafh = new lfh*[_num_jfiles];
+    // 0 the pointer array first because new() can throw exceptions
     ::memset(_datafh, 0, sizeof(lfh*) * _num_jfiles);
     for (u_int16_t i=0; i<_num_jfiles; i++)
     {
         std::ostringstream oss;
         oss << _jdir << "/" << _base_filename;
-        _datafh[i] = ::new lfh(oss.str(), i, _jfsize_sblks, &_rcvdat);
+        _datafh[i] = new lfh(oss.str(), i, _jfsize_sblks, &_rcvdat);
     }
 
     // TODO: Check the following comment/note (may be obsolete):
@@ -185,8 +180,8 @@
     // constrains read activity (i.e. one can't read what has not yet been written).
     _wrfc.initialize(_num_jfiles, _jfsize_sblks, (nlfh**)_datafh, &_rcvdat);
     _rrfc.initialize(_num_jfiles, (nlfh**)_datafh, _rcvdat._ffid);
-    _rmgr.initialize(rdtoklp, rd_cb, _rcvdat._fro);
-    _wmgr.initialize(wdtoklp, wr_cb, JRNL_WMGR_MAXDTOKPP, JRNL_WMGR_MAXWAITUS, _rcvdat._eo);
+    _rmgr.initialize(rd_cb, _rcvdat._fro);
+    _wmgr.initialize(wr_cb, JRNL_WMGR_MAXDTOKPP, JRNL_WMGR_MAXWAITUS, _rcvdat._eo);
     
     _readonly_flag = true;
     _init_flag = true;
@@ -221,7 +216,7 @@
     {
         slock s(&_wr_mutex);
         iores r;
-        while (handle_aio_wait(_wmgr.enqueue(data_buff, tot_data_len, this_data_len, dtokp, NULL,
+        while (handle_aio_wait(_wmgr.enqueue(data_buff, tot_data_len, this_data_len, dtokp, 0,
                 0, transient, false), r));
         return r;
     }
@@ -234,7 +229,7 @@
     {
         slock s(&_wr_mutex);
         iores r;
-        while (handle_aio_wait(_wmgr.enqueue(NULL, tot_data_len, 0, dtokp, NULL, 0, transient,
+        while (handle_aio_wait(_wmgr.enqueue(0, tot_data_len, 0, dtokp, 0, 0, transient,
                 true), r));
         return r;
     }
@@ -263,7 +258,7 @@
     {
         slock s(&_wr_mutex);
         iores r;
-        while (handle_aio_wait(_wmgr.enqueue(NULL, tot_data_len, 0, dtokp, xid.data(), xid.size(),
+        while (handle_aio_wait(_wmgr.enqueue(0, tot_data_len, 0, dtokp, xid.data(), xid.size(),
                 transient, true), r));
         return r;
     }
@@ -299,7 +294,7 @@
     {
         slock s(&_wr_mutex);
         iores r;
-        while (handle_aio_wait(_wmgr.dequeue(dtokp, NULL, 0), r));
+        while (handle_aio_wait(_wmgr.dequeue(dtokp, 0, 0), r));
         return r;
     }
 }
@@ -523,7 +518,7 @@
 jcntl::rcvr_get_next_record(u_int16_t& fid, std::ifstream* ifsp, bool& lowi, rcvdat& rd)
 {
     size_t cum_size_read = 0;
-    void* xidp = NULL;
+    void* xidp = 0;
     rec_hdr h;
     if (!jfile_cycle(fid, ifsp, lowi, rd, true))
         return false;
@@ -542,7 +537,7 @@
                     if (er.xid_size())
                     {
                         er.get_xid(&xidp);
-                        assert(xidp != NULL);
+                        assert(xidp != 0);
                         std::string xid((char*)xidp, er.xid_size());
                         _tmap.insert_txn_data(xid, txn_data(h._rid, 0, fid, true));
                         ::free(xidp);
@@ -566,7 +561,7 @@
                         if (e.err_code() != jerrno::JERR_MAP_NOTFOUND) throw;
                     }
                     dr.get_xid(&xidp);
-                    assert(xidp != NULL);
+                    assert(xidp != 0);
                     std::string xid((char*)xidp, dr.xid_size());
                     _tmap.insert_txn_data(xid, txn_data(dr.rid(), dr.deq_rid(), fid, false));
                     ::free(xidp);
@@ -592,7 +587,7 @@
                     return false;
                 // Delete this txn from tmap, unlock any locked records in emap
                 ar.get_xid(&xidp);
-                assert(xidp != NULL);
+                assert(xidp != 0);
                 std::string xid((char*)xidp, ar.xid_size());
                 txn_data_list tdl = _tmap.get_remove_tdata_list(xid);
                 for (tdl_itr itr = tdl.begin(); itr != tdl.end(); itr++)
@@ -619,7 +614,7 @@
                     return false;
                 // Delete this txn from tmap, process records into emap
                 cr.get_xid(&xidp);
-                assert(xidp != NULL);
+                assert(xidp != 0);
                 std::string xid((char*)xidp, cr.xid_size());
                 txn_data_list tdl = _tmap.get_remove_tdata_list(xid);
                 for (tdl_itr itr = tdl.begin(); itr != tdl.end(); itr++)
@@ -777,7 +772,7 @@
             throw jexception(jerrno::JERR__FILEIO, oss.str(), "jcntl", "check_journal_alignment");
         ofsp.seekp(file_pos);
         void* buff = ::malloc(JRNL_DBLK_SIZE);
-        assert(buff != NULL);
+        assert(buff != 0);
         ::memcpy(buff, (void*)&xmagic, sizeof(xmagic));
         // Normally, RHM_CLEAN must be set before these fills are done, but this is a recover
         // situation (i.e. performance is not an issue), and it makes the location of the write

Modified: store/trunk/cpp/lib/jrnl/jcntl.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.hpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/jcntl.hpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * Messaging journal top-level control and interface class
 * rhm::journal::jcntl. See class documentation for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -161,6 +159,8 @@
         * \brief Destructor.
         */
          virtual ~jcntl();
+         
+         inline const std::string& id() const { return _jid; }
 
         /**
         * \brief Initialize the journal for storing data.
@@ -177,16 +177,12 @@
         * <b>NOTE: If <i>NULL</i> is passed to the callbacks, internal default callbacks will be
         * used.</b>
         *
-        * \param rdtoklp deque for storing data tokens retruning from read AIO operations.
-        * \param rd_cb Function pointer to callback function for read operations. May be NULL.
-        * \param wdtoklp deque for storing data tokens retruning from enqueue and dequeue (write)
-        *     AIO operations.
-        * \param wr_cb Function pointer to callback function for write operations. May be NULL.
+        * \param rd_cb Function pointer to callback function for read operations. May be 0 (NULL).
+        * \param wr_cb Function pointer to callback function for write operations. May be 0 (NULL).
         *
         * \exception TODO
         */
-        void initialize(std::deque<data_tok*>* rdtoklp, const aio_cb rd_cb,
-			std::deque<data_tok*>* wdtoklp, const aio_cb wr_cb);
+        void initialize(const aio_cb rd_cb, const aio_cb wr_cb);
 
         /**
         * /brief Initialize journal by recovering state from previously written journal.
@@ -203,19 +199,15 @@
         * <b>NOTE: If <i>NULL</i> is passed to the callbacks, internal default callbacks will be
         * used.</b>
         *
-        * \param rdtoklp deque for storing data tokens retruning from read AIO operations.
-        * \param rd_cb Function pointer to callback function for read operations. May be NULL.
-        * \param wdtoklp deque for storing data tokens retruning from enqueue and dequeue (write)
-        *     AIO operations.
-        * \param wr_cb Function pointer to callback function for write operations. May be NULL.
+        * \param rd_cb Function pointer to callback function for read operations. May be 0 (NULL).
+        * \param wr_cb Function pointer to callback function for write operations. May be 0 (NULL).
         * \param prep_txn_list
         * \param highest_rid Returns the highest rid found in the journal during recover
         *
         * \exception TODO
         */
-        void recover(std::deque<data_tok*>* rdtoklp, const aio_cb rd_cb,
-			std::deque<data_tok*>* wdtoklp, const aio_cb wr_cb,
-            const std::vector<std::string>& prep_txn_list, u_int64_t& highest_rid);
+        void recover(const aio_cb rd_cb, const aio_cb wr_cb,
+                const std::vector<std::string>& prep_txn_list, u_int64_t& highest_rid);
 
         /**
         * \brief Notification to the journal that recovery is complete and that normal operation

Modified: store/trunk/cpp/lib/jrnl/jdir.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jdir.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/jdir.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -7,10 +7,8 @@
 * directory), used for controlling and manipulating journal data
 * direcories and files. See comments in file jdir.hpp for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -131,7 +129,7 @@
     struct dirent* entry;
     bool found = false;
     std::string bak_dir;
-    while ((entry = ::readdir(dir)) != NULL)
+    while ((entry = ::readdir(dir)) != 0)
     {
         // Ignore . and ..
         if (::strcmp(entry->d_name, ".") != 0 && ::strcmp(entry->d_name, "..") != 0)
@@ -249,7 +247,7 @@
     }
     else
     {
-        while ((entry = ::readdir(dir)) != NULL)
+        while ((entry = ::readdir(dir)) != 0)
         {
             // Ignore . and ..
             if (::strcmp(entry->d_name, ".") != 0 && ::strcmp(entry->d_name, "..") != 0)
@@ -325,7 +323,7 @@
         throw jexception(jerrno::JERR_JDIR_OPENDIR, oss.str(), "jdir", "create_bak_dir");
     }
     struct dirent* entry;
-    while ((entry = ::readdir(dir)) != NULL)
+    while ((entry = ::readdir(dir)) != 0)
     {
         // Ignore . and ..
         if (::strcmp(entry->d_name, ".") != 0 && ::strcmp(entry->d_name, "..") != 0)
@@ -336,8 +334,7 @@
                 oss << "_" << base_filename << ".bak.";
                 if (::strncmp(entry->d_name, oss.str().c_str(), base_filename.size() + 6) == 0)
                 {
-                    long this_dir_num = ::strtol(entry->d_name + base_filename.size() + 6,
-                            NULL, 16);
+                    long this_dir_num = ::strtol(entry->d_name + base_filename.size() + 6, 0, 16);
                     if (this_dir_num > dir_num)
                         dir_num = this_dir_num;
                 }

Modified: store/trunk/cpp/lib/jrnl/jexception.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jexception.hpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/jexception.hpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -8,10 +8,8 @@
 * class for all more speicalized exceptions in the message journal. See
 * class documentation for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -50,7 +48,7 @@
 // Macro for formatting commom system errors
 #define FORMAT_SYSERR(errno) " errno=" << errno << " (" << strerror(errno) << ")"
 
-#define MALLOC_CHK(ptr, var, cls, fn) if(ptr == NULL) { \
+#define MALLOC_CHK(ptr, var, cls, fn) if(ptr == 0) { \
     clean(); \
     std::ostringstream oss; \
     oss << var << ": malloc() failed: " << FORMAT_SYSERR(errno); \

Modified: store/trunk/cpp/lib/jrnl/jinf.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jinf.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/jinf.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -7,10 +7,8 @@
 *
 * See jinf.hpp comments for details of this class.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -54,7 +52,7 @@
         _wmgr_num_pages(0),
         _rmgr_page_size_dblks(0),
         _rmgr_num_pages(0),
-        _tm_ptr(NULL),
+        _tm_ptr(0),
         _valid_flag(false),
         _analyzed_flag(false),
         _start_file(0),
@@ -361,12 +359,12 @@
     const char* target1_str = "value=\"";
     int target2_char = '\"';
     char* t1 = ::strstr(line, target1_str);
-    if (t1 == NULL)
+    if (t1 == 0)
         throw jexception(jerrno::JERR_JINF_NOVALUESTR, line, "jinf", "find_value");
     t1 += ::strlen(target1_str);
 
     char* t2 = ::strchr(t1, target2_char);
-    if (t2 == NULL)
+    if (t2 == 0)
         throw jexception(jerrno::JERR_JINF_BADVALUESTR, line, "jinf", "find_value");
     *t2 = '\0';
     return t1;

Modified: store/trunk/cpp/lib/jrnl/nlfh.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/nlfh.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/nlfh.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -7,10 +7,8 @@
 * handle), used for controlling journal log files. See comments in file
 * nlfh.hpp for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -145,7 +143,7 @@
             // header which precedes all data on each file and is exactly one sblock in size.
             u_int32_t nsblks = jfsize_sblks + 1;
 
-            void* nullbuf = NULL;
+            void* nullbuf = 0;
             if (::posix_memalign(&nullbuf, sblksize, writesize))
             {
                 std::ostringstream oss;

Modified: store/trunk/cpp/lib/jrnl/nlfh.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/nlfh.hpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/nlfh.hpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -7,10 +7,8 @@
 * handle), used for controlling journal log files. See class documentation for
 * details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -78,7 +76,7 @@
 
         virtual void initialize(const std::string& fbasename, const u_int16_t fid,
                 const u_int32_t jfsize_sblks, const rcvdat* const ro);
-        virtual bool reset(const rcvdat* const ro = NULL);
+        virtual bool reset(const rcvdat* const ro = 0);
 
         inline const std::string& fname() const { return _fname; }
         inline const u_int16_t fid() const { return _fid; }

Modified: store/trunk/cpp/lib/jrnl/pmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/pmgr.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/pmgr.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * File containing code for class rhm::journal::pmgr (page manager). See
 * comments in file pmgr.hpp for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -48,10 +46,10 @@
         _state(UNUSED),
         _wdblks(0),
         _rdblks(0),
-        _pdtokl(NULL),
-        _wfh(NULL),
-        _rfh(NULL),
-        _pbuff(NULL)
+        _pdtokl(0),
+        _wfh(0),
+        _rfh(0),
+        _pbuff(0)
 {}
 
 const char*
@@ -80,12 +78,11 @@
         _jc(jc),
         _emap(emap),
         _tmap(tmap),
-        _dtoklp(NULL),
-        _page_base_ptr(NULL),
-        _page_ptr_arr(NULL),
-        _page_cb_arr(NULL),
-        _iocb_arr(NULL),
-        _ioevt_arr(NULL),
+        _page_base_ptr(0),
+        _page_ptr_arr(0),
+        _page_cb_arr(0),
+        _iocb_arr(0),
+        _ioevt_arr(0),
         _ioctx(0),
         _pg_index(0),
         _pg_cntr(0),
@@ -94,35 +91,9 @@
         _enq_rec(),
         _deq_rec(),
         _txn_rec(),
-        _cb(NULL)
+        _cb(0)
 {}
 
-pmgr::pmgr(jcntl* jc, enq_map& emap, txn_map& tmap, const u_int32_t pagesize, const u_int16_t pages,
-        std::deque<data_tok*>* const dtoklp):
-        _pagesize(pagesize),
-        _pages(pages),
-        _jc(jc),
-        _emap(emap),
-        _tmap(tmap),
-        _dtoklp(dtoklp),
-        _page_base_ptr(NULL),
-        _page_ptr_arr(NULL),
-        _page_cb_arr(NULL),
-        _iocb_arr(NULL),
-        _ioevt_arr(NULL),
-        _ioctx(0),
-        _pg_index(0),
-        _pg_cntr(0),
-        _pg_offset_dblks(0),
-        _aio_evt_rem(0),
-        _enq_rec(),
-        _deq_rec(),
-        _txn_rec(),
-        _cb(NULL)
-{
-    initialize();
-}
-
 pmgr::~pmgr()
 {
     clean();
@@ -168,7 +139,7 @@
         _page_cb_arr[i]._index = i;
         _page_cb_arr[i]._state = UNUSED;
         _page_cb_arr[i]._pbuff = _page_ptr_arr[i];
-        _page_cb_arr[i]._pdtokl = ::new std::deque<data_tok*>;
+        _page_cb_arr[i]._pdtokl = new std::deque<data_tok*>;
         _page_cb_arr[i]._pdtokl->clear();
         _iocb_arr[i].data = (void*)&_page_cb_arr[i];
     }
@@ -191,35 +162,29 @@
 pmgr::clean()
 {
     // clean up allocated memory here
+
     if (_ioctx)
         ::io_queue_release(_ioctx);
-    if (_page_base_ptr)
+
+    ::free(_page_base_ptr);
+    _page_base_ptr = 0;
+
+    if (_page_cb_arr)
     {
-        ::free(_page_base_ptr);
-        _page_base_ptr = NULL;
-    }
-    if (_page_ptr_arr)
-    {
         for (int i=0; i<_pages; i++)
-            ::delete _page_cb_arr[i]._pdtokl;
+            delete _page_cb_arr[i]._pdtokl;
         ::free(_page_ptr_arr);
-        _page_ptr_arr = NULL;
+        _page_ptr_arr = 0;
     }
-    if (_page_cb_arr)
-    {
-        ::free(_page_cb_arr);
-        _page_cb_arr = NULL;
-    }
-    if (_iocb_arr)
-    {
-        ::free(_iocb_arr);
-        _iocb_arr = NULL;
-    }
-    if (_ioevt_arr)
-    {
-        ::free(_ioevt_arr);
-        _ioevt_arr = NULL;
-    }
+
+    ::free(_page_cb_arr);
+    _page_cb_arr = 0;
+
+    ::free(_iocb_arr);
+    _iocb_arr = 0;
+
+    ::free(_ioevt_arr);
+    _ioevt_arr = 0;
 }
 
 const char*

Modified: store/trunk/cpp/lib/jrnl/pmgr.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/pmgr.hpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/pmgr.hpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * File containing code for class rhm::journal::pmgr (page manager). See
 * class documentation for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -103,7 +101,6 @@
         jcntl* _jc;                     ///< Pointer to journal controller
         enq_map& _emap;                 ///< Ref to enqueue map
         txn_map& _tmap;                 ///< Ref to transaction map
-        std::deque<data_tok*>* _dtoklp; ///< Pointer to external data token list
         void* _page_base_ptr;           ///< Base pointer to page memory
         void** _page_ptr_arr;           ///< Array of pointers to pages in page memory
         page_cb* _page_cb_arr;          ///< Array of page_cb structs
@@ -124,8 +121,6 @@
     public:
         pmgr(jcntl* jc, enq_map& emap, txn_map& tmap, const u_int32_t pagesize,
                 const u_int16_t pages);
-        pmgr(jcntl* jc, enq_map& emap, txn_map& tmap, const u_int32_t pagesize,
-                const u_int16_t pages, std::deque<data_tok*>* const dtoklp);
         virtual ~pmgr();
 
         virtual const u_int32_t get_events(page_state state) = 0;

Modified: store/trunk/cpp/lib/jrnl/rmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/rmgr.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * File containing code for class rhm::journal::rmgr (read manager). See
 * comments in file rmgr.hpp for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -49,20 +47,12 @@
         _hdr()
 {}
 
-rmgr::rmgr(jcntl* jc, enq_map& emap, txn_map& tmap, rrfc& rrfc,
-        std::deque<data_tok*>* const dtokl):
-        pmgr(jc, emap, tmap, JRNL_RMGR_PAGE_SIZE, JRNL_RMGR_PAGES, dtokl),
-        _rrfc(rrfc),
-        _hdr()
-{}
-
 rmgr::~rmgr()
 {}
 
 void
-rmgr::initialize(std::deque<data_tok*>* const dtoklp, const aio_cb rd_cb, size_t fro)
+rmgr::initialize(const aio_cb rd_cb, size_t fro)
 {
-    _dtoklp = dtoklp;
     _cb = rd_cb;
     initialize();
     if (fro)
@@ -82,14 +72,14 @@
         const void** const /*data*/, bool /*auto_discard*/)
 {
 //std::cout << " rmgr::get()" << std::flush;
-    iores res = pre_read_check(NULL);
+    iores res = pre_read_check(0);
     if (res != RHM_IORES_SUCCESS)
         return res;
 
     return RHM_IORES_NOTIMPL;
 
-//TODO - untangle this...
-/*     _hdr.reset();
+/* TODO...
+    _hdr.reset();
     // Read header, determine next record type
     while (true)
     {
@@ -182,7 +172,7 @@
 
     return RHM_IORES_NOTIMPL;
 
-/* TODO - untangle this...
+/* TODO...
     _hdr.reset();
     // Read header, determine next record type
     while (true)
@@ -392,7 +382,7 @@
 rmgr::get_events(page_state state)
 {
     int ret = 0;
-    if ((ret = ::io_getevents(_ioctx, 0, JRNL_RMGR_PAGES + JRNL_WMGR_PAGES, _ioevt_arr, NULL)) < 0)
+    if ((ret = ::io_getevents(_ioctx, 0, JRNL_RMGR_PAGES + JRNL_WMGR_PAGES, _ioevt_arr, 0)) < 0)
     {
         if (ret == -EINTR) // No events
             return 0;
@@ -427,8 +417,9 @@
 
         // Transfer all data tokens
         u_int32_t s = pcbp->_pdtokl->size();
+        std::vector<data_tok*> dtokl(s, 0);
         for (u_int32_t k=0; k<s; k++)
-            _dtoklp->push_back(pcbp->_pdtokl->at(k));
+            dtokl[k] = pcbp->_pdtokl->at(k);
         tot_data_toks += s;
 
         // Increment the completed read offset
@@ -443,7 +434,7 @@
 
         // Perform AIO return callback
         if (_cb)
-            (_cb)(_jc, s);
+            (_cb)(_jc, dtokl);
     }
 
     return tot_data_toks;
@@ -748,9 +739,9 @@
 void
 rmgr::set_params_null(void** const datapp, size_t& dsize, void** const xidpp, size_t& xidsize)
 {
-    *datapp = NULL;
+    *datapp = 0;
     dsize = 0;
-    *xidpp = NULL;
+    *xidpp = 0;
     xidsize = 0;
 }
 

Modified: store/trunk/cpp/lib/jrnl/rmgr.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.hpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/rmgr.hpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * File containing code for class rhm::journal::rmgr (read manager). See
 * class documentation for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -65,11 +63,9 @@
 
     public:
         rmgr(jcntl* jc, enq_map& emap, txn_map& tmap, rrfc& rrfc);
-        rmgr(jcntl* jc, enq_map& emap, txn_map& tmap, rrfc& rrfc,
-                std::deque<data_tok*>* const dtokl);
         virtual ~rmgr();
 
-        void initialize(std::deque<data_tok*>* const dtoklp, const aio_cb rd_cb, size_t fro);
+        void initialize(const aio_cb rd_cb, size_t fro);
         const iores get(const u_int64_t& rid, const size_t& dsize, const size_t& dsize_avail,
                 const void** const data, bool auto_discard);
         const iores discard(data_tok* dtok);

Modified: store/trunk/cpp/lib/jrnl/rrfc.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/rrfc.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/rrfc.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * File containing code for class rhm::journal::rrfc (rotating
 * file controller). See comments in file rrfc.hpp for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -43,9 +41,9 @@
 
 rrfc::rrfc():
         _nfiles(0),
-        _fh_arr(NULL),
+        _fh_arr(0),
         _fh_index(0),
-        _curr_fh(NULL)
+        _curr_fh(0)
 {}
 
 rrfc::~rrfc() {}

Modified: store/trunk/cpp/lib/jrnl/slock.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/slock.hpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/slock.hpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * Messaging journal scoped lock class rhm::journal::slock and scoped try-clock
 * class rhm::journal::stlock.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -33,6 +31,7 @@
 #ifndef rhm_journal_slock_hpp
 #define rhm_journal_slock_hpp
 
+#include <sstream>
 #include <pthread.h>
 #include <errno.h>
 #include <jrnl/jerrno.hpp>

Modified: store/trunk/cpp/lib/jrnl/txn_map.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/txn_map.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/txn_map.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * File containing code for class rhm::journal::txn_map (transaction map). See
 * comments in file txn_map.hpp for details.
 *
-* \author Kim van der Riet
+* Copyright (C) 2007, 2008 Red Hat Inc.
 *
-* Copyright (C) 2007 Red Hat Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -54,7 +52,7 @@
 txn_map::txn_map():
         _map()
 {
-    pthread_mutex_init(&_mutex, NULL);
+    pthread_mutex_init(&_mutex, 0);
 }
 
 txn_map::~txn_map()

Modified: store/trunk/cpp/lib/jrnl/txn_rec.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/txn_rec.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/txn_rec.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * This file contains the code for the rhm::journal::txn_rec (journal dequeue
 * record) class. See comments in file txn_rec.hpp for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -46,8 +44,8 @@
 
 txn_rec::txn_rec():
         _txn_hdr(),
-        _xidp(NULL),
-        _buff(NULL),
+        _xidp(0),
+        _buff(0),
         _txn_tail()
 {
     _txn_hdr._version = RHM_JDAT_VERSION;
@@ -57,7 +55,7 @@
         const size_t xidlen, const bool owi):
         _txn_hdr(magic, RHM_JDAT_VERSION, rid, xidlen, owi),
         _xidp(xidp),
-        _buff(NULL),
+        _buff(0),
         _txn_tail(_txn_hdr)
 {}
 
@@ -72,8 +70,8 @@
     _txn_hdr._magic = magic;
     _txn_hdr._rid = 0;
     _txn_hdr._xidsize = 0;
-    _xidp = NULL;
-    _buff = NULL;
+    _xidp = 0;
+    _buff = 0;
     _txn_tail._xmagic = ~magic;
     _txn_tail._rid = 0;
 }
@@ -87,7 +85,7 @@
     _txn_hdr.set_owi(owi);
     _txn_hdr._xidsize = xidlen;
     _xidp = xidp;
-    _buff = NULL;
+    _buff = 0;
     _txn_tail._xmagic = ~magic;
     _txn_tail._rid = rid;
 }
@@ -95,9 +93,9 @@
 const u_int32_t
 txn_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
 {
-    assert(wptr != NULL);
+    assert(wptr != 0);
     assert(max_size_dblks > 0);
-    assert(_xidp != NULL && _txn_hdr._xidsize > 0);
+    assert(_xidp != 0 && _txn_hdr._xidsize > 0);
 
     size_t rec_offs = rec_offs_dblks * JRNL_DBLK_SIZE;
     size_t rem = max_size_dblks * JRNL_DBLK_SIZE;
@@ -203,7 +201,7 @@
 const u_int32_t
 txn_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
 {
-    assert(rptr != NULL);
+    assert(rptr != 0);
     assert(max_size_dblks > 0);
 
     size_t rd_cnt = 0;
@@ -365,7 +363,7 @@
 {
     if (!_buff)
     {
-        *xidpp = NULL;
+        *xidpp = 0;
         return 0;
     }
     *xidpp = _buff;

Modified: store/trunk/cpp/lib/jrnl/wmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/wmgr.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * File containing code for class rhm::journal::wmgr (read manager). See
 * comments in file wmgr.hpp for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -49,9 +47,9 @@
         _wrfc(wrfc),
         _max_dtokpp(0),
         _max_io_wait_us(0),
-        _fhdr_base_ptr(NULL),
-        _fhdr_ptr_arr(NULL),
-        _iocba(NULL),
+        _fhdr_base_ptr(0),
+        _fhdr_ptr_arr(0),
+        _iocba(0),
         _cached_offset_dblks(0),
         _jfsize_dblks(_jc->jfsize_sblks() * JRNL_SBLK_SIZE),
         _jfsize_pgs(_jc->jfsize_sblks() / JRNL_WMGR_PAGE_SIZE),
@@ -64,15 +62,15 @@
     assert(_jc->jfsize_sblks() % JRNL_RMGR_PAGE_SIZE == 0);
 }
 
-wmgr::wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc, std::deque<data_tok*>* const dtoklp,
+wmgr::wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc,
         const u_int32_t max_dtokpp, const u_int32_t max_iowait_us):
-        pmgr(jc, emap, tmap, JRNL_WMGR_PAGE_SIZE, JRNL_WMGR_PAGES, dtoklp),
+        pmgr(jc, emap, tmap, JRNL_WMGR_PAGE_SIZE, JRNL_WMGR_PAGES/* , dtoklp */),
         _wrfc(wrfc),
         _max_dtokpp(max_dtokpp),
         _max_io_wait_us(max_iowait_us),
-        _fhdr_base_ptr(NULL),
-        _fhdr_ptr_arr(NULL),
-        _iocba(NULL),
+        _fhdr_base_ptr(0),
+        _fhdr_ptr_arr(0),
+        _iocba(0),
         _cached_offset_dblks(0),
         _jfsize_dblks(_jc->jfsize_sblks() * JRNL_SBLK_SIZE),
         _jfsize_pgs(_jc->jfsize_sblks() / JRNL_WMGR_PAGE_SIZE),
@@ -91,14 +89,13 @@
 }
 
 void
-wmgr::initialize(std::deque<data_tok*>* dtoklp, const aio_cb wr_cb, const u_int32_t max_dtokpp,
-        const u_int32_t max_iowait_us, size_t eo)
+wmgr::initialize(const aio_cb wr_cb, const u_int32_t max_dtokpp, const u_int32_t max_iowait_us,
+        size_t eo)
 {
     _enq_busy = false;
     _deq_busy = false;
     _abort_busy = false;
     _commit_busy = false;
-    _dtoklp = dtoklp;
     _max_dtokpp = max_dtokpp;
     _max_io_wait_us = max_iowait_us;
     _cb = wr_cb;
@@ -118,7 +115,7 @@
         const bool external)
 {
     if (xid_len)
-        assert(xid_ptr != NULL);
+        assert(xid_ptr != 0);
 
     if (this_data_len != tot_data_len && !external)
         return RHM_IORES_NOTIMPL;
@@ -258,7 +255,7 @@
 wmgr::dequeue(data_tok* dtokp, const void* const xid_ptr, const size_t xid_len)
 {
     if (xid_len)
-        assert(xid_ptr != NULL);
+        assert(xid_ptr != 0);
 
     iores res = pre_write_check(WMGR_DEQUEUE, dtokp);
     if (res != RHM_IORES_SUCCESS)
@@ -406,7 +403,7 @@
 wmgr::abort(data_tok* dtokp, const void* const xid_ptr, const size_t xid_len)
 {
     // commit and abort MUST have a valid xid
-    assert(xid_ptr != NULL && xid_len > 0);
+    assert(xid_ptr != 0 && xid_len > 0);
 
     if (_enq_busy || _deq_busy || _commit_busy)
         return RHM_IORES_BUSY;
@@ -552,7 +549,7 @@
 wmgr::commit(data_tok* dtokp, const void* const xid_ptr, const size_t xid_len)
 {
     // commit and abort MUST have a valid xid
-    assert(xid_ptr != NULL && xid_len > 0);
+    assert(xid_ptr != 0 && xid_len > 0);
 
     if (_enq_busy || _deq_busy || _abort_busy)
         return RHM_IORES_BUSY;
@@ -766,7 +763,7 @@
 wmgr::get_events(page_state state)
 {
     int ret = 0;
-    if ((ret = ::io_getevents(_ioctx, 0, JRNL_RMGR_PAGES + JRNL_WMGR_PAGES, _ioevt_arr, NULL)) < 0)
+    if ((ret = ::io_getevents(_ioctx, 0, JRNL_RMGR_PAGES + JRNL_WMGR_PAGES, _ioevt_arr, 0)) < 0)
     {
         if (ret == -EINTR) // No events
             return 0;
@@ -799,9 +796,11 @@
         if (pcbp) // Page writes have pcb
         {
             u_int32_t s = pcbp->_pdtokl->size();
+            std::vector<data_tok*> dtokl(s, 0);
             for (u_int32_t k=0; k<s; k++)
             {
                 data_tok* dtp = pcbp->_pdtokl->at(k);
+                dtokl[k] = dtp;
                 std::set<std::string>::iterator it;
                 switch (dtp->wstate())
                 {
@@ -849,7 +848,6 @@
                     throw jexception(jerrno::JERR_WMGR_BADDTOKSTATE, oss.str(), "wmgr",
                             "get_events");
                 }
-                _dtoklp->push_back(dtp);
             }
             tot_data_toks += s;
 
@@ -862,6 +860,10 @@
             // Clean up this pcb's data_tok list
             pcbp->_pdtokl->clear();
             pcbp->_state = state;
+
+            // Perform AIO return callback
+            if (_cb && tot_data_toks)
+                (_cb)(_jc, dtokl);
         }
         else // File header writes have no pcb
         {
@@ -874,10 +876,6 @@
         }        
     }
 
-    // Perform AIO return callback
-    if (_cb && tot_data_toks)
-        (_cb)(_jc, tot_data_toks);
-
     return tot_data_toks;
 }
 
@@ -919,7 +917,7 @@
     for (u_int16_t i=0; i<num_jfiles; i++)
     {
         _fhdr_ptr_arr[i] = (void*)((char*)_fhdr_base_ptr + _sblksize * i);
-        _iocba[i] = ::new iocb;
+        _iocba[i] = new iocb;
     }
     _page_cb_arr[0]._state = IN_USE;
     _ddtokl.clear();
@@ -1043,23 +1041,18 @@
 wmgr::clean()
 {
     // clean up allocated memory here
-    if (_fhdr_base_ptr)
-    {
-        ::free(_fhdr_base_ptr);
-        _fhdr_base_ptr = NULL;
-    }
-    if (_fhdr_ptr_arr)
-    {
-        ::free(_fhdr_ptr_arr);
-        _fhdr_ptr_arr = NULL;
-    }
+    ::free(_fhdr_base_ptr);
+    _fhdr_base_ptr = 0;
+
+    ::free(_fhdr_ptr_arr);
+    _fhdr_ptr_arr = 0;
+
     if (_iocba)
     {
         for (u_int32_t i=0; i<_jc->num_jfiles(); i++)
-            if (_iocba[i])
-                ::delete _iocba[i];
+            delete _iocba[i];
         ::free(_iocba);
-        _iocba = NULL;
+        _iocba = 0;
     }
 }
 

Modified: store/trunk/cpp/lib/jrnl/wmgr.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.hpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/wmgr.hpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * File containing code for class rhm::journal::wmgr (read manager). See
 * class documentation for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -99,13 +97,12 @@
 
     public:
         wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc);
-        wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc,
-                std::deque<data_tok*>* const dtoklp, const u_int32_t max_dtokpp,
+        wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc, const u_int32_t max_dtokpp,
                 const u_int32_t max_iowait_us);
         virtual ~wmgr();
 
-        void initialize(std::deque<data_tok*>* const dtoklp, aio_cb wr_cb,
-                const u_int32_t max_dtokpp, const u_int32_t max_iowait_us, size_t eo = 0);
+        void initialize(aio_cb wr_cb, const u_int32_t max_dtokpp, const u_int32_t max_iowait_us,
+                size_t eo = 0);
         const iores enqueue(const void* const data_buff, const size_t tot_data_len,
                 const size_t this_data_len, data_tok* dtokp, const void* const xid_ptr,
                 const size_t xid_len, const bool transient, const bool external);

Modified: store/trunk/cpp/lib/jrnl/wrfc.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wrfc.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/wrfc.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * File containing code for class rhm::journal::rrfc (rotating
 * file controller). See comments in file rrfc.hpp for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -30,8 +28,6 @@
 * The GNU Lesser General Public License is available in the file COPYING.
 */
 
-#include <iostream> // TODO: remove later, for debug only.
-
 #include <jrnl/wrfc.hpp>
 #include <jrnl/jerrno.hpp>
 #include <jrnl/jexception.hpp>

Modified: store/trunk/cpp/lib/jrnl/wrfc.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wrfc.hpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/lib/jrnl/wrfc.hpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -6,10 +6,8 @@
 * File containing code for class rhm::journal::wrfc (write rotating
 * file controller). See class documentation for details.
 *
-* \author Kim van der Riet
+* Copyright 2007, 2008 Red Hat, Inc.
 *
-* Copyright 2007 Red Hat, Inc.
-*
 * This file is part of Red Hat Messaging.
 *
 * Red Hat Messaging is free software; you can redistribute it and/or
@@ -73,10 +71,10 @@
         * \param fh_arr Pointer to an array of file handles (nlogging_fh or subclasses),
         *     each of which correspond to one of the physical files.
         * \param rdp Struct carrying restore information. Optional for non-restore use, defaults to
-        *     NULL.
+        *     0 (NULL).
         */
         void initialize(const u_int16_t nfiles, const u_int32_t fsize_sblks, nlfh** fh_arr,
-                rcvdat* rdp = NULL);
+                rcvdat* rdp = 0);
 
         /**
         * \brief Rotate active file handle to next file in rotating file group.


Property changes on: store/trunk/cpp/tests/jrnl
___________________________________________________________________
Name: svn:ignore
   - .deps
.libs
Makefile
Makefile.in
jtest
unit_test_enq_map
unit_test_jdir
unit_test_jerrno
unit_test_jexception
unit_test_jinf
unit_test_rec_hdr
unit_test_txn_map

   + .deps
.libs
Makefile
Makefile.in
jtest
_ut_enq_map
_ut_jdir
_ut_jerrno
_ut_jexception
_ut_jinf
_ut_rec_hdr
_ut_txn_map


Modified: store/trunk/cpp/tests/jrnl/JournalSystemTests.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/JournalSystemTests.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/tests/jrnl/JournalSystemTests.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -647,14 +647,14 @@
 void
 JournalSystemTests::jrnl_init(rhm::journal::jcntl* jc)
 {
-    jc->initialize(&aioRdCmplList, NULL, &aioWrCmplList, NULL);
+    jc->initialize(0, 0);
 }
 
 void
 JournalSystemTests::jrnl_recover(rhm::journal::jcntl* jc, vector<string> txn_list,
         u_int64_t& highest_rid)
 {
-    jc->recover(&aioRdCmplList, NULL, &aioWrCmplList, NULL, txn_list, highest_rid);
+    jc->recover(0, 0, txn_list, highest_rid);
 }
 
 void

Modified: store/trunk/cpp/tests/jrnl/JournalSystemTests.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/JournalSystemTests.hpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/tests/jrnl/JournalSystemTests.hpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -56,8 +56,6 @@
     size_t xidsize;
     bool transientFlag;
     bool externalFlag;
-    std::deque<rhm::journal::data_tok*> aioRdCmplList;
-    std::deque<rhm::journal::data_tok*> aioWrCmplList;
 
 public:
     void InstantiationTest();

Modified: store/trunk/cpp/tests/jrnl/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.am	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/tests/jrnl/Makefile.am	2008-01-18 14:14:21 UTC (rev 1570)
@@ -1,4 +1,4 @@
-# Copyright (C) 2007 Red Hat Inc.
+# Copyright (C) 2007, 2008 Red Hat Inc.
 #
 # This file is part of Red Hat Messaging.
 #
@@ -25,14 +25,16 @@
 
 INCLUDES=-I../../lib
 
+# SUBDIRS = jtt
+
 TESTS = \
-  unit_test_jexception \
-  unit_test_jerrno \
-  unit_test_rec_hdr \
-  unit_test_jinf \
-  unit_test_jdir \
-  unit_test_enq_map \
-  unit_test_txn_map \
+  _ut_jexception \
+  _ut_jerrno \
+  _ut_rec_hdr \
+  _ut_jinf \
+  _ut_jdir \
+  _ut_enq_map \
+  _ut_txn_map \
   run-journal-tests
 
 check_LTLIBRARIES = \
@@ -40,37 +42,37 @@
   libdlclose_noop.la
 
 check_PROGRAMS = \
-  unit_test_jexception \
-  unit_test_jerrno \
-  unit_test_rec_hdr \
-  unit_test_jinf \
-  unit_test_jdir \
-  unit_test_enq_map \
-  unit_test_txn_map
+  _ut_jexception \
+  _ut_jerrno \
+  _ut_rec_hdr \
+  _ut_jinf \
+  _ut_jdir \
+  _ut_enq_map \
+  _ut_txn_map
 
 UNIT_TEST_SRCS = ../unit_test.cpp
 UNIT_TEST_LDADD = -lboost_unit_test_framework -lbdbstore -L../../lib/.libs 
 
-unit_test_jexception_SOURCES = unit_test_jexception.cpp $(UNIT_TEST_SRCS)
-unit_test_jexception_LDFLAGS = $(UNIT_TEST_LDADD)
+_ut_jexception_SOURCES = _ut_jexception.cpp $(UNIT_TEST_SRCS)
+_ut_jexception_LDFLAGS = $(UNIT_TEST_LDADD)
 
-unit_test_jerrno_SOURCES = unit_test_jerrno.cpp $(UNIT_TEST_SRCS)
-unit_test_jerrno_LDADD = $(UNIT_TEST_LDADD)
+_ut_jerrno_SOURCES = _ut_jerrno.cpp $(UNIT_TEST_SRCS)
+_ut_jerrno_LDADD = $(UNIT_TEST_LDADD)
 
-unit_test_rec_hdr_SOURCES = unit_test_rec_hdr.cpp $(UNIT_TEST_SRCS)
-unit_test_rec_hdr_LDADD = $(UNIT_TEST_LDADD) -lrt
+_ut_rec_hdr_SOURCES = _ut_rec_hdr.cpp $(UNIT_TEST_SRCS)
+_ut_rec_hdr_LDADD = $(UNIT_TEST_LDADD) -lrt
 
-unit_test_jinf_SOURCES = unit_test_jinf.cpp $(UNIT_TEST_SRCS)
-unit_test_jinf_LDADD = $(UNIT_TEST_LDADD) -lrt
+_ut_jinf_SOURCES = _ut_jinf.cpp $(UNIT_TEST_SRCS)
+_ut_jinf_LDADD = $(UNIT_TEST_LDADD) -lrt
 
-unit_test_jdir_SOURCES = unit_test_jdir.cpp $(UNIT_TEST_SRCS)
-unit_test_jdir_LDADD = $(UNIT_TEST_LDADD) -lrt
+_ut_jdir_SOURCES = _ut_jdir.cpp $(UNIT_TEST_SRCS)
+_ut_jdir_LDADD = $(UNIT_TEST_LDADD) -lrt
 
-unit_test_enq_map_SOURCES = unit_test_enq_map.cpp $(UNIT_TEST_SRCS)
-unit_test_enq_map_LDADD = $(UNIT_TEST_LDADD) -lrt
+_ut_enq_map_SOURCES = _ut_enq_map.cpp $(UNIT_TEST_SRCS)
+_ut_enq_map_LDADD = $(UNIT_TEST_LDADD) -lrt
 
-unit_test_txn_map_SOURCES = unit_test_txn_map.cpp $(UNIT_TEST_SRCS)
-unit_test_txn_map_LDADD = $(UNIT_TEST_LDADD) -lrt
+_ut_txn_map_SOURCES = _ut_txn_map.cpp $(UNIT_TEST_SRCS)
+_ut_txn_map_LDADD = $(UNIT_TEST_LDADD) -lrt
 
 JournalSystemTests_la_SOURCES = \
   JournalSystemTests.cpp   \

Copied: store/trunk/cpp/tests/jrnl/_ut_enq_map.cpp (from rev 1569, store/trunk/cpp/tests/jrnl/unit_test_enq_map.cpp)
===================================================================
--- store/trunk/cpp/tests/jrnl/_ut_enq_map.cpp	                        (rev 0)
+++ store/trunk/cpp/tests/jrnl/_ut_enq_map.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -0,0 +1,238 @@
+/**
+* \file _ut_enq_map.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the unit tests for the journal.
+*
+* Copyright 2007, 2008 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include "../unit_test.h"
+#include <jrnl/enq_map.hpp>
+#include <jrnl/jerrno.hpp>
+
+using namespace boost::unit_test;
+using namespace rhm::journal;
+
+QPID_AUTO_TEST_SUITE(eng_map_suite)
+
+BOOST_AUTO_TEST_CASE(test_constructor)
+{
+    enq_map e1;
+    BOOST_CHECK(e1.empty());
+    BOOST_CHECK_EQUAL(e1.size(), 0);
+}
+
+BOOST_AUTO_TEST_CASE(test_insert_get)
+{
+    u_int16_t fid;
+    u_int64_t rid;
+    u_int16_t fid_start = 0x2000U;
+    u_int64_t rid_begin = 0xffffffff00000000ULL;
+    u_int64_t rid_end   = 0xffffffff00000200ULL;
+
+    // insert with no dups
+    u_int64_t rid_incr_1 = 4ULL;
+    enq_map e2;
+    for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_1, fid++)
+        e2.insert_fid(rid, fid);
+    BOOST_CHECK(!e2.empty());
+    BOOST_CHECK_EQUAL(e2.size(), 128);
+    
+    // get
+    u_int64_t rid_incr_2 = 6ULL;
+    for (u_int64_t rid = rid_begin; rid < rid_end; rid += rid_incr_2)
+    {
+        BOOST_CHECK_EQUAL(e2.is_enqueued(rid), (rid%rid_incr_1 ? false : true));
+        try
+        {
+            u_int16_t exp_fid = fid_start + (u_int16_t)((rid - rid_begin)/rid_incr_1);
+            u_int16_t ret_fid = e2.get_fid(rid);
+            BOOST_CHECK_EQUAL(ret_fid, exp_fid);
+            BOOST_CHECK(rid%rid_incr_1 == 0);
+        }
+        catch (const jexception& e)
+        {
+            BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_NOTFOUND);
+            BOOST_CHECK(rid%rid_incr_1);
+        }
+        if ((rid + rid_incr_2)%(8 * rid_incr_2) == 0)
+            fid++;
+    }
+
+    // insert with dups
+    for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_2, fid++)
+    {
+        try
+        {
+            e2.insert_fid(rid, fid);
+            BOOST_CHECK(rid%rid_incr_1);
+        }
+        catch (const jexception& e)
+        {
+            BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_DUPLICATE);
+            BOOST_CHECK(rid%rid_incr_1 == 0);
+        }
+    }
+    BOOST_CHECK_EQUAL(e2.size(), 171ULL);
+    e2.clear();
+    BOOST_CHECK(e2.empty());
+    BOOST_CHECK_EQUAL(e2.size(), 0);
+}
+
+BOOST_AUTO_TEST_CASE(test_get_remove)
+{
+    u_int16_t fid;
+    u_int64_t rid;
+    u_int16_t fid_start = 0x3000U;
+    u_int64_t rid_begin = 0xeeeeeeee00000000ULL;
+    u_int64_t rid_end   = 0xeeeeeeee00000200ULL;
+
+    u_int64_t rid_incr_1 = 4ULL;
+    u_int64_t num_incr_1 = (rid_end - rid_begin)/rid_incr_1;
+    enq_map e3;
+    for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_1, fid++)
+        e3.insert_fid(rid, fid);
+    BOOST_CHECK_EQUAL(e3.size(), num_incr_1);
+
+    u_int64_t rid_incr_2 = 6ULL;
+    for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_2, fid++)
+    {
+        try
+        {
+            u_int16_t exp_fid = fid_start + (u_int16_t)((rid - rid_begin)/rid_incr_1);
+            u_int16_t ret_fid = e3.get_remove_fid(rid);
+            BOOST_CHECK_EQUAL(ret_fid, exp_fid);
+            BOOST_CHECK(rid%rid_incr_1 == 0);
+        }
+        catch (const jexception& e)
+        {
+            BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_NOTFOUND);
+            BOOST_CHECK(rid%rid_incr_1);
+        }
+    }
+    BOOST_CHECK_EQUAL(e3.size(), 85ULL);
+}
+
+BOOST_AUTO_TEST_CASE(test_lock)
+{
+    u_int16_t fid;
+    u_int64_t rid;
+    u_int16_t fid_start = 0x4000U;
+    u_int64_t rid_begin = 0xdddddddd00000000ULL;
+    u_int64_t rid_end   = 0xdddddddd00000200ULL;
+
+    // insert, every second entry is locked
+    u_int64_t rid_incr_1 = 4ULL;
+    u_int64_t num_incr_1 = (rid_end - rid_begin)/rid_incr_1;
+    bool locked = false;
+    enq_map e4;
+    for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_1, fid++)
+    {
+        e4.insert_fid(rid, fid, locked);
+        locked = !locked;
+    }
+    BOOST_CHECK_EQUAL(e4.size(), num_incr_1);
+
+    // unlock and lock non-existent rids
+    try
+    {
+        e4.lock(1ULL);
+        BOOST_ERROR("Failed to throw exception when locking non-existent rid.");
+    }
+    catch (const jexception& e) { BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_NOTFOUND); }
+    try
+    {
+        e4.unlock(2ULL);
+        BOOST_ERROR("Failed to throw exception when locking non-existent rid.");
+    }
+    catch (const jexception& e) { BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_NOTFOUND); }
+    
+    // get / unlock
+    for (u_int64_t rid = rid_begin; rid < rid_end; rid += rid_incr_1)
+    {
+        try { e4.get_fid(rid); }
+        catch(const jexception& e)
+        {
+            BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_LOCKED);
+            BOOST_CHECK(rid%(2*rid_incr_1));
+            // unlock, read, then relock
+            e4.unlock(rid);
+            e4.get_fid(rid);
+            e4.lock(rid);
+            try
+            {
+               e4.get_fid(rid);
+               BOOST_ERROR("Failed to throw exception when getting locked record");
+            }
+            catch(const jexception& e)
+            {
+                BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_LOCKED);
+            }
+        }
+    }
+
+    // remove all; if locked, use with txn_flag true; should ignore all locked records
+    for (u_int64_t rid = rid_begin; rid < rid_end; rid += rid_incr_1)
+        e4.get_remove_fid(rid, true);
+    BOOST_CHECK(e4.empty());
+}
+
+BOOST_AUTO_TEST_CASE(test_lists)
+{
+    u_int16_t fid;
+    u_int64_t rid;
+    u_int16_t fid_start = 0x5000UL;
+    u_int64_t rid_begin = 0xdddddddd00000000ULL;
+    u_int64_t rid_end   = 0xdddddddd00000200ULL;
+
+    // insert, every second entry is locked
+    u_int64_t rid_incr_1 = 4ULL;
+    u_int64_t num_incr_1 = (rid_end - rid_begin)/rid_incr_1;
+    std::vector<u_int64_t> rid_list;
+    std::vector<u_int16_t> fid_list;
+    enq_map e5;
+    for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_1, fid++)
+    {
+        e5.insert_fid(rid, fid);
+        rid_list.push_back(rid);
+        fid_list.push_back(fid);
+    }
+    BOOST_CHECK_EQUAL(e5.size(), num_incr_1);
+    BOOST_CHECK_EQUAL(rid_list.size(), num_incr_1);
+    BOOST_CHECK_EQUAL(fid_list.size(), num_incr_1);
+
+    std::vector<u_int64_t> ret_rid_list;
+    e5.rid_list(ret_rid_list);
+    BOOST_CHECK_EQUAL(ret_rid_list.size(), num_incr_1);
+    for (unsigned i=0; i<ret_rid_list.size(); i++)
+        BOOST_CHECK_EQUAL(rid_list[i], ret_rid_list[i]);
+
+    std::vector<u_int16_t> ret_fid_list;
+    e5.fid_list(ret_fid_list);
+    BOOST_CHECK_EQUAL(ret_fid_list.size(), num_incr_1);
+    for (unsigned i=0; i<ret_fid_list.size(); i++)
+        BOOST_CHECK_EQUAL(fid_list[i], ret_fid_list[i]);
+}
+
+QPID_AUTO_TEST_SUITE_END()

Copied: store/trunk/cpp/tests/jrnl/_ut_jdir.cpp (from rev 1569, store/trunk/cpp/tests/jrnl/unit_test_jdir.cpp)
===================================================================
--- store/trunk/cpp/tests/jrnl/_ut_jdir.cpp	                        (rev 0)
+++ store/trunk/cpp/tests/jrnl/_ut_jdir.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -0,0 +1,386 @@
+/**
+* \file _ut_jdir.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the unit tests for the journal.
+*
+* Copyright 2007, 2008 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include "../unit_test.h"
+#include <dirent.h>
+#include <errno.h>
+#include <fstream>
+#include <iomanip>
+#include <jrnl/file_hdr.hpp>
+#include <jrnl/jcfg.hpp>
+#include <jrnl/jdir.hpp>
+#include <jrnl/jerrno.hpp>
+#include <jrnl/jexception.hpp>
+#include <sys/stat.h>
+
+QPID_AUTO_TEST_SUITE(jdir_suite)
+
+#define NUM_JFILES 4
+#define JFSIZE_SBLKS 128
+
+#define ERRORSTR(e) ::strerror(ret) << " (" << ret << ")"
+#define NUM_CLEAR_OPS 20
+
+using namespace boost::unit_test;
+using namespace rhm::journal;
+
+// Helper function declarations
+void create_file(const char* filename, mode_t fmode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+void create_jrnl_fileset(const char* dirname, const char* base_filename);
+void create_jdat_file(const char* dirname, const char* base_filename, u_int32_t fid,
+        u_int64_t first_rid);
+void create_jinf_file(const char* dirname, const char* base_filename);
+void check_dir_contents(const char* dirname, const char* base_filename, unsigned num_subdirs,
+        bool jrnl_present);
+unsigned count_dir_contents(const char* dirname, bool incl_files = true, bool incl_dirs = true);
+void check_dir_not_existing(const char* dirname);
+
+BOOST_AUTO_TEST_CASE(test_constructor)
+{
+    std::string dir("/tmp/A/B/C/D/E/F");
+    std::string bfn("test_base");
+    jdir dir1(dir, bfn);
+    BOOST_CHECK(dir1.dirname().compare(dir) == 0);
+    BOOST_CHECK(dir1.base_filename().compare(bfn) == 0);
+}
+
+BOOST_AUTO_TEST_CASE(test_create_delete_dir)
+{
+    // Use instance
+    std::string dir_A("/tmp/A");
+    std::string dir_Ats("/tmp/A/"); // trailing '/'
+    check_dir_not_existing("/tmp/A");
+    jdir dir1(dir_A, "test_base");
+    dir1.create_dir();
+    // check all combos of jdir::exists and jdir::is_dir()
+    BOOST_CHECK(jdir::exists(dir_A));
+    BOOST_CHECK(jdir::exists(dir_Ats));
+    BOOST_CHECK(jdir::exists(dir_A.c_str()));
+    BOOST_CHECK(jdir::exists(dir_Ats.c_str()));
+    BOOST_CHECK(jdir::is_dir(dir_A));
+    BOOST_CHECK(jdir::is_dir(dir_Ats));
+    BOOST_CHECK(jdir::is_dir(dir_Ats.c_str()));
+    BOOST_CHECK(jdir::is_dir(dir_Ats.c_str()));
+    // do it a second time when dir exists
+    dir1.create_dir();
+    BOOST_CHECK(jdir::is_dir(dir_A));
+    dir1.delete_dir();
+    BOOST_CHECK(!jdir::exists(dir_A));
+    
+    // Use static fn
+    check_dir_not_existing("/tmp/B");
+    jdir::create_dir("/tmp/B");
+    BOOST_CHECK(jdir::is_dir("/tmp/B"));
+    jdir::create_dir("/tmp/B");
+    BOOST_CHECK(jdir::is_dir("/tmp/B"));
+    jdir::delete_dir("/tmp/B");
+    BOOST_CHECK(!jdir::exists("/tmp/B"));
+    
+    // Non-empty dirs
+    check_dir_not_existing("/tmp/C");
+    jdir::create_dir("/tmp/C");
+    BOOST_CHECK(jdir::is_dir("/tmp/C"));
+    create_file("/tmp/C/test_file_1.txt"); // mode 644 (default)
+    create_file("/tmp/C/test_file_2.txt", S_IRWXU | S_IRWXG | S_IRWXO); // mode 777
+    create_file("/tmp/C/test_file_3.txt", S_IRUSR | S_IRGRP | S_IROTH); // mode 444 (read-only)
+    create_file("/tmp/C/test_file_4.txt", 0); // mode 000 (no permissions)
+    BOOST_CHECK(jdir::is_dir("/tmp/C"));
+    jdir::create_dir("/tmp/C");
+    BOOST_CHECK(jdir::is_dir("/tmp/C"));
+    jdir::delete_dir("/tmp/C");
+    BOOST_CHECK(!jdir::exists("/tmp/C"));
+
+    // Check non-existent dirs fail
+    check_dir_not_existing("/tmp/D");
+    try
+    {
+        jdir::is_dir("/tmp/D");
+        BOOST_ERROR("jdir::is_dir() failed to throw jexeption for non-existent directory.");
+    }
+    catch(const jexception& e)
+    {
+        BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_JDIR_STAT);
+    }
+}
+
+BOOST_AUTO_TEST_CASE(test_create_delete_dir_recursive)
+{
+    // Use instances
+    check_dir_not_existing("/tmp/E");
+    jdir dir1("/tmp/E/F/G/H", "test_base");
+    dir1.create_dir();
+    BOOST_CHECK(jdir::is_dir("/tmp/E/F/G/H"));
+    dir1.delete_dir();
+    BOOST_CHECK(!jdir::exists("/tmp/E/F/G/H")); // only H deleted, E/F/G remain
+    BOOST_CHECK(jdir::exists("/tmp/E"));
+    jdir::delete_dir("/tmp/E"); // delete remaining dirs
+    BOOST_CHECK(!jdir::exists("/tmp/E"));
+
+    check_dir_not_existing("/tmp/F");
+    jdir dir2("/tmp/F/G/H/I/", "test_base"); // trailing '/'
+    dir2.create_dir();
+    BOOST_CHECK(jdir::is_dir("/tmp/F/G/H/I/"));
+    dir2.delete_dir();
+    BOOST_CHECK(!jdir::exists("/tmp/F/G/H/I/"));
+    BOOST_CHECK(jdir::exists("/tmp/F"));
+    jdir::delete_dir("/tmp/F");
+    BOOST_CHECK(!jdir::exists("/tmp/F"));
+    
+    // Use static fn
+    check_dir_not_existing("/tmp/G");
+    jdir::create_dir("/tmp/G/H/I/J");
+    BOOST_CHECK(jdir::is_dir("/tmp/G/H/I/J"));
+    jdir::delete_dir("/tmp/G/H/I/J");
+    BOOST_CHECK(!jdir::exists("/tmp/G/H/I/J"));
+    BOOST_CHECK(jdir::exists("/tmp/G"));
+    jdir::delete_dir("/tmp/G");
+    BOOST_CHECK(!jdir::exists("/tmp/G"));
+
+    check_dir_not_existing("/tmp/H");
+    jdir::create_dir("/tmp/H/I/J/K/");
+    BOOST_CHECK(jdir::is_dir("/tmp/H/I/J/K/"));
+    jdir::delete_dir("/tmp/H/I/J/K/");
+    BOOST_CHECK(!jdir::exists("/tmp/H/I/J/K/"));
+    BOOST_CHECK(jdir::exists("/tmp/H"));
+    jdir::delete_dir("/tmp/H");
+    BOOST_CHECK(!jdir::exists("/tmp/H"));
+    
+    // Non-empty dirs
+    check_dir_not_existing("/tmp/I");
+    jdir::create_dir("/tmp/I/J/K1/L1");
+    jdir::create_dir("/tmp/I/J/K1/L2");
+    jdir::create_dir("/tmp/I/J/K1/L3");
+    jdir::create_dir("/tmp/I/J/K1/L4");
+    create_file("/tmp/I/J/K1/L4/test_file_1.txt"); // mode 644 (default)
+    create_file("/tmp/I/J/K1/L4/test_file_2.txt", S_IRWXU | S_IRWXG | S_IRWXO); // mode 777
+    create_file("/tmp/I/J/K1/L4/test_file_3.txt", S_IRUSR | S_IRGRP | S_IROTH); // mode 444
+    create_file("/tmp/I/J/K1/L4/test_file_4.txt", 0); // mode 000 (no permissions)
+    jdir::create_dir("/tmp/I/J/K2");
+    jdir::create_dir("/tmp/I/J/K3/L5");
+    jdir::create_dir("/tmp/I/J/K3/L6");
+    BOOST_CHECK(jdir::is_dir("/tmp/I/J/K1/L1"));
+    BOOST_CHECK(jdir::is_dir("/tmp/I/J/K1/L2"));
+    BOOST_CHECK(jdir::is_dir("/tmp/I/J/K1/L3"));
+    BOOST_CHECK(jdir::is_dir("/tmp/I/J/K1/L4"));
+    BOOST_CHECK(jdir::is_dir("/tmp/I/J/K2"));
+    BOOST_CHECK(jdir::is_dir("/tmp/I/J/K3/L5"));
+    BOOST_CHECK(jdir::is_dir("/tmp/I/J/K3/L6"));
+    jdir::delete_dir("/tmp/I");
+    BOOST_CHECK(!jdir::exists("/tmp/I"));
+}
+
+BOOST_AUTO_TEST_CASE(test_clear_verify_dir)
+{
+    // Use instances
+    const char* jrnl_dir = "/tmp/test_dir_1";
+    const char* bfn = "test_base";
+    check_dir_not_existing(jrnl_dir);
+    jdir test_dir_1(jrnl_dir, bfn);
+    test_dir_1.create_dir();
+    BOOST_CHECK(jdir::is_dir(jrnl_dir));
+    // add journal files, check they exist, then clear them
+    unsigned cnt = 0;
+    while (cnt < NUM_CLEAR_OPS)
+    {
+        create_jrnl_fileset(jrnl_dir, bfn);
+        check_dir_contents(jrnl_dir, bfn, cnt, true);
+        test_dir_1.clear_dir();
+        check_dir_contents(jrnl_dir, bfn, ++cnt, false);
+    }
+    // clean up
+    test_dir_1.delete_dir();
+    BOOST_CHECK(!jdir::exists(jrnl_dir));
+
+    // Non-existent dir with auto-create true
+    jrnl_dir = "/tmp/test_dir_2";
+    check_dir_not_existing(jrnl_dir);
+    jdir test_dir_2(jrnl_dir, bfn);
+    // clear dir
+    test_dir_2.clear_dir(); // create flag is true by default
+    check_dir_contents(jrnl_dir, bfn, 0, false);
+    // clear empty dir, should not create subdir
+    test_dir_2.clear_dir(); // create flag is true by default
+    check_dir_contents(jrnl_dir, bfn, 0, false);
+    // clean up
+    test_dir_2.delete_dir();
+    BOOST_CHECK(!jdir::exists(jrnl_dir));
+        
+    // non-existent dir with auto-create false
+    jrnl_dir = "/tmp/test_dir_3";
+    check_dir_not_existing(jrnl_dir);
+    jdir test_dir_3(jrnl_dir, bfn);
+    try
+    {
+        test_dir_3.clear_dir(false);
+        BOOST_ERROR("jdir::clear_dir(flase) failed to throw jexeption for non-existent directory.");
+    }
+    catch(const jexception& e)
+    {
+        BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_JDIR_OPENDIR);
+    }
+    
+    // Use static fn
+    jrnl_dir = "/tmp/test_dir_4";
+    check_dir_not_existing(jrnl_dir);
+    jdir::clear_dir(jrnl_dir, bfn); // should create dir if it does not exist
+    // add journal files, check they exist, then clear them
+    cnt = 0;
+    while (cnt < NUM_CLEAR_OPS)
+    {
+        create_jrnl_fileset(jrnl_dir, bfn);
+        check_dir_contents(jrnl_dir, bfn, cnt, true);
+        jdir::clear_dir(jrnl_dir, bfn);
+        check_dir_contents(jrnl_dir, bfn, ++cnt, false);
+    }
+    // clean up
+    jdir::delete_dir(jrnl_dir);
+    BOOST_CHECK(!jdir::exists(jrnl_dir));
+}
+
+// Helper functions
+
+void create_file(const char* filename, mode_t fmode)
+{
+    std::ofstream of(filename, std::ofstream::out | std::ofstream::trunc);
+    if (!of.good())
+        BOOST_FAIL("Unable to open file " << filename << " for writing.");
+    of.write(filename, ::strlen(filename));
+    of.close();
+    ::chmod(filename, fmode);
+}
+
+void create_jrnl_fileset(const char* dirname, const char* base_filename)
+{
+    create_jinf_file(dirname, base_filename);
+    for (u_int32_t fid = 0; fid < NUM_JFILES; fid++)
+    {
+        u_int64_t rid = 0x12340000 + (fid * 0x25);
+        create_jdat_file(dirname, base_filename, fid, rid);
+    }
+}
+
+void create_jdat_file(const char* dirname, const char* base_filename, u_int32_t fid,
+        u_int64_t first_rid)
+{
+    std::stringstream fn;
+    fn << dirname << "/" << base_filename << ".";
+    fn << std::setfill('0') << std::hex << std::setw(4) << fid << ".jdat";
+    file_hdr fh(RHM_JDAT_FILE_MAGIC, RHM_JDAT_VERSION, 0, first_rid, fid, 0x200, true);
+    std::ofstream of(fn.str().c_str(), std::ofstream::out | std::ofstream::trunc);
+    if (!of.good())
+        BOOST_FAIL("Unable to open journal data file " << fn << " for writing.");
+    of.write((const char*)&fh, sizeof(file_hdr));
+    of.close();
+}
+
+void create_jinf_file(const char* dirname, const char* base_filename)
+{
+    timespec ts;
+    ::clock_gettime(CLOCK_REALTIME, &ts);
+    jinf ji("test journal id", dirname, base_filename, NUM_JFILES, JFSIZE_SBLKS, ts);
+    ji.write();
+}
+
+void check_dir_contents(const char* dirname, const char* base_filename, unsigned num_subdirs,
+        bool jrnl_present)
+{
+    if (jdir::is_dir(dirname))
+    {
+        // Subdir count
+        BOOST_CHECK_EQUAL(count_dir_contents(dirname, false, true), num_subdirs);
+    
+        // Journal file count
+        unsigned num_jrnl_files = jrnl_present ? NUM_JFILES + 1 : 0;
+        BOOST_CHECK_EQUAL(count_dir_contents(dirname, true, false), num_jrnl_files);
+    
+        // Check journal files are present
+        if (jrnl_present)
+            try { jdir::verify_dir(dirname, base_filename); }
+            catch(const jexception& e) { BOOST_ERROR(e); }
+        for (unsigned subdir_num = 1; subdir_num <= num_subdirs; subdir_num++)
+        {
+            std::stringstream subdir_name;
+            subdir_name << dirname << "/_" << base_filename << ".bak.";
+            subdir_name << std::hex << std::setfill('0') << std::setw(4) << subdir_num;
+            try { jdir::verify_dir(subdir_name.str().c_str(), base_filename); }
+            catch(const jexception& e) { BOOST_ERROR(e); }
+        }
+    }
+    else
+        BOOST_ERROR(dirname << " is not a directory");
+}
+
+unsigned count_dir_contents(const char* dirname, bool incl_files, bool incl_dirs)
+{
+    struct dirent* entry;
+    struct stat s;
+    unsigned file_cnt = 0;
+    unsigned dir_cnt = 0;
+    unsigned other_cnt = 0;
+    DIR* dir = ::opendir(dirname);
+    if (!dir)
+        BOOST_FAIL("Unable to open directory " << dirname);
+    while ((entry = ::readdir(dir)) != NULL)
+    {
+        // Ignore . and ..
+        if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0)
+        {
+            std::stringstream fn;
+            fn << dirname << "/" << entry->d_name;
+            if (::stat(fn.str().c_str(), &s))
+                BOOST_FAIL("Unable to stat dir entry " << entry->d_name << "; err=" <<
+                        strerror(errno));
+            if (S_ISREG(s.st_mode))
+                file_cnt++;
+            else if (S_ISDIR(s.st_mode))
+                dir_cnt++;
+            else
+                other_cnt++;
+        }
+    }
+    if (incl_files)
+    {
+        if (incl_dirs)
+            return file_cnt + dir_cnt;
+        return file_cnt;
+    }
+    else if (incl_dirs)
+        return dir_cnt;
+    return other_cnt;
+}
+
+void check_dir_not_existing(const char* dirname)
+{
+    if (jdir::exists(dirname) && jdir::is_dir(dirname))
+        jdir::delete_dir(dirname);
+    if (jdir::exists(dirname))
+        BOOST_FAIL("Unable to remove directory " << dirname);
+}
+
+QPID_AUTO_TEST_SUITE_END()

Copied: store/trunk/cpp/tests/jrnl/_ut_jerrno.cpp (from rev 1569, store/trunk/cpp/tests/jrnl/unit_test_jerrno.cpp)
===================================================================
--- store/trunk/cpp/tests/jrnl/_ut_jerrno.cpp	                        (rev 0)
+++ store/trunk/cpp/tests/jrnl/_ut_jerrno.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -0,0 +1,46 @@
+/**
+* \file _ut_jerrno.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the unit tests for the journal.
+*
+* Copyright 2007, 2008 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include "../unit_test.h"
+#include <jrnl/jerrno.hpp>
+
+QPID_AUTO_TEST_SUITE(jerrno_suite)
+
+using namespace boost::unit_test;
+using namespace rhm::journal;
+
+BOOST_AUTO_TEST_CASE(test_jerrno)
+{
+    const char* m = "JERR__MALLOC";
+    std::string malloc_msg = std::string(jerrno::err_msg(jerrno::JERR__MALLOC));
+    BOOST_CHECK(malloc_msg.substr(0, ::strlen(m)).compare(m) == 0);
+    BOOST_CHECK(::strcmp(jerrno::err_msg(0), "<Unknown error code>") == 0);
+}
+        
+QPID_AUTO_TEST_SUITE_END()

Copied: store/trunk/cpp/tests/jrnl/_ut_jexception.cpp (from rev 1569, store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp)
===================================================================
--- store/trunk/cpp/tests/jrnl/_ut_jexception.cpp	                        (rev 0)
+++ store/trunk/cpp/tests/jrnl/_ut_jexception.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -0,0 +1,329 @@
+/**
+* \file _ut_jexception.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the unit tests for the journal.
+*
+* Copyright 2007, 2008 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include "../unit_test.h"
+#include <jrnl/jerrno.hpp>
+#include <jrnl/jexception.hpp>
+
+using namespace boost::unit_test;
+using namespace rhm::journal;
+
+QPID_AUTO_TEST_SUITE(jexception_suite)
+
+// Helper function declarations
+void throw_exception(const jexception& e, size_t what_len, size_t ai_len);
+void throw_exception(const jexception& e, size_t what_len, size_t tc_len, size_t tf_len);
+void throw_exception(const jexception& e, size_t what_len, size_t ai_len, size_t tc_len,
+        size_t tf_len);
+
+BOOST_AUTO_TEST_CASE(test_constructor_1)
+{
+    try
+    {
+        jexception e1;
+        BOOST_CHECK_EQUAL(e1.err_code(), (u_int32_t)0);
+        BOOST_CHECK(e1.additional_info().size() == 0);
+        BOOST_CHECK(e1.throwing_class().size() == 0);
+        BOOST_CHECK(e1.throwing_fn().size() == 0);
+        BOOST_CHECK(::strlen(e1.what()) > 0);
+        throw e1;
+    }
+    catch (const jexception& e)
+    {
+        BOOST_CHECK_EQUAL(e.err_code(), (u_int32_t)0);
+        BOOST_CHECK(e.additional_info().size() == 0);
+        BOOST_CHECK(e.throwing_class().size() == 0);
+        BOOST_CHECK(e.throwing_fn().size() == 0);
+        BOOST_CHECK(::strlen(e.what()) > 0);
+    }
+}
+
+BOOST_AUTO_TEST_CASE(test_constructor_2)
+{
+    const u_int32_t err_code = 2;
+    try
+    {
+        jexception e2(err_code);
+        BOOST_CHECK_EQUAL(e2.err_code(), err_code);
+        BOOST_CHECK(e2.additional_info().size() == 0);
+        BOOST_CHECK(e2.throwing_class().size() == 0);
+        BOOST_CHECK(e2.throwing_fn().size() == 0);
+        BOOST_CHECK(::strlen(e2.what()) > 0);
+        throw e2;
+    }
+    catch (const jexception& e)
+    {
+        BOOST_CHECK_EQUAL(e.err_code(), err_code);
+        BOOST_CHECK(e.additional_info().size() == 0);
+        BOOST_CHECK(e.throwing_class().size() == 0);
+        BOOST_CHECK(e.throwing_fn().size() == 0);
+        BOOST_CHECK(::strlen(e.what()) > 0);
+    }
+}
+
+BOOST_AUTO_TEST_CASE(test_constructor_3a)
+{
+    const char* err_msg = "exception3";
+    try
+    {
+        jexception e3(err_msg);
+        BOOST_CHECK_EQUAL(e3.err_code(), (u_int32_t)0);
+        BOOST_CHECK(e3.additional_info().compare(err_msg) == 0);
+        BOOST_CHECK(e3.throwing_class().size() == 0);
+        BOOST_CHECK(e3.throwing_fn().size() == 0);
+        BOOST_CHECK(::strlen(e3.what()) > 0);
+        throw e3;
+    }
+    catch (const jexception& e)
+    {
+        BOOST_CHECK_EQUAL(e.err_code(), (u_int32_t)0);
+        BOOST_CHECK(e.additional_info().compare(err_msg) == 0);
+        BOOST_CHECK(e.throwing_class().size() == 0);
+        BOOST_CHECK(e.throwing_fn().size() == 0);
+        BOOST_CHECK(::strlen(e.what()) > 0);
+    }
+}
+
+BOOST_AUTO_TEST_CASE(test_constructor_3b)
+{
+    const std::string err_msg("exception3");
+    try
+    {
+        jexception e3(err_msg);
+        BOOST_CHECK_EQUAL(e3.err_code(), (u_int32_t)0);
+        BOOST_CHECK(e3.additional_info().compare(err_msg) == 0);
+        BOOST_CHECK(e3.throwing_class().size() == 0);
+        BOOST_CHECK(e3.throwing_fn().size() == 0);
+        BOOST_CHECK(::strlen(e3.what()) > 0);
+        throw e3;
+    }
+    catch (const jexception& e)
+    {
+        BOOST_CHECK_EQUAL(e.err_code(), (u_int32_t)0);
+        BOOST_CHECK(e.additional_info().compare(err_msg) == 0);
+        BOOST_CHECK(e.throwing_class().size() == 0);
+        BOOST_CHECK(e.throwing_fn().size() == 0);
+        BOOST_CHECK(::strlen(e.what()) > 0);
+    }
+}
+
+BOOST_AUTO_TEST_CASE(test_constructor_4a)
+{
+    const u_int32_t err_code = 4;
+    const char* err_msg = "exception4";
+    try
+    {
+        jexception e4(err_code, err_msg);
+        BOOST_CHECK_EQUAL(e4.err_code(), err_code);
+        BOOST_CHECK(e4.additional_info().compare(err_msg) == 0);
+        BOOST_CHECK(e4.throwing_class().size() == 0);
+        BOOST_CHECK(e4.throwing_fn().size() == 0);
+        BOOST_CHECK(::strlen(e4.what()) > 0);
+        throw e4;
+    }
+    catch (const jexception& e)
+    {
+        BOOST_CHECK_EQUAL(e.err_code(), err_code);
+        BOOST_CHECK(e.additional_info().compare(err_msg) == 0);
+        BOOST_CHECK(e.throwing_class().size() == 0);
+        BOOST_CHECK(e.throwing_fn().size() == 0);
+        BOOST_CHECK(::strlen(e.what()) > 0);
+    }
+}
+
+BOOST_AUTO_TEST_CASE(test_constructor_4b)
+{
+    const u_int32_t err_code = 4;
+    const std::string err_msg("exception4");
+    try
+    {
+        jexception e4(err_code, err_msg);
+        BOOST_CHECK_EQUAL(e4.err_code(), err_code);
+        BOOST_CHECK(e4.additional_info().compare(err_msg) == 0);
+        BOOST_CHECK(e4.throwing_class().size() == 0);
+        BOOST_CHECK(e4.throwing_fn().size() == 0);
+        BOOST_CHECK(::strlen(e4.what()) > 0);
+        throw e4;
+    }
+    catch (const jexception& e)
+    {
+        BOOST_CHECK_EQUAL(e.err_code(), err_code);
+        BOOST_CHECK(e.additional_info().compare(err_msg) == 0);
+        BOOST_CHECK(e.throwing_class().size() == 0);
+        BOOST_CHECK(e.throwing_fn().size() == 0);
+        BOOST_CHECK(::strlen(e.what()) > 0);
+    }
+}
+
+BOOST_AUTO_TEST_CASE(test_constructor_5a)
+{
+    const u_int32_t err_code = 5;
+    const char* err_class = "class5";
+    const char* err_fn = "fn5";
+    try
+    {
+        jexception e5(err_code, err_class, err_fn);
+        BOOST_CHECK_EQUAL(e5.err_code(), err_code);
+        BOOST_CHECK(e5.additional_info().size() == 0);
+        BOOST_CHECK(e5.throwing_class().compare(err_class) == 0);
+        BOOST_CHECK(e5.throwing_fn().compare(err_fn) == 0);
+        BOOST_CHECK(::strlen(e5.what()) > 0);
+        throw e5;
+    }
+    catch (const jexception& e)
+    {
+        BOOST_CHECK_EQUAL(e.err_code(), err_code);
+        BOOST_CHECK(e.additional_info().size() == 0);
+        BOOST_CHECK(e.throwing_class().compare(err_class) == 0);
+        BOOST_CHECK(e.throwing_fn().compare(err_fn) == 0);
+        BOOST_CHECK(::strlen(e.what()) > 0);
+    }
+}
+
+BOOST_AUTO_TEST_CASE(test_constructor_5b)
+{
+    const u_int32_t err_code = 5;
+    const std::string err_class("class5");
+    const std::string err_fn("fn5");
+    try
+    {
+        jexception e5(err_code, err_class, err_fn);
+        BOOST_CHECK_EQUAL(e5.err_code(), err_code);
+        BOOST_CHECK(e5.additional_info().size() == 0);
+        BOOST_CHECK(e5.throwing_class().compare(err_class) == 0);
+        BOOST_CHECK(e5.throwing_fn().compare(err_fn) == 0);
+        BOOST_CHECK(::strlen(e5.what()) > 0);
+        throw e5;
+    }
+    catch (const jexception& e)
+    {
+        BOOST_CHECK_EQUAL(e.err_code(), err_code);
+        BOOST_CHECK(e.additional_info().size() == 0);
+        BOOST_CHECK(e.throwing_class().compare(err_class) == 0);
+        BOOST_CHECK(e.throwing_fn().compare(err_fn) == 0);
+        BOOST_CHECK(::strlen(e.what()) > 0);
+    }
+}
+
+BOOST_AUTO_TEST_CASE(test_constructor_6a)
+{
+    const u_int32_t err_code = 6;
+    const char* err_msg = "exception6";
+    const char* err_class = "class6";
+    const char* err_fn = "fn6";
+    try
+    {
+        jexception e6(err_code, err_msg, err_class, err_fn);
+        BOOST_CHECK_EQUAL(e6.err_code(), err_code);
+        BOOST_CHECK(e6.additional_info().compare(err_msg) == 0);
+        BOOST_CHECK(e6.throwing_class().compare(err_class) == 0);
+        BOOST_CHECK(e6.throwing_fn().compare(err_fn) == 0);
+        BOOST_CHECK(::strlen(e6.what()) > 0);
+        throw e6;
+    }
+    catch (const jexception& e)
+    {
+        BOOST_CHECK_EQUAL(e.err_code(), err_code);
+        BOOST_CHECK(e.additional_info().compare(err_msg) == 0);
+        BOOST_CHECK(e.throwing_class().compare(err_class) == 0);
+        BOOST_CHECK(e.throwing_fn().compare(err_fn) == 0);
+        BOOST_CHECK(::strlen(e.what()) > 0);
+    }
+}
+
+BOOST_AUTO_TEST_CASE(test_constructor_6b)
+{
+    const u_int32_t err_code = 6;
+    const std::string err_msg("exception6");
+    const std::string err_class("class6");
+    const std::string err_fn("fn6");
+    try
+    {
+        jexception e6(err_code, err_msg, err_class, err_fn);
+        BOOST_CHECK_EQUAL(e6.err_code(), err_code);
+        BOOST_CHECK(e6.additional_info().compare(err_msg) == 0);
+        BOOST_CHECK(e6.throwing_class().compare(err_class) == 0);
+        BOOST_CHECK(e6.throwing_fn().compare(err_fn) == 0);
+        BOOST_CHECK(::strlen(e6.what()) > 0);
+        throw e6;
+    }
+    catch (const jexception& e)
+    {
+        BOOST_CHECK_EQUAL(e.err_code(), err_code);
+        BOOST_CHECK(e.additional_info().compare(err_msg) == 0);
+        BOOST_CHECK(e.throwing_class().compare(err_class) == 0);
+        BOOST_CHECK(e.throwing_fn().compare(err_fn) == 0);
+        BOOST_CHECK(::strlen(e.what()) > 0);
+    }
+}
+
+BOOST_AUTO_TEST_CASE(test_msg_scope)
+{
+    try
+    {
+        // These will go out of scope as soon as jexception is thrown...
+        const std::string msg("Error message");
+        const std::string cls("class");
+        const std::string fn("function");
+        throw jexception(100, msg, cls, fn);
+    }
+    catch (const jexception& e)
+    {
+        std::stringstream ss;
+        ss << e;
+        BOOST_CHECK(ss.str().size() > 0);
+    }    
+}
+
+// Helper functions
+
+void throw_exception(const jexception& e, size_t what_len, size_t ai_len)
+{
+    throw_exception(e, what_len, ai_len, 0, 0);
+}
+
+void throw_exception(const jexception& e, size_t what_len, size_t tc_len, size_t tf_len)
+{
+    throw_exception(e, what_len, 0, tc_len, tf_len);
+}
+
+void throw_exception(const jexception& e, size_t what_len, size_t ai_len, size_t tc_len,
+        size_t tf_len)
+{
+    try { throw e; }
+    catch (const jexception& e)
+    {
+        BOOST_CHECK_EQUAL(::strlen(e.what()), what_len);
+        BOOST_CHECK_EQUAL(e.additional_info().size(), ai_len);
+        BOOST_CHECK_EQUAL(e.throwing_class().size(), tc_len);
+        BOOST_CHECK_EQUAL(e.throwing_fn().size(), tf_len);
+    }
+}
+
+QPID_AUTO_TEST_SUITE_END()

Copied: store/trunk/cpp/tests/jrnl/_ut_jinf.cpp (from rev 1569, store/trunk/cpp/tests/jrnl/unit_test_jinf.cpp)
===================================================================
--- store/trunk/cpp/tests/jrnl/_ut_jinf.cpp	                        (rev 0)
+++ store/trunk/cpp/tests/jrnl/_ut_jinf.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -0,0 +1,240 @@
+/**
+* \file _ut_jinf.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the unit tests for the journal.
+*
+* Copyright 2007, 2008 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include "../unit_test.h"
+#include <fstream>
+#include <iomanip>
+#include <jrnl/file_hdr.hpp>
+#include <jrnl/jcfg.hpp>
+#include <jrnl/jerrno.hpp>
+#include <jrnl/jexception.hpp>
+#include <jrnl/jinf.hpp>
+
+#define NUM_JFILES 4
+#define JFSIZE_SBLKS 128
+
+using namespace boost::unit_test;
+using namespace rhm::journal;
+
+QPID_AUTO_TEST_SUITE(jinf_suite)
+
+// Helper function declarations
+const std::string jid("test journal id");
+const std::string jdir("/tmp");
+const std::string base_filename("test_base");
+timespec ts;
+enum rid_scheme { RID_NONE, RID_LINEAR };
+
+// Helper functions
+void create_journal_filenames(std::vector<std::string>& jfiles);
+void create_journal_files(std::vector<std::string>& jfiles, rid_scheme scheme,
+        u_int32_t min_fid_offs = 0, u_int64_t rid_offs = 0);
+void clean_journal_files(std::vector<std::string>& jfiles);
+void init_fhdr(file_hdr& fh, const u_int32_t fid, const u_int64_t rid, const bool owi,
+        const bool no_enq = false);
+void clean_journal_info_file();
+
+BOOST_AUTO_TEST_CASE(test_write_constructor)
+{
+    ::clock_gettime(CLOCK_REALTIME, &ts);
+    jinf ji(jid, jdir, base_filename, NUM_JFILES, JFSIZE_SBLKS, ts);
+    BOOST_CHECK_EQUAL(ji.jver(), RHM_JDAT_VERSION);
+    BOOST_CHECK(ji.jid().compare(jid) == 0);
+    BOOST_CHECK(ji.jdir().compare(jdir) == 0);
+    BOOST_CHECK(ji.base_filename().compare(base_filename) == 0);
+    timespec this_ts = ji.ts();
+    BOOST_CHECK_EQUAL(this_ts.tv_sec, ts.tv_sec);
+    BOOST_CHECK_EQUAL(this_ts.tv_nsec, ts.tv_nsec);
+    BOOST_CHECK_EQUAL(ji.num_jfiles(), (u_int16_t)NUM_JFILES);
+    BOOST_CHECK_EQUAL(ji.jfsize_sblks(), (u_int32_t)JFSIZE_SBLKS);
+    BOOST_CHECK_EQUAL(ji.sblk_size_dblks(), (u_int16_t)JRNL_SBLK_SIZE);
+    BOOST_CHECK_EQUAL(ji.dblk_size(), (u_int32_t)JRNL_DBLK_SIZE);
+    BOOST_CHECK_EQUAL(ji.wmgr_page_size_dblks(), (u_int32_t)JRNL_WMGR_PAGE_SIZE);
+    BOOST_CHECK_EQUAL(ji.wmgr_num_pages(), (u_int32_t)JRNL_WMGR_PAGES);
+    BOOST_CHECK_EQUAL(ji.rmgr_page_size_dblks(), (u_int32_t)JRNL_RMGR_PAGE_SIZE);
+    BOOST_CHECK_EQUAL(ji.rmgr_num_pages(), (u_int32_t)JRNL_RMGR_PAGES);
+    ji.write();
+}
+
+BOOST_AUTO_TEST_CASE(test_read_constructor)
+{
+    std::stringstream fn;
+    fn << jdir << "/" << base_filename << "." << JRNL_INFO_EXTENSION;
+    jinf ji(fn.str(), false);
+    BOOST_CHECK_EQUAL(ji.jver(), RHM_JDAT_VERSION);
+    BOOST_CHECK(ji.jid().compare(jid) == 0);
+    BOOST_CHECK(ji.jdir().compare(jdir) == 0);
+    BOOST_CHECK(ji.base_filename().compare(base_filename) == 0);
+    const timespec this_ts = ji.ts();
+    BOOST_CHECK_EQUAL(this_ts.tv_sec, ts.tv_sec);
+    BOOST_CHECK_EQUAL(this_ts.tv_nsec, ts.tv_nsec);
+    BOOST_CHECK_EQUAL(ji.num_jfiles(), (u_int16_t)NUM_JFILES);
+    BOOST_CHECK_EQUAL(ji.jfsize_sblks(), (u_int32_t)JFSIZE_SBLKS);
+    BOOST_CHECK_EQUAL(ji.sblk_size_dblks(), (u_int16_t)JRNL_SBLK_SIZE);
+    BOOST_CHECK_EQUAL(ji.dblk_size(), (u_int32_t)JRNL_DBLK_SIZE);
+    BOOST_CHECK_EQUAL(ji.wmgr_page_size_dblks(), (u_int32_t)JRNL_WMGR_PAGE_SIZE);
+    BOOST_CHECK_EQUAL(ji.wmgr_num_pages(), (u_int32_t)JRNL_WMGR_PAGES);
+    BOOST_CHECK_EQUAL(ji.rmgr_page_size_dblks(), (u_int32_t)JRNL_RMGR_PAGE_SIZE);
+    BOOST_CHECK_EQUAL(ji.rmgr_num_pages(), (u_int32_t)JRNL_RMGR_PAGES);
+}
+
+BOOST_AUTO_TEST_CASE(test_validate)
+{
+    std::stringstream fn;
+    fn << jdir << "/" << base_filename << "." << JRNL_INFO_EXTENSION;
+    jinf ji(fn.str(), true);
+    // TODO: Check validation picks up conflict, but need to be friend to jinf to do it
+}
+
+BOOST_AUTO_TEST_CASE(test_analyze_empty_journal)
+{
+    std::vector<std::string> jfiles;
+    create_journal_filenames(jfiles);
+    
+    create_journal_files(jfiles, RID_NONE);
+
+    std::stringstream fn;
+    fn << jdir << "/" << base_filename << "." << JRNL_INFO_EXTENSION;
+    jinf ji(fn.str(), false);
+    try { ji.analyze(); }
+    catch (const jexception& e)
+    {
+        if (e.err_code() != jerrno::JERR_JINF_JDATEMPTY)
+            BOOST_ERROR("Failed to throw expected exception jerrno::JERR_JINF_JDATEMPTY");
+    }
+
+    clean_journal_files(jfiles);
+}
+
+BOOST_AUTO_TEST_CASE(test_analyze_linear_journal)
+{
+    std::vector<std::string> jfiles;
+    for (int i=0; i<NUM_JFILES; i++)
+    {
+        create_journal_filenames(jfiles);
+    
+        create_journal_files(jfiles, RID_LINEAR, i, 0x12340000);
+
+        std::stringstream fn;
+        fn << jdir << "/" << base_filename << "." << JRNL_INFO_EXTENSION;
+        jinf ji(fn.str(), false);
+        BOOST_CHECK_EQUAL(ji.analyze(), i);
+
+        clean_journal_files(jfiles);
+    }
+    
+    // last test cleans up jinf file
+    clean_journal_info_file();
+}
+
+// Helper functions
+
+void create_journal_filenames(std::vector<std::string>& jfiles)
+{
+    for (int fnum=0; fnum<NUM_JFILES; fnum++)
+    {
+        std::stringstream fn;
+        fn << jdir << "/" << base_filename << ".";
+        fn << std::setfill('0') << std::hex << std::setw(4) << fnum << "." << JRNL_DATA_EXTENSION;
+        jfiles.push_back(fn.str());
+    }
+}
+
+void create_journal_files(std::vector<std::string>& jfiles, rid_scheme scheme,
+        u_int32_t min_fid_offs, u_int64_t rid_offs)
+{
+    const u_int64_t rid_incr = 0x10;
+    file_hdr fh;
+    std::vector<std::string>::iterator itr;
+    u_int32_t fid = 0;
+    u_int64_t rid = rid_offs + ((NUM_JFILES - min_fid_offs) % NUM_JFILES) * rid_incr;
+    for (itr=jfiles.begin(); itr<jfiles.end(); itr++)
+    {
+        
+        std::ofstream of(itr->c_str(), std::ofstream::out | std::ofstream::trunc);
+        if (!of.good())
+            BOOST_FAIL("Unable to open test journal file " << *itr << " for writing.");
+        
+        // prepare file_hdr
+        if (scheme == RID_NONE) // create file containing 0s
+            ::memset(&fh, 0, sizeof(file_hdr));
+        else
+            init_fhdr(fh, fid, rid, fid >= min_fid_offs);
+        
+        // write file header
+        int cnt = sizeof(file_hdr);
+        of.write((const char*)&fh, cnt);
+        
+        // fill remaining sblk with 0s
+        while (cnt++ < JRNL_DBLK_SIZE * JRNL_SBLK_SIZE)
+            of.put(0);
+        of.close();
+        
+        if (++fid == min_fid_offs)
+            rid -= rid_incr * (NUM_JFILES - 1);
+        else
+            rid += rid_incr;
+    }
+}
+
+void clean_journal_info_file()
+{
+    std::stringstream fn;
+    fn << jdir << "/" << base_filename << "." << JRNL_INFO_EXTENSION;
+    BOOST_WARN_MESSAGE(::unlink(fn.str().c_str()) == 0, "Failed to remove file " << fn.str());
+}
+
+void clean_journal_files(std::vector<std::string>& jfiles)
+{
+    for (std::vector<std::string>::iterator itr=jfiles.begin(); itr != jfiles.end(); itr++)
+        BOOST_WARN_MESSAGE(::unlink(itr->c_str()) == 0, "Failed to remove file " << *itr);
+    jfiles.clear();
+}
+
+void init_fhdr(file_hdr& fh, const u_int32_t fid, const u_int64_t rid, const bool owi,
+        const bool no_enq)
+{
+    fh._magic = RHM_JDAT_FILE_MAGIC;
+    fh._version = RHM_JDAT_VERSION;
+#if defined(JRNL_BIG_ENDIAN)
+    fh._eflag = RHM_BENDIAN_FLAG;
+#else
+    fh._eflag = RHM_LENDIAN_FLAG;
+#endif
+    fh._uflag = owi ? rec_hdr::HDR_OVERWRITE_INDICATOR_MASK : 0;
+    fh._rid = rid;
+    fh._fid = fid;
+    fh._fro = no_enq ? 0 : 0x200;
+    timespec ts;
+    ::clock_gettime(CLOCK_REALTIME, &ts);
+    fh._ts_sec = ts.tv_sec;
+    fh._ts_nsec = ts.tv_nsec;
+}
+        
+QPID_AUTO_TEST_SUITE_END()

Copied: store/trunk/cpp/tests/jrnl/_ut_rec_hdr.cpp (from rev 1569, store/trunk/cpp/tests/jrnl/unit_test_rec_hdr.cpp)
===================================================================
--- store/trunk/cpp/tests/jrnl/_ut_rec_hdr.cpp	                        (rev 0)
+++ store/trunk/cpp/tests/jrnl/_ut_rec_hdr.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -0,0 +1,424 @@
+/**
+* \file _ut_file_hdr.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the unit tests for the journal.
+*
+* Copyright 2007, 2008 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include "../unit_test.h"
+#include <jrnl/deq_hdr.hpp>
+#include <jrnl/enq_hdr.hpp>
+#include <jrnl/file_hdr.hpp>
+#include <jrnl/jcfg.hpp>
+#include <jrnl/rec_tail.hpp>
+#include <jrnl/txn_hdr.hpp>
+
+using namespace boost::unit_test;
+using namespace rhm::journal;
+
+QPID_AUTO_TEST_SUITE(rec_hdr_suite)
+
+BOOST_AUTO_TEST_CASE(test_hdr)
+{
+    rec_hdr h1;
+    BOOST_CHECK_EQUAL(h1._magic, 0UL);
+    BOOST_CHECK_EQUAL(h1._version, 0);
+    BOOST_CHECK_EQUAL(h1._eflag, 0);
+    BOOST_CHECK_EQUAL(h1._uflag, 0);
+    BOOST_CHECK_EQUAL(h1._rid, 0ULL);
+    BOOST_CHECK(!h1.get_owi());
+
+    const u_int32_t magic = 0x89abcdefUL;    
+    const u_int16_t uflag = 0x5537;
+    const u_int8_t version = 0xef;    
+    const u_int64_t rid = 0x123456789abcdef0ULL;
+    const bool owi = true;
+
+    rec_hdr h2(magic, version, rid, owi);
+    BOOST_CHECK_EQUAL(h2._magic, magic);
+    BOOST_CHECK_EQUAL(h2._version, version);
+#ifdef JRNL_LITTLE_ENDIAN
+    BOOST_CHECK_EQUAL(h2._eflag, RHM_LENDIAN_FLAG);
+#else
+    BOOST_CHECK_EQUAL(h2._eflag, RHM_BENDIAN_FLAG);
+#endif
+    BOOST_CHECK_EQUAL(h2._uflag, (const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK);
+    BOOST_CHECK_EQUAL(h2._rid, rid);
+    BOOST_CHECK_EQUAL(h2.get_owi(), owi);
+    h2._uflag = uflag;
+    BOOST_CHECK(h2.get_owi());
+    h2.set_owi(true);
+    BOOST_CHECK(h2.get_owi());
+    BOOST_CHECK_EQUAL(h2._uflag, uflag);
+    h2.set_owi(false);
+    BOOST_CHECK(!h2.get_owi());
+    BOOST_CHECK_EQUAL(h2._uflag, (uflag & ~(const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK));
+    h2.set_owi(true);
+    BOOST_CHECK(h2.get_owi());
+    BOOST_CHECK_EQUAL(h2._uflag, uflag);
+
+    h1.hdr_copy(h2);    
+    BOOST_CHECK_EQUAL(h1._magic, magic);
+    BOOST_CHECK_EQUAL(h1._version, version);
+#ifdef JRNL_LITTLE_ENDIAN
+    BOOST_CHECK_EQUAL(h1._eflag, RHM_LENDIAN_FLAG);
+#else
+    BOOST_CHECK_EQUAL(h1._eflag, RHM_BENDIAN_FLAG);
+#endif
+    BOOST_CHECK_EQUAL(h1._uflag, uflag);
+    BOOST_CHECK_EQUAL(h1._rid, rid);
+    BOOST_CHECK(h1.get_owi());
+    BOOST_CHECK_EQUAL(h1._uflag, uflag);
+
+    h1.reset();
+    BOOST_CHECK_EQUAL(h1._magic, 0UL);
+    BOOST_CHECK_EQUAL(h1._version, 0);
+    BOOST_CHECK_EQUAL(h1._eflag, 0);
+    BOOST_CHECK_EQUAL(h1._uflag, 0);
+    BOOST_CHECK_EQUAL(h1._rid, 0ULL);
+    BOOST_CHECK(!h1.get_owi());
+}
+
+BOOST_AUTO_TEST_CASE(test_rec_tail)
+{
+    const u_int32_t magic = 0xfedcba98;
+    const u_int64_t rid = 0xfedcba9876543210ULL;
+    const u_int32_t xmagic = ~magic;
+
+    {
+        rec_tail rt1;
+        BOOST_CHECK_EQUAL(rt1._xmagic, 0xffffffffUL);
+        BOOST_CHECK_EQUAL(rt1._rid, 0ULL);
+    }
+
+    {
+        rec_tail rt2(magic, rid);
+        BOOST_CHECK_EQUAL(rt2._xmagic, magic);
+        BOOST_CHECK_EQUAL(rt2._rid, rid);
+    }
+
+    {
+        rec_hdr h(magic, RHM_JDAT_VERSION, rid, true);
+        rec_tail rt3(h);
+        BOOST_CHECK_EQUAL(rt3._xmagic, xmagic);
+        BOOST_CHECK_EQUAL(rt3._rid, rid);
+    }
+}
+
+BOOST_AUTO_TEST_CASE(test_file_hdr)
+{
+    const u_int32_t magic = 0xfedcba98UL;
+    const u_int8_t version = 0xa5;
+    const u_int16_t uflag = 0x5537;
+    const u_int64_t rid = 0xfedcba9876543210ULL;
+    const u_int32_t fid = 0xfedcba98UL;
+#ifdef JRNL_32_BIT
+    const size_t fro = 0xfedcba98UL;
+#else
+    const size_t fro = 0xfedcba9876543210ULL;
+#endif
+    timespec ts;
+    const bool owi = true;
+
+    {
+        file_hdr fh1;
+        BOOST_CHECK_EQUAL(fh1._magic, 0UL);
+        BOOST_CHECK_EQUAL(fh1._version, 0);
+        BOOST_CHECK_EQUAL(fh1._eflag, 0);
+        BOOST_CHECK_EQUAL(fh1._uflag, 0);
+        BOOST_CHECK_EQUAL(fh1._rid, 0ULL);
+        BOOST_CHECK_EQUAL(fh1._fid, 0UL);
+        BOOST_CHECK_EQUAL(fh1._fro, size_t(0));
+        BOOST_CHECK_EQUAL(fh1._ts_sec, time_t(0));
+        BOOST_CHECK_EQUAL(fh1._ts_nsec, uint32_t(0));
+        BOOST_CHECK(!fh1.get_owi());
+    }
+
+    {
+        file_hdr fh2(magic, version, rid, fid, fro, owi, false);
+        BOOST_CHECK_EQUAL(fh2._magic, magic);
+        BOOST_CHECK_EQUAL(fh2._version, version);
+#ifdef JRNL_LITTLE_ENDIAN
+        BOOST_CHECK_EQUAL(fh2._eflag, RHM_LENDIAN_FLAG);
+#else
+        BOOST_CHECK_EQUAL(fh2._eflag, RHM_BENDIAN_FLAG);
+#endif
+        BOOST_CHECK_EQUAL(fh2._uflag, (const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK);
+        BOOST_CHECK_EQUAL(fh2._rid, rid);
+        BOOST_CHECK_EQUAL(fh2._fid,fid );
+        BOOST_CHECK_EQUAL(fh2._fro, fro);
+        BOOST_CHECK_EQUAL(fh2._ts_sec, time_t(0));
+        BOOST_CHECK_EQUAL(fh2._ts_nsec, uint32_t(0));
+        ::clock_gettime(CLOCK_REALTIME, &ts);
+        fh2.set_time(ts);
+        BOOST_CHECK_EQUAL(fh2._ts_sec, ts.tv_sec);
+        BOOST_CHECK_EQUAL(fh2._ts_nsec, u_int32_t(ts.tv_nsec));
+        BOOST_CHECK(fh2.get_owi());
+
+        fh2._uflag = uflag;
+        BOOST_CHECK(fh2.get_owi());
+
+        fh2.set_owi(false);
+        BOOST_CHECK(!fh2.get_owi());
+        BOOST_CHECK_EQUAL(fh2._uflag,
+                (uflag & ~(const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK));
+
+        fh2.set_owi(true);
+        BOOST_CHECK(fh2.get_owi());
+        BOOST_CHECK_EQUAL(fh2._uflag, uflag);
+    }
+
+    {
+        file_hdr fh3(magic, version, rid, fid, fro, owi, true);
+        BOOST_CHECK_EQUAL(fh3._magic, magic);
+        BOOST_CHECK_EQUAL(fh3._version, version);
+#ifdef JRNL_LITTLE_ENDIAN
+        BOOST_CHECK_EQUAL(fh3._eflag, RHM_LENDIAN_FLAG);
+#else
+        BOOST_CHECK_EQUAL(fh3._eflag, RHM_BENDIAN_FLAG);
+#endif
+        BOOST_CHECK_EQUAL(fh3._uflag, (const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK);
+        BOOST_CHECK_EQUAL(fh3._rid, rid);
+        BOOST_CHECK_EQUAL(fh3._fid, fid);
+        BOOST_CHECK_EQUAL(fh3._fro, fro);
+        BOOST_CHECK(fh3._ts_sec - ts.tv_sec <= 1); // No more than 1 sec difference
+    }
+}
+
+BOOST_AUTO_TEST_CASE(test_enq_hdr)
+{
+    const u_int32_t magic = 0xfedcba98UL;
+    const u_int8_t version = 0xa5;
+    const u_int64_t rid = 0xfedcba9876543210ULL;
+    const u_int16_t uflag = 0x5537;
+#ifdef JRNL_32_BIT
+    const size_t xidsize = 0xfedcba98UL;
+    const size_t dsize = 0x76543210UL;
+#else
+    const size_t xidsize = 0xfedcba9876543210ULL;
+    const size_t dsize = 0x76543210fedcba98ULL;
+#endif
+    const bool owi = true;
+
+    {
+        enq_hdr eh1;
+        BOOST_CHECK_EQUAL(eh1._magic, 0UL);
+        BOOST_CHECK_EQUAL(eh1._version, 0);
+        BOOST_CHECK_EQUAL(eh1._eflag, 0);
+        BOOST_CHECK_EQUAL(eh1._uflag, 0);
+        BOOST_CHECK_EQUAL(eh1._rid, 0ULL);
+        BOOST_CHECK_EQUAL(eh1._xidsize, size_t(0));
+        BOOST_CHECK_EQUAL(eh1._dsize, size_t(0));
+        BOOST_CHECK(!eh1.get_owi());
+    }
+
+    {
+        enq_hdr eh2(magic, version, rid, xidsize, dsize, owi, false);
+        BOOST_CHECK_EQUAL(eh2._magic, magic);
+        BOOST_CHECK_EQUAL(eh2._version, version);
+#ifdef JRNL_LITTLE_ENDIAN
+        BOOST_CHECK_EQUAL(eh2._eflag, RHM_LENDIAN_FLAG);
+#else
+        BOOST_CHECK_EQUAL(eh2._eflag, RHM_BENDIAN_FLAG);
+#endif
+        BOOST_CHECK_EQUAL(eh2._uflag, (const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK);
+        BOOST_CHECK_EQUAL(eh2._rid, rid);
+        BOOST_CHECK_EQUAL(eh2._xidsize, xidsize);
+        BOOST_CHECK_EQUAL(eh2._dsize, dsize);
+        BOOST_CHECK(eh2.get_owi());
+        BOOST_CHECK(!eh2.is_transient());
+        BOOST_CHECK(!eh2.is_external());
+
+        eh2._uflag = uflag;
+        BOOST_CHECK(eh2.get_owi());
+        BOOST_CHECK(eh2.is_transient());
+        BOOST_CHECK(eh2.is_external());
+
+        eh2.set_owi(false);
+        BOOST_CHECK(!eh2.get_owi());
+        BOOST_CHECK(eh2.is_transient());
+        BOOST_CHECK(eh2.is_external());
+        BOOST_CHECK_EQUAL(eh2._uflag,
+                (uflag & ~(const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK));
+
+        eh2.set_owi(true);
+        BOOST_CHECK(eh2.get_owi());
+        BOOST_CHECK(eh2.is_transient());
+        BOOST_CHECK(eh2.is_external());
+        BOOST_CHECK_EQUAL(eh2._uflag, uflag);
+
+        eh2.set_transient(false);
+        BOOST_CHECK(eh2.get_owi());
+        BOOST_CHECK(!eh2.is_transient());
+        BOOST_CHECK(eh2.is_external());
+        BOOST_CHECK_EQUAL(eh2._uflag, uflag & ~(const u_int16_t)enq_hdr::ENQ_HDR_TRANSIENT_MASK);
+
+        eh2.set_transient(true);
+        BOOST_CHECK(eh2.get_owi());
+        BOOST_CHECK(eh2.is_transient());
+        BOOST_CHECK(eh2.is_external());
+        BOOST_CHECK_EQUAL(eh2._uflag, uflag);
+
+        eh2.set_external(false);
+        BOOST_CHECK(eh2.get_owi());
+        BOOST_CHECK(eh2.is_transient());
+        BOOST_CHECK(!eh2.is_external());
+        BOOST_CHECK_EQUAL(eh2._uflag, uflag & ~(const u_int16_t)enq_hdr::ENQ_HDR_EXTERNAL_MASK);
+
+        eh2.set_external(true);
+        BOOST_CHECK(eh2.get_owi());
+        BOOST_CHECK(eh2.is_transient());
+        BOOST_CHECK(eh2.is_external());
+        BOOST_CHECK_EQUAL(eh2._uflag, uflag);
+    }
+
+    {
+        enq_hdr eh3(magic, version, rid, xidsize, dsize, owi, true);
+        BOOST_CHECK_EQUAL(eh3._magic, magic);
+        BOOST_CHECK_EQUAL(eh3._version, version);
+#ifdef JRNL_LITTLE_ENDIAN
+        BOOST_CHECK_EQUAL(eh3._eflag, RHM_LENDIAN_FLAG);
+#else
+        BOOST_CHECK_EQUAL(eh3._eflag, RHM_BENDIAN_FLAG);
+#endif
+        BOOST_CHECK_EQUAL(eh3._uflag, (const u_int16_t)enq_hdr::ENQ_HDR_TRANSIENT_MASK |
+                (const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK);
+        BOOST_CHECK_EQUAL(eh3._rid, rid);
+        BOOST_CHECK_EQUAL(eh3._xidsize, xidsize);
+        BOOST_CHECK_EQUAL(eh3._dsize, dsize);
+        BOOST_CHECK(eh3.get_owi());
+        BOOST_CHECK(eh3.is_transient());
+        BOOST_CHECK(!eh3.is_external());
+    }
+}
+
+BOOST_AUTO_TEST_CASE(test_deq_hdr)
+{
+    const u_int32_t magic = 0xfedcba98UL;
+    const u_int8_t version = 0xa5;
+    const u_int16_t uflag = 0x5537;
+    const u_int64_t rid = 0xfedcba9876543210ULL;
+    const u_int64_t drid = 0x76543210fedcba98ULL;
+#ifdef JRNL_32_BIT
+    const size_t xidsize = 0xfedcba98UL;
+#else
+    const size_t xidsize = 0xfedcba9876543210ULL;
+#endif
+    const bool owi = true;
+
+    {
+        deq_hdr dh1;
+        BOOST_CHECK_EQUAL(dh1._magic, 0UL);
+        BOOST_CHECK_EQUAL(dh1._version, 0);
+        BOOST_CHECK_EQUAL(dh1._eflag, 0);
+        BOOST_CHECK_EQUAL(dh1._uflag, 0);
+        BOOST_CHECK_EQUAL(dh1._rid, 0ULL);
+        BOOST_CHECK_EQUAL(dh1._deq_rid, 0ULL);
+        BOOST_CHECK_EQUAL(dh1._xidsize, size_t(0));
+        BOOST_CHECK(!dh1.get_owi());
+    }
+
+    {
+        deq_hdr dh2(magic, version, rid, drid, xidsize, owi);
+        BOOST_CHECK_EQUAL(dh2._magic, magic);
+        BOOST_CHECK_EQUAL(dh2._version, version);
+#ifdef JRNL_LITTLE_ENDIAN
+        BOOST_CHECK_EQUAL(dh2._eflag, RHM_LENDIAN_FLAG);
+#else
+        BOOST_CHECK_EQUAL(dh2._eflag, RHM_BENDIAN_FLAG);
+#endif
+        BOOST_CHECK_EQUAL(dh2._uflag, (const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK);
+        BOOST_CHECK_EQUAL(dh2._rid, rid);
+        BOOST_CHECK_EQUAL(dh2._deq_rid, drid);
+        BOOST_CHECK_EQUAL(dh2._xidsize, xidsize);
+        BOOST_CHECK(dh2.get_owi());
+
+        dh2._uflag = uflag;
+        BOOST_CHECK(dh2.get_owi());
+
+        dh2.set_owi(false);
+        BOOST_CHECK(!dh2.get_owi());
+        BOOST_CHECK_EQUAL(dh2._uflag,
+                (uflag & ~(const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK));
+
+        dh2.set_owi(true);
+        BOOST_CHECK(dh2.get_owi());
+        BOOST_CHECK_EQUAL(dh2._uflag, uflag);
+    }
+}
+
+BOOST_AUTO_TEST_CASE(test_txn_hdr)
+{
+    const u_int32_t magic = 0xfedcba98UL;
+    const u_int8_t version = 0xa5;
+    const u_int16_t uflag = 0x5537;
+    const u_int64_t rid = 0xfedcba9876543210ULL;
+#ifdef JRNL_32_BIT
+    const size_t xidsize = 0xfedcba98UL;
+#else
+    const size_t xidsize = 0xfedcba9876543210ULL;
+#endif
+    const bool owi = true;
+
+    {
+        txn_hdr th1;
+        BOOST_CHECK_EQUAL(th1._magic, 0UL);
+        BOOST_CHECK_EQUAL(th1._version, 0);
+        BOOST_CHECK_EQUAL(th1._eflag, 0);
+        BOOST_CHECK_EQUAL(th1._uflag, 0);
+        BOOST_CHECK_EQUAL(th1._rid, 0ULL);
+        BOOST_CHECK_EQUAL(th1._xidsize, size_t(0));
+        BOOST_CHECK(!th1.get_owi());
+    }
+
+    {
+        txn_hdr th2(magic, version, rid, xidsize, owi);
+        BOOST_CHECK_EQUAL(th2._magic, magic);
+        BOOST_CHECK_EQUAL(th2._version, version);
+#ifdef JRNL_LITTLE_ENDIAN
+        BOOST_CHECK_EQUAL(th2._eflag, RHM_LENDIAN_FLAG);
+#else
+        BOOST_CHECK_EQUAL(th2._eflag, RHM_BENDIAN_FLAG);
+#endif
+        BOOST_CHECK_EQUAL(th2._uflag, (const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK);
+        BOOST_CHECK_EQUAL(th2._rid, rid);
+        BOOST_CHECK_EQUAL(th2._xidsize, xidsize);
+        BOOST_CHECK(th2.get_owi());
+
+        th2._uflag = uflag;
+        BOOST_CHECK(th2.get_owi());
+
+        th2.set_owi(false);
+        BOOST_CHECK(!th2.get_owi());
+        BOOST_CHECK_EQUAL(th2._uflag,
+                (uflag & ~(const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK));
+
+        th2.set_owi(true);
+        BOOST_CHECK(th2.get_owi());
+        BOOST_CHECK_EQUAL(th2._uflag, uflag);
+    }
+}
+
+QPID_AUTO_TEST_SUITE_END()

Copied: store/trunk/cpp/tests/jrnl/_ut_txn_map.cpp (from rev 1569, store/trunk/cpp/tests/jrnl/unit_test_txn_map.cpp)
===================================================================
--- store/trunk/cpp/tests/jrnl/_ut_txn_map.cpp	                        (rev 0)
+++ store/trunk/cpp/tests/jrnl/_ut_txn_map.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -0,0 +1,106 @@
+/**
+* \file _ut_txn_map.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the unit tests for the journal.
+*
+* Copyright 2007, 2008 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include "../unit_test.h"
+#include <iomanip>
+#include <jrnl/txn_map.hpp>
+#include <sstream>
+
+using namespace boost::unit_test;
+using namespace rhm::journal;
+
+QPID_AUTO_TEST_SUITE(txn_map_suite)
+
+// Helper function declarations
+const std::string make_xid(u_int64_t rid);
+void check_td_equal(txn_data& td1, txn_data& td2);
+
+BOOST_AUTO_TEST_CASE(test_constructor)
+{
+    const u_int64_t rid = 0x123456789abcdef0ULL;
+    const u_int64_t drid = 0xfedcba9876543210ULL;
+    const u_int16_t fid = 0xfedcU;
+    const bool enq_flag = true;
+    txn_data td(rid, drid, fid, enq_flag);
+    BOOST_CHECK_EQUAL(td._rid, rid);
+    BOOST_CHECK_EQUAL(td._drid, drid);
+    BOOST_CHECK_EQUAL(td._fid, fid);
+    BOOST_CHECK_EQUAL(td._enq_flag, enq_flag);
+    BOOST_CHECK_EQUAL(td._aio_compl, false);
+    
+    txn_map t1;
+    BOOST_CHECK(t1.empty());
+    BOOST_CHECK_EQUAL(t1.size(), 0);
+}
+
+BOOST_AUTO_TEST_CASE(test_insert_get)
+{
+    u_int16_t fid;
+    u_int64_t rid;
+    u_int16_t fid_start = 0x2000U;
+    u_int64_t rid_begin = 0xffffffff00000000ULL;
+    u_int64_t rid_end   = 0xffffffff00000200ULL;
+
+    // insert with no dups
+    u_int64_t rid_incr_1 = 4ULL;
+    txn_map t2;
+    for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_1, fid++)
+        t2.insert_txn_data(make_xid(rid), txn_data(rid, ~rid, fid, false));
+    BOOST_CHECK(!t2.empty());
+    BOOST_CHECK_EQUAL(t2.size(), 128);
+    
+    // get
+    u_int64_t rid_incr_2 = 6ULL;
+    for (u_int64_t rid = rid_begin; rid < rid_end; rid += rid_incr_2)
+    {
+        std::string xid = make_xid(rid);
+        BOOST_CHECK_EQUAL(t2.in_map(xid), (rid%rid_incr_1 ? false : true));
+    }
+}
+
+// Helper functions
+
+const std::string make_xid(u_int64_t rid)
+{
+    std::stringstream ss;
+    ss << "XID-" << std::setfill('0') << std::setw(16) << std::hex << rid;
+    ss << "-0123456789abcdef";
+    return ss.str();  
+}
+
+void check_td_equal(txn_data& td1, txn_data& td2)
+{
+    BOOST_CHECK_EQUAL(td1._rid,       td2._rid);
+    BOOST_CHECK_EQUAL(td1._drid,      td2._drid);
+    BOOST_CHECK_EQUAL(td1._fid,       td2._fid);
+    BOOST_CHECK_EQUAL(td1._enq_flag,  td2._enq_flag);
+    BOOST_CHECK_EQUAL(td1._aio_compl, td2._aio_compl);
+}
+
+QPID_AUTO_TEST_SUITE_END()

Added: store/trunk/cpp/tests/jrnl/jhexdump
===================================================================
--- store/trunk/cpp/tests/jrnl/jhexdump	                        (rev 0)
+++ store/trunk/cpp/tests/jrnl/jhexdump	2008-01-18 14:14:21 UTC (rev 1570)
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+# Copyright (C) 2008 Red Hat Inc.
+#
+# This file is part of Red Hat Messaging.
+#
+# Red Hat Messaging is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+# USA
+#
+# The GNU Lesser General Public License is available in the file COPYING.
+
+if [ -z $1 ]; then
+    echo "No directory specified."
+    exit
+fi
+
+JDIR=$1
+echo "Target directory: ${JDIR}"
+
+rm -f j*.txt
+
+if [ -d ${JDIR} ]; then
+    n=0
+    for f in ${JDIR}/*.jdat; do
+        echo "$f -> j$n.txt"
+        hexdump -C $f > j$n.txt
+        (( n += 1 ))
+    done
+else
+    echo "This directory does not exist."
+fi


Property changes on: store/trunk/cpp/tests/jrnl/jhexdump
___________________________________________________________________
Name: svn:executable
   + *

Deleted: store/trunk/cpp/tests/jrnl/unit_test_enq_map.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_enq_map.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/tests/jrnl/unit_test_enq_map.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -1,244 +0,0 @@
-/**
-* \file unit_test_enq_map.cpp
-*
-* Red Hat Messaging - Message Journal
-*
-* This file contains the unit tests for the journal.
-*
-* \author Kim van der Riet
-*
-* Copyright 2007 Red Hat, Inc.
-*
-* This file is part of Red Hat Messaging.
-*
-* Red Hat Messaging is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2.1 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
-* USA
-*
-* The GNU Lesser General Public License is available in the file COPYING.
-*/
-
-#include "../unit_test.h"
-#include <iostream>
-#include <jrnl/enq_map.hpp>
-#include <jrnl/jerrno.hpp>
-
-using namespace boost::unit_test;
-using namespace rhm::journal;
-
-QPID_AUTO_TEST_SUITE(eng_map_suite)
-
-// Test functions of the form
-// void fn() {...}
-
-BOOST_AUTO_TEST_CASE(test_constructor)
-{
-    enq_map e1;
-    BOOST_CHECK(e1.empty());
-    BOOST_CHECK_EQUAL(e1.size(), 0);
-}
-
-BOOST_AUTO_TEST_CASE(test_insert_get)
-{
-    u_int16_t fid;
-    u_int64_t rid;
-    u_int16_t fid_start = 0x2000U;
-    u_int64_t rid_begin = 0xffffffff00000000ULL;
-    u_int64_t rid_end   = 0xffffffff00000200ULL;
-
-    // insert with no dups
-    u_int64_t rid_incr_1 = 4ULL;
-    enq_map e2;
-    for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_1, fid++)
-        e2.insert_fid(rid, fid);
-    BOOST_CHECK(!e2.empty());
-    BOOST_CHECK_EQUAL(e2.size(), 128);
-    
-    // get
-    u_int64_t rid_incr_2 = 6ULL;
-    for (u_int64_t rid = rid_begin; rid < rid_end; rid += rid_incr_2)
-    {
-        BOOST_CHECK_EQUAL(e2.is_enqueued(rid), (rid%rid_incr_1 ? false : true));
-        try
-        {
-            u_int16_t exp_fid = fid_start + (u_int16_t)((rid - rid_begin)/rid_incr_1);
-            u_int16_t ret_fid = e2.get_fid(rid);
-            BOOST_CHECK_EQUAL(ret_fid, exp_fid);
-            BOOST_CHECK(rid%rid_incr_1 == 0);
-        }
-        catch (const jexception& e)
-        {
-            BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_NOTFOUND);
-            BOOST_CHECK(rid%rid_incr_1);
-        }
-        if ((rid + rid_incr_2)%(8 * rid_incr_2) == 0)
-            fid++;
-    }
-
-    // insert with dups
-    for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_2, fid++)
-    {
-        try
-        {
-            e2.insert_fid(rid, fid);
-            BOOST_CHECK(rid%rid_incr_1);
-        }
-        catch (const jexception& e)
-        {
-            BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_DUPLICATE);
-            BOOST_CHECK(rid%rid_incr_1 == 0);
-        }
-    }
-    BOOST_CHECK_EQUAL(e2.size(), 171ULL);
-    e2.clear();
-    BOOST_CHECK(e2.empty());
-    BOOST_CHECK_EQUAL(e2.size(), 0);
-}
-
-BOOST_AUTO_TEST_CASE(test_get_remove)
-{
-    u_int16_t fid;
-    u_int64_t rid;
-    u_int16_t fid_start = 0x3000U;
-    u_int64_t rid_begin = 0xeeeeeeee00000000ULL;
-    u_int64_t rid_end   = 0xeeeeeeee00000200ULL;
-
-    u_int64_t rid_incr_1 = 4ULL;
-    u_int64_t num_incr_1 = (rid_end - rid_begin)/rid_incr_1;
-    enq_map e3;
-    for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_1, fid++)
-        e3.insert_fid(rid, fid);
-    BOOST_CHECK_EQUAL(e3.size(), num_incr_1);
-
-    u_int64_t rid_incr_2 = 6ULL;
-    for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_2, fid++)
-    {
-        try
-        {
-            u_int16_t exp_fid = fid_start + (u_int16_t)((rid - rid_begin)/rid_incr_1);
-            u_int16_t ret_fid = e3.get_remove_fid(rid);
-            BOOST_CHECK_EQUAL(ret_fid, exp_fid);
-            BOOST_CHECK(rid%rid_incr_1 == 0);
-        }
-        catch (const jexception& e)
-        {
-            BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_NOTFOUND);
-            BOOST_CHECK(rid%rid_incr_1);
-        }
-    }
-    BOOST_CHECK_EQUAL(e3.size(), 85ULL);
-}
-
-BOOST_AUTO_TEST_CASE(test_lock)
-{
-    u_int16_t fid;
-    u_int64_t rid;
-    u_int16_t fid_start = 0x4000U;
-    u_int64_t rid_begin = 0xdddddddd00000000ULL;
-    u_int64_t rid_end   = 0xdddddddd00000200ULL;
-
-    // insert, every second entry is locked
-    u_int64_t rid_incr_1 = 4ULL;
-    u_int64_t num_incr_1 = (rid_end - rid_begin)/rid_incr_1;
-    bool locked = false;
-    enq_map e4;
-    for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_1, fid++)
-    {
-        e4.insert_fid(rid, fid, locked);
-        locked = !locked;
-    }
-    BOOST_CHECK_EQUAL(e4.size(), num_incr_1);
-
-    // unlock and lock non-existent rids
-    try
-    {
-        e4.lock(1ULL);
-        BOOST_ERROR("Failed to throw exception when locking non-existent rid.");
-    }
-    catch (const jexception& e) { BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_NOTFOUND); }
-    try
-    {
-        e4.unlock(2ULL);
-        BOOST_ERROR("Failed to throw exception when locking non-existent rid.");
-    }
-    catch (const jexception& e) { BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_NOTFOUND); }
-    
-    // get / unlock
-    for (u_int64_t rid = rid_begin; rid < rid_end; rid += rid_incr_1)
-    {
-        try { e4.get_fid(rid); }
-        catch(const jexception& e)
-        {
-            BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_LOCKED);
-            BOOST_CHECK(rid%(2*rid_incr_1));
-            // unlock, read, then relock
-            e4.unlock(rid);
-            e4.get_fid(rid);
-            e4.lock(rid);
-            try
-            {
-               e4.get_fid(rid);
-               BOOST_ERROR("Failed to throw exception when getting locked record");
-            }
-            catch(const jexception& e)
-            {
-                BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_LOCKED);
-            }
-        }
-    }
-
-    // remove all; if locked, use with txn_flag true; should ignore all locked records
-    for (u_int64_t rid = rid_begin; rid < rid_end; rid += rid_incr_1)
-        e4.get_remove_fid(rid, true);
-    BOOST_CHECK(e4.empty());
-}
-
-BOOST_AUTO_TEST_CASE(test_lists)
-{
-    u_int16_t fid;
-    u_int64_t rid;
-    u_int16_t fid_start = 0x5000UL;
-    u_int64_t rid_begin = 0xdddddddd00000000ULL;
-    u_int64_t rid_end   = 0xdddddddd00000200ULL;
-
-    // insert, every second entry is locked
-    u_int64_t rid_incr_1 = 4ULL;
-    u_int64_t num_incr_1 = (rid_end - rid_begin)/rid_incr_1;
-    std::vector<u_int64_t> rid_list;
-    std::vector<u_int16_t> fid_list;
-    enq_map e5;
-    for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_1, fid++)
-    {
-        e5.insert_fid(rid, fid);
-        rid_list.push_back(rid);
-        fid_list.push_back(fid);
-    }
-    BOOST_CHECK_EQUAL(e5.size(), num_incr_1);
-    BOOST_CHECK_EQUAL(rid_list.size(), num_incr_1);
-    BOOST_CHECK_EQUAL(fid_list.size(), num_incr_1);
-
-    std::vector<u_int64_t> ret_rid_list;
-    e5.rid_list(ret_rid_list);
-    BOOST_CHECK_EQUAL(ret_rid_list.size(), num_incr_1);
-    for (unsigned i=0; i<ret_rid_list.size(); i++)
-        BOOST_CHECK_EQUAL(rid_list[i], ret_rid_list[i]);
-
-    std::vector<u_int16_t> ret_fid_list;
-    e5.fid_list(ret_fid_list);
-    BOOST_CHECK_EQUAL(ret_fid_list.size(), num_incr_1);
-    for (unsigned i=0; i<ret_fid_list.size(); i++)
-        BOOST_CHECK_EQUAL(fid_list[i], ret_fid_list[i]);
-}
-
-QPID_AUTO_TEST_SUITE_END()

Deleted: store/trunk/cpp/tests/jrnl/unit_test_jdir.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_jdir.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/tests/jrnl/unit_test_jdir.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -1,392 +0,0 @@
-/**
-* \file unit_test_jdir.cpp
-*
-* Red Hat Messaging - Message Journal
-*
-* This file contains the unit tests for the journal.
-*
-* \author Kim van der Riet
-*
-* Copyright 2007 Red Hat, Inc.
-*
-* This file is part of Red Hat Messaging.
-*
-* Red Hat Messaging is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2.1 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
-* USA
-*
-* The GNU Lesser General Public License is available in the file COPYING.
-*/
-
-#include "../unit_test.h"
-#include <dirent.h>
-#include <errno.h>
-#include <fstream>
-#include <iomanip>
-#include <iostream>
-#include <jrnl/file_hdr.hpp>
-#include <jrnl/jcfg.hpp>
-#include <jrnl/jdir.hpp>
-#include <jrnl/jerrno.hpp>
-#include <jrnl/jexception.hpp>
-#include <sys/stat.h>
-
-QPID_AUTO_TEST_SUITE(jdir_suite)
-
-#define NUM_JFILES 4
-#define JFSIZE_SBLKS 128
-
-#define ERRORSTR(e) ::strerror(ret) << " (" << ret << ")"
-#define NUM_CLEAR_OPS 20
-
-using namespace boost::unit_test;
-using namespace rhm::journal;
-
-// Helper function declarations
-void create_file(const char* filename, mode_t fmode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-void create_jrnl_fileset(const char* dirname, const char* base_filename);
-void create_jdat_file(const char* dirname, const char* base_filename, u_int32_t fid,
-        u_int64_t first_rid);
-void create_jinf_file(const char* dirname, const char* base_filename);
-void check_dir_contents(const char* dirname, const char* base_filename, unsigned num_subdirs,
-        bool jrnl_present);
-unsigned count_dir_contents(const char* dirname, bool incl_files = true, bool incl_dirs = true);
-void check_dir_not_existing(const char* dirname);
-
-// Test functions of the form
-// void fn() {...}
-
-BOOST_AUTO_TEST_CASE(test_constructor)
-{
-    std::string dir("/tmp/A/B/C/D/E/F");
-    std::string bfn("test_base");
-    jdir dir1(dir, bfn);
-    BOOST_CHECK(dir1.dirname().compare(dir) == 0);
-    BOOST_CHECK(dir1.base_filename().compare(bfn) == 0);
-}
-
-BOOST_AUTO_TEST_CASE(test_create_delete_dir)
-{
-    // Use instance
-    std::string dir_A("/tmp/A");
-    std::string dir_Ats("/tmp/A/"); // trailing '/'
-    check_dir_not_existing("/tmp/A");
-    jdir dir1(dir_A, "test_base");
-    dir1.create_dir();
-    // check all combos of jdir::exists and jdir::is_dir()
-    BOOST_CHECK(jdir::exists(dir_A));
-    BOOST_CHECK(jdir::exists(dir_Ats));
-    BOOST_CHECK(jdir::exists(dir_A.c_str()));
-    BOOST_CHECK(jdir::exists(dir_Ats.c_str()));
-    BOOST_CHECK(jdir::is_dir(dir_A));
-    BOOST_CHECK(jdir::is_dir(dir_Ats));
-    BOOST_CHECK(jdir::is_dir(dir_Ats.c_str()));
-    BOOST_CHECK(jdir::is_dir(dir_Ats.c_str()));
-    // do it a second time when dir exists
-    dir1.create_dir();
-    BOOST_CHECK(jdir::is_dir(dir_A));
-    dir1.delete_dir();
-    BOOST_CHECK(!jdir::exists(dir_A));
-    
-    // Use static fn
-    check_dir_not_existing("/tmp/B");
-    jdir::create_dir("/tmp/B");
-    BOOST_CHECK(jdir::is_dir("/tmp/B"));
-    jdir::create_dir("/tmp/B");
-    BOOST_CHECK(jdir::is_dir("/tmp/B"));
-    jdir::delete_dir("/tmp/B");
-    BOOST_CHECK(!jdir::exists("/tmp/B"));
-    
-    // Non-empty dirs
-    check_dir_not_existing("/tmp/C");
-    jdir::create_dir("/tmp/C");
-    BOOST_CHECK(jdir::is_dir("/tmp/C"));
-    create_file("/tmp/C/test_file_1.txt"); // mode 644 (default)
-    create_file("/tmp/C/test_file_2.txt", S_IRWXU | S_IRWXG | S_IRWXO); // mode 777
-    create_file("/tmp/C/test_file_3.txt", S_IRUSR | S_IRGRP | S_IROTH); // mode 444 (read-only)
-    create_file("/tmp/C/test_file_4.txt", 0); // mode 000 (no permissions)
-    BOOST_CHECK(jdir::is_dir("/tmp/C"));
-    jdir::create_dir("/tmp/C");
-    BOOST_CHECK(jdir::is_dir("/tmp/C"));
-    jdir::delete_dir("/tmp/C");
-    BOOST_CHECK(!jdir::exists("/tmp/C"));
-
-    // Check non-existent dirs fail
-    check_dir_not_existing("/tmp/D");
-    try
-    {
-        jdir::is_dir("/tmp/D");
-        BOOST_ERROR("jdir::is_dir() failed to throw jexeption for non-existent directory.");
-    }
-    catch(const jexception& e)
-    {
-        BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_JDIR_STAT);
-    }
-}
-
-BOOST_AUTO_TEST_CASE(test_create_delete_dir_recursive)
-{
-    // Use instances
-    check_dir_not_existing("/tmp/E");
-    jdir dir1("/tmp/E/F/G/H", "test_base");
-    dir1.create_dir();
-    BOOST_CHECK(jdir::is_dir("/tmp/E/F/G/H"));
-    dir1.delete_dir();
-    BOOST_CHECK(!jdir::exists("/tmp/E/F/G/H")); // only H deleted, E/F/G remain
-    BOOST_CHECK(jdir::exists("/tmp/E"));
-    jdir::delete_dir("/tmp/E"); // delete remaining dirs
-    BOOST_CHECK(!jdir::exists("/tmp/E"));
-
-    check_dir_not_existing("/tmp/F");
-    jdir dir2("/tmp/F/G/H/I/", "test_base"); // trailing '/'
-    dir2.create_dir();
-    BOOST_CHECK(jdir::is_dir("/tmp/F/G/H/I/"));
-    dir2.delete_dir();
-    BOOST_CHECK(!jdir::exists("/tmp/F/G/H/I/"));
-    BOOST_CHECK(jdir::exists("/tmp/F"));
-    jdir::delete_dir("/tmp/F");
-    BOOST_CHECK(!jdir::exists("/tmp/F"));
-    
-    // Use static fn
-    check_dir_not_existing("/tmp/G");
-    jdir::create_dir("/tmp/G/H/I/J");
-    BOOST_CHECK(jdir::is_dir("/tmp/G/H/I/J"));
-    jdir::delete_dir("/tmp/G/H/I/J");
-    BOOST_CHECK(!jdir::exists("/tmp/G/H/I/J"));
-    BOOST_CHECK(jdir::exists("/tmp/G"));
-    jdir::delete_dir("/tmp/G");
-    BOOST_CHECK(!jdir::exists("/tmp/G"));
-
-    check_dir_not_existing("/tmp/H");
-    jdir::create_dir("/tmp/H/I/J/K/");
-    BOOST_CHECK(jdir::is_dir("/tmp/H/I/J/K/"));
-    jdir::delete_dir("/tmp/H/I/J/K/");
-    BOOST_CHECK(!jdir::exists("/tmp/H/I/J/K/"));
-    BOOST_CHECK(jdir::exists("/tmp/H"));
-    jdir::delete_dir("/tmp/H");
-    BOOST_CHECK(!jdir::exists("/tmp/H"));
-    
-    // Non-empty dirs
-    check_dir_not_existing("/tmp/I");
-    jdir::create_dir("/tmp/I/J/K1/L1");
-    jdir::create_dir("/tmp/I/J/K1/L2");
-    jdir::create_dir("/tmp/I/J/K1/L3");
-    jdir::create_dir("/tmp/I/J/K1/L4");
-    create_file("/tmp/I/J/K1/L4/test_file_1.txt"); // mode 644 (default)
-    create_file("/tmp/I/J/K1/L4/test_file_2.txt", S_IRWXU | S_IRWXG | S_IRWXO); // mode 777
-    create_file("/tmp/I/J/K1/L4/test_file_3.txt", S_IRUSR | S_IRGRP | S_IROTH); // mode 444
-    create_file("/tmp/I/J/K1/L4/test_file_4.txt", 0); // mode 000 (no permissions)
-    jdir::create_dir("/tmp/I/J/K2");
-    jdir::create_dir("/tmp/I/J/K3/L5");
-    jdir::create_dir("/tmp/I/J/K3/L6");
-    BOOST_CHECK(jdir::is_dir("/tmp/I/J/K1/L1"));
-    BOOST_CHECK(jdir::is_dir("/tmp/I/J/K1/L2"));
-    BOOST_CHECK(jdir::is_dir("/tmp/I/J/K1/L3"));
-    BOOST_CHECK(jdir::is_dir("/tmp/I/J/K1/L4"));
-    BOOST_CHECK(jdir::is_dir("/tmp/I/J/K2"));
-    BOOST_CHECK(jdir::is_dir("/tmp/I/J/K3/L5"));
-    BOOST_CHECK(jdir::is_dir("/tmp/I/J/K3/L6"));
-    jdir::delete_dir("/tmp/I");
-    BOOST_CHECK(!jdir::exists("/tmp/I"));
-}
-
-BOOST_AUTO_TEST_CASE(test_clear_verify_dir)
-{
-    // Use instances
-    const char* jrnl_dir = "/tmp/test_dir_1";
-    const char* bfn = "test_base";
-    check_dir_not_existing(jrnl_dir);
-    jdir test_dir_1(jrnl_dir, bfn);
-    test_dir_1.create_dir();
-    BOOST_CHECK(jdir::is_dir(jrnl_dir));
-    // add journal files, check they exist, then clear them
-    unsigned cnt = 0;
-    while (cnt < NUM_CLEAR_OPS)
-    {
-        create_jrnl_fileset(jrnl_dir, bfn);
-        check_dir_contents(jrnl_dir, bfn, cnt, true);
-        test_dir_1.clear_dir();
-        check_dir_contents(jrnl_dir, bfn, ++cnt, false);
-    }
-    // clean up
-    test_dir_1.delete_dir();
-    BOOST_CHECK(!jdir::exists(jrnl_dir));
-
-    // Non-existent dir with auto-create true
-    jrnl_dir = "/tmp/test_dir_2";
-    check_dir_not_existing(jrnl_dir);
-    jdir test_dir_2(jrnl_dir, bfn);
-    // clear dir
-    test_dir_2.clear_dir(); // create flag is true by default
-    check_dir_contents(jrnl_dir, bfn, 0, false);
-    // clear empty dir, should not create subdir
-    test_dir_2.clear_dir(); // create flag is true by default
-    check_dir_contents(jrnl_dir, bfn, 0, false);
-    // clean up
-    test_dir_2.delete_dir();
-    BOOST_CHECK(!jdir::exists(jrnl_dir));
-        
-    // non-existent dir with auto-create false
-    jrnl_dir = "/tmp/test_dir_3";
-    check_dir_not_existing(jrnl_dir);
-    jdir test_dir_3(jrnl_dir, bfn);
-    try
-    {
-        test_dir_3.clear_dir(false);
-        BOOST_ERROR("jdir::clear_dir(flase) failed to throw jexeption for non-existent directory.");
-    }
-    catch(const jexception& e)
-    {
-        BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_JDIR_OPENDIR);
-    }
-    
-    // Use static fn
-    jrnl_dir = "/tmp/test_dir_4";
-    check_dir_not_existing(jrnl_dir);
-    jdir::clear_dir(jrnl_dir, bfn); // should create dir if it does not exist
-    // add journal files, check they exist, then clear them
-    cnt = 0;
-    while (cnt < NUM_CLEAR_OPS)
-    {
-        create_jrnl_fileset(jrnl_dir, bfn);
-        check_dir_contents(jrnl_dir, bfn, cnt, true);
-        jdir::clear_dir(jrnl_dir, bfn);
-        check_dir_contents(jrnl_dir, bfn, ++cnt, false);
-    }
-    // clean up
-    jdir::delete_dir(jrnl_dir);
-    BOOST_CHECK(!jdir::exists(jrnl_dir));
-}
-
-// Helper functions
-
-void create_file(const char* filename, mode_t fmode)
-{
-    std::ofstream of(filename, std::ofstream::out | std::ofstream::trunc);
-    if (!of.good())
-        BOOST_FAIL("Unable to open file " << filename << " for writing.");
-    of.write(filename, ::strlen(filename));
-    of.close();
-    ::chmod(filename, fmode);
-}
-
-void create_jrnl_fileset(const char* dirname, const char* base_filename)
-{
-    create_jinf_file(dirname, base_filename);
-    for (u_int32_t fid = 0; fid < NUM_JFILES; fid++)
-    {
-        u_int64_t rid = 0x12340000 + (fid * 0x25);
-        create_jdat_file(dirname, base_filename, fid, rid);
-    }
-}
-
-void create_jdat_file(const char* dirname, const char* base_filename, u_int32_t fid,
-        u_int64_t first_rid)
-{
-    std::stringstream fn;
-    fn << dirname << "/" << base_filename << ".";
-    fn << std::setfill('0') << std::hex << std::setw(4) << fid << ".jdat";
-    file_hdr fh(RHM_JDAT_FILE_MAGIC, RHM_JDAT_VERSION, 0, first_rid, fid, 0x200, true);
-    std::ofstream of(fn.str().c_str(), std::ofstream::out | std::ofstream::trunc);
-    if (!of.good())
-        BOOST_FAIL("Unable to open journal data file " << fn << " for writing.");
-    of.write((const char*)&fh, sizeof(file_hdr));
-    of.close();
-}
-
-void create_jinf_file(const char* dirname, const char* base_filename)
-{
-    timespec ts;
-    ::clock_gettime(CLOCK_REALTIME, &ts);
-    jinf ji("test journal id", dirname, base_filename, NUM_JFILES, JFSIZE_SBLKS, ts);
-    ji.write();
-}
-
-void check_dir_contents(const char* dirname, const char* base_filename, unsigned num_subdirs,
-        bool jrnl_present)
-{
-    if (jdir::is_dir(dirname))
-    {
-        // Subdir count
-        BOOST_CHECK_EQUAL(count_dir_contents(dirname, false, true), num_subdirs);
-    
-        // Journal file count
-        unsigned num_jrnl_files = jrnl_present ? NUM_JFILES + 1 : 0;
-        BOOST_CHECK_EQUAL(count_dir_contents(dirname, true, false), num_jrnl_files);
-    
-        // Check journal files are present
-        if (jrnl_present)
-            try { jdir::verify_dir(dirname, base_filename); }
-            catch(const jexception& e) { BOOST_ERROR(e); }
-        for (unsigned subdir_num = 1; subdir_num <= num_subdirs; subdir_num++)
-        {
-            std::stringstream subdir_name;
-            subdir_name << dirname << "/_" << base_filename << ".bak.";
-            subdir_name << std::hex << std::setfill('0') << std::setw(4) << subdir_num;
-            try { jdir::verify_dir(subdir_name.str().c_str(), base_filename); }
-            catch(const jexception& e) { BOOST_ERROR(e); }
-        }
-    }
-    else
-        BOOST_ERROR(dirname << " is not a directory");
-}
-
-unsigned count_dir_contents(const char* dirname, bool incl_files, bool incl_dirs)
-{
-    struct dirent* entry;
-    struct stat s;
-    unsigned file_cnt = 0;
-    unsigned dir_cnt = 0;
-    unsigned other_cnt = 0;
-    DIR* dir = ::opendir(dirname);
-    if (!dir)
-        BOOST_FAIL("Unable to open directory " << dirname);
-    while ((entry = ::readdir(dir)) != NULL)
-    {
-        // Ignore . and ..
-        if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0)
-        {
-            std::stringstream fn;
-            fn << dirname << "/" << entry->d_name;
-            if (::stat(fn.str().c_str(), &s))
-                BOOST_FAIL("Unable to stat dir entry " << entry->d_name << "; err=" <<
-                        strerror(errno));
-            if (S_ISREG(s.st_mode))
-                file_cnt++;
-            else if (S_ISDIR(s.st_mode))
-                dir_cnt++;
-            else
-                other_cnt++;
-        }
-    }
-    if (incl_files)
-    {
-        if (incl_dirs)
-            return file_cnt + dir_cnt;
-        return file_cnt;
-    }
-    else if (incl_dirs)
-        return dir_cnt;
-    return other_cnt;
-}
-
-void check_dir_not_existing(const char* dirname)
-{
-    if (jdir::exists(dirname) && jdir::is_dir(dirname))
-        jdir::delete_dir(dirname);
-    if (jdir::exists(dirname))
-        BOOST_FAIL("Unable to remove directory " << dirname);
-}
-
-QPID_AUTO_TEST_SUITE_END()

Deleted: store/trunk/cpp/tests/jrnl/unit_test_jerrno.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_jerrno.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/tests/jrnl/unit_test_jerrno.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -1,52 +0,0 @@
-/**
-* \file unit_test_jerrno.cpp
-*
-* Red Hat Messaging - Message Journal
-*
-* This file contains the unit tests for the journal.
-*
-* \author Kim van der Riet
-*
-* Copyright 2007 Red Hat, Inc.
-*
-* This file is part of Red Hat Messaging.
-*
-* Red Hat Messaging is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2.1 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
-* USA
-*
-* The GNU Lesser General Public License is available in the file COPYING.
-*/
-
-#include "../unit_test.h"
-#include <iostream>
-#include <jrnl/jerrno.hpp>
-
-QPID_AUTO_TEST_SUITE(jerrno_suite)
-
-using namespace boost::unit_test;
-using namespace rhm::journal;
-
-// Test functions of the form
-// void fn() {...}
-
-BOOST_AUTO_TEST_CASE(test_jerrno)
-{
-    const char* m = "JERR__MALLOC";
-    std::string malloc_msg = std::string(jerrno::err_msg(jerrno::JERR__MALLOC));
-    BOOST_CHECK(malloc_msg.substr(0, ::strlen(m)).compare(m) == 0);
-    BOOST_CHECK(::strcmp(jerrno::err_msg(0), "<Unknown error code>") == 0);
-}
-        
-QPID_AUTO_TEST_SUITE_END()

Deleted: store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -1,335 +0,0 @@
-/**
-* \file unit_test_jexception.cpp
-*
-* Red Hat Messaging - Message Journal
-*
-* This file contains the unit tests for the journal.
-*
-* \author Kim van der Riet
-*
-* Copyright 2007 Red Hat, Inc.
-*
-* This file is part of Red Hat Messaging.
-*
-* Red Hat Messaging is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2.1 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
-* USA
-*
-* The GNU Lesser General Public License is available in the file COPYING.
-*/
-
-#include "../unit_test.h"
-#include <iostream>
-#include <jrnl/jerrno.hpp>
-#include <jrnl/jexception.hpp>
-
-using namespace boost::unit_test;
-using namespace rhm::journal;
-
-QPID_AUTO_TEST_SUITE(jexception_suite)
-
-// Helper function declarations
-void throw_exception(const jexception& e, size_t what_len, size_t ai_len);
-void throw_exception(const jexception& e, size_t what_len, size_t tc_len, size_t tf_len);
-void throw_exception(const jexception& e, size_t what_len, size_t ai_len, size_t tc_len,
-        size_t tf_len);
-
-// Test functions of the form
-// void fn() {...}
-
-BOOST_AUTO_TEST_CASE(test_constructor_1)
-{
-    try
-    {
-        jexception e1;
-        BOOST_CHECK_EQUAL(e1.err_code(), (u_int32_t)0);
-        BOOST_CHECK(e1.additional_info().size() == 0);
-        BOOST_CHECK(e1.throwing_class().size() == 0);
-        BOOST_CHECK(e1.throwing_fn().size() == 0);
-        BOOST_CHECK(::strlen(e1.what()) > 0);
-        throw e1;
-    }
-    catch (const jexception& e)
-    {
-        BOOST_CHECK_EQUAL(e.err_code(), (u_int32_t)0);
-        BOOST_CHECK(e.additional_info().size() == 0);
-        BOOST_CHECK(e.throwing_class().size() == 0);
-        BOOST_CHECK(e.throwing_fn().size() == 0);
-        BOOST_CHECK(::strlen(e.what()) > 0);
-    }
-}
-
-BOOST_AUTO_TEST_CASE(test_constructor_2)
-{
-    const u_int32_t err_code = 2;
-    try
-    {
-        jexception e2(err_code);
-        BOOST_CHECK_EQUAL(e2.err_code(), err_code);
-        BOOST_CHECK(e2.additional_info().size() == 0);
-        BOOST_CHECK(e2.throwing_class().size() == 0);
-        BOOST_CHECK(e2.throwing_fn().size() == 0);
-        BOOST_CHECK(::strlen(e2.what()) > 0);
-        throw e2;
-    }
-    catch (const jexception& e)
-    {
-        BOOST_CHECK_EQUAL(e.err_code(), err_code);
-        BOOST_CHECK(e.additional_info().size() == 0);
-        BOOST_CHECK(e.throwing_class().size() == 0);
-        BOOST_CHECK(e.throwing_fn().size() == 0);
-        BOOST_CHECK(::strlen(e.what()) > 0);
-    }
-}
-
-BOOST_AUTO_TEST_CASE(test_constructor_3a)
-{
-    const char* err_msg = "exception3";
-    try
-    {
-        jexception e3(err_msg);
-        BOOST_CHECK_EQUAL(e3.err_code(), (u_int32_t)0);
-        BOOST_CHECK(e3.additional_info().compare(err_msg) == 0);
-        BOOST_CHECK(e3.throwing_class().size() == 0);
-        BOOST_CHECK(e3.throwing_fn().size() == 0);
-        BOOST_CHECK(::strlen(e3.what()) > 0);
-        throw e3;
-    }
-    catch (const jexception& e)
-    {
-        BOOST_CHECK_EQUAL(e.err_code(), (u_int32_t)0);
-        BOOST_CHECK(e.additional_info().compare(err_msg) == 0);
-        BOOST_CHECK(e.throwing_class().size() == 0);
-        BOOST_CHECK(e.throwing_fn().size() == 0);
-        BOOST_CHECK(::strlen(e.what()) > 0);
-    }
-}
-
-BOOST_AUTO_TEST_CASE(test_constructor_3b)
-{
-    const std::string err_msg("exception3");
-    try
-    {
-        jexception e3(err_msg);
-        BOOST_CHECK_EQUAL(e3.err_code(), (u_int32_t)0);
-        BOOST_CHECK(e3.additional_info().compare(err_msg) == 0);
-        BOOST_CHECK(e3.throwing_class().size() == 0);
-        BOOST_CHECK(e3.throwing_fn().size() == 0);
-        BOOST_CHECK(::strlen(e3.what()) > 0);
-        throw e3;
-    }
-    catch (const jexception& e)
-    {
-        BOOST_CHECK_EQUAL(e.err_code(), (u_int32_t)0);
-        BOOST_CHECK(e.additional_info().compare(err_msg) == 0);
-        BOOST_CHECK(e.throwing_class().size() == 0);
-        BOOST_CHECK(e.throwing_fn().size() == 0);
-        BOOST_CHECK(::strlen(e.what()) > 0);
-    }
-}
-
-BOOST_AUTO_TEST_CASE(test_constructor_4a)
-{
-    const u_int32_t err_code = 4;
-    const char* err_msg = "exception4";
-    try
-    {
-        jexception e4(err_code, err_msg);
-        BOOST_CHECK_EQUAL(e4.err_code(), err_code);
-        BOOST_CHECK(e4.additional_info().compare(err_msg) == 0);
-        BOOST_CHECK(e4.throwing_class().size() == 0);
-        BOOST_CHECK(e4.throwing_fn().size() == 0);
-        BOOST_CHECK(::strlen(e4.what()) > 0);
-        throw e4;
-    }
-    catch (const jexception& e)
-    {
-        BOOST_CHECK_EQUAL(e.err_code(), err_code);
-        BOOST_CHECK(e.additional_info().compare(err_msg) == 0);
-        BOOST_CHECK(e.throwing_class().size() == 0);
-        BOOST_CHECK(e.throwing_fn().size() == 0);
-        BOOST_CHECK(::strlen(e.what()) > 0);
-    }
-}
-
-BOOST_AUTO_TEST_CASE(test_constructor_4b)
-{
-    const u_int32_t err_code = 4;
-    const std::string err_msg("exception4");
-    try
-    {
-        jexception e4(err_code, err_msg);
-        BOOST_CHECK_EQUAL(e4.err_code(), err_code);
-        BOOST_CHECK(e4.additional_info().compare(err_msg) == 0);
-        BOOST_CHECK(e4.throwing_class().size() == 0);
-        BOOST_CHECK(e4.throwing_fn().size() == 0);
-        BOOST_CHECK(::strlen(e4.what()) > 0);
-        throw e4;
-    }
-    catch (const jexception& e)
-    {
-        BOOST_CHECK_EQUAL(e.err_code(), err_code);
-        BOOST_CHECK(e.additional_info().compare(err_msg) == 0);
-        BOOST_CHECK(e.throwing_class().size() == 0);
-        BOOST_CHECK(e.throwing_fn().size() == 0);
-        BOOST_CHECK(::strlen(e.what()) > 0);
-    }
-}
-
-BOOST_AUTO_TEST_CASE(test_constructor_5a)
-{
-    const u_int32_t err_code = 5;
-    const char* err_class = "class5";
-    const char* err_fn = "fn5";
-    try
-    {
-        jexception e5(err_code, err_class, err_fn);
-        BOOST_CHECK_EQUAL(e5.err_code(), err_code);
-        BOOST_CHECK(e5.additional_info().size() == 0);
-        BOOST_CHECK(e5.throwing_class().compare(err_class) == 0);
-        BOOST_CHECK(e5.throwing_fn().compare(err_fn) == 0);
-        BOOST_CHECK(::strlen(e5.what()) > 0);
-        throw e5;
-    }
-    catch (const jexception& e)
-    {
-        BOOST_CHECK_EQUAL(e.err_code(), err_code);
-        BOOST_CHECK(e.additional_info().size() == 0);
-        BOOST_CHECK(e.throwing_class().compare(err_class) == 0);
-        BOOST_CHECK(e.throwing_fn().compare(err_fn) == 0);
-        BOOST_CHECK(::strlen(e.what()) > 0);
-    }
-}
-
-BOOST_AUTO_TEST_CASE(test_constructor_5b)
-{
-    const u_int32_t err_code = 5;
-    const std::string err_class("class5");
-    const std::string err_fn("fn5");
-    try
-    {
-        jexception e5(err_code, err_class, err_fn);
-        BOOST_CHECK_EQUAL(e5.err_code(), err_code);
-        BOOST_CHECK(e5.additional_info().size() == 0);
-        BOOST_CHECK(e5.throwing_class().compare(err_class) == 0);
-        BOOST_CHECK(e5.throwing_fn().compare(err_fn) == 0);
-        BOOST_CHECK(::strlen(e5.what()) > 0);
-        throw e5;
-    }
-    catch (const jexception& e)
-    {
-        BOOST_CHECK_EQUAL(e.err_code(), err_code);
-        BOOST_CHECK(e.additional_info().size() == 0);
-        BOOST_CHECK(e.throwing_class().compare(err_class) == 0);
-        BOOST_CHECK(e.throwing_fn().compare(err_fn) == 0);
-        BOOST_CHECK(::strlen(e.what()) > 0);
-    }
-}
-
-BOOST_AUTO_TEST_CASE(test_constructor_6a)
-{
-    const u_int32_t err_code = 6;
-    const char* err_msg = "exception6";
-    const char* err_class = "class6";
-    const char* err_fn = "fn6";
-    try
-    {
-        jexception e6(err_code, err_msg, err_class, err_fn);
-        BOOST_CHECK_EQUAL(e6.err_code(), err_code);
-        BOOST_CHECK(e6.additional_info().compare(err_msg) == 0);
-        BOOST_CHECK(e6.throwing_class().compare(err_class) == 0);
-        BOOST_CHECK(e6.throwing_fn().compare(err_fn) == 0);
-        BOOST_CHECK(::strlen(e6.what()) > 0);
-        throw e6;
-    }
-    catch (const jexception& e)
-    {
-        BOOST_CHECK_EQUAL(e.err_code(), err_code);
-        BOOST_CHECK(e.additional_info().compare(err_msg) == 0);
-        BOOST_CHECK(e.throwing_class().compare(err_class) == 0);
-        BOOST_CHECK(e.throwing_fn().compare(err_fn) == 0);
-        BOOST_CHECK(::strlen(e.what()) > 0);
-    }
-}
-
-BOOST_AUTO_TEST_CASE(test_constructor_6b)
-{
-    const u_int32_t err_code = 6;
-    const std::string err_msg("exception6");
-    const std::string err_class("class6");
-    const std::string err_fn("fn6");
-    try
-    {
-        jexception e6(err_code, err_msg, err_class, err_fn);
-        BOOST_CHECK_EQUAL(e6.err_code(), err_code);
-        BOOST_CHECK(e6.additional_info().compare(err_msg) == 0);
-        BOOST_CHECK(e6.throwing_class().compare(err_class) == 0);
-        BOOST_CHECK(e6.throwing_fn().compare(err_fn) == 0);
-        BOOST_CHECK(::strlen(e6.what()) > 0);
-        throw e6;
-    }
-    catch (const jexception& e)
-    {
-        BOOST_CHECK_EQUAL(e.err_code(), err_code);
-        BOOST_CHECK(e.additional_info().compare(err_msg) == 0);
-        BOOST_CHECK(e.throwing_class().compare(err_class) == 0);
-        BOOST_CHECK(e.throwing_fn().compare(err_fn) == 0);
-        BOOST_CHECK(::strlen(e.what()) > 0);
-    }
-}
-
-BOOST_AUTO_TEST_CASE(test_msg_scope)
-{
-    try
-    {
-        // These will go out of scope as soon as jexception is thrown...
-        const std::string msg("Error message");
-        const std::string cls("class");
-        const std::string fn("function");
-        throw jexception(100, msg, cls, fn);
-    }
-    catch (const jexception& e)
-    {
-        std::stringstream ss;
-        ss << e;
-        BOOST_CHECK(ss.str().size() > 0);
-    }    
-}
-
-// Helper functions
-
-void throw_exception(const jexception& e, size_t what_len, size_t ai_len)
-{
-    throw_exception(e, what_len, ai_len, 0, 0);
-}
-
-void throw_exception(const jexception& e, size_t what_len, size_t tc_len, size_t tf_len)
-{
-    throw_exception(e, what_len, 0, tc_len, tf_len);
-}
-
-void throw_exception(const jexception& e, size_t what_len, size_t ai_len, size_t tc_len,
-        size_t tf_len)
-{
-    try { throw e; }
-    catch (const jexception& e)
-    {
-        BOOST_CHECK_EQUAL(::strlen(e.what()), what_len);
-        BOOST_CHECK_EQUAL(e.additional_info().size(), ai_len);
-        BOOST_CHECK_EQUAL(e.throwing_class().size(), tc_len);
-        BOOST_CHECK_EQUAL(e.throwing_fn().size(), tf_len);
-    }
-}
-
-QPID_AUTO_TEST_SUITE_END()

Deleted: store/trunk/cpp/tests/jrnl/unit_test_jinf.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_jinf.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/tests/jrnl/unit_test_jinf.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -1,247 +0,0 @@
-/**
-* \file unit_test_jinf.cpp
-*
-* Red Hat Messaging - Message Journal
-*
-* This file contains the unit tests for the journal.
-*
-* \author Kim van der Riet
-*
-* Copyright 2007 Red Hat, Inc.
-*
-* This file is part of Red Hat Messaging.
-*
-* Red Hat Messaging is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2.1 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
-* USA
-*
-* The GNU Lesser General Public License is available in the file COPYING.
-*/
-
-#include "../unit_test.h"
-#include <fstream>
-#include <iomanip>
-#include <iostream>
-#include <jrnl/file_hdr.hpp>
-#include <jrnl/jcfg.hpp>
-#include <jrnl/jerrno.hpp>
-#include <jrnl/jexception.hpp>
-#include <jrnl/jinf.hpp>
-
-#define NUM_JFILES 4
-#define JFSIZE_SBLKS 128
-
-using namespace boost::unit_test;
-using namespace rhm::journal;
-
-QPID_AUTO_TEST_SUITE(jinf_suite)
-
-// Helper function declarations
-const std::string jid("test journal id");
-const std::string jdir("/tmp");
-const std::string base_filename("test_base");
-timespec ts;
-enum rid_scheme { RID_NONE, RID_LINEAR };
-
-// Helper functions
-void create_journal_filenames(std::vector<std::string>& jfiles);
-void create_journal_files(std::vector<std::string>& jfiles, rid_scheme scheme,
-        u_int32_t min_fid_offs = 0, u_int64_t rid_offs = 0);
-void clean_journal_files(std::vector<std::string>& jfiles);
-void init_fhdr(file_hdr& fh, const u_int32_t fid, const u_int64_t rid, const bool owi,
-        const bool no_enq = false);
-void clean_journal_info_file();
-
-
-// Test functions of the form
-// void fn() {...}
-
-BOOST_AUTO_TEST_CASE(test_write_constructor)
-{
-    ::clock_gettime(CLOCK_REALTIME, &ts);
-    jinf ji(jid, jdir, base_filename, NUM_JFILES, JFSIZE_SBLKS, ts);
-    BOOST_CHECK_EQUAL(ji.jver(), RHM_JDAT_VERSION);
-    BOOST_CHECK(ji.jid().compare(jid) == 0);
-    BOOST_CHECK(ji.jdir().compare(jdir) == 0);
-    BOOST_CHECK(ji.base_filename().compare(base_filename) == 0);
-    timespec this_ts = ji.ts();
-    BOOST_CHECK_EQUAL(this_ts.tv_sec, ts.tv_sec);
-    BOOST_CHECK_EQUAL(this_ts.tv_nsec, ts.tv_nsec);
-    BOOST_CHECK_EQUAL(ji.num_jfiles(), (u_int16_t)NUM_JFILES);
-    BOOST_CHECK_EQUAL(ji.jfsize_sblks(), (u_int32_t)JFSIZE_SBLKS);
-    BOOST_CHECK_EQUAL(ji.sblk_size_dblks(), (u_int16_t)JRNL_SBLK_SIZE);
-    BOOST_CHECK_EQUAL(ji.dblk_size(), (u_int32_t)JRNL_DBLK_SIZE);
-    BOOST_CHECK_EQUAL(ji.wmgr_page_size_dblks(), (u_int32_t)JRNL_WMGR_PAGE_SIZE);
-    BOOST_CHECK_EQUAL(ji.wmgr_num_pages(), (u_int32_t)JRNL_WMGR_PAGES);
-    BOOST_CHECK_EQUAL(ji.rmgr_page_size_dblks(), (u_int32_t)JRNL_RMGR_PAGE_SIZE);
-    BOOST_CHECK_EQUAL(ji.rmgr_num_pages(), (u_int32_t)JRNL_RMGR_PAGES);
-    ji.write();
-}
-
-BOOST_AUTO_TEST_CASE(test_read_constructor)
-{
-    std::stringstream fn;
-    fn << jdir << "/" << base_filename << "." << JRNL_INFO_EXTENSION;
-    jinf ji(fn.str(), false);
-    BOOST_CHECK_EQUAL(ji.jver(), RHM_JDAT_VERSION);
-    BOOST_CHECK(ji.jid().compare(jid) == 0);
-    BOOST_CHECK(ji.jdir().compare(jdir) == 0);
-    BOOST_CHECK(ji.base_filename().compare(base_filename) == 0);
-    const timespec this_ts = ji.ts();
-    BOOST_CHECK_EQUAL(this_ts.tv_sec, ts.tv_sec);
-    BOOST_CHECK_EQUAL(this_ts.tv_nsec, ts.tv_nsec);
-    BOOST_CHECK_EQUAL(ji.num_jfiles(), (u_int16_t)NUM_JFILES);
-    BOOST_CHECK_EQUAL(ji.jfsize_sblks(), (u_int32_t)JFSIZE_SBLKS);
-    BOOST_CHECK_EQUAL(ji.sblk_size_dblks(), (u_int16_t)JRNL_SBLK_SIZE);
-    BOOST_CHECK_EQUAL(ji.dblk_size(), (u_int32_t)JRNL_DBLK_SIZE);
-    BOOST_CHECK_EQUAL(ji.wmgr_page_size_dblks(), (u_int32_t)JRNL_WMGR_PAGE_SIZE);
-    BOOST_CHECK_EQUAL(ji.wmgr_num_pages(), (u_int32_t)JRNL_WMGR_PAGES);
-    BOOST_CHECK_EQUAL(ji.rmgr_page_size_dblks(), (u_int32_t)JRNL_RMGR_PAGE_SIZE);
-    BOOST_CHECK_EQUAL(ji.rmgr_num_pages(), (u_int32_t)JRNL_RMGR_PAGES);
-}
-
-BOOST_AUTO_TEST_CASE(test_validate)
-{
-    std::stringstream fn;
-    fn << jdir << "/" << base_filename << "." << JRNL_INFO_EXTENSION;
-    jinf ji(fn.str(), true);
-    // TODO: Check validation picks up conflict, but need to be friend to jinf to do it
-}
-
-BOOST_AUTO_TEST_CASE(test_analyze_empty_journal)
-{
-    std::vector<std::string> jfiles;
-    create_journal_filenames(jfiles);
-    
-    create_journal_files(jfiles, RID_NONE);
-
-    std::stringstream fn;
-    fn << jdir << "/" << base_filename << "." << JRNL_INFO_EXTENSION;
-    jinf ji(fn.str(), false);
-    try { ji.analyze(); }
-    catch (const jexception& e)
-    {
-        if (e.err_code() != jerrno::JERR_JINF_JDATEMPTY)
-            BOOST_ERROR("Failed to throw expected exception jerrno::JERR_JINF_JDATEMPTY");
-    }
-
-    clean_journal_files(jfiles);
-}
-
-BOOST_AUTO_TEST_CASE(test_analyze_linear_journal)
-{
-    std::vector<std::string> jfiles;
-    for (int i=0; i<NUM_JFILES; i++)
-    {
-        create_journal_filenames(jfiles);
-    
-        create_journal_files(jfiles, RID_LINEAR, i, 0x12340000);
-
-        std::stringstream fn;
-        fn << jdir << "/" << base_filename << "." << JRNL_INFO_EXTENSION;
-        jinf ji(fn.str(), false);
-        BOOST_CHECK_EQUAL(ji.analyze(), i);
-
-        clean_journal_files(jfiles);
-    }
-    
-    // last test cleans up jinf file
-    clean_journal_info_file();
-}
-
-// Helper functions
-
-void create_journal_filenames(std::vector<std::string>& jfiles)
-{
-    for (int fnum=0; fnum<NUM_JFILES; fnum++)
-    {
-        std::stringstream fn;
-        fn << jdir << "/" << base_filename << ".";
-        fn << std::setfill('0') << std::hex << std::setw(4) << fnum << "." << JRNL_DATA_EXTENSION;
-        jfiles.push_back(fn.str());
-    }
-}
-
-void create_journal_files(std::vector<std::string>& jfiles, rid_scheme scheme,
-        u_int32_t min_fid_offs, u_int64_t rid_offs)
-{
-    const u_int64_t rid_incr = 0x10;
-    file_hdr fh;
-    std::vector<std::string>::iterator itr;
-    u_int32_t fid = 0;
-    u_int64_t rid = rid_offs + ((NUM_JFILES - min_fid_offs) % NUM_JFILES) * rid_incr;
-    for (itr=jfiles.begin(); itr<jfiles.end(); itr++)
-    {
-        
-        std::ofstream of(itr->c_str(), std::ofstream::out | std::ofstream::trunc);
-        if (!of.good())
-            BOOST_FAIL("Unable to open test journal file " << *itr << " for writing.");
-        
-        // prepare file_hdr
-        if (scheme == RID_NONE) // create file containing 0s
-            ::memset(&fh, 0, sizeof(file_hdr));
-        else
-            init_fhdr(fh, fid, rid, fid >= min_fid_offs);
-        
-        // write file header
-        int cnt = sizeof(file_hdr);
-        of.write((const char*)&fh, cnt);
-        
-        // fill remaining sblk with 0s
-        while (cnt++ < JRNL_DBLK_SIZE * JRNL_SBLK_SIZE)
-            of.put(0);
-        of.close();
-        
-        if (++fid == min_fid_offs)
-            rid -= rid_incr * (NUM_JFILES - 1);
-        else
-            rid += rid_incr;
-    }
-}
-
-void clean_journal_info_file()
-{
-    std::stringstream fn;
-    fn << jdir << "/" << base_filename << "." << JRNL_INFO_EXTENSION;
-    BOOST_WARN_MESSAGE(::unlink(fn.str().c_str()) == 0, "Failed to remove file " << fn.str());
-}
-
-void clean_journal_files(std::vector<std::string>& jfiles)
-{
-    for (std::vector<std::string>::iterator itr=jfiles.begin(); itr != jfiles.end(); itr++)
-        BOOST_WARN_MESSAGE(::unlink(itr->c_str()) == 0, "Failed to remove file " << *itr);
-    jfiles.clear();
-}
-
-void init_fhdr(file_hdr& fh, const u_int32_t fid, const u_int64_t rid, const bool owi,
-        const bool no_enq)
-{
-    fh._magic = RHM_JDAT_FILE_MAGIC;
-    fh._version = RHM_JDAT_VERSION;
-#if defined(JRNL_BIG_ENDIAN)
-    fh._eflag = RHM_BENDIAN_FLAG;
-#else
-    fh._eflag = RHM_LENDIAN_FLAG;
-#endif
-    fh._uflag = owi ? rec_hdr::HDR_OVERWRITE_INDICATOR_MASK : 0;
-    fh._rid = rid;
-    fh._fid = fid;
-    fh._fro = no_enq ? 0 : 0x200;
-    timespec ts;
-    ::clock_gettime(CLOCK_REALTIME, &ts);
-    fh._ts_sec = ts.tv_sec;
-    fh._ts_nsec = ts.tv_nsec;
-}
-        
-QPID_AUTO_TEST_SUITE_END()

Deleted: store/trunk/cpp/tests/jrnl/unit_test_rec_hdr.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_rec_hdr.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/tests/jrnl/unit_test_rec_hdr.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -1,430 +0,0 @@
-/**
-* \file unit_test_file_hdr.cpp
-*
-* Red Hat Messaging - Message Journal
-*
-* This file contains the unit tests for the journal.
-*
-* \author Kim van der Riet
-*
-* Copyright 2007 Red Hat, Inc.
-*
-* This file is part of Red Hat Messaging.
-*
-* Red Hat Messaging is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2.1 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
-* USA
-*
-* The GNU Lesser General Public License is available in the file COPYING.
-*/
-
-#include "../unit_test.h"
-#include <iostream>
-#include <jrnl/deq_hdr.hpp>
-#include <jrnl/enq_hdr.hpp>
-#include <jrnl/file_hdr.hpp>
-#include <jrnl/jcfg.hpp>
-#include <jrnl/rec_tail.hpp>
-#include <jrnl/txn_hdr.hpp>
-
-using namespace boost::unit_test;
-using namespace rhm::journal;
-
-QPID_AUTO_TEST_SUITE(rec_hdr_suite)
-
-// Test functions of the form
-// void fn() {...}
-
-BOOST_AUTO_TEST_CASE(test_hdr)
-{
-    rec_hdr h1;
-    BOOST_CHECK_EQUAL(h1._magic, 0UL);
-    BOOST_CHECK_EQUAL(h1._version, 0);
-    BOOST_CHECK_EQUAL(h1._eflag, 0);
-    BOOST_CHECK_EQUAL(h1._uflag, 0);
-    BOOST_CHECK_EQUAL(h1._rid, 0ULL);
-    BOOST_CHECK(!h1.get_owi());
-
-    const u_int32_t magic = 0x89abcdefUL;    
-    const u_int16_t uflag = 0x5537;
-    const u_int8_t version = 0xef;    
-    const u_int64_t rid = 0x123456789abcdef0ULL;
-    const bool owi = true;
-
-    rec_hdr h2(magic, version, rid, owi);
-    BOOST_CHECK_EQUAL(h2._magic, magic);
-    BOOST_CHECK_EQUAL(h2._version, version);
-#ifdef JRNL_LITTLE_ENDIAN
-    BOOST_CHECK_EQUAL(h2._eflag, RHM_LENDIAN_FLAG);
-#else
-    BOOST_CHECK_EQUAL(h2._eflag, RHM_BENDIAN_FLAG);
-#endif
-    BOOST_CHECK_EQUAL(h2._uflag, (const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK);
-    BOOST_CHECK_EQUAL(h2._rid, rid);
-    BOOST_CHECK_EQUAL(h2.get_owi(), owi);
-    h2._uflag = uflag;
-    BOOST_CHECK(h2.get_owi());
-    h2.set_owi(true);
-    BOOST_CHECK(h2.get_owi());
-    BOOST_CHECK_EQUAL(h2._uflag, uflag);
-    h2.set_owi(false);
-    BOOST_CHECK(!h2.get_owi());
-    BOOST_CHECK_EQUAL(h2._uflag, (uflag & ~(const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK));
-    h2.set_owi(true);
-    BOOST_CHECK(h2.get_owi());
-    BOOST_CHECK_EQUAL(h2._uflag, uflag);
-
-    h1.hdr_copy(h2);    
-    BOOST_CHECK_EQUAL(h1._magic, magic);
-    BOOST_CHECK_EQUAL(h1._version, version);
-#ifdef JRNL_LITTLE_ENDIAN
-    BOOST_CHECK_EQUAL(h1._eflag, RHM_LENDIAN_FLAG);
-#else
-    BOOST_CHECK_EQUAL(h1._eflag, RHM_BENDIAN_FLAG);
-#endif
-    BOOST_CHECK_EQUAL(h1._uflag, uflag);
-    BOOST_CHECK_EQUAL(h1._rid, rid);
-    BOOST_CHECK(h1.get_owi());
-    BOOST_CHECK_EQUAL(h1._uflag, uflag);
-
-    h1.reset();
-    BOOST_CHECK_EQUAL(h1._magic, 0UL);
-    BOOST_CHECK_EQUAL(h1._version, 0);
-    BOOST_CHECK_EQUAL(h1._eflag, 0);
-    BOOST_CHECK_EQUAL(h1._uflag, 0);
-    BOOST_CHECK_EQUAL(h1._rid, 0ULL);
-    BOOST_CHECK(!h1.get_owi());
-}
-
-BOOST_AUTO_TEST_CASE(test_rec_tail)
-{
-    const u_int32_t magic = 0xfedcba98;
-    const u_int64_t rid = 0xfedcba9876543210ULL;
-    const u_int32_t xmagic = ~magic;
-
-    {
-        rec_tail rt1;
-        BOOST_CHECK_EQUAL(rt1._xmagic, 0xffffffffUL);
-        BOOST_CHECK_EQUAL(rt1._rid, 0ULL);
-    }
-
-    {
-        rec_tail rt2(magic, rid);
-        BOOST_CHECK_EQUAL(rt2._xmagic, magic);
-        BOOST_CHECK_EQUAL(rt2._rid, rid);
-    }
-
-    {
-        rec_hdr h(magic, RHM_JDAT_VERSION, rid, true);
-        rec_tail rt3(h);
-        BOOST_CHECK_EQUAL(rt3._xmagic, xmagic);
-        BOOST_CHECK_EQUAL(rt3._rid, rid);
-    }
-}
-
-BOOST_AUTO_TEST_CASE(test_file_hdr)
-{
-    const u_int32_t magic = 0xfedcba98UL;
-    const u_int8_t version = 0xa5;
-    const u_int16_t uflag = 0x5537;
-    const u_int64_t rid = 0xfedcba9876543210ULL;
-    const u_int32_t fid = 0xfedcba98UL;
-#ifdef JRNL_32_BIT
-    const size_t fro = 0xfedcba98UL;
-#else
-    const size_t fro = 0xfedcba9876543210ULL;
-#endif
-    timespec ts;
-    const bool owi = true;
-
-    {
-        file_hdr fh1;
-        BOOST_CHECK_EQUAL(fh1._magic, 0UL);
-        BOOST_CHECK_EQUAL(fh1._version, 0);
-        BOOST_CHECK_EQUAL(fh1._eflag, 0);
-        BOOST_CHECK_EQUAL(fh1._uflag, 0);
-        BOOST_CHECK_EQUAL(fh1._rid, 0ULL);
-        BOOST_CHECK_EQUAL(fh1._fid, 0UL);
-        BOOST_CHECK_EQUAL(fh1._fro, size_t(0));
-        BOOST_CHECK_EQUAL(fh1._ts_sec, time_t(0));
-        BOOST_CHECK_EQUAL(fh1._ts_nsec, uint32_t(0));
-        BOOST_CHECK(!fh1.get_owi());
-    }
-
-    {
-        file_hdr fh2(magic, version, rid, fid, fro, owi, false);
-        BOOST_CHECK_EQUAL(fh2._magic, magic);
-        BOOST_CHECK_EQUAL(fh2._version, version);
-#ifdef JRNL_LITTLE_ENDIAN
-        BOOST_CHECK_EQUAL(fh2._eflag, RHM_LENDIAN_FLAG);
-#else
-        BOOST_CHECK_EQUAL(fh2._eflag, RHM_BENDIAN_FLAG);
-#endif
-        BOOST_CHECK_EQUAL(fh2._uflag, (const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK);
-        BOOST_CHECK_EQUAL(fh2._rid, rid);
-        BOOST_CHECK_EQUAL(fh2._fid,fid );
-        BOOST_CHECK_EQUAL(fh2._fro, fro);
-        BOOST_CHECK_EQUAL(fh2._ts_sec, time_t(0));
-        BOOST_CHECK_EQUAL(fh2._ts_nsec, uint32_t(0));
-        ::clock_gettime(CLOCK_REALTIME, &ts);
-        fh2.set_time(ts);
-        BOOST_CHECK_EQUAL(fh2._ts_sec, ts.tv_sec);
-        BOOST_CHECK_EQUAL(fh2._ts_nsec, u_int32_t(ts.tv_nsec));
-        BOOST_CHECK(fh2.get_owi());
-
-        fh2._uflag = uflag;
-        BOOST_CHECK(fh2.get_owi());
-
-        fh2.set_owi(false);
-        BOOST_CHECK(!fh2.get_owi());
-        BOOST_CHECK_EQUAL(fh2._uflag,
-                (uflag & ~(const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK));
-
-        fh2.set_owi(true);
-        BOOST_CHECK(fh2.get_owi());
-        BOOST_CHECK_EQUAL(fh2._uflag, uflag);
-    }
-
-    {
-        file_hdr fh3(magic, version, rid, fid, fro, owi, true);
-        BOOST_CHECK_EQUAL(fh3._magic, magic);
-        BOOST_CHECK_EQUAL(fh3._version, version);
-#ifdef JRNL_LITTLE_ENDIAN
-        BOOST_CHECK_EQUAL(fh3._eflag, RHM_LENDIAN_FLAG);
-#else
-        BOOST_CHECK_EQUAL(fh3._eflag, RHM_BENDIAN_FLAG);
-#endif
-        BOOST_CHECK_EQUAL(fh3._uflag, (const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK);
-        BOOST_CHECK_EQUAL(fh3._rid, rid);
-        BOOST_CHECK_EQUAL(fh3._fid, fid);
-        BOOST_CHECK_EQUAL(fh3._fro, fro);
-        BOOST_CHECK(fh3._ts_sec - ts.tv_sec <= 1); // No more than 1 sec difference
-    }
-}
-
-BOOST_AUTO_TEST_CASE(test_enq_hdr)
-{
-    const u_int32_t magic = 0xfedcba98UL;
-    const u_int8_t version = 0xa5;
-    const u_int64_t rid = 0xfedcba9876543210ULL;
-    const u_int16_t uflag = 0x5537;
-#ifdef JRNL_32_BIT
-    const size_t xidsize = 0xfedcba98UL;
-    const size_t dsize = 0x76543210UL;
-#else
-    const size_t xidsize = 0xfedcba9876543210ULL;
-    const size_t dsize = 0x76543210fedcba98ULL;
-#endif
-    const bool owi = true;
-
-    {
-        enq_hdr eh1;
-        BOOST_CHECK_EQUAL(eh1._magic, 0UL);
-        BOOST_CHECK_EQUAL(eh1._version, 0);
-        BOOST_CHECK_EQUAL(eh1._eflag, 0);
-        BOOST_CHECK_EQUAL(eh1._uflag, 0);
-        BOOST_CHECK_EQUAL(eh1._rid, 0ULL);
-        BOOST_CHECK_EQUAL(eh1._xidsize, size_t(0));
-        BOOST_CHECK_EQUAL(eh1._dsize, size_t(0));
-        BOOST_CHECK(!eh1.get_owi());
-    }
-
-    {
-        enq_hdr eh2(magic, version, rid, xidsize, dsize, owi, false);
-        BOOST_CHECK_EQUAL(eh2._magic, magic);
-        BOOST_CHECK_EQUAL(eh2._version, version);
-#ifdef JRNL_LITTLE_ENDIAN
-        BOOST_CHECK_EQUAL(eh2._eflag, RHM_LENDIAN_FLAG);
-#else
-        BOOST_CHECK_EQUAL(eh2._eflag, RHM_BENDIAN_FLAG);
-#endif
-        BOOST_CHECK_EQUAL(eh2._uflag, (const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK);
-        BOOST_CHECK_EQUAL(eh2._rid, rid);
-        BOOST_CHECK_EQUAL(eh2._xidsize, xidsize);
-        BOOST_CHECK_EQUAL(eh2._dsize, dsize);
-        BOOST_CHECK(eh2.get_owi());
-        BOOST_CHECK(!eh2.is_transient());
-        BOOST_CHECK(!eh2.is_external());
-
-        eh2._uflag = uflag;
-        BOOST_CHECK(eh2.get_owi());
-        BOOST_CHECK(eh2.is_transient());
-        BOOST_CHECK(eh2.is_external());
-
-        eh2.set_owi(false);
-        BOOST_CHECK(!eh2.get_owi());
-        BOOST_CHECK(eh2.is_transient());
-        BOOST_CHECK(eh2.is_external());
-        BOOST_CHECK_EQUAL(eh2._uflag,
-                (uflag & ~(const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK));
-
-        eh2.set_owi(true);
-        BOOST_CHECK(eh2.get_owi());
-        BOOST_CHECK(eh2.is_transient());
-        BOOST_CHECK(eh2.is_external());
-        BOOST_CHECK_EQUAL(eh2._uflag, uflag);
-
-        eh2.set_transient(false);
-        BOOST_CHECK(eh2.get_owi());
-        BOOST_CHECK(!eh2.is_transient());
-        BOOST_CHECK(eh2.is_external());
-        BOOST_CHECK_EQUAL(eh2._uflag, uflag & ~(const u_int16_t)enq_hdr::ENQ_HDR_TRANSIENT_MASK);
-
-        eh2.set_transient(true);
-        BOOST_CHECK(eh2.get_owi());
-        BOOST_CHECK(eh2.is_transient());
-        BOOST_CHECK(eh2.is_external());
-        BOOST_CHECK_EQUAL(eh2._uflag, uflag);
-
-        eh2.set_external(false);
-        BOOST_CHECK(eh2.get_owi());
-        BOOST_CHECK(eh2.is_transient());
-        BOOST_CHECK(!eh2.is_external());
-        BOOST_CHECK_EQUAL(eh2._uflag, uflag & ~(const u_int16_t)enq_hdr::ENQ_HDR_EXTERNAL_MASK);
-
-        eh2.set_external(true);
-        BOOST_CHECK(eh2.get_owi());
-        BOOST_CHECK(eh2.is_transient());
-        BOOST_CHECK(eh2.is_external());
-        BOOST_CHECK_EQUAL(eh2._uflag, uflag);
-    }
-
-    {
-        enq_hdr eh3(magic, version, rid, xidsize, dsize, owi, true);
-        BOOST_CHECK_EQUAL(eh3._magic, magic);
-        BOOST_CHECK_EQUAL(eh3._version, version);
-#ifdef JRNL_LITTLE_ENDIAN
-        BOOST_CHECK_EQUAL(eh3._eflag, RHM_LENDIAN_FLAG);
-#else
-        BOOST_CHECK_EQUAL(eh3._eflag, RHM_BENDIAN_FLAG);
-#endif
-        BOOST_CHECK_EQUAL(eh3._uflag, (const u_int16_t)enq_hdr::ENQ_HDR_TRANSIENT_MASK |
-                (const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK);
-        BOOST_CHECK_EQUAL(eh3._rid, rid);
-        BOOST_CHECK_EQUAL(eh3._xidsize, xidsize);
-        BOOST_CHECK_EQUAL(eh3._dsize, dsize);
-        BOOST_CHECK(eh3.get_owi());
-        BOOST_CHECK(eh3.is_transient());
-        BOOST_CHECK(!eh3.is_external());
-    }
-}
-
-BOOST_AUTO_TEST_CASE(test_deq_hdr)
-{
-    const u_int32_t magic = 0xfedcba98UL;
-    const u_int8_t version = 0xa5;
-    const u_int16_t uflag = 0x5537;
-    const u_int64_t rid = 0xfedcba9876543210ULL;
-    const u_int64_t drid = 0x76543210fedcba98ULL;
-#ifdef JRNL_32_BIT
-    const size_t xidsize = 0xfedcba98UL;
-#else
-    const size_t xidsize = 0xfedcba9876543210ULL;
-#endif
-    const bool owi = true;
-
-    {
-        deq_hdr dh1;
-        BOOST_CHECK_EQUAL(dh1._magic, 0UL);
-        BOOST_CHECK_EQUAL(dh1._version, 0);
-        BOOST_CHECK_EQUAL(dh1._eflag, 0);
-        BOOST_CHECK_EQUAL(dh1._uflag, 0);
-        BOOST_CHECK_EQUAL(dh1._rid, 0ULL);
-        BOOST_CHECK_EQUAL(dh1._deq_rid, 0ULL);
-        BOOST_CHECK_EQUAL(dh1._xidsize, size_t(0));
-        BOOST_CHECK(!dh1.get_owi());
-    }
-
-    {
-        deq_hdr dh2(magic, version, rid, drid, xidsize, owi);
-        BOOST_CHECK_EQUAL(dh2._magic, magic);
-        BOOST_CHECK_EQUAL(dh2._version, version);
-#ifdef JRNL_LITTLE_ENDIAN
-        BOOST_CHECK_EQUAL(dh2._eflag, RHM_LENDIAN_FLAG);
-#else
-        BOOST_CHECK_EQUAL(dh2._eflag, RHM_BENDIAN_FLAG);
-#endif
-        BOOST_CHECK_EQUAL(dh2._uflag, (const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK);
-        BOOST_CHECK_EQUAL(dh2._rid, rid);
-        BOOST_CHECK_EQUAL(dh2._deq_rid, drid);
-        BOOST_CHECK_EQUAL(dh2._xidsize, xidsize);
-        BOOST_CHECK(dh2.get_owi());
-
-        dh2._uflag = uflag;
-        BOOST_CHECK(dh2.get_owi());
-
-        dh2.set_owi(false);
-        BOOST_CHECK(!dh2.get_owi());
-        BOOST_CHECK_EQUAL(dh2._uflag,
-                (uflag & ~(const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK));
-
-        dh2.set_owi(true);
-        BOOST_CHECK(dh2.get_owi());
-        BOOST_CHECK_EQUAL(dh2._uflag, uflag);
-    }
-}
-
-BOOST_AUTO_TEST_CASE(test_txn_hdr)
-{
-    const u_int32_t magic = 0xfedcba98UL;
-    const u_int8_t version = 0xa5;
-    const u_int16_t uflag = 0x5537;
-    const u_int64_t rid = 0xfedcba9876543210ULL;
-#ifdef JRNL_32_BIT
-    const size_t xidsize = 0xfedcba98UL;
-#else
-    const size_t xidsize = 0xfedcba9876543210ULL;
-#endif
-    const bool owi = true;
-
-    {
-        txn_hdr th1;
-        BOOST_CHECK_EQUAL(th1._magic, 0UL);
-        BOOST_CHECK_EQUAL(th1._version, 0);
-        BOOST_CHECK_EQUAL(th1._eflag, 0);
-        BOOST_CHECK_EQUAL(th1._uflag, 0);
-        BOOST_CHECK_EQUAL(th1._rid, 0ULL);
-        BOOST_CHECK_EQUAL(th1._xidsize, size_t(0));
-        BOOST_CHECK(!th1.get_owi());
-    }
-
-    {
-        txn_hdr th2(magic, version, rid, xidsize, owi);
-        BOOST_CHECK_EQUAL(th2._magic, magic);
-        BOOST_CHECK_EQUAL(th2._version, version);
-#ifdef JRNL_LITTLE_ENDIAN
-        BOOST_CHECK_EQUAL(th2._eflag, RHM_LENDIAN_FLAG);
-#else
-        BOOST_CHECK_EQUAL(th2._eflag, RHM_BENDIAN_FLAG);
-#endif
-        BOOST_CHECK_EQUAL(th2._uflag, (const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK);
-        BOOST_CHECK_EQUAL(th2._rid, rid);
-        BOOST_CHECK_EQUAL(th2._xidsize, xidsize);
-        BOOST_CHECK(th2.get_owi());
-
-        th2._uflag = uflag;
-        BOOST_CHECK(th2.get_owi());
-
-        th2.set_owi(false);
-        BOOST_CHECK(!th2.get_owi());
-        BOOST_CHECK_EQUAL(th2._uflag,
-                (uflag & ~(const u_int16_t)rec_hdr::HDR_OVERWRITE_INDICATOR_MASK));
-
-        th2.set_owi(true);
-        BOOST_CHECK(th2.get_owi());
-        BOOST_CHECK_EQUAL(th2._uflag, uflag);
-    }
-}
-
-QPID_AUTO_TEST_SUITE_END()

Deleted: store/trunk/cpp/tests/jrnl/unit_test_txn_map.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_txn_map.cpp	2008-01-17 22:48:44 UTC (rev 1569)
+++ store/trunk/cpp/tests/jrnl/unit_test_txn_map.cpp	2008-01-18 14:14:21 UTC (rev 1570)
@@ -1,112 +0,0 @@
-/**
-* \file unit_test_txn_map.cpp
-*
-* Red Hat Messaging - Message Journal
-*
-* This file contains the unit tests for the journal.
-*
-* \author Kim van der Riet
-*
-* Copyright 2007 Red Hat, Inc.
-*
-* This file is part of Red Hat Messaging.
-*
-* Red Hat Messaging is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2.1 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
-* USA
-*
-* The GNU Lesser General Public License is available in the file COPYING.
-*/
-
-#include "../unit_test.h"
-#include <iostream>
-#include <iomanip>
-#include <jrnl/txn_map.hpp>
-#include <sstream>
-
-using namespace boost::unit_test;
-using namespace rhm::journal;
-
-QPID_AUTO_TEST_SUITE(txn_map_suite)
-
-// Helper function declarations
-const std::string make_xid(u_int64_t rid);
-void check_td_equal(txn_data& td1, txn_data& td2);
-
-// Test functions of the form
-// void fn() {...}
-
-BOOST_AUTO_TEST_CASE(test_constructor)
-{
-    const u_int64_t rid = 0x123456789abcdef0ULL;
-    const u_int64_t drid = 0xfedcba9876543210ULL;
-    const u_int16_t fid = 0xfedcU;
-    const bool enq_flag = true;
-    txn_data td(rid, drid, fid, enq_flag);
-    BOOST_CHECK_EQUAL(td._rid, rid);
-    BOOST_CHECK_EQUAL(td._drid, drid);
-    BOOST_CHECK_EQUAL(td._fid, fid);
-    BOOST_CHECK_EQUAL(td._enq_flag, enq_flag);
-    BOOST_CHECK_EQUAL(td._aio_compl, false);
-    
-    txn_map t1;
-    BOOST_CHECK(t1.empty());
-    BOOST_CHECK_EQUAL(t1.size(), 0);
-}
-
-BOOST_AUTO_TEST_CASE(test_insert_get)
-{
-    u_int16_t fid;
-    u_int64_t rid;
-    u_int16_t fid_start = 0x2000U;
-    u_int64_t rid_begin = 0xffffffff00000000ULL;
-    u_int64_t rid_end   = 0xffffffff00000200ULL;
-
-    // insert with no dups
-    u_int64_t rid_incr_1 = 4ULL;
-    txn_map t2;
-    for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_1, fid++)
-        t2.insert_txn_data(make_xid(rid), txn_data(rid, ~rid, fid, false));
-    BOOST_CHECK(!t2.empty());
-    BOOST_CHECK_EQUAL(t2.size(), 128);
-    
-    // get
-    u_int64_t rid_incr_2 = 6ULL;
-    for (u_int64_t rid = rid_begin; rid < rid_end; rid += rid_incr_2)
-    {
-        std::string xid = make_xid(rid);
-        BOOST_CHECK_EQUAL(t2.in_map(xid), (rid%rid_incr_1 ? false : true));
-    }
-}
-
-// Helper functions
-
-const std::string make_xid(u_int64_t rid)
-{
-    std::stringstream ss;
-    ss << "XID-" << std::setfill('0') << std::setw(16) << std::hex << rid;
-    ss << "-0123456789abcdef";
-    return ss.str();  
-}
-
-void check_td_equal(txn_data& td1, txn_data& td2)
-{
-    BOOST_CHECK_EQUAL(td1._rid,       td2._rid);
-    BOOST_CHECK_EQUAL(td1._drid,      td2._drid);
-    BOOST_CHECK_EQUAL(td1._fid,       td2._fid);
-    BOOST_CHECK_EQUAL(td1._enq_flag,  td2._enq_flag);
-    BOOST_CHECK_EQUAL(td1._aio_compl, td2._aio_compl);
-}
-
-QPID_AUTO_TEST_SUITE_END()




More information about the rhmessaging-commits mailing list