[hydra-commits] hydra/bridging.git branch "master" updated.

Commits to the Hydra project code repositories hydra-commits at lists.digium.com
Tue Aug 10 01:52:35 CDT 2010


branch "master" has been updated
       via  fa3eeec679e6f051324725fdadcba4d7a5cb08c4 (commit)
      from  b01714ec9657c3a3147284502376243e061ac12e (commit)

Summary of changes:
 src/BridgeFactoryImpl.cpp |  274 +++++++++++++++++++--------------
 src/BridgeImpl.cpp        |  221 ++++++++++++++------------
 src/BridgeImpl.h          |    2 +
 src/Logger.h              |   10 ++
 test/TestBridging.cpp     |  374 ++++++++++++++++++++++++++++++++++-----------
 5 files changed, 576 insertions(+), 305 deletions(-)


- Log -----------------------------------------------------------------
commit fa3eeec679e6f051324725fdadcba4d7a5cb08c4
Author: Brent Eagles <beagles at digium.com>
Date:   Tue Aug 10 04:20:19 2010 -0230

    Some new tests and tracing.

diff --git a/src/BridgeFactoryImpl.cpp b/src/BridgeFactoryImpl.cpp
index 7a2279d..3836af0 100644
--- a/src/BridgeFactoryImpl.cpp
+++ b/src/BridgeFactoryImpl.cpp
@@ -1,30 +1,32 @@
 #include "BridgeFactoryImpl.h"
-#include <Ice/ObjectAdapter.h>
+#include <Ice/Ice.h>
 
 namespace Hydra
 {
 namespace BridgeService
 {
+    //
+    // Functor used with for_each on shutdown.
+    //
+    class ShutdownFunctor : public std::unary_function<Hydra::BridgeService::BridgeImplPtr, void>
+    {
+    public:
+        ShutdownFunctor(const Ice::Current& c) :
+            mCurrent(c)
+        {
+        }
 
-   class ShutdownFunctor : public std::unary_function<Hydra::BridgeService::BridgeImplPtr, void>
-   {
-   public:
-      ShutdownFunctor(const Ice::Current& c) :
-          mCurrent(c)
-      {
-      }
+        void operator()(Hydra::BridgeService::BridgeImplPtr b) 
+        { 
+            b->shutdown(mCurrent); 
+        }
 
-      void operator()(Hydra::BridgeService::BridgeImplPtr b) 
-      { 
-         b->shutdown(mCurrent); 
-      }
+    private:
+        const Ice::Current mCurrent;
+    };
 
-   private:
-      const Ice::Current mCurrent;
-   };
-
-}; // End of namespace BridgeService
-};// End of namespace Hydra
+} // End of namespace BridgeService
+} // End of namespace Hydra
 
 Hydra::BridgeService::BridgeFactoryImpl::BridgeFactoryImpl(Ice::ObjectAdapterPtr adapter) :
    mShuttingDown(false),
@@ -40,118 +42,164 @@ Hydra::Core::Bridging::V1::BridgePrx Hydra::BridgeService::BridgeFactoryImpl::cr
   const Hydra::Core::Bridging::V1::BridgeMonitorPrx& mgr,
   const Ice::Current& current)
 {
-   //
-   // Verify the endpoints are of the correct type before doing anything else.
-   //
-   Hydra::Session::V1::SessionEndpointPtr adminEp(Hydra::Session::V1::SessionEndpointPtr::dynamicCast(ep));
-   if(ep != 0)
-   {
-       if(!adminEp)
-       {
-           throw Hydra::Core::Bridging::V1::UnsupportedEndpoint(ep->id);
-       }
-       if(!checkEndpointId(*ep->id))
-       {
-           throw Hydra::Core::Endpoint::V1::InvalidEndpointId(ep->id);
-       }
-   }
-
-   Hydra::Session::V1::SessionEndpointSeq eps(endpoints.size());
-   for(Hydra::Core::Endpoint::V1::EndpointSeq::const_iterator i = endpoints.begin(); i != endpoints.end(); ++i)
-   {
-      if(*i == 0)
-      {
-          throw Hydra::Core::Bridging::V1::UnsupportedEndpoint(0);
-      }
-      Hydra::Session::V1::SessionEndpointPtr t(Hydra::Session::V1::SessionEndpointPtr::dynamicCast(*i));
-      if(!t)
-      {
-          throw Hydra::Core::Bridging::V1::UnsupportedEndpoint((*i)->id);
-      }
-      if(!t->id || !checkEndpointId(*t->id))
-      {
-          throw Hydra::Core::Endpoint::V1::InvalidEndpointId(t->id);
-      }
-      eps.push_back(t);
-   }
+    mLogger.getTraceStream() << __FUNCTION__ << ":" << current.adapter->getCommunicator()->identityToString(current.id) << std::endl;
+    //
+    // Verify the endpoints are of the correct type before doing anything else.
+    //
+    mLogger.getDebugStream() << __FUNCTION__ << ": validating endpoints." << std::endl;
+    Hydra::Session::V1::SessionEndpointPtr adminEp(Hydra::Session::V1::SessionEndpointPtr::dynamicCast(ep));
+    if(ep != 0)
+    {
+        if(!adminEp)
+        {
+            mLogger.getDebugStream() << __FUNCTION__ << ": casting admin endpoint resulted in null value." << std::endl;
+            throw Hydra::Core::Bridging::V1::UnsupportedEndpoint(ep->id);
+        }
+        if(!checkEndpointId(*ep->id))
+        {
+            mLogger.getDebugStream() << __FUNCTION__ << ": admin endpoint had invalid id." << std::endl;
+            throw Hydra::Core::Endpoint::V1::InvalidEndpointId(ep->id);
+        }
+    }
 
-   //
-   // It is arguable that it might be better to do the shutting down check before going through all the casting work. 
-   // This order has been chosen as the work above is actually an argument validation check that will be required
-   // for all running bridges and it was felt that it was better to arrange things so the lock was not obtained
-   // under normal running conditions for the check. The alternative would be to do two locks, one to check the 
-   // shutdown state and then anothert to modify the state.. but that that is probably more costly still.
-   //
-   boost::unique_lock<boost::shared_mutex> lock(mLock);
-   if(mShuttingDown)
-   {
-      throw Hydra::System::Component::V1::ShuttingDown();
-   }
-   if(mSuspended)
-   {
-      throw Hydra::System::Component::V1::Suspended();
-   }
-   reap();
+    Hydra::Session::V1::SessionEndpointSeq eps;
+    mLogger.getDebugStream() << __FUNCTION__ << ": scanning " << eps.size() << " endpoints." << std::endl;
+    for(Hydra::Core::Endpoint::V1::EndpointSeq::const_iterator i = endpoints.begin(); i != endpoints.end(); ++i)
+    {
+        if(*i == 0)
+        {
+            mLogger.getDebugStream() << __FUNCTION__ << ": null endpoint encountered." << std::endl;
+            throw Hydra::Core::Bridging::V1::UnsupportedEndpoint(0);
+        }
+        Hydra::Session::V1::SessionEndpointPtr t(Hydra::Session::V1::SessionEndpointPtr::dynamicCast(*i));
+        if(!t)
+        {
+            mLogger.getDebugStream() << __FUNCTION__ << ": casting endpoint resulted in null value." << std::endl;
+            throw Hydra::Core::Bridging::V1::UnsupportedEndpoint((*i)->id);
+        }
+        if(!t->id || !checkEndpointId(*t->id))
+        {
+            if(mLogger.debugTracing())
+            {
+                if(!t->id)
+                {
+                    mLogger.getDebugStream() << __FUNCTION__ << ": endpoint has null id." << std::endl;
+                }
+                else
+                {
+                    mLogger.getDebugStream() << __FUNCTION__ << ": id (" << t->id->endpointManagerId << ":" << t->id->deviceId << ") is invalid." << std::endl;
+                }
+            }
+            throw Hydra::Core::Endpoint::V1::InvalidEndpointId(t->id);
+        }
+        if(adminEp != 0 && adminEp->id != 0)
+        {
+            if(adminEp->id->endpointManagerId == t->id->endpointManagerId && adminEp->id->deviceId == t->id->deviceId)
+            {
+                mLogger.getDebugStream() << __FUNCTION__ << ": endpoint id collision between admin endpoint and initial endpoint set for id " <<
+                    adminEp->id->endpointManagerId << ":" << adminEp->id->deviceId << std::endl;
+                throw Hydra::Core::Bridging::V1::EndpointCollision(adminEp->id, t->id); 
+            }
+        }
+        eps.push_back(t);
+    }
+    mLogger.getDebugStream() << __FUNCTION__ << ": endpoints have been successfully validated." << std::endl;
 
+    //
+    // It is arguable that it might be better to do the shutting down check before going through all the casting work. 
+    // This order has been chosen as the work above is actually an argument validation check that will be required
+    // for all running bridges and it was felt that it was better to arrange things so the lock was not obtained
+    // under normal running conditions for the check. The alternative would be to do two locks, one to check the 
+    // shutdown state and then anothert to modify the state.. but that that is probably more costly still.
+    //
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
+    if(mShuttingDown)
+    {
+        mLogger.getDebugStream() << __FUNCTION__ << ": called when shutting down." << std::endl;
+        throw Hydra::System::Component::V1::ShuttingDown();
+    }
+    if(mSuspended)
+    {
+        mLogger.getDebugStream() << __FUNCTION__ << ": called when suspended." << std::endl;
+        throw Hydra::System::Component::V1::Suspended();
+    }
+    reap();
 
-   Hydra::BridgeService::BridgeImplPtr bridge = new Hydra::BridgeService::BridgeImpl(adminEp, eps, mgr);
-   Ice::ObjectPrx obj = mAdapter->addWithUUID(bridge);
-   mBridges.push_back(bridge);
-   return Hydra::Core::Bridging::V1::BridgePrx::uncheckedCast(obj);
+    Hydra::BridgeService::BridgeImplPtr bridge = new Hydra::BridgeService::BridgeImpl(adminEp, eps, mgr);
+    Ice::ObjectPrx obj = mAdapter->addWithUUID(bridge);
+    mBridges.push_back(bridge);
+    mLogger.getInfoStream() << current.adapter->getCommunicator()->identityToString(current.id) << ": creating new bridge " << obj->ice_toString() << "." << std::endl;
+    return Hydra::Core::Bridging::V1::BridgePrx::uncheckedCast(obj);
 }
 
 void Hydra::BridgeService::BridgeFactoryImpl::shutdown(const Ice::Current& current)
 {
-   boost::unique_lock<boost::shared_mutex> lock(mLock);
-   if(mShuttingDown)
-   {
-      return;
-   }
-   if(mSuspended)
-   {
-      throw Hydra::System::Component::V1::Suspended();
-   }
-   mShuttingDown = true;
-   reap();
-   std::for_each(mBridges.begin(), mBridges.end(), Hydra::BridgeService::ShutdownFunctor(current));
+    mLogger.getTraceStream() << __FUNCTION__ << ":" << current.adapter->getCommunicator()->identityToString(current.id) << std::endl;
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
+    if(mShuttingDown)
+    {
+        mLogger.getDebugStream() << __FUNCTION__ << ": called when shutting down." << std::endl;
+        return;
+    }
+    if(mSuspended)
+    {
+        mLogger.getDebugStream() << __FUNCTION__ << ": called when suspended." << std::endl;
+        throw Hydra::System::Component::V1::Suspended();
+    }
+    mLogger.getInfoStream() << current.adapter->getCommunicator()->identityToString(current.id) << ": shutting down." << std::endl;
+    mShuttingDown = true;
+    reap();
+    std::for_each(mBridges.begin(), mBridges.end(), Hydra::BridgeService::ShutdownFunctor(current));
+
+    mAdapter->getCommunicator()->shutdown();
 }
 
 void Hydra::BridgeService::BridgeFactoryImpl::suspend(const Ice::Current& current)
 {
-   boost::unique_lock<boost::shared_mutex> lock(mLock);
-   if(mShuttingDown)
-   {
-      throw Hydra::System::Component::V1::ShuttingDown();
-   }
-   if(mSuspended)
-   {
-      return;
-   }
-   mSuspended = true;
+    mLogger.getTraceStream() << __FUNCTION__ << ":" << current.adapter->getCommunicator()->identityToString(current.id) << std::endl;
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
+    if(mShuttingDown)
+    {
+        mLogger.getDebugStream() << __FUNCTION__ << ": called when shutting down." << std::endl;
+        throw Hydra::System::Component::V1::ShuttingDown();
+    }
+    if(mSuspended)
+    {
+        mLogger.getDebugStream() << __FUNCTION__ << ": called when suspended." << std::endl;
+        return;
+    }
+    mLogger.getInfoStream() << current.adapter->getCommunicator()->identityToString(current.id) << ": suspending." << std::endl;
+    mSuspended = true;
 }
 
 void Hydra::BridgeService::BridgeFactoryImpl::resume(const Ice::Current& current)
 {
-   boost::unique_lock<boost::shared_mutex> lock(mLock);
-   if(mShuttingDown)
-   {
-      throw Hydra::System::Component::V1::ShuttingDown();
-   }
-   if(!mSuspended)
-   {
-      return;
-   }
-   mSuspended = false;
+    mLogger.getTraceStream() << __FUNCTION__ << ":" << current.adapter->getCommunicator()->identityToString(current.id) << std::endl;
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
+    if(mShuttingDown)
+    {
+        mLogger.getDebugStream() << __FUNCTION__ << ": called when shutting down." << std::endl;
+        throw Hydra::System::Component::V1::ShuttingDown();
+    }
+    if(!mSuspended)
+    {
+        mLogger.getDebugStream() << __FUNCTION__ << ": called when suspended." << std::endl;
+        return;
+    }
+    mLogger.getInfoStream() << current.adapter->getCommunicator()->identityToString(current.id) << ": resuming." << std::endl;
+    mSuspended = false;
 }
 
 void Hydra::BridgeService::BridgeFactoryImpl::reap()
 {
-   for(std::vector<Hydra::BridgeService::BridgeImplPtr>::iterator i = mBridges.begin(); i != mBridges.end(); ++i)
-   {
-      if((*i)->destroyed())
-      {
-	 std::vector<Hydra::BridgeService::BridgeImplPtr>::iterator t = i;
-	 mBridges.erase(t);
-      }
-   }
+    mLogger.getDebugStream() << __FUNCTION__ << ": reaping bridge set of " << mBridges.size() << " bridges." << std::endl;
+    for(std::vector<Hydra::BridgeService::BridgeImplPtr>::iterator i = mBridges.begin(); i != mBridges.end(); ++i)
+    {
+        if((*i)->destroyed())
+        {
+            std::vector<Hydra::BridgeService::BridgeImplPtr>::iterator t = i;
+            mBridges.erase(t);
+        }
+    }
+    mLogger.getDebugStream() << __FUNCTION__ << ": reaping completed, bridge set size is now " << mBridges.size() << "." << std::endl;
 }
diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index 8a3f5dc..505ae06 100644
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -1,6 +1,6 @@
 #include "BridgeImpl.h"
 #include <System/Component/ComponentServiceIf.h>
-#include <Ice/LocalException.h>
+#include <Ice/Ice.h>
 
 //
 // TODO:
@@ -53,133 +53,150 @@ Hydra::BridgeService::BridgeImpl::BridgeImpl(
 
 void Hydra::BridgeService::BridgeImpl::addEndpoint(const Hydra::Core::Endpoint::V1::BaseEndpointPtr& ep, const Ice::Current& current)
 {
-   if(ep == 0 || ep->id == 0)
-   {
-      throw Hydra::Core::Endpoint::V1::InvalidEndpointId(new Hydra::Core::Endpoint::V1::EndpointId);
-   }
-
-   if(!checkEndpointId(*ep->id))
-   {
-      throw Hydra::Core::Endpoint::V1::InvalidEndpointId(ep->id);
-   }
-
-   Hydra::Session::V1::SessionEndpointPtr newEndpoint(Hydra::Session::V1::SessionEndpointPtr::dynamicCast(ep));
-   if(!newEndpoint)
-   {
-      throw Hydra::Core::Bridging::V1::UnsupportedEndpoint(ep->id);
-   }
-   boost::unique_lock<boost::shared_mutex> lock(mLock);
-   statePreCheck();
-   Hydra::Session::V1::SessionEndpointSeq::iterator  i = find(ep->id);
-   if(i != mEndpoints.end())
-   {
-      throw Hydra::Core::Bridging::V1::EndpointAlreadyRegistered();
-   }
-   mEndpoints.push_back(newEndpoint);
+    mLogger.getTraceStream() << __FUNCTION__ << ":" << current.adapter->getCommunicator()->identityToString(current.id) << std::endl;
+    if(ep == 0 || ep->id == 0)
+    {
+        throw Hydra::Core::Endpoint::V1::InvalidEndpointId(new Hydra::Core::Endpoint::V1::EndpointId);
+    }
+
+    if(!checkEndpointId(*ep->id))
+    {
+        throw Hydra::Core::Endpoint::V1::InvalidEndpointId(ep->id);
+    }
+
+    Hydra::Session::V1::SessionEndpointPtr newEndpoint(Hydra::Session::V1::SessionEndpointPtr::dynamicCast(ep));
+    if(!newEndpoint)
+    {
+        throw Hydra::Core::Bridging::V1::UnsupportedEndpoint(ep->id);
+    }
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
+    statePreCheck();
+    Hydra::Session::V1::SessionEndpointSeq::iterator  i = find(ep->id);
+    if(i != mEndpoints.end())
+    {
+        throw Hydra::Core::Bridging::V1::EndpointAlreadyRegistered();
+    }
+    mEndpoints.push_back(newEndpoint);
 }
 
 void Hydra::BridgeService::BridgeImpl::removeEndpoint(const Hydra::Core::Endpoint::V1::EndpointIdPtr& ep, const Ice::Current& current)
 {
-   boost::unique_lock<boost::shared_mutex> lock(mLock);
-   statePreCheck();
-   Hydra::Session::V1::SessionEndpointSeq::iterator  i = find(ep);
-
-   if(mManager && !mManager->onRemoveEndpoint(*i))
-   {
-      return;
-   }
-   mEndpoints.erase(i);
+    mLogger.getTraceStream() << __FUNCTION__ << ":" << current.adapter->getCommunicator()->identityToString(current.id) << std::endl;
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
+    statePreCheck();
+    Hydra::Session::V1::SessionEndpointSeq::iterator  i = find(ep);
+
+    if(mManager && !mManager->onRemoveEndpoint(*i))
+    {
+        return;
+    }
+    mEndpoints.erase(i);
 }
 
 Hydra::Core::Endpoint::V1::EndpointSeq Hydra::BridgeService::BridgeImpl::listEndpoints(const Ice::Current& current)
 {
-   boost::shared_lock<boost::shared_mutex> lock(mLock);
-   statePreCheck();
-
-   Hydra::Core::Endpoint::V1::EndpointSeq eps;
-   if(mAdminEndpointInList && mAdminEndpoint)
-   {
-      eps.push_back(mAdminEndpoint);
-   }
-   for(Hydra::Session::V1::SessionEndpointSeq::const_iterator i = mEndpoints.begin(); i != mEndpoints.end(); ++i)
-   {
-      eps.push_back(*i);
-   }
-   return eps;
+    mLogger.getTraceStream() << __FUNCTION__ << ":" << current.adapter->getCommunicator()->identityToString(current.id) << std::endl;
+    boost::shared_lock<boost::shared_mutex> lock(mLock);
+    statePreCheck();
+    mLogger.getDebugStream() << __FUNCTION__ << ": working with " << mEndpoints.size() << " endpoints." << std::endl;
+
+    Hydra::Core::Endpoint::V1::EndpointSeq eps;
+    if(mAdminEndpointInList && mAdminEndpoint != 0)
+    {
+        mLogger.getDebugStream() << __FUNCTION__ << ": adding admin endpoint to result set." << std::endl;
+        eps.push_back(mAdminEndpoint);
+    }
+    for(Hydra::Session::V1::SessionEndpointSeq::const_iterator i = mEndpoints.begin(); i != mEndpoints.end(); ++i)
+    {
+        eps.push_back(*i);
+    }
+    mLogger.getDebugStream() << __FUNCTION__ << ": returning " << eps.size() << " endpoints." << std::endl;
+    return eps;
 }
 
 void Hydra::BridgeService::BridgeImpl::shutdown(const Ice::Current& current)
 {
-   {
-      boost::unique_lock<boost::shared_mutex> lock(mLock);
-      if(mState == ShuttingDown)
-      {
-	 return;
-      }
-      if(mState == Destroyed)
-      {
-	 throw Ice::ObjectNotExistException(__FILE__, __LINE__);
-      }
-      mState = ShuttingDown;
-   }
-
-   //
-   // TODO: Source ids for bridge generated operations should come from configuration, etc.
-   //
-   Hydra::Core::Endpoint::V1::EndpointIdPtr sourceId;
-   if(mAdminEndpoint)
-   {
-      sourceId = mAdminEndpoint->id;
-   }
-   //
-   // TODO: Response code for termination messages for bridges shutting down should come from configuration
-   //
-   Hydra::Session::V1::ResponseCodePtr response(new Hydra::Session::V1::ResponseCode(0));
-   std::for_each(mEndpoints.begin(), mEndpoints.end(), Hydra::BridgeService::BridgeShutdownFunctor(sourceId, response));
+    mLogger.getTraceStream() << __FUNCTION__ << ":" << current.adapter->getCommunicator()->identityToString(current.id) << std::endl;
+    {
+        boost::unique_lock<boost::shared_mutex> lock(mLock);
+        if(mState == ShuttingDown)
+        {
+            mLogger.getDebugStream() << __FUNCTION__ << ": called when shutting down." << std::endl;
+            return;
+        }
+        if(mState == Destroyed)
+        {
+            mLogger.getDebugStream() << __FUNCTION__ << ": called when destroyed." << std::endl;
+            throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+        }
+        mState = ShuttingDown;
+    }
+
+    //
+    // TODO: Source ids for bridge generated operations should come from configuration, etc.
+    //
+    Hydra::Core::Endpoint::V1::EndpointIdPtr sourceId;
+    if(mAdminEndpoint)
+    {
+        sourceId = mAdminEndpoint->id;
+    }
+    //
+    // TODO: Response code for termination messages for bridges shutting down should come from configuration
+    //
+    Hydra::Session::V1::ResponseCodePtr response(new Hydra::Session::V1::ResponseCode(0));
+    std::for_each(mEndpoints.begin(), mEndpoints.end(), Hydra::BridgeService::BridgeShutdownFunctor(sourceId, response));
+    mLogger.getInfoStream() << current.adapter->getCommunicator()->identityToString(current.id) << ": is shutdown." << std::endl;
 }
 
 void Hydra::BridgeService::BridgeImpl::destroy(const Ice::Current& current)
 {
-   {
-      boost::unique_lock<boost::shared_mutex> lock(mLock);
-      if(mState == ShuttingDown)
-      {
-	 throw Hydra::System::Component::V1::ShuttingDown();
-      }
-      if(mState == Destroyed)
-      {
-	 throw Ice::ObjectNotExistException(__FILE__, __LINE__);
-      }
-      mState = Destroyed;
-   }
+    mLogger.getTraceStream() << __FUNCTION__ << ":" << current.adapter->getCommunicator()->identityToString(current.id) << std::endl;
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
+    if(mState == ShuttingDown)
+    {
+        mLogger.getDebugStream() << __FUNCTION__ << ": called when shutting down." << std::endl;
+        throw Hydra::System::Component::V1::ShuttingDown();
+    }
+    if(mState == Destroyed)
+    {
+        mLogger.getDebugStream() << __FUNCTION__ << ": called when destroyed." << std::endl;
+        throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+    }
+    mState = Destroyed;
+    mLogger.getInfoStream() << current.adapter->getCommunicator()->identityToString(current.id) << ": is now destroyed." << std::endl;
 }
 
 bool Hydra::BridgeService::BridgeImpl::destroyed()
 {
-   boost::shared_lock<boost::shared_mutex> lock(mLock);
-   return mState == Destroyed;
+    boost::shared_lock<boost::shared_mutex> lock(mLock);
+    mLogger.getDebugStream() << __FUNCTION__ << ": " << (mState == Destroyed ? "yes, I am destroyed." : "no, I am not destroyed") << std::endl;
+    return mState == Destroyed;
 }
 
 void Hydra::BridgeService::BridgeImpl::statePreCheck()
 {
-   if(mState == ShuttingDown)
-   {
-      throw Hydra::System::Component::V1::ShuttingDown();
-   }
-   if(mState == Destroyed)
-   {
-      throw Ice::ObjectNotExistException(__FILE__, __LINE__);
-   }
+    if(mState == ShuttingDown)
+    {
+        mLogger.getDebugStream() << __FUNCTION__ << ": called when shutting down." << std::endl;
+        throw Hydra::System::Component::V1::ShuttingDown();
+    }
+    if(mState == Destroyed)
+    {
+        mLogger.getDebugStream() << __FUNCTION__ << ": called when destroyed." << std::endl;
+        throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+    }
 }
 
 Hydra::Session::V1::SessionEndpointSeq::iterator Hydra::BridgeService::BridgeImpl::find(const Core::Endpoint::V1::EndpointIdPtr& e)
 {
-   for(Hydra::Session::V1::SessionEndpointSeq::iterator i = mEndpoints.begin(); i != mEndpoints.end(); ++i)
-   {
-      if(e->endpointManagerId == (*i)->id->endpointManagerId && e->deviceId == (*i)->id->deviceId)
-      {
-	 return i;
-      }
-   }
-   return mEndpoints.end();
+    mLogger.getDebugStream() << __FUNCTION__ << ": searching endpoints for " << e->endpointManagerId << ":" << e->deviceId << "." << std::endl;
+    for(Hydra::Session::V1::SessionEndpointSeq::iterator i = mEndpoints.begin(); i != mEndpoints.end(); ++i)
+    {
+        if(e->endpointManagerId == (*i)->id->endpointManagerId && e->deviceId == (*i)->id->deviceId)
+        {
+            return i;
+        }
+    }
+    mLogger.getDebugStream() << __FUNCTION__ << ": endpoint " << e->endpointManagerId << ":" << e->deviceId << " not found." << std::endl;
+    return mEndpoints.end();
 }
diff --git a/src/BridgeImpl.h b/src/BridgeImpl.h
index 3ae280b..59961ad 100644
--- a/src/BridgeImpl.h
+++ b/src/BridgeImpl.h
@@ -6,6 +6,7 @@
 #include <Session/SessionIf.h>
 #include <boost/thread/shared_mutex.hpp>
 #include <vector>
+#include "Logger.h"
 
 namespace Hydra
 {
@@ -63,6 +64,7 @@ namespace BridgeService
       // Policy values.
       //
       bool mAdminEndpointInList;
+      Logger mLogger;
 
       void statePreCheck();
       Session::V1::SessionEndpointSeq::iterator find(const Core::Endpoint::V1::EndpointIdPtr& e);
diff --git a/src/Logger.h b/src/Logger.h
index a4a7f0f..e5600fc 100644
--- a/src/Logger.h
+++ b/src/Logger.h
@@ -12,6 +12,11 @@ namespace BridgeService
     class Logger 
     {
     public:
+        Logger() :
+            mTraceDebug(true)
+        {
+        }
+
         std::ostream& getTraceStream()
         {
             return std::cerr;
@@ -27,10 +32,15 @@ namespace BridgeService
             return std::cerr;
         }
 
+        bool debugTracing() { return mTraceDebug; }
+
         std::ostream& getInfoStream()
         {
             return std::cerr;
         }
+
+    private:
+        bool mTraceDebug;
     };
 } // End of namespace BridgeImpl
 } // End of namespace Hydra
diff --git a/test/TestBridging.cpp b/test/TestBridging.cpp
index 0665f2c..2d2d658 100644
--- a/test/TestBridging.cpp
+++ b/test/TestBridging.cpp
@@ -56,107 +56,208 @@ int BOOST_TEST_CALL_DECL main( int argc, char* argv[] )
 
 BOOST_AUTO_TEST_CASE(BridgeEndpointValidationAddInvalidType)
 {
-   Hydra::BridgeService::BridgeImplPtr b(new Hydra::BridgeService::BridgeImpl(0, Hydra::Session::V1::SessionEndpointSeq(), 0));
-   try
-   {
-       Hydra::Core::Endpoint::V1::BaseEndpointPtr p(new Hydra::Core::Endpoint::V1::BaseEndpoint);
-       p->id = new Hydra::Core::Endpoint::V1::EndpointId;
-       p->id->endpointManagerId = "foo";
-       p->id->deviceId = "bar";
-       b->addEndpoint(p, Ice::Current());
-       BOOST_CHECK("Should not have succeeded" == 0);
-   }
-   catch(Hydra::Core::Bridging::V1::UnsupportedEndpoint&)
-   {
-      BOOST_CHECK(true);
-   }
+    Ice::InitializationData initData;
+    initData.properties = Ice::createProperties(0);
+    initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
+    Ice::CommunicatorPtr comm = Ice::initialize(initData);
+    Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+    Ice::Current dummy;
+    dummy.adapter = adapter;
+    dummy.id = comm->stringToIdentity("testobject");
+    try
+    {
+        Hydra::BridgeService::BridgeImplPtr b(new Hydra::BridgeService::BridgeImpl(0, Hydra::Session::V1::SessionEndpointSeq(), 0));
+        try
+        {
+            Hydra::Core::Endpoint::V1::BaseEndpointPtr p(new Hydra::Core::Endpoint::V1::BaseEndpoint);
+            p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+            p->id->endpointManagerId = "foo";
+            p->id->deviceId = "bar";
+            b->addEndpoint(p, dummy);
+            BOOST_CHECK("Should not have succeeded" == 0);
+        }
+        catch(Hydra::Core::Bridging::V1::UnsupportedEndpoint&)
+        {
+            BOOST_CHECK(true);
+        }
+    }
+    catch(...)
+    {
+        adapter->destroy();
+        throw;
+    }
+    adapter->destroy();
 }
 
 BOOST_AUTO_TEST_CASE(BridgeEndpointValidationAddInvalidValue)
 {
-   Hydra::BridgeService::BridgeImplPtr b(new Hydra::BridgeService::BridgeImpl(0, Hydra::Session::V1::SessionEndpointSeq(), 0));
-   try
-   {
-      b->addEndpoint(0, Ice::Current());
-      BOOST_CHECK("Should not have succeeded" == 0);
-   }
-   catch(Hydra::Core::Endpoint::V1::InvalidEndpointId&)
-   {
-      BOOST_CHECK(true);
-   }
+    Ice::InitializationData initData;
+    initData.properties = Ice::createProperties(0);
+    initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
+    Ice::CommunicatorPtr comm = Ice::initialize(initData);
+    Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+    Ice::Current dummy;
+    dummy.adapter = adapter;
+    dummy.id = comm->stringToIdentity("testobject");
+    try
+    {
+        Hydra::BridgeService::BridgeImplPtr b(new Hydra::BridgeService::BridgeImpl(0, Hydra::Session::V1::SessionEndpointSeq(), 0));
+        try
+        {
+            b->addEndpoint(0, dummy);
+            BOOST_CHECK("Should not have succeeded" == 0);
+        }
+        catch(Hydra::Core::Endpoint::V1::InvalidEndpointId&)
+        {
+            BOOST_CHECK(true);
+        }
+    }
+    catch(...)
+    {
+        adapter->destroy();
+        throw;
+    }
+    adapter->destroy();
 }
 
 BOOST_AUTO_TEST_CASE(BridgeEndpointValidationAddValidTypeNullId)
 {
-   Hydra::BridgeService::BridgeImplPtr b(new Hydra::BridgeService::BridgeImpl(0, Hydra::Session::V1::SessionEndpointSeq(), 0));
-   try
-   {
-      Hydra::Session::V1::SessionEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
-      b->addEndpoint(p, Ice::Current());
-      BOOST_CHECK("Should not have succeeded" == 0);
-   }
-   catch(Hydra::Core::Endpoint::V1::InvalidEndpointId&)
-   {
-      BOOST_CHECK(true);
-   }
+    Ice::InitializationData initData;
+    initData.properties = Ice::createProperties(0);
+    initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
+    Ice::CommunicatorPtr comm = Ice::initialize(initData);
+    Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+    Ice::Current dummy;
+    dummy.adapter = adapter;
+    dummy.id = comm->stringToIdentity("testobject");
+    Hydra::BridgeService::BridgeImplPtr b(new Hydra::BridgeService::BridgeImpl(0, Hydra::Session::V1::SessionEndpointSeq(), 0));
+    try
+    {
+        try
+        {
+            Hydra::Session::V1::SessionEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
+            b->addEndpoint(p, dummy);
+            BOOST_CHECK("Should not have succeeded" == 0);
+        }
+        catch(Hydra::Core::Endpoint::V1::InvalidEndpointId&)
+        {
+            BOOST_CHECK(true);
+        }
+    }
+    catch(...)
+    {
+        adapter->destroy();
+        throw;
+    }
+    adapter->destroy();
 }
 
 BOOST_AUTO_TEST_CASE(BridgeEndpointValidationAddValidTypeInvalidId)
 {
-   Hydra::BridgeService::BridgeImplPtr b(new Hydra::BridgeService::BridgeImpl(0, Hydra::Session::V1::SessionEndpointSeq(), 0));
-   try
-   {
-      Hydra::Session::V1::SessionEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
-      p->id = new Hydra::Core::Endpoint::V1::EndpointId;
-      p->id->endpointManagerId = "";
-      p->id->deviceId = "";
-      b->addEndpoint(p, Ice::Current());
-      BOOST_CHECK("Should not have succeeded" == 0);
-   }
-   catch(Hydra::Core::Endpoint::V1::InvalidEndpointId& ex)
-   {
-       BOOST_CHECK(ex.badId->endpointManagerId == "");
-       BOOST_CHECK(ex.badId->deviceId == "");
-       BOOST_CHECK(true);
-   }
+    Ice::InitializationData initData;
+    initData.properties = Ice::createProperties(0);
+    initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
+    Ice::CommunicatorPtr comm = Ice::initialize(initData);
+    Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+    Ice::Current dummy;
+    dummy.adapter = adapter;
+    dummy.id = comm->stringToIdentity("testobject");
+    Hydra::BridgeService::BridgeImplPtr b(new Hydra::BridgeService::BridgeImpl(0, Hydra::Session::V1::SessionEndpointSeq(), 0));
+    try
+    {
+        try
+        {
+            Hydra::Session::V1::SessionEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
+            p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+            p->id->endpointManagerId = "";
+            p->id->deviceId = "";
+            b->addEndpoint(p, dummy);
+            BOOST_CHECK("Should not have succeeded" == 0);
+        }
+        catch(Hydra::Core::Endpoint::V1::InvalidEndpointId& ex)
+        {
+            BOOST_CHECK(ex.badId->endpointManagerId == "");
+            BOOST_CHECK(ex.badId->deviceId == "");
+        }
+    }
+    catch(...)
+    {
+        adapter->destroy();
+        throw;
+    }
+    adapter->destroy();
 }
 
 BOOST_AUTO_TEST_CASE(BridgeEndpointAddValidTypeValidValue)
 {
-   Hydra::BridgeService::BridgeImplPtr b(new Hydra::BridgeService::BridgeImpl(0, Hydra::Session::V1::SessionEndpointSeq(), 0));
-   try
-   {
-      Hydra::Session::V1::SessionEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
-      p->id = new Hydra::Core::Endpoint::V1::EndpointId;
-      p->id->endpointManagerId = "foo";
-      p->id->deviceId = "bar";
-      b->addEndpoint(p, Ice::Current());
-      BOOST_CHECK(true);
-   }
-   catch(...)
-   {
-       BOOST_CHECK("Unexpected exception thrown!" == 0);
-   }
+    Ice::InitializationData initData;
+    initData.properties = Ice::createProperties(0);
+    initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
+    Ice::CommunicatorPtr comm = Ice::initialize(initData);
+    Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+    Ice::Current dummy;
+    dummy.adapter = adapter;
+    dummy.id = comm->stringToIdentity("testobject");
+    Hydra::BridgeService::BridgeImplPtr b(new Hydra::BridgeService::BridgeImpl(0, Hydra::Session::V1::SessionEndpointSeq(), 0));
+    try
+    {
+        try
+        {
+            Hydra::Session::V1::SessionEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
+            p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+            p->id->endpointManagerId = "foo";
+            p->id->deviceId = "bar";
+            b->addEndpoint(p, dummy);
+            BOOST_CHECK(true);
+        }
+        catch(...)
+        {
+            BOOST_CHECK("Unexpected exception thrown!" == 0);
+        }
+    }
+    catch(...)
+    {
+        adapter->destroy();
+        throw;
+    }
+    adapter->destroy();
 }
 
 BOOST_AUTO_TEST_CASE(BridgeEndpointListEp)
 {
-   Hydra::BridgeService::BridgeImplPtr b(new Hydra::BridgeService::BridgeImpl(0, Hydra::Session::V1::SessionEndpointSeq(), 0));
-   try
-   {
-      Hydra::Session::V1::SessionEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
-      p->id = new Hydra::Core::Endpoint::V1::EndpointId;
-      p->id->endpointManagerId = "foo";
-      p->id->deviceId = "bar";
-      b->addEndpoint(p, Ice::Current());
-      Hydra::Core::Endpoint::V1::EndpointSeq endpoints = b->listEndpoints(Ice::Current());
-      BOOST_CHECK(endpoints.size() == 1);
-      BOOST_CHECK(endpoints.back()->id->endpointManagerId == "foo" && endpoints.back()->id->deviceId == "bar");
-   }
-   catch(...)
-   {
-       BOOST_CHECK("Unexpected exception thrown!" == 0);
-   }
+    Ice::InitializationData initData;
+    initData.properties = Ice::createProperties(0);
+    initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
+    Ice::CommunicatorPtr comm = Ice::initialize(initData);
+    Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+    Ice::Current dummy;
+    dummy.adapter = adapter;
+    dummy.id = comm->stringToIdentity("testobject");
+    Hydra::BridgeService::BridgeImplPtr b(new Hydra::BridgeService::BridgeImpl(0, Hydra::Session::V1::SessionEndpointSeq(), 0));
+    try
+    {
+        try
+        {
+            Hydra::Session::V1::SessionEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
+            p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+            p->id->endpointManagerId = "foo";
+            p->id->deviceId = "bar";
+            b->addEndpoint(p, dummy);
+            Hydra::Core::Endpoint::V1::EndpointSeq endpoints = b->listEndpoints(dummy);
+            BOOST_CHECK(endpoints.size() == 1);
+            BOOST_CHECK(endpoints.back()->id->endpointManagerId == "foo" && endpoints.back()->id->deviceId == "bar");
+        }
+        catch(...)
+        {
+            BOOST_CHECK("Unexpected exception thrown!" == 0);
+        }
+    }
+    catch(...)
+    {
+        adapter->destroy();
+        throw;
+    }
+    adapter->destroy();
 }
 
 BOOST_AUTO_TEST_CASE(BridgeFactoryCreateBridgeWithInvalidAdminEndpoint)
@@ -166,6 +267,9 @@ BOOST_AUTO_TEST_CASE(BridgeFactoryCreateBridgeWithInvalidAdminEndpoint)
     initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
     Ice::CommunicatorPtr comm = Ice::initialize(initData);
     Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+    Ice::Current dummy;
+    dummy.adapter = adapter;
+    dummy.id = comm->stringToIdentity("testobject");
     try
     {
         Hydra::BridgeService::BridgeFactoryImplPtr factory(new Hydra::BridgeService::BridgeFactoryImpl(adapter));
@@ -176,7 +280,7 @@ BOOST_AUTO_TEST_CASE(BridgeFactoryCreateBridgeWithInvalidAdminEndpoint)
             p->id = new Hydra::Core::Endpoint::V1::EndpointId;
             p->id->endpointManagerId = "foo";
             p->id->deviceId = "bar";
-            Hydra::Core::Bridging::V1::BridgePrx b =  factory->createBridge(p, Hydra::Core::Endpoint::V1::EndpointSeq(), 0, Ice::Current());
+            Hydra::Core::Bridging::V1::BridgePrx b =  factory->createBridge(p, Hydra::Core::Endpoint::V1::EndpointSeq(), 0, dummy);
             BOOST_CHECK("Should not have succeeded" == 0);
         }
         catch(const Hydra::Core::Bridging::V1::UnsupportedEndpoint& x)
@@ -199,6 +303,9 @@ BOOST_AUTO_TEST_CASE(BridgeFactoryCreateBridgeWithInvalidAdminEndpointId)
     initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
     Ice::CommunicatorPtr comm = Ice::initialize(initData);
     Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+    Ice::Current dummy;
+    dummy.adapter = adapter;
+    dummy.id = comm->stringToIdentity("testobject");
     try
     {
         Hydra::BridgeService::BridgeFactoryImplPtr factory(new Hydra::BridgeService::BridgeFactoryImpl(adapter));
@@ -210,7 +317,7 @@ BOOST_AUTO_TEST_CASE(BridgeFactoryCreateBridgeWithInvalidAdminEndpointId)
             p->id->endpointManagerId = "";
             p->id->deviceId = "";
             Hydra::Core::Bridging::V1::BridgeMonitorPrx monitor;
-            Hydra::Core::Bridging::V1::BridgePrx b = factory->createBridge(p, Hydra::Core::Endpoint::V1::EndpointSeq(), 0, Ice::Current());
+            Hydra::Core::Bridging::V1::BridgePrx b = factory->createBridge(p, Hydra::Core::Endpoint::V1::EndpointSeq(), 0, dummy);
             BOOST_CHECK("Should not have succeeded" == 0);
         }
         catch(const Hydra::Core::Endpoint::V1::InvalidEndpointId& id)
@@ -233,6 +340,9 @@ BOOST_AUTO_TEST_CASE(BridgeFactoryCreateBridgeWithValidAdminEndpoint)
     initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
     Ice::CommunicatorPtr comm = Ice::initialize(initData);
     Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+    Ice::Current dummy;
+    dummy.adapter = adapter;
+    dummy.id = comm->stringToIdentity("testobject");
     try
     {
         Hydra::BridgeService::BridgeFactoryImplPtr factory(new Hydra::BridgeService::BridgeFactoryImpl(adapter));
@@ -241,7 +351,7 @@ BOOST_AUTO_TEST_CASE(BridgeFactoryCreateBridgeWithValidAdminEndpoint)
         p->id->endpointManagerId = "foo";
         p->id->deviceId = "bar";
         Hydra::Core::Bridging::V1::BridgeMonitorPrx monitor;
-        Hydra::Core::Bridging::V1::BridgePrx b =  factory->createBridge(p, Hydra::Core::Endpoint::V1::EndpointSeq(), monitor, Ice::Current());
+        Hydra::Core::Bridging::V1::BridgePrx b =  factory->createBridge(p, Hydra::Core::Endpoint::V1::EndpointSeq(), monitor, dummy);
         BOOST_CHECK(b);
         Hydra::Core::Endpoint::V1::EndpointSeq endpoints = b->listEndpoints();
         BOOST_CHECK(endpoints.size() == 1);
@@ -262,10 +372,13 @@ BOOST_AUTO_TEST_CASE(BridgeFactoryEmptyBridge)
     initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
     Ice::CommunicatorPtr comm = Ice::initialize(initData);
     Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+    Ice::Current dummy;
+    dummy.adapter = adapter;
+    dummy.id = comm->stringToIdentity("testobject");
     try
     {
         Hydra::BridgeService::BridgeFactoryImplPtr factory(new Hydra::BridgeService::BridgeFactoryImpl(adapter));
-        Hydra::Core::Bridging::V1::BridgePrx b =  factory->createBridge(0, Hydra::Core::Endpoint::V1::EndpointSeq(), 0, Ice::Current());
+        Hydra::Core::Bridging::V1::BridgePrx b =  factory->createBridge(0, Hydra::Core::Endpoint::V1::EndpointSeq(), 0, dummy);
         BOOST_CHECK(b);
         Hydra::Core::Endpoint::V1::EndpointSeq endpoints = b->listEndpoints();
         BOOST_CHECK(endpoints.size() == 0);
@@ -285,6 +398,9 @@ BOOST_AUTO_TEST_CASE(BridgeFactoryInitialEndpointInvalidType)
     initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
     Ice::CommunicatorPtr comm = Ice::initialize(initData);
     Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+    Ice::Current dummy;
+    dummy.adapter = adapter;
+    dummy.id = comm->stringToIdentity("testobject");
     try
     {
         Hydra::BridgeService::BridgeFactoryImplPtr factory(new Hydra::BridgeService::BridgeFactoryImpl(adapter));
@@ -296,7 +412,7 @@ BOOST_AUTO_TEST_CASE(BridgeFactoryInitialEndpointInvalidType)
         Hydra::Core::Endpoint::V1::EndpointSeq eps;
         eps.push_back(p);
 
-        Hydra::Core::Bridging::V1::BridgePrx b =  factory->createBridge(0, eps, 0, Ice::Current());
+        Hydra::Core::Bridging::V1::BridgePrx b =  factory->createBridge(0, eps, 0, dummy);
         BOOST_CHECK("Should not have succeeded" == 0);
     }
     catch(const Hydra::Core::Bridging::V1::UnsupportedEndpoint& ex)
@@ -318,6 +434,9 @@ BOOST_AUTO_TEST_CASE(BridgeFactoryInitialEndpointNullId)
     initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
     Ice::CommunicatorPtr comm = Ice::initialize(initData);
     Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+    Ice::Current dummy;
+    dummy.adapter = adapter;
+    dummy.id = comm->stringToIdentity("testobject");
     try
     {
         Hydra::BridgeService::BridgeFactoryImplPtr factory(new Hydra::BridgeService::BridgeFactoryImpl(adapter));
@@ -326,7 +445,7 @@ BOOST_AUTO_TEST_CASE(BridgeFactoryInitialEndpointNullId)
         Hydra::Core::Endpoint::V1::EndpointSeq eps;
         eps.push_back(p);
 
-        Hydra::Core::Bridging::V1::BridgePrx b =  factory->createBridge(0, eps, 0, Ice::Current());
+        Hydra::Core::Bridging::V1::BridgePrx b =  factory->createBridge(0, eps, 0, dummy);
         BOOST_CHECK("Should not have succeeded" == 0);
     }
     catch(const Hydra::Core::Endpoint::V1::InvalidEndpointId&)
@@ -348,18 +467,21 @@ BOOST_AUTO_TEST_CASE(BridgeFactoryInitialEndpointInvalidId)
     initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
     Ice::CommunicatorPtr comm = Ice::initialize(initData);
     Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+    Ice::Current dummy;
+    dummy.adapter = adapter;
+    dummy.id = comm->stringToIdentity("testobject");
     try
     {
         Hydra::BridgeService::BridgeFactoryImplPtr factory(new Hydra::BridgeService::BridgeFactoryImpl(adapter));
         Hydra::Core::Endpoint::V1::BaseEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
         p->id = new Hydra::Core::Endpoint::V1::EndpointId;
-        p->id->endpointManagerId == "";
-        p->id->deviceId == "bar";
+        p->id->endpointManagerId = "";
+        p->id->deviceId = "bar";
 
         Hydra::Core::Endpoint::V1::EndpointSeq eps;
         eps.push_back(p);
 
-        Hydra::Core::Bridging::V1::BridgePrx b =  factory->createBridge(0, eps, 0, Ice::Current());
+        Hydra::Core::Bridging::V1::BridgePrx b =  factory->createBridge(0, eps, 0, dummy);
         BOOST_CHECK("Should not have succeeded" == 0);
     }
     catch(const Hydra::Core::Endpoint::V1::InvalidEndpointId& ex)
@@ -374,3 +496,75 @@ BOOST_AUTO_TEST_CASE(BridgeFactoryInitialEndpointInvalidId)
     }
     adapter->destroy();
 }
+
+BOOST_AUTO_TEST_CASE(BridgeFactoryCreateBridgeWithValidEndpoint)
+{
+    Ice::InitializationData initData;
+    initData.properties = Ice::createProperties(0);
+    initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
+    Ice::CommunicatorPtr comm = Ice::initialize(initData);
+    Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+    Ice::Current dummy;
+    dummy.adapter = adapter;
+    dummy.id = comm->stringToIdentity("testobject");
+    try
+    {
+        Hydra::BridgeService::BridgeFactoryImplPtr factory(new Hydra::BridgeService::BridgeFactoryImpl(adapter));
+        Hydra::Core::Endpoint::V1::BaseEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
+        p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+        p->id->endpointManagerId = "foo";
+        p->id->deviceId = "bar";
+        Hydra::Core::Endpoint::V1::EndpointSeq eps;
+        eps.push_back(p);
+        Hydra::Core::Bridging::V1::BridgePrx b =  factory->createBridge(0, eps, 0, dummy);
+        BOOST_CHECK(b);
+        Hydra::Core::Endpoint::V1::EndpointSeq endpoints = b->listEndpoints();
+        BOOST_CHECK(endpoints.size() == 1);
+        BOOST_CHECK(endpoints.back()->id->endpointManagerId == "foo" && endpoints.back()->id->deviceId == "bar");
+    }
+    catch(...)
+    {
+        adapter->destroy();
+        throw;
+    }
+    adapter->destroy();
+}
+
+BOOST_AUTO_TEST_CASE(BridgeFactoryCreateBridgeWithCollidingAdminAndInitialEndpoint)
+{
+    Ice::InitializationData initData;
+    initData.properties = Ice::createProperties(0);
+    initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
+    Ice::CommunicatorPtr comm = Ice::initialize(initData);
+    Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+    Ice::Current dummy;
+    dummy.adapter = adapter;
+    dummy.id = comm->stringToIdentity("testobject");
+    try
+    {
+        Hydra::BridgeService::BridgeFactoryImplPtr factory(new Hydra::BridgeService::BridgeFactoryImpl(adapter));
+        Hydra::Core::Endpoint::V1::BaseEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
+        p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+        p->id->endpointManagerId = "foo";
+        p->id->deviceId = "bar";
+        Hydra::Core::Endpoint::V1::EndpointSeq eps;
+        eps.push_back(p);
+        p = new Hydra::Session::V1::SessionEndpoint;
+        p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+        p->id->endpointManagerId = "foo";
+        p->id->deviceId = "bar";
+        Hydra::Core::Bridging::V1::BridgePrx b =  factory->createBridge(p, eps, 0, dummy);
+        BOOST_CHECK("Should not have succeeded." == 0);
+    }
+    catch(const Hydra::Core::Bridging::V1::EndpointCollision& ex)
+    {
+        BOOST_CHECK(ex.first->endpointManagerId == "foo" && ex.first->deviceId == "bar");
+        BOOST_CHECK(ex.second->endpointManagerId == "foo" && ex.second->deviceId == "bar");
+    }
+    catch(...)
+    {
+        adapter->destroy();
+        throw;
+    }
+    adapter->destroy();
+}

-----------------------------------------------------------------------


-- 
hydra/bridging.git




More information about the asterisk-scf-commits mailing list