[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
Tue Sep 14 13:18:17 CDT 2010


branch "master" has been updated
       via  8cc90fe5811390f59f4d4a0ec4ea964bd78b07ca (commit)
      from  e031e9d51c6db7becc4a7a69c93dc922563941dc (commit)

Summary of changes:
 cmake                            |    2 +-
 src/BridgeManagerListenerMgr.cpp |   15 +--
 src/BridgeManagerListenerMgr.h   |    1 -
 test/BridgeManagerListenerI.cpp  |   10 +-
 test/BridgeManagerListenerI.h    |    8 +
 test/CMakeLists.txt              |   10 +-
 test/TestBridging.cpp            |  348 ++++++++++++++++++++++++++++++--------
 test/TestCommandDriver.cpp       |   18 ++
 test/TestCommandDriver.h         |   24 +++
 test/channel_driver              |    2 +-
 10 files changed, 347 insertions(+), 91 deletions(-)
 create mode 100644 test/TestCommandDriver.cpp
 create mode 100644 test/TestCommandDriver.h


- Log -----------------------------------------------------------------
commit 8cc90fe5811390f59f4d4a0ec4ea964bd78b07ca
Author: Brent Eagles <beagles at digium.com>
Date:   Tue Sep 14 15:42:09 2010 -0230

    Basic bridging tests succeed.
     - added the command driver required to interface with the test channel driver
     - modified a few of the tests to use different communicators to allow for
       calls to complete to test objects after bridge service objects were shutdown.
    
    Refactored the test infrastructure to make it a little easier to read
    and write.
    
    Fixed a bug in the Bridge manager listener manager which still had
    a class member that hid the parent class's member.
    
    (cmake and channel_driver submodules have been updated with this commit)

diff --git a/cmake b/cmake
index 6fea9c4..22dfc54 160000
--- a/cmake
+++ b/cmake
@@ -1 +1 @@
-Subproject commit 6fea9c4ced66f0dcac70076b7f63d1f429fa2a7d
+Subproject commit 22dfc54c50affccc06f25b6391b0bbd71f7da568
diff --git a/src/BridgeManagerListenerMgr.cpp b/src/BridgeManagerListenerMgr.cpp
index e8e6ff0..107ad2e 100644
--- a/src/BridgeManagerListenerMgr.cpp
+++ b/src/BridgeManagerListenerMgr.cpp
@@ -17,26 +17,17 @@ AsteriskSCF::BridgeService::BridgeManagerListenerMgr::BridgeManagerListenerMgr(c
 
 void AsteriskSCF::BridgeService::BridgeManagerListenerMgr::bridgeCreated(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx& bridge)
 {
-    if(mPublisher)
-    {
-        mPublisher->bridgeCreated(mPrx, bridge);
-    }
+    mPublisher->bridgeCreated(mPrx, bridge);
 }
 
 void AsteriskSCF::BridgeService::BridgeManagerListenerMgr::stopped()
 {
-    if(mPublisher)
-    {
-        mPublisher->stopped(mPrx);
-    }
+    mPublisher->stopped(mPrx);
 }
 
 void AsteriskSCF::BridgeService::BridgeManagerListenerMgr::stopping()
 {
-    if(mPublisher)
-    {
-        mPublisher->stopping(mPrx);
-    }
+    mPublisher->stopping(mPrx);
 }
 
 void AsteriskSCF::BridgeService::BridgeManagerListenerMgr::setSource(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& mgr)
diff --git a/src/BridgeManagerListenerMgr.h b/src/BridgeManagerListenerMgr.h
index eb46b81..8c8dc6c 100644
--- a/src/BridgeManagerListenerMgr.h
+++ b/src/BridgeManagerListenerMgr.h
@@ -30,7 +30,6 @@ namespace BridgeService
         void setSource(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& source);
     private:
         AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx mPrx;
-        AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerListenerPrx mPublisher;
     };
 
     typedef IceUtil::Handle<BridgeManagerListenerMgr> BridgeManagerListenerMgrPtr;
diff --git a/test/BridgeManagerListenerI.cpp b/test/BridgeManagerListenerI.cpp
index 9dd3364..0c33a89 100644
--- a/test/BridgeManagerListenerI.cpp
+++ b/test/BridgeManagerListenerI.cpp
@@ -1,20 +1,24 @@
 #include "BridgeManagerListenerI.h"
 
-BridgeManagerListenerI::BridgeManagerListenerI()
+BridgeManagerListenerI::BridgeManagerListenerI() :
+    mCreated(0),
+    mStopped(0),
+    mStopping(0)
 {
 }
 
 void BridgeManagerListenerI::bridgeCreated(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& manager,
         const AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx& bridge, const Ice::Current&)
 {
+    ++mCreated;
 }
 
 void BridgeManagerListenerI::stopped(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& manager, const Ice::Current&)
 {
-    std::cerr << __FILE__ << ":" <<  __FUNCTION__ << " from " << manager->ice_toString() << std::endl;
+    ++mStopped;
 }
 
 void BridgeManagerListenerI::stopping(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& manager, const Ice::Current&)
 {
-    std::cerr << __FILE__ << ":" <<  __FUNCTION__ << " from " << manager->ice_toString() << std::endl;
+    ++mStopping;
 }
diff --git a/test/BridgeManagerListenerI.h b/test/BridgeManagerListenerI.h
index 49eab4c..ebb9570 100644
--- a/test/BridgeManagerListenerI.h
+++ b/test/BridgeManagerListenerI.h
@@ -17,6 +17,14 @@ public:
             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&);
