[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Sep 13 09:33:26 CDT 2010


branch "master" has been updated
       via  de322876fc27aa6e8c0dbad2512644e32c90fb14 (commit)
       via  303777292662810b5f8816d5e6ba7633ee8bedd6 (commit)
       via  bd5aabe82ab1fd25150c08274d5d360d16e7ad0e (commit)
       via  ff228072a829b24b01bff16a84019af6bd67578a (commit)
      from  b7834509d2e3b80a72136ce8d0a6de83c5184ab2 (commit)

Summary of changes:
 .gitmodules                      |    3 +
 src/BridgeImpl.cpp               |   32 ++---
 src/BridgeImpl.h                 |    1 -
 src/BridgeManagerImpl.cpp        |   13 ++-
 test/BridgeListenerI.cpp         |   46 +++++++
 test/BridgeListenerI.h           |   26 ++++
 test/BridgeManagerListenerI.cpp  |   18 +++
 test/BridgeManagerListenerI.h    |   22 +++
 test/BridgeTestChannelDriver.cpp |    4 +
 test/BridgeTestChannelDriver.h   |   15 ++
 test/CMakeLists.txt              |   12 ++
 test/IceStormCollocator.cpp      |   84 ++++++++++++
 test/IceStormCollocator.h        |   56 ++++++++
 test/SessionListenerI.cpp        |   68 +++++++++
 test/SessionListenerI.h          |   33 +++++
 test/TestBridging.cpp            |  277 +++++++++++---------------------------
 test/channel_driver              |    1 +
 17 files changed, 488 insertions(+), 223 deletions(-)
 create mode 100644 test/BridgeListenerI.cpp
 create mode 100644 test/BridgeListenerI.h
 create mode 100644 test/BridgeManagerListenerI.cpp
 create mode 100644 test/BridgeManagerListenerI.h
 create mode 100644 test/BridgeTestChannelDriver.cpp
 create mode 100644 test/BridgeTestChannelDriver.h
 create mode 100644 test/IceStormCollocator.cpp
 create mode 100644 test/IceStormCollocator.h
 create mode 100644 test/SessionListenerI.cpp
 create mode 100644 test/SessionListenerI.h
 create mode 160000 test/channel_driver


- Log -----------------------------------------------------------------
commit de322876fc27aa6e8c0dbad2512644e32c90fb14
Merge: 3037772 b783450
Author: Brent Eagles <beagles at digium.com>
Date:   Mon Sep 13 11:58:31 2010 -0230

    Merge branch 'master' of ssh://git.asterisk.org/asterisk-scf/integration/bridging


commit 303777292662810b5f8816d5e6ba7633ee8bedd6
Author: Brent Eagles <beagles at digium.com>
Date:   Mon Sep 13 11:57:01 2010 -0230

    - fix a std::for_each usage issue in the bridge components.
    - updates to the IceStormCollocator helper class.
    - added some initial test servants (to be fleshed out shortly)

diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index 785e041..ee5c7bf 100644
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -142,7 +142,10 @@ namespace BridgeService
         void ringing(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source, const Ice::Current&)
         {
             std::vector<BridgeImpl::BridgeSession> sessions(mBridge->currentSessions());
-            std::for_each(sessions.begin(), sessions.end(), RingImpl());
+            if(sessions.size() > 0)
+            {
+                std::for_each(sessions.begin(), sessions.end(), RingImpl());
+            }
         }
 
         void stopped(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source, const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response, const Ice::Current& current)
@@ -324,8 +327,11 @@ void AsteriskSCF::BridgeService::BridgeImpl::shutdown(const Ice::Current& curren
     //
     // TODO: Response code for termination messages for bridges shutting down should come from configuration
     //
-    std::for_each(copyOfSessions.begin(), copyOfSessions.end(),
-            AsteriskSCF::BridgeService::ShutdownImpl(new AsteriskSCF::SessionCommunications::V1::ResponseCode));
+    if(copyOfSessions.size())
+    {
+        std::for_each(copyOfSessions.begin(), copyOfSessions.end(),
+                AsteriskSCF::BridgeService::ShutdownImpl(new AsteriskSCF::SessionCommunications::V1::ResponseCode));
+    }
 
     mLogger.getInfoStream() << current.adapter->getCommunicator()->identityToString(current.id) << ": is shutdown." << std::endl;
     mListeners->stopped();
diff --git a/src/BridgeManagerImpl.cpp b/src/BridgeManagerImpl.cpp
index 33ad775..8998871 100644
--- a/src/BridgeManagerImpl.cpp
+++ b/src/BridgeManagerImpl.cpp
@@ -134,7 +134,10 @@ void AsteriskSCF::BridgeService::BridgeManagerImpl::shutdown(const Ice::Current&
     mLogger.getInfoStream() << current.adapter->getCommunicator()->identityToString(current.id) << ": shutting down." << std::endl;
     mShuttingDown = true;
     reap();
-    std::for_each(mBridges.begin(), mBridges.end(), AsteriskSCF::BridgeService::ShutdownImpl(current));
+    if(mBridges.size() > 0)
+    {
+        std::for_each(mBridges.begin(), mBridges.end(), AsteriskSCF::BridgeService::ShutdownImpl(current));
+    }
 
     mAdapter->getCommunicator()->shutdown();
 }
diff --git a/test/BridgeManagerListenerI.cpp b/test/BridgeManagerListenerI.cpp
new file mode 100644
index 0000000..408b2d3
--- /dev/null
+++ b/test/BridgeManagerListenerI.cpp
@@ -0,0 +1,18 @@
+#include "BridgeManagerListenerI.h"
+
+BridgeManagerListenerI::BridgeManagerListenerI()
+{
+}
+
+void BridgeManagerListenerI::bridgeCreated(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& manager,
+        const AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx& bridge, const Ice::Current&)
+{
+}
+
+void BridgeManagerListenerI::stopped(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& manager, const Ice::Current&)
+{
+}
+
+void BridgeManagerListenerI::stopping(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& manager, const Ice::Current&)
+{
+}
diff --git a/test/BridgeManagerListenerI.h b/test/BridgeManagerListenerI.h
new file mode 100644
index 0000000..49eab4c
--- /dev/null
+++ b/test/BridgeManagerListenerI.h
@@ -0,0 +1,22 @@
+/*
+ * Asterisk Scalable Communications Framework
+ *
+ * Copyright (C) 2010 -- Digium, Inc.
+ *
+ * All rights reserved.
+ */
+#pragma once
+
+#include <SessionCommunications/Bridging/BridgingIf.h>
+
+class BridgeManagerListenerI : public AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerListener
+{
+public:
+    BridgeManagerListenerI();
+    void bridgeCreated(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& manager,
+            const AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx& bridge, const Ice::Current&);
+    void stopped(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& manager, const Ice::Current&);
+    void stopping(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& manager, const Ice::Current&);
+};
+
+typedef IceUtil::Handle<BridgeManagerListenerI> BridgeManagerListenerIPtr;
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index c58f70f..f50b566 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -13,6 +13,8 @@ hydra_component_add_file(bridging_unit_test SessionListenerI.h)
 hydra_component_add_file(bridging_unit_test SessionListenerI.cpp)
 hydra_component_add_file(bridging_unit_test BridgeListenerI.h)
 hydra_component_add_file(bridging_unit_test BridgeListenerI.cpp)
+hydra_component_add_file(bridging_unit_test BridgeManagerListenerI.h)
+hydra_component_add_file(bridging_unit_test BridgeManagerListenerI.cpp)
 
 hydra_component_add_file(bridging_unit_test "../src/BridgeImpl.cpp")
 hydra_component_add_file(bridging_unit_test "../src/BridgeImpl.h")
diff --git a/test/IceStormCollocator.cpp b/test/IceStormCollocator.cpp
index ebb9d9b..2287957 100644
--- a/test/IceStormCollocator.cpp
+++ b/test/IceStormCollocator.cpp
@@ -8,6 +8,7 @@
 #include <Ice/Ice.h>
 #include <IceStorm/IceStorm.h>
 #include <assert.h>
+#include <algorithm>
 #include "IceStormCollocator.h"
 
 //
@@ -36,16 +37,17 @@ IceStormInstance::~IceStormInstance()
 
 typedef IceBox::Service* (*FACTORY)(Ice::CommunicatorPtr);
 
-void IceStormInstance::start(const std::string& namePrefix, const Ice::StringSeq& options)
+void IceStormInstance::start(const std::string& namePrefix, const Ice::PropertiesPtr& p)
 {
     //
     // TODO: Configuration?
     //
-    Ice::StringSeq mutableCopy(options);
-    mCommunicator = Ice::initialize(mutableCopy);
+    Ice::InitializationData initData;
+    initData.properties = p;
+    mCommunicator = Ice::initialize(initData);
     mLibrary = new IceInternal::DynamicLibrary();
 
-    IceInternal::DynamicLibrary::symbol_type entry = mLibrary->loadEntryPoint("IceStorm:createIceStorm");
+    IceInternal::DynamicLibrary::symbol_type entry = mLibrary->loadEntryPoint("IceStormService:createIceStorm");
     if(entry == 0)
     {
         throw mLibrary->getErrorMessage();
@@ -53,7 +55,8 @@ void IceStormInstance::start(const std::string& namePrefix, const Ice::StringSeq
     FACTORY factory = (FACTORY)entry;
     mService = factory(mCommunicator);
     assert(mService != 0);
-    mService->start(namePrefix + ".Service", mCommunicator, options);
+    Ice::StringSeq options;
+    mService->start(namePrefix, mCommunicator, options);
 }
 
 void IceStormInstance::stop()
@@ -75,6 +78,7 @@ IceStormInstancePtr IceStormInstance::getInstance()
         //
         // Need to initialize!
         //
+        return new IceStormInstance;
     }
     return mInstance;
 }
diff --git a/test/IceStormCollocator.h b/test/IceStormCollocator.h
index 68c9b0e..34e030b 100644
--- a/test/IceStormCollocator.h
+++ b/test/IceStormCollocator.h
@@ -32,7 +32,7 @@ public:
      * start() creates a communicator and two object adapters. All are destroyed
      * when stop is called or the object is deleted.
      */
-    void start(const std::string&,  const Ice::StringSeq&);
+    void start(const std::string&,  const Ice::PropertiesPtr&);
 
     /**
      * "nice" applications should explictly call stop !
diff --git a/test/TestBridging.cpp b/test/TestBridging.cpp
index 1a2ee62..30dbe90 100644
--- a/test/TestBridging.cpp
+++ b/test/TestBridging.cpp
@@ -21,6 +21,9 @@
 #include <ConsoleDriver.h>
 
 #include "IceStormCollocator.h"
+#include "BridgeManagerListenerI.h"
+#include "BridgeListenerI.h"
+#include "SessionListenerI.h"
 
 #include <Ice/Ice.h>
 
@@ -31,120 +34,6 @@ public:
    int argc;
    char **argv;
 };
-
-class SessionListenerI : public AsteriskSCF::SessionCommunications::V1::SessionListener
-{
-public:
-
-    SessionListenerI() : mTerminated(0)
-    {
-    }
-
-    void ring(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&)
-    {
-        BOOST_TEST_MESSAGE(__FUNCTION__);
-    }
-
-    void connected(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&)
-    {
-        BOOST_TEST_MESSAGE(__FUNCTION__);
-    }
-
-    void terminated(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
-            const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& r, const Ice::Current& current)
-    {
-        ++mTerminated;
-        BOOST_TEST_MESSAGE(__FUNCTION__);
-    }
-
-    void busy(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&)
-    {
-        BOOST_TEST_MESSAGE(__FUNCTION__);
-    }
-
-    void congestion(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
-            const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& r, const Ice::Current&)
-    {
-        BOOST_TEST_MESSAGE(__FUNCTION__);
-    }
-
-    void hold(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&)
-    {
-        BOOST_TEST_MESSAGE(__FUNCTION__);
-    }
-
-    void unhold(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&)
-    {
-        BOOST_TEST_MESSAGE(__FUNCTION__);
-    }
-
-    void flash(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&)
-    {
-        BOOST_TEST_MESSAGE(__FUNCTION__);
-    }
-
-    void progress(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
-            const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& r, const Ice::Current&)
-    {
-        BOOST_TEST_MESSAGE(__FUNCTION__);
-    }
-
-    unsigned long terminateReceived()
-    {
-        return mTerminated;
-    }
-
-protected:
-
-    unsigned long mTerminated;
-};
-
-class BridgeEventSubscriberI : public AsteriskSCF::SessionCommunications::Bridging::V1::BridgeListener
-{
-public:
-    BridgeEventSubscriberI() :
-        mShuttingDown(false),
-        mStopped(false)
-    {
-    }
-
-    void sessionsAdded(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, const Ice::Current& current)
-    {
-    }
-
-    void sessionsRemoved(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, const Ice::Current& current)
-    {
-    }
-
-    void stopping(const Ice::Current& current)
-    {
-        mShuttingDown = true;
-    }
-
-    void stopped(const Ice::Current& current)
-    {
-        mStopped = true;
-    }
-
-    bool resetShuttingDown()
-    {
-        bool result = mShuttingDown;
-        mShuttingDown = false;
-        return result;
-    }
-
-    bool resetStopped()
-    {
-        bool result = mStopped;
-        mStopped = false;
-        return result;
-    }
-
-private:
-    bool mShuttingDown;
-    bool mStopped;
-};
-
 static ArgCacheType mCachedArgs;
 
 /**
@@ -181,6 +70,72 @@ int BOOST_TEST_CALL_DECL main( int argc, char* argv[] )
    return ::boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
 }
 
+BOOST_AUTO_TEST_CASE(CreateBridgeFactory)
+{
+    Ice::PropertiesPtr p = Ice::createProperties();
+    p->setProperty("TestStorm.TopicManager.Endpoints","default -p 55555");
+    p->setProperty("TestStorm.Publish.Endpoints", "default -p 55556");
+    p->setProperty("TestStorm.InstanceName", "TestStorm");
+    p->setProperty("TestStorm.Transient", "1");
+    IceStormInstancePtr iceStorm(IceStormInstance::getInstance());
+    iceStorm->start("TestStorm", p);
+    try
+    {
+        p = Ice::createProperties();
+        p->setProperty("TopicManager.Proxy", "TestStorm/TopicManager:default -p 55555");
+        p->setProperty("TestUtilAdapter.Endpoints", "default -p 55557");
+        p->setProperty("TestBridgeAdapter.Endpoints", "default -p 55558");
+
+        Ice::InitializationData initData;
+        initData.properties = p;
+        Ice::CommunicatorPtr communicator = Ice::initialize(initData);
+        try
+        {
+            Ice::ObjectAdapterPtr testAdapter = communicator->createObjectAdapter("TestUtilAdapter");
+            BridgeManagerListenerIPtr servant = new BridgeManagerListenerI;
+            AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerListenerPrx listenerPrx =
+                AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerListenerPrx::uncheckedCast(
+                    testAdapter->add(servant,
+                            communicator->stringToIdentity("testBridgeManagerListener")
+                    )
+                );
+
+            Ice::ObjectAdapterPtr bridgeAdapter = communicator->createObjectAdapter("TestBridgeAdapter");
+            AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPtr mgrServant(
+                new AsteriskSCF::BridgeService::BridgeManagerImpl(bridgeAdapter, "TestBridgeManager", listenerPrx));
+            AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx mgrPrx(
+                AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx::uncheckedCast(
+                    testAdapter->add(mgrServant,
+                            communicator->stringToIdentity("testBridgeManager")
+                    )
+                )
+            );
+            mgrPrx->shutdown();
+        }
+        catch(const Ice::Exception& ex)
+        {
+            std::cerr << ex << std::endl;
+            BOOST_CHECK(false);
+        }
+        catch(...)
+        {
+            BOOST_CHECK(false);
+        }
+        communicator->destroy();
+    }
+    catch(...)
+    {
+        BOOST_CHECK(false);
+    }
+
+    iceStorm->stop();
+
+}
+
+BOOST_AUTO_TEST_CASE(CreateEmptyBridge)
+{
+}
+
 #if 0
 BOOST_AUTO_TEST_CASE(BridgeEndpointValidationAddInvalidType)
 {

commit bd5aabe82ab1fd25150c08274d5d360d16e7ad0e
Author: Brent Eagles <beagles at digium.com>
Date:   Mon Sep 13 10:04:17 2010 -0230

     - separation of test servants into their own files
     - adding collocated IceStorm support.

diff --git a/src/BridgeManagerImpl.cpp b/src/BridgeManagerImpl.cpp
index f746786..33ad775 100644
--- a/src/BridgeManagerImpl.cpp
+++ b/src/BridgeManagerImpl.cpp
@@ -89,6 +89,9 @@ AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx AsteriskSCF::BridgeS
     info.proxy = AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx::uncheckedCast(obj);
     mBridges.push_back(info);
 
+    //
+    // Don't forget to add the initial sessions.
+    //
     bridge->addSessions(sessions, current);
 
     return info.proxy;
diff --git a/test/BridgeListenerI.cpp b/test/BridgeListenerI.cpp
new file mode 100644
index 0000000..a3ccfd1
--- /dev/null
+++ b/test/BridgeListenerI.cpp
@@ -0,0 +1,46 @@
+/*
+ * Asterisk Scalable Communications Framework
+ *
+ * Copyright (C) 2010 -- Digium, Inc.
+ *
+ * All rights reserved.
+ */
+#include "BridgeListenerI.h"
+
+BridgeListenerI::BridgeListenerI() :
+    mShuttingDown(false),
+    mStopped(false)
+{
+}
+
+void BridgeListenerI::sessionsAdded(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, const Ice::Current& current)
+{
+}
+
+void BridgeListenerI::sessionsRemoved(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, const Ice::Current& current)
+{
+}
+
+void BridgeListenerI::stopping(const Ice::Current& current)
+{
+    mShuttingDown = true;
+}
+
+void BridgeListenerI::stopped(const Ice::Current& current)
+{
+    mStopped = true;
+}
+
+bool BridgeListenerI::resetShuttingDown()
+{
+    bool result = mShuttingDown;
+    mShuttingDown = false;
+    return result;
+}
+
+bool BridgeListenerI::resetStopped()
+{
+    bool result = mStopped;
+    mStopped = false;
+    return result;
+}
diff --git a/test/BridgeListenerI.h b/test/BridgeListenerI.h
new file mode 100644
index 0000000..075a4f7
--- /dev/null
+++ b/test/BridgeListenerI.h
@@ -0,0 +1,26 @@
+/*
+ * Asterisk Scalable Communications Framework
+ *
+ * Copyright (C) 2010 -- Digium, Inc.
+ *
+ * All rights reserved.
+ */
+#pragma once
+
+#include <SessionCommunications/Bridging/BridgingIf.h>
+
+class BridgeListenerI : public AsteriskSCF::SessionCommunications::Bridging::V1::BridgeListener
+{
+public:
+    BridgeListenerI();
+    void sessionsAdded(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, const Ice::Current& current);
+    void sessionsRemoved(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, const Ice::Current& current);
+    void stopping(const Ice::Current& current);
+    void stopped(const Ice::Current& current);
+    bool resetShuttingDown();
+    bool resetStopped();
+
+private:
+    bool mShuttingDown;
+    bool mStopped;
+};
diff --git a/test/BridgeTestChannelDriver.cpp b/test/BridgeTestChannelDriver.cpp
new file mode 100644
index 0000000..14f3e1e
--- /dev/null
+++ b/test/BridgeTestChannelDriver.cpp
@@ -0,0 +1,4 @@
+
+BridgeTestChannelDriver::setHandler(const CommandsPtr& cmd)
+{
+}
diff --git a/test/BridgeTestChannelDriver.h b/test/BridgeTestChannelDriver.h
new file mode 100644
index 0000000..413d1eb
--- /dev/null
+++ b/test/BridgeTestChannelDriver.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include <Commands.h>
+
+//
+// The test endpoint.
+//
+class BridgeTestChannelDriver : public CommandDriver
+{
+public:
+    virtual void setHandler(const CommandsPtr& cmd);
+private:
+    IceUtil::Mutex mLocks;
+    CommandsPtr mCommands;
+};
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 0f7e3e0..c58f70f 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,11 +1,19 @@
 hydra_component_init(bridging_unit_test CXX)
 add_subdirectory(channel_driver/src)
 include_directories("../src")
+include_directories("channel_driver/include")
 hydra_component_add_slice(bridging_unit_test EndpointIf)
 hydra_component_add_slice(bridging_unit_test ComponentServiceIf)
 hydra_component_add_slice(bridging_unit_test SessionCommunicationsIf)
 hydra_component_add_slice(bridging_unit_test BridgingIf)
 hydra_component_add_file(bridging_unit_test TestBridging.cpp)
+hydra_component_add_file(bridging_unit_test IceStormCollocator.cpp)
+hydra_component_add_file(bridging_unit_test IceStormCollocator.h)
+hydra_component_add_file(bridging_unit_test SessionListenerI.h)
+hydra_component_add_file(bridging_unit_test SessionListenerI.cpp)
+hydra_component_add_file(bridging_unit_test BridgeListenerI.h)
+hydra_component_add_file(bridging_unit_test BridgeListenerI.cpp)
+
 hydra_component_add_file(bridging_unit_test "../src/BridgeImpl.cpp")
 hydra_component_add_file(bridging_unit_test "../src/BridgeImpl.h")
 hydra_component_add_file(bridging_unit_test "../src/BridgeManagerImpl.cpp")
@@ -15,6 +23,7 @@ hydra_component_add_file(bridging_unit_test "../src/BridgeListenerMgr.cpp")
 hydra_component_add_file(bridging_unit_test "../src/BridgeListenerMgr.h")
 hydra_component_add_file(bridging_unit_test "../src/MediaSplicer.h")
 hydra_component_add_ice_libraries(bridging_unit_test IceStorm)
+hydra_component_add_ice_libraries(bridging_unit_test IceBox)
 hydra_component_add_boost_libraries(bridging_unit_test unit_test_framework)
 hydra_component_add_boost_libraries(bridging_unit_test thread)
 hydra_component_build_standalone(bridging_unit_test)
diff --git a/test/IceStormCollocator.cpp b/test/IceStormCollocator.cpp
new file mode 100644
index 0000000..ebb9d9b
--- /dev/null
+++ b/test/IceStormCollocator.cpp
@@ -0,0 +1,80 @@
+/*
+* Asterisk Scalable Communications Framework
+*
+* Copyright (C) 2010 -- Digium, Inc.
+*
+* All rights reserved.
+*/
+#include <Ice/Ice.h>
+#include <IceStorm/IceStorm.h>
+#include <assert.h>
+#include "IceStormCollocator.h"
+
+//
+// The idea behind this class is that it needs to access the entry point that IceBox would
+// have used and then invoke the methods that are needed to start and stop the IceStorm
+// service.
+//
+
+IceStormInstance::IceStormInstance()
+{
+    //
+    // Intentionally left blank.
+    //
+}
+
+IceStormInstance::~IceStormInstance()
+{
+    try
+    {
+        stop();
+    }
+    catch(...)
+    {
+    }
+}
+
+typedef IceBox::Service* (*FACTORY)(Ice::CommunicatorPtr);
+
+void IceStormInstance::start(const std::string& namePrefix, const Ice::StringSeq& options)
+{
+    //
+    // TODO: Configuration?
+    //
+    Ice::StringSeq mutableCopy(options);
+    mCommunicator = Ice::initialize(mutableCopy);
+    mLibrary = new IceInternal::DynamicLibrary();
+
+    IceInternal::DynamicLibrary::symbol_type entry = mLibrary->loadEntryPoint("IceStorm:createIceStorm");
+    if(entry == 0)
+    {
+        throw mLibrary->getErrorMessage();
+    }
+    FACTORY factory = (FACTORY)entry;
+    mService = factory(mCommunicator);
+    assert(mService != 0);
+    mService->start(namePrefix + ".Service", mCommunicator, options);
+}
+
+void IceStormInstance::stop()
+{
+    if(mService)
+    {
+        mService->stop();
+    }
+}
+
+IceUtil::Mutex IceStormInstance::mInstanceMutex;
+IceStormInstancePtr IceStormInstance::mInstance;
+
+IceStormInstancePtr IceStormInstance::getInstance()
+{
+    IceUtil::Mutex::Lock lock(mInstanceMutex);
+    if(!mInstance)
+    {
+        //
+        // Need to initialize!
+        //
+    }
+    return mInstance;
+}
diff --git a/test/IceStormCollocator.h b/test/IceStormCollocator.h
new file mode 100644
index 0000000..68c9b0e
--- /dev/null
+++ b/test/IceStormCollocator.h
@@ -0,0 +1,56 @@
+/*
+* Asterisk Scalable Communications Framework
+*
+* Copyright (C) 2010 -- Digium, Inc.
+*
+* All rights reserved.
+*/
+#pragma once
+
+#include <Ice/DynamicLibrary.h>
+#include <Ice/Service.h>
+#include <IceBox/IceBox.h>
+#include <Ice/Ice.h>
+#include <IceStorm/IceStorm.h>
+#include <string>
+
+/**
+ * A helper class that instantiates IceStorm in-process, removing the need to launch
+ * a separate process to access IceStorm services. Useful for testing!
+ */
+
+class IceStormInstance;
+typedef IceUtil::Handle<IceStormInstance> IceStormInstancePtr;
+
+class IceStormInstance : public IceUtil::Shared
+{
+    IceStormInstance();
+public:
+    ~IceStormInstance();
+
+    /**
+     * start() creates a communicator and two object adapters. All are destroyed
+     * when stop is called or the object is deleted.
+     */
+    void start(const std::string&,  const Ice::StringSeq&);
+
+    /**
+     * "nice" applications should explictly call stop !
+     */
+    void stop();
+
+    static IceStormInstancePtr getInstance();
+
+private:
+    static IceUtil::Mutex mInstanceMutex;
+    static IceStormInstancePtr mInstance;
+
+    IceInternal::DynamicLibraryPtr mLibrary;
+    IceBox::ServicePtr mService;
+
+    Ice::CommunicatorPtr mCommunicator;
+};
+
+typedef IceUtil::Handle<IceStormInstance> IceStormInstancePtr;
+
+
diff --git a/test/SessionListenerI.cpp b/test/SessionListenerI.cpp
new file mode 100644
index 0000000..4822bd1
--- /dev/null
+++ b/test/SessionListenerI.cpp
@@ -0,0 +1,68 @@
+/*
+* Asterisk Scalable Communications Framework
+*
+* Copyright (C) 2010 -- Digium, Inc.
+*
+* All rights reserved.
+*/
+
+#include "SessionListenerI.h"
+#include <boost/test/unit_test.hpp>
+
+SessionListenerI::SessionListenerI() : mTerminated(0)
+{
+}
+
+void SessionListenerI::ring(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&)
+{
+    BOOST_TEST_MESSAGE(__FUNCTION__);
+}
+
+void SessionListenerI::connected(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&)
+{
+    BOOST_TEST_MESSAGE(__FUNCTION__);
+}
+
+void SessionListenerI::terminated(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
+        const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& r, const Ice::Current& current)
+{
+    ++mTerminated;
+    BOOST_TEST_MESSAGE(__FUNCTION__);
+}
+
+void SessionListenerI::busy(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&)
+{
+    BOOST_TEST_MESSAGE(__FUNCTION__);
+}
+
+void SessionListenerI::congestion(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
+        const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& r, const Ice::Current&)
+{
+    BOOST_TEST_MESSAGE(__FUNCTION__);
+}
+
+void SessionListenerI::hold(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&)
+{
+    BOOST_TEST_MESSAGE(__FUNCTION__);
+}
+
+void SessionListenerI::unhold(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&)
+{
+    BOOST_TEST_MESSAGE(__FUNCTION__);
+}
+
+void SessionListenerI::flash(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&)
+{
+    BOOST_TEST_MESSAGE(__FUNCTION__);
+}
+
+void SessionListenerI::progress(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
+        const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& r, const Ice::Current&)
+{
+    BOOST_TEST_MESSAGE(__FUNCTION__);
+}
+
+unsigned long SessionListenerI::terminateReceived()
+{
+    return mTerminated;
+}
diff --git a/test/SessionListenerI.h b/test/SessionListenerI.h
new file mode 100644
index 0000000..738176a
--- /dev/null
+++ b/test/SessionListenerI.h
@@ -0,0 +1,33 @@
+/*
+* Asterisk Scalable Communications Framework
+*
+* Copyright (C) 2010 -- Digium, Inc.
+*
+* All rights reserved.
+*/
+#pragma once
+
+#include <Ice/Ice.h>
+#include <SessionCommunications/SessionCommunicationsIf.h>
+
+class SessionListenerI : public AsteriskSCF::SessionCommunications::V1::SessionListener
+{
+public:
+    SessionListenerI();
+    void ring(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&);
+    void connected(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&);
+    void terminated(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
+            const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& r, const Ice::Current& current);
+    void busy(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&);
+    void congestion(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
+            const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& r, const Ice::Current&);
+    void hold(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&);
+    void unhold(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&);
+    void flash(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&);
+    void progress(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
+            const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& r, const Ice::Current&);
+    unsigned long terminateReceived();
+
+protected:
+    unsigned long mTerminated;
+};
diff --git a/test/TestBridging.cpp b/test/TestBridging.cpp
index a464af0..1a2ee62 100644
--- a/test/TestBridging.cpp
+++ b/test/TestBridging.cpp
@@ -1,3 +1,10 @@
+/*
+* Asterisk Scalable Communications Framework
+*
+* Copyright (C) 2010 -- Digium, Inc.
+*
+* All rights reserved.
+*/
 #define BOOST_TEST_DYN_LINK
 #define BOOST_TEST_MODULE BridgingTestSuite
 #define BOOST_TEST_NO_MAIN
@@ -10,15 +17,10 @@
 #include <SessionCommunications/SessionCommunicationsIf.h>
 #include <SessionCommunications/Bridging/BridgingIf.h>
 #include <Media/MediaIf.h>
-#include "./channel_driver/src/TestEndpoint.h"
-#include "./channel_driver/src/ConsoleDriver.h"
+#include <TestEndpoint.h>
+#include <ConsoleDriver.h>
 
-//
-// The test endpoint.
-//
-class DummyDriver : public ConsoleDriver
-{
-};
+#include "IceStormCollocator.h"
 
 #include <Ice/Ice.h>
 
@@ -30,92 +32,6 @@ public:
    char **argv;
 };
 
-class SourceI : public AsteriskSCF::Media::V1::StreamSource
-{
-public:
-
-    SourceI(const std::string& id) :
-        mId(id)
-    {
-    }
-
-    void setSink(const AsteriskSCF::Media::V1::StreamSinkPrx& sink, const Ice::Current&)
-    {
-        mSink = sink;
-    }
-
-    AsteriskSCF::Media::V1::StreamSinkPrx getSink(const Ice::Current&)
-    {
-        return mSink;
-    }
-
-    AsteriskSCF::Media::V1::FormatSeq getFormats(const Ice::Current&)
-    {
-        return mFormats;
-    }
-
-    std::string getId(const Ice::Current&)
-    {
-        return mId;
-    }
-
-    void requestFormat(const AsteriskSCF::Media::V1::FormatPtr& format, const Ice::Current&)
-    {
-        // XXX
-    }
-
-private:
-    AsteriskSCF::Media::V1::StreamSinkPrx mSink;
-    AsteriskSCF::Media::V1::FormatSeq mFormats;
-
-    std::string mId;
-};
-
-class SinkI : public AsteriskSCF::Media::V1::StreamSink
-{
-public:
-
-    SinkI(const std::string& id) :
-        mId(id)
-    {
-    }
-
-    void write(const AsteriskSCF::Media::V1::FrameSeq& frames, const Ice::Current&)
-    {
-    }
-
-    void setSource(const AsteriskSCF::Media::V1::StreamSourcePrx& source, const Ice::Current&)
-    {
-        mSource = source;
-    }
-
-    AsteriskSCF::Media::V1::StreamSourcePrx getSource(const Ice::Current&)
-    {
-        return mSource;
-    }
-
-    AsteriskSCF::Media::V1::FormatSeq getFormats(const Ice::Current&)
-    {
-        return mFormats;
-    }
-
-    std::string getId(const Ice::Current&)
-    {
-        return mId;
-    }
-
-    void requestFormat(const AsteriskSCF::Media::V1::FormatPtr& format, const Ice::Current&)
-    {
-        // XXX
-    }
-
-private:
-    AsteriskSCF::Media::V1::StreamSourcePrx mSource;
-    AsteriskSCF::Media::V1::FormatSeq mFormats;
-
-    std::string mId;
-};
-
 class SessionListenerI : public AsteriskSCF::SessionCommunications::V1::SessionListener
 {
 public:
@@ -134,7 +50,8 @@ public:
         BOOST_TEST_MESSAGE(__FUNCTION__);
     }
 
-    void terminated(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& r, const Ice::Current& current)
+    void terminated(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
+            const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& r, const Ice::Current& current)
     {
         ++mTerminated;
         BOOST_TEST_MESSAGE(__FUNCTION__);
@@ -145,7 +62,8 @@ public:
         BOOST_TEST_MESSAGE(__FUNCTION__);
     }
 
-    void congestion(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& r, const Ice::Current&)
+    void congestion(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
+            const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& r, const Ice::Current&)
     {
         BOOST_TEST_MESSAGE(__FUNCTION__);
     }
@@ -165,7 +83,8 @@ public:
         BOOST_TEST_MESSAGE(__FUNCTION__);
     }
 
-    void progress(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& r, const Ice::Current&)
+    void progress(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
+            const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& r, const Ice::Current&)
     {
         BOOST_TEST_MESSAGE(__FUNCTION__);
     }
diff --git a/test/channel_driver b/test/channel_driver
index 422b49f..5fc5fcd 160000
--- a/test/channel_driver
+++ b/test/channel_driver
@@ -1 +1 @@
-Subproject commit 422b49fd2ebb96a49a24fdb314bb4306d9b23367
+Subproject commit 5fc5fcdb39d379b76a33eeff91a378f4447714b9

commit ff228072a829b24b01bff16a84019af6bd67578a
Author: Brent Eagles <beagles at digium.com>
Date:   Fri Sep 10 16:29:15 2010 -0230

    Seperate construction of bridge from the adding of the initial listeners
    to avoid race conditions that might occur as the bridge is not available
    while it is adding an associated object as a session listener.

diff --git a/.gitmodules b/.gitmodules
index e2b290b..81540dd 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,3 +4,6 @@
 [submodule "cmake"]
 	path = cmake
 	url = ../../release/cmake
+[submodule "test/channel_driver"]
+	path = test/channel_driver
+	url = ssh://git@git.asterisk.org/asterisk-scf/integration/test_channel
diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index ee1106a..785e041 100644
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -167,7 +167,6 @@ namespace BridgeService
 
 AsteriskSCF::BridgeService::BridgeImpl::BridgeImpl(
   const Ice::ObjectAdapterPtr& adapter,
-  const AsteriskSCF::SessionCommunications::V1::SessionSeq& initialSessions,
   const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeListenerPrx& ev,
   const AsteriskSCF::BridgeService::BridgeListenerMgrPtr& listenerMgr
   ) :
@@ -178,25 +177,6 @@ AsteriskSCF::BridgeService::BridgeImpl::BridgeImpl(
 {
     mListeners->addListener(ev);
     mSessionListenerPrx = AsteriskSCF::SessionCommunications::V1::SessionListenerPrx::uncheckedCast(mObjAdapter->addWithUUID(mSessionListener));
-
-    for(AsteriskSCF::SessionCommunications::V1::SessionSeq::const_iterator i = initialSessions.begin();
-        i != initialSessions.end(); ++i)
-    {
-        AsteriskSCF::SessionCommunications::V1::SessionInfoPtr info = (*i)->addListener(mSessionListenerPrx);
-        //
-        // We need to define these states! Especially the ones that define when start is called or not.
-        //
-        if(info->currentState == "ready")
-        {
-            (*i)->start();
-            mSessions.push_back(BridgeSession(*i, 0));
-        }
-        else
-        {
-            mSessions.push_back(BridgeSession(*i, mSplicer.connect(*i)));
-        }
-    }
-    mListeners->sessionsAdded(initialSessions);
 }
 
 AsteriskSCF::BridgeService::BridgeImpl::~BridgeImpl()
diff --git a/src/BridgeImpl.h b/src/BridgeImpl.h
index 242babc..61f8e38 100644
--- a/src/BridgeImpl.h
+++ b/src/BridgeImpl.h
@@ -38,7 +38,6 @@ namespace BridgeService
         };
 
         BridgeImpl(const Ice::ObjectAdapterPtr& objAdapter,
-                const SessionCommunications::V1::SessionSeq& initialSessions,
                 const SessionCommunications::Bridging::V1::BridgeListenerPrx& ev,
                 const AsteriskSCF::BridgeService::BridgeListenerMgrPtr& listenerMgr);
 
diff --git a/src/BridgeManagerImpl.cpp b/src/BridgeManagerImpl.cpp
index 83e4bc6..f746786 100644
--- a/src/BridgeManagerImpl.cpp
+++ b/src/BridgeManagerImpl.cpp
@@ -81,13 +81,16 @@ AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx AsteriskSCF::BridgeS
         AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx::uncheckedCast(mAdapter->createProxy(id)));
     AsteriskSCF::BridgeService::BridgeListenerMgrPtr mgr(new BridgeListenerMgr(mAdapter->getCommunicator(), stringId, prx));
     
-    AsteriskSCF::BridgeService::BridgeImplPtr bridge = new AsteriskSCF::BridgeService::BridgeImpl(mAdapter, sessions, listener, mgr);
+    AsteriskSCF::BridgeService::BridgeImplPtr bridge = new AsteriskSCF::BridgeService::BridgeImpl(mAdapter, listener, mgr);
     Ice::ObjectPrx obj = mAdapter->add(bridge, id);
     mLogger.getInfoStream() << current.adapter->getCommunicator()->identityToString(current.id) << ": creating new bridge " << obj->ice_toString() << "." << std::endl;
     BridgeInfo info;
     info.servant = bridge;
     info.proxy = AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx::uncheckedCast(obj);
     mBridges.push_back(info);
+
+    bridge->addSessions(sessions, current);
+
     return info.proxy;
 }
 
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 651102a..0f7e3e0 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,4 +1,5 @@
 hydra_component_init(bridging_unit_test CXX)
+add_subdirectory(channel_driver/src)
 include_directories("../src")
 hydra_component_add_slice(bridging_unit_test EndpointIf)
 hydra_component_add_slice(bridging_unit_test ComponentServiceIf)
diff --git a/test/TestBridging.cpp b/test/TestBridging.cpp
index 94a8f46..a464af0 100644
--- a/test/TestBridging.cpp
+++ b/test/TestBridging.cpp
@@ -10,6 +10,15 @@
 #include <SessionCommunications/SessionCommunicationsIf.h>
 #include <SessionCommunications/Bridging/BridgingIf.h>
 #include <Media/MediaIf.h>
+#include "./channel_driver/src/TestEndpoint.h"
+#include "./channel_driver/src/ConsoleDriver.h"
+
+//
+// The test endpoint.
+//
+class DummyDriver : public ConsoleDriver
+{
+};
 
 #include <Ice/Ice.h>
 
diff --git a/test/channel_driver b/test/channel_driver
new file mode 160000
index 0000000..422b49f
--- /dev/null
+++ b/test/channel_driver
@@ -0,0 +1 @@
+Subproject commit 422b49fd2ebb96a49a24fdb314bb4306d9b23367

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


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list