+
+    unsigned long createCalls() { return mCreated; }
+    unsigned long stoppedCalls() { return mStopped; }
+    unsigned long stoppingCalls() { return mStopping; }
+private:
+    unsigned long mCreated;
+    unsigned long mStopped;
+    unsigned long mStopping;
 };
 
 typedef IceUtil::Handle<BridgeManagerListenerI> BridgeManagerListenerIPtr;
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index ced80df..1e15496 100755
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -15,7 +15,8 @@ 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 TestCommandDriver.cpp)
+hydra_component_add_file(bridging_unit_test TestCommandDriver.h)
 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")
@@ -29,6 +30,13 @@ 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)
+#
+# "Kind of a hack", it's the standard way to add this kind of thing, but
+# we seem to be wrapping lots of stuff. According to a post somewhere this
+# works because cmake tracks anything it builds and this library is built
+# earlier in this file.
+#
+list(APPEND target_libs "test_channel_lib")
 hydra_component_add_boost_libraries(bridging_unit_test thread)
 hydra_component_build_standalone(bridging_unit_test)
 hydra_component_install(bridging_unit_test RUNTIME bin "Bridging Test Driver." Core)
diff --git a/test/TestBridging.cpp b/test/TestBridging.cpp
index b24cc6f..fd5acb4 100644
--- a/test/TestBridging.cpp
+++ b/test/TestBridging.cpp
@@ -18,12 +18,12 @@
 #include <SessionCommunications/Bridging/BridgingIf.h>
 #include <Media/MediaIf.h>
 #include <TestEndpoint.h>
-#include <ConsoleDriver.h>
 
 #include "IceStormCollocator.h"
 #include "BridgeManagerListenerI.h"
 #include "BridgeListenerI.h"
 #include "SessionListenerI.h"
+#include "TestCommandDriver.h"
 
 #include <Ice/Ice.h>
 
@@ -58,6 +58,156 @@ struct GlobalTestFixture
 
 BOOST_GLOBAL_FIXTURE(GlobalTestFixture);
 
+//
+// Just a little helper function to help deal with the setting up a servant and getting a proxy.
+//
+template <class T>
+void addServant(T& proxy, const Ice::ObjectAdapterPtr& adapter, const Ice::ObjectPtr& servant, const Ice::Identity& t)
+{
+    proxy = T::uncheckedCast(adapter->add(servant, t));
+}
+
+//
+// Wrapper around IceStorm test usage.
+//
+class UseIceStorm
+{
+public:
+    UseIceStorm(const std::string& instanceName = "TestStorm", const std::string& mgrPort = "55555",
+            const std::string& pubPort = "55556")
+    {
+        Ice::PropertiesPtr p = Ice::createProperties();
+        p->setProperty(instanceName + ".TopicManager.Endpoints","default -p " + mgrPort);
+        p->setProperty(instanceName + ".Publish.Endpoints", "default -p " + pubPort);
+        p->setProperty(instanceName + ".InstanceName", instanceName);
+        p->setProperty(instanceName + ".Transient", "1");
+    
+        mInst = IceStormInstance::getInstance();
+        mInst->start("TestStorm", p);
+    }
+
+    ~UseIceStorm()
+    {
+        try
+        {
+            mInst->stop();
+        }
+        catch(...)
+        {
+        }
+    }
+    
+private:
+    IceStormInstancePtr mInst;
+};
+
+class IceEnvironment
+{
+public:
+    IceEnvironment()
+    {
+        Ice::PropertiesPtr 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;
+        mCommunicator = Ice::initialize(initData);
+    }
+
+    Ice::CommunicatorPtr communicator()
+    {
+        return mCommunicator;
+    }
+
+    ~IceEnvironment()
+    {
+        try
+        {
+            mCommunicator->destroy();
+        }
+        catch(...)
+        {
+        }
+    }
+
+    Ice::Identity strToIdent(const std::string& s)
+    {
+        return mCommunicator->stringToIdentity(s);
+    }
+
+private:
+    Ice::CommunicatorPtr mCommunicator;
+};
+
+class TestChannelDriver
+{
+public:
+    TestChannelDriver(const std::string& adapterName = "TestChannel", const std::string& id = "Test.Channel")
+    {
+        Ice::PropertiesPtr p = Ice::createProperties();
+        p->setProperty("TopicManager.Proxy", "TestStorm/TopicManager:default -p 55555");
+        p->setProperty(adapterName + ".Endpoints", "default -p 55559");
+
+        Ice::InitializationData initData;
+        initData.properties = p;
+        mCommunicator = Ice::initialize(initData);
+        mAdapter = mCommunicator->createObjectAdapter(adapterName);
+        mAdapter->activate();
+        mDriver = new TestCommandDriver;
+        mLocator = AsteriskSCF::TestUtil::TestEndpoint::initialize(mDriver, mAdapter, id);
+        addServant(mLocatorPrx, mAdapter, mLocator, mCommunicator->stringToIdentity(id));
+    }
+
+    ~TestChannelDriver()
+    {
+        try
+        {
+            mCommunicator->destroy();
+        }
+        catch(...)
+        {
+        }
+    }
+
+    AsteriskSCF::Core::Routing::V1::EndpointLocatorPrx locator()
+    {
+        return mLocatorPrx;
+    }
+
+    AsteriskSCF::SessionCommunications::V1::SessionPrx getSession(const std::string& id)
+    {
+        AsteriskSCF::Core::Endpoint::V1::EndpointSeq eps = mLocatorPrx->lookup(id);
+        assert(eps.size() > 0);
+        return AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx::checkedCast(eps[0])->createSession(id, 0);
+    }
+
+    CommandsPtr commands()
+    {
+        return mDriver->commands();
+    }
+
+private:
+    Ice::CommunicatorPtr mCommunicator;
+    Ice::ObjectAdapterPtr mAdapter;
+    AsteriskSCF::Core::Routing::V1::EndpointLocatorPtr mLocator;
+    AsteriskSCF::Core::Routing::V1::EndpointLocatorPrx mLocatorPrx;
+    TestCommandDriverPtr mDriver;
+};
+
+bool find(const std::vector<std::string>& list, const std::string& value)
+{
+    for(std::vector<std::string>::const_iterator i = list.begin(); i != list.end(); ++i)
+    {
+        if(i->find(value) != std::string::npos)
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
 /**
  * Implement our own main to intercept the command line args.
  * (A default main() is provided if we hadn't set BOOST_TEST_NO_MAIN at the top of file.)
@@ -70,50 +220,36 @@ int BOOST_TEST_CALL_DECL main( int argc, char* argv[] )
    return ::boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
 }
 
+//
+// Tests basic initialization.
+//
 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);
+    UseIceStorm iceStorm;
     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);
+        IceEnvironment bridgeEnv;
+        IceEnvironment testEnv;
         try
         {
-            Ice::ObjectAdapterPtr testAdapter = communicator->createObjectAdapter("TestUtilAdapter");
+            Ice::ObjectAdapterPtr testAdapter = testEnv.communicator()->createObjectAdapter("TestUtilAdapter");
+            testAdapter->activate();
             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::BridgeManagerListenerPrx listenerPrx;
+            addServant(listenerPrx, testAdapter, servant, testEnv.strToIdent("testBridgeManagerListener"));
+
+            Ice::ObjectAdapterPtr bridgeAdapter = bridgeEnv.communicator()->createObjectAdapter("TestBridgeAdapter");
+            bridgeAdapter->activate();
             AsteriskSCF::BridgeService::BridgeManagerImplPtr mgrServant(
                 new AsteriskSCF::BridgeService::BridgeManagerImpl(bridgeAdapter, "TestBridgeManager"));
-            AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx mgrPrx(
-                AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx::uncheckedCast(
-                    testAdapter->add(mgrServant,
-                            communicator->stringToIdentity("testBridgeManager")
-                    )
-                )
-            );
+            AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx mgrPrx;
+            addServant(mgrPrx, bridgeAdapter, mgrServant, bridgeEnv.strToIdent("testBridgeManager"));
             mgrServant->setPublishProxy(mgrPrx);
             mgrPrx->addListener(listenerPrx);
-            
+            BOOST_CHECK(servant->stoppingCalls() == 0);
+            BOOST_CHECK(servant->stoppedCalls() == 0);
             mgrPrx->shutdown();
+            BOOST_CHECK(servant->stoppingCalls() == 1);
         }
         catch(const Ice::Exception& ex)
         {
@@ -124,64 +260,50 @@ BOOST_AUTO_TEST_CASE(CreateBridgeFactory)
         {
             BOOST_CHECK(false);
         }
-        communicator->destroy();
     }
     catch(...)
     {
         BOOST_CHECK(false);
     }
-
-    iceStorm->stop();
-
 }
 
+//
+// Tests simple bridge creation.
+//
 BOOST_AUTO_TEST_CASE(CreateEmptyBridge)
 {
-    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);
+    UseIceStorm iceStorm;
     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);
+        IceEnvironment testEnv;
+        IceEnvironment bridgeEnv;
         try
         {
-            Ice::ObjectAdapterPtr testAdapter = communicator->createObjectAdapter("TestUtilAdapter");
+            Ice::ObjectAdapterPtr testAdapter = testEnv.communicator()->createObjectAdapter("TestUtilAdapter");
+            testAdapter->activate();
             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::BridgeManagerListenerPrx listenerPrx;
+            addServant(listenerPrx, testAdapter, servant, testEnv.strToIdent("testBridgeManagerListener"));
+
+            Ice::ObjectAdapterPtr bridgeAdapter = bridgeEnv.communicator()->createObjectAdapter("TestBridgeAdapter");
+            bridgeAdapter->activate();
             AsteriskSCF::BridgeService::BridgeManagerImplPtr mgrServant(
                 new AsteriskSCF::BridgeService::BridgeManagerImpl(bridgeAdapter, "TestBridgeManager"));
-            AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx mgrPrx(
-                AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx::uncheckedCast(
-                    testAdapter->add(mgrServant,
-                            communicator->stringToIdentity("testBridgeManager")
-                    )
-                )
-            );
+            AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx mgrPrx;
+            addServant(mgrPrx, bridgeAdapter, mgrServant, bridgeEnv.strToIdent("testBridgeManager"));
             mgrServant->setPublishProxy(mgrPrx);
             mgrPrx->addListener(listenerPrx);
-
+            BOOST_CHECK(servant->stoppingCalls() == 0);
+            BOOST_CHECK(servant->stoppedCalls() == 0);
+            BOOST_CHECK(servant->createCalls() == 0);
             AsteriskSCF::SessionCommunications::V1::SessionSeq sessions;
             AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx bridge(mgrPrx->createBridge(sessions, 0));
-            
             mgrPrx->shutdown();
+            bridgeEnv.communicator()->waitForShutdown();
+            BOOST_CHECK(servant->stoppingCalls() == 1);
+            BOOST_CHECK(servant->stoppedCalls() == 1);
+            BOOST_CHECK(servant->createCalls() == 1);
+
         }
         catch(const Ice::Exception& ex)
         {
@@ -192,15 +314,97 @@ BOOST_AUTO_TEST_CASE(CreateEmptyBridge)
         {
             BOOST_CHECK(false);
         }
-        communicator->destroy();
     }
     catch(...)
     {
         BOOST_CHECK(false);
     }
+}
+
+//
+// Employs the test channel driver to create a *live* test.
+//
+BOOST_AUTO_TEST_CASE(SimpleBridgingTest)
+{
+    UseIceStorm iceStorm;
+    try
+    {
+        IceEnvironment testEnv;
+        IceEnvironment bridgeEnv;
+        try
+        {
+            Ice::ObjectAdapterPtr testAdapter = testEnv.communicator()->createObjectAdapter("TestUtilAdapter");
+            testAdapter->activate();
+            BridgeManagerListenerIPtr servant = new BridgeManagerListenerI;
+            AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerListenerPrx listenerPrx;
+            addServant(listenerPrx, testAdapter, servant, testEnv.strToIdent("testBridgeManagerListener"));
 
-    iceStorm->stop();
+            Ice::ObjectAdapterPtr bridgeAdapter = bridgeEnv.communicator()->createObjectAdapter("TestBridgeAdapter");
+            bridgeAdapter->activate();
+            AsteriskSCF::BridgeService::BridgeManagerImplPtr mgrServant(
+                new AsteriskSCF::BridgeService::BridgeManagerImpl(bridgeAdapter, "TestBridgeManager"));
+            AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx mgrPrx;
+            addServant(mgrPrx, bridgeAdapter, mgrServant, bridgeEnv.strToIdent("testBridgeManager"));
+            mgrServant->setPublishProxy(mgrPrx);
+            mgrPrx->addListener(listenerPrx);
+            BOOST_CHECK(servant->stoppingCalls() == 0);
+            BOOST_CHECK(servant->stoppedCalls() == 0);
+            BOOST_CHECK(servant->createCalls() == 0);
+            AsteriskSCF::SessionCommunications::V1::SessionSeq sessions;
+            AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx bridge(mgrPrx->createBridge(sessions, 0));
+            TestChannelDriver channel;
+            
+            AsteriskSCF::SessionCommunications::V1::SessionPrx a = channel.getSession("311");
+            AsteriskSCF::SessionCommunications::V1::SessionPrx b = channel.getSession("312");
+            sessions.push_back(a);
+            sessions.push_back(b);
+            //
+            // precondition checks for test validity.
+            //
+            std::string idA = testEnv.communicator()->identityToString(a->ice_getIdentity());
+            std::string idB = testEnv.communicator()->identityToString(b->ice_getIdentity());
+            std::vector<std::string> log;
+            channel.commands()->getlog(idA, log);
+            BOOST_CHECK(!find(log, "start"));
+            channel.commands()->getlog(idB, log);
+            BOOST_CHECK(!find(log, "start"));
+            
+            bridge->addSessions(sessions);
+            channel.commands()->getlog(idA, log);
+            BOOST_CHECK(find(log, "start"));
+            channel.commands()->getlog(idB, log);
+            BOOST_CHECK(find(log, "start"));
 
+            //
+            // Should result in a media hookup!
+            //
+            channel.commands()->answer(idA);
+            channel.commands()->answer(idB);
+            
+            mgrPrx->shutdown();
+            bridgeEnv.communicator()->waitForShutdown();
+            BOOST_CHECK(servant->stoppingCalls() == 1);
+            BOOST_CHECK(servant->stoppedCalls() == 1);
+            BOOST_CHECK(servant->createCalls() == 1);
+            channel.commands()->getlog(idA, log);
+            BOOST_CHECK(find(log, "stop"));
+            channel.commands()->getlog(idB, log);
+            BOOST_CHECK(find(log, "stop"));
+        }
+        catch(const Ice::Exception& ex)
+        {
+            std::cerr << ex << std::endl;
+            BOOST_CHECK(false);
+        }
+        catch(...)
+        {
+            BOOST_CHECK(false);
+        }
+    }
+    catch(...)
+    {
+        BOOST_CHECK(false);
+    }
 }
 
 #if 0
diff --git a/test/TestCommandDriver.cpp b/test/TestCommandDriver.cpp
new file mode 100644
index 0000000..4f45af5
--- /dev/null
+++ b/test/TestCommandDriver.cpp
@@ -0,0 +1,18 @@
+/*
+ * Asterisk Scalable Communications Framework
+ *
+ * Copyright (C) 2010 -- Digium, Inc.
+ *
+ * All rights reserved.
+ */
+#include "TestCommandDriver.h"
+
+TestCommandDriver::TestCommandDriver()
+{
+}
+
+void TestCommandDriver::setHandler(const CommandsPtr& cmdInterface)
+{
+    mCommands = cmdInterface;
+}
+
diff --git a/test/TestCommandDriver.h b/test/TestCommandDriver.h
new file mode 100644
index 0000000..bb66cf3
--- /dev/null
+++ b/test/TestCommandDriver.h
@@ -0,0 +1,24 @@
+/*
+ * Asterisk Scalable Communications Framework
+ *
+ * Copyright (C) 2010 -- Digium, Inc.
+ *
+ * All rights reserved.
+ */
+#pragma once
+
+#include <Commands.h>
+
+class TestCommandDriver : public virtual CommandDriver
+{
+public:
+    TestCommandDriver();
+
+    void setHandler(const CommandsPtr& cmdInterface);
+
+    CommandsPtr commands() { return  mCommands; }
+private:
+    CommandsPtr mCommands;
+};
+
+typedef IceUtil::Handle<TestCommandDriver> TestCommandDriverPtr;
diff --git a/test/channel_driver b/test/channel_driver
index 5fc5fcd..10f9386 160000
--- a/test/channel_driver
+++ b/test/channel_driver
@@ -1 +1 @@
-Subproject commit 5fc5fcdb39d379b76a33eeff91a378f4447714b9
+Subproject commit 10f938698e0c42155dfd3630ef84a98ba578448c

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


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list