[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
Wed Oct 6 09:47:15 CDT 2010


branch "master" has been updated
       via  40a21c95e3e5b252ca2c4a41bc2636e2aacb4746 (commit)
      from  f05bd336a9a66fe8a5362d35b85c06092dfaf494 (commit)

Summary of changes:
 src/CMakeLists.txt         |    6 +-
 src/Service.cpp            |   58 +++--
 test/CMakeLists.txt        |   30 +--
 test/TestBridging.cpp      |  628 ++++++++++++++++++++------------------------
 test/TestCommandDriver.cpp |    2 +-
 test/TestCommandDriver.h   |   11 +-
 test/channel_driver        |    2 +-
 7 files changed, 336 insertions(+), 401 deletions(-)


- Log -----------------------------------------------------------------
commit 40a21c95e3e5b252ca2c4a41bc2636e2aacb4746
Author: Brent Eagles <beagles at digium.com>
Date:   Wed Oct 6 12:00:10 2010 -0230

    Convert bridge and bridge test to icebox services.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index bb897a3..d59b09a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -16,6 +16,7 @@ hydra_component_add_file(bridgeservice BridgeManagerImpl.cpp)
 hydra_component_add_file(bridgeservice MediaSplicer.h)
 hydra_component_add_file(bridgeservice MediaSplicer.cpp)
 hydra_component_add_ice_libraries(bridgeservice IceStorm)
+hydra_component_add_ice_libraries(bridgeservice IceBox)
 hydra_component_add_boost_libraries(bridgeservice thread)
 
 if(NOT logger_dir)
@@ -24,6 +25,5 @@ endif()
 include_directories(${logger_dir}/common)
 include_directories(${logger_dir}/client/src)
 
-hydra_component_build_standalone(bridgeservice)
-target_link_libraries(bridgeservice logging-client)
-hydra_component_install(bridgeservice RUNTIME bin "Bridge Service." Core)
+hydra_component_build_icebox(bridgeservice)
+
diff --git a/src/Service.cpp b/src/Service.cpp
index d2d5530..9b28baf 100644
--- a/src/Service.cpp
+++ b/src/Service.cpp
@@ -8,6 +8,7 @@
 #include "BridgeManagerImpl.h"
 
 #include <Ice/Ice.h>
+#include <IceBox/IceBox.h>
 #include <IceStorm/IceStorm.h>
 
 #include "Core/Discovery/ServiceLocatorIf.h"
@@ -22,66 +23,73 @@ Logger &lg = getLoggerFactory().getLogger(
         "AsteriskSCF.BridgeService");
 }
 
-class BridgingApp : public Ice::Application
+static const std::string ManagerName = "BridgeManager";
+
+class BridgingApp : public IceBox::Service
 {
 public:
     BridgingApp();
 
 protected:
-    int run(int, char*[]);
-    void interruptCallback(int);
+    void start(const std::string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args);
+    void stop();
 
 private:
     /**
      * A proxy to the service locator manager for the bridge manager service.
      */
     AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx mServiceManagement;
+    Ice::ObjectAdapterPtr mAdapter;
 };
 
 BridgingApp::BridgingApp()
 {
 }
 
-static const std::string ManagerName = "BridgeManager";
-
-int BridgingApp::run(int, char*[])
+void BridgingApp::start(const std::string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args)
 {
-    callbackOnInterrupt();
-
     lg(Debug) << "Launching AsteriskSCF Session-Oriented Bridging Service." ;
 
-    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("AsteriskSCF.BridgeService");
+    std::string adapterName;
+    if(name.size() == 0)
+    {
+        adapterName = "BridgeService";
+    }
+    else
+    {
+        adapterName = name + ".BridgeService";
+    }
+    mAdapter = communicator->createObjectAdapter(adapterName);
 
     // setup the logger
-    ConfiguredIceLoggerPtr iceLogger = createIceLogger(adapter);
+    ConfiguredIceLoggerPtr iceLogger = createIceLogger(mAdapter);
     getLoggerFactory().setLogOutput(iceLogger->getLogger());
 
-    AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPtr servant(new AsteriskSCF::BridgeService::BridgeManagerImpl(adapter, ManagerName));
+    AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPtr servant(new AsteriskSCF::BridgeService::BridgeManagerImpl(mAdapter, ManagerName));
     AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx s(
-        AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx::uncheckedCast(adapter->add(servant, communicator()->stringToIdentity(ManagerName))
+        AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx::uncheckedCast(mAdapter->add(servant, communicator->stringToIdentity(ManagerName))
         )
     );
-    adapter->activate();
+    mAdapter->activate();
 
-    AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx management = AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx::checkedCast(communicator()->propertyToProxy("ServiceLocatorManagementProxy"));
-    mServiceManagement = AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx::uncheckedCast(management->addService(s, "BridgeManagerService"));
+    AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx management = 
+        AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx::checkedCast(communicator->propertyToProxy("ServiceLocatorManagementProxy"));
+    mServiceManagement = AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx::uncheckedCast(management->addService(s, adapterName));
     AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr params = new AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams();
     params->category = AsteriskSCF::SessionCommunications::Bridging::V1::BridgeServiceDiscoveryCategory;
     mServiceManagement->addLocatorParams(params, "");
-
-    communicator()->waitForShutdown();
-
-    return EXIT_SUCCESS;
 }
 
-void BridgingApp::interruptCallback(int)
+void BridgingApp::stop()
 {
    mServiceManagement->unregister();
-    _exit(EXIT_SUCCESS);
+   mAdapter->deactivate();
 }
 
-int main(int argc, char* argv[])
-{
-    BridgingApp app;
-    return app.main(argc, argv);
+
+extern "C" {
+    HYDRA_ICEBOX_EXPORT ::IceBox::Service* create(Ice::CommunicatorPtr communicator)
+    {
+        return new BridgingApp;
+    }
 }
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index aea9152..31b63c4 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,14 +1,12 @@
+add_subdirectory(channel_driver/local_slice)
 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_slice(bridging_unit_test CommandsIf)
 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)
@@ -17,26 +15,9 @@ 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")
-hydra_component_add_file(bridging_unit_test "../src/BridgeManagerImpl.h")
-hydra_component_add_file(bridging_unit_test "../src/MediaSplicer.cpp")
-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/BridgeManagerListenerMgr.cpp")
-hydra_component_add_file(bridging_unit_test "../src/BridgeManagerListenerMgr.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)
-#
-# "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)
 
 if(NOT logger_dir)
@@ -45,10 +26,5 @@ endif()
 include_directories(${logger_dir}/common)
 include_directories(${logger_dir}/client/src)
 
-hydra_component_build_standalone(bridging_unit_test)
-
-target_link_libraries(bridging_unit_test logging-client)
-
-hydra_component_install(bridging_unit_test RUNTIME bin "Bridging Test Driver." Core)
-
+hydra_component_build_icebox(bridging_unit_test)
 boost_add_test(bridging_unit_test)
diff --git a/test/TestBridging.cpp b/test/TestBridging.cpp
index 9fa711e..7f5694d 100644
--- a/test/TestBridging.cpp
+++ b/test/TestBridging.cpp
@@ -6,8 +6,6 @@
 * All rights reserved.
 */
 #define BOOST_TEST_DYN_LINK
-#define BOOST_TEST_MODULE BridgingTestSuite
-#define BOOST_TEST_NO_MAIN
 
 #include <BridgeImpl.h>
 #include <BridgeManagerImpl.h>
@@ -17,102 +15,90 @@
 #include <SessionCommunications/SessionCommunicationsIf.h>
 #include <SessionCommunications/Bridging/BridgingIf.h>
 #include <Media/MediaIf.h>
-#include <TestEndpoint.h>
 
-#include "IceStormCollocator.h"
 #include "BridgeManagerListenerI.h"
 #include "BridgeListenerI.h"
 #include "SessionListenerI.h"
 #include "TestCommandDriver.h"
 
 #include <Ice/Ice.h>
+#include <IceBox/IceBox.h>
 
 /* Cache the command line arguments so that Ice can be initialized within the global fixture. */
-struct ArgCacheType
+
+class TestEnvironment : public IceUtil::Shared
 {
 public:
-   int argc;
-   char **argv;
-};
-static ArgCacheType mCachedArgs;
+    TestEnvironment(const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args) :
+        mCommunicator(communicator),
+        mArgs(args),
+        mArgv(0)
+    {
+        const char* fakeName = "BRIDGE_TEST_SERVICE";
+        mArgc = args.size() + 1;
+        mArgv = new char*[mArgc];
+        mArgv[0] = new char[strlen(fakeName) + 1];
+        strcpy(mArgv[0], fakeName);
+        for(size_t i = 1; i < mArgc; ++i)
+        {
+            mArgv[i] = new char[args[i].size() + 1];
+            strcpy(mArgv[i], args[i].c_str());
+        }
+    }
 
-/**
- * A global fixture for Ice initialization.
- * Provides setup/teardown for the entire set of tests.
- */
-struct GlobalTestFixture
-{
-   GlobalTestFixture()
-   {
-      BOOST_TEST_MESSAGE("Setting up bridging test fixture");
-
-      ::boost::debug::detect_memory_leaks(false);
-      ::boost::unit_test::unit_test_log.set_stream( std::cout );
-   } 
-
-   ~GlobalTestFixture()
-   {
-      BOOST_TEST_MESSAGE("Tearing down bridging test fixture");
-   }
-};
+    ~TestEnvironment()
+    {
+        if(mArgc > 0)
+        {
+            for(size_t i = 0; i < mArgc; ++i)
+            {
+                delete[] mArgv[i];
+            }
+            delete[] mArgv;
+        }
+    }
 
-BOOST_GLOBAL_FIXTURE(GlobalTestFixture);
+    size_t argc() 
+    {
+        return mArgc;
+    }
 
-//
-// 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));
-}
+    char** argv()
+    {
+        return mArgv;
+    }
 
-//
-// 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::CommunicatorPtr communicator()
     {
-        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);
+        return mCommunicator;
     }
 
-    ~UseIceStorm()
+    Ice::PropertiesPtr properties()
     {
-        try
-        {
-            mInst->stop();
-        }
-        catch(...)
-        {
-        }
+        return mCommunicator->getProperties();
     }
-    
+
 private:
-    IceStormInstancePtr mInst;
+    Ice::CommunicatorPtr mCommunicator;
+    Ice::StringSeq mArgs;
+
+    size_t mArgc;
+    char** mArgv;
 };
+typedef IceUtil::Handle<TestEnvironment> TestEnvironmentPtr;
+
+//
+// Global!! Yes, I know it sucks, but its the most direct route to getting a proper test environment initialization.
+//
+TestEnvironmentPtr globalTestEnvironment;
 
 class IceEnvironment
 {
 public:
-    IceEnvironment()
+    IceEnvironment(const Ice::PropertiesPtr& properties)
     {
-        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;
+        initData.properties = properties;
         mCommunicator = Ice::initialize(initData);
     }
 
@@ -141,26 +127,22 @@ private:
     Ice::CommunicatorPtr mCommunicator;
 };
 
-class TestChannelDriver
+class TestChannelWrapper
 {
 public:
-    TestChannelDriver(const std::string& adapterName = "TestChannel", const std::string& id = "Test.Channel")
+    TestChannelWrapper(const Ice::PropertiesPtr& properties, 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;
+        initData.properties = properties;
         mCommunicator = Ice::initialize(initData);
-        mAdapter = mCommunicator->createObjectAdapter(adapterName);
-        mAdapter->activate();
         mDriver = new TestCommandDriver;
-        mLocator = AsteriskSCF::TestUtil::TestEndpoint::create(mDriver, mAdapter, id);
-        addServant(mLocatorPrx, mAdapter, mLocator, mCommunicator->stringToIdentity(id));
+        AsteriskSCF::TestChannel::V1::CommandsPrx prx = AsteriskSCF::TestChannel::V1::CommandsPrx::checkedCast(mCommunicator->propertyToProxy("Commands.Proxy")); 
+        mDriver->setHandler(prx);
+        mLocatorPrx = 
+            AsteriskSCF::Core::Routing::V1::EndpointLocatorPrx::checkedCast(mCommunicator->propertyToProxy("TestChannel.Proxy"));
     }
 
-    ~TestChannelDriver()
+    ~TestChannelWrapper()
     {
         try
         {
@@ -187,15 +169,13 @@ public:
         return session;
     }
 
-    CommandsPtr commands()
+    AsteriskSCF::TestChannel::V1::CommandsPrx 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;
 };
@@ -212,305 +192,275 @@ bool find(const std::vector<std::string>& list, const std::string& value)
     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.)
- * NOTE: Pass in --log_level=message to see the debug print statements.
- */
-int BOOST_TEST_CALL_DECL main( int argc, char* argv[] )
+//
+// 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)
 {
-   mCachedArgs.argc = argc;
-   mCachedArgs.argv = argv;
-   return ::boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
+    proxy = T::uncheckedCast(adapter->add(servant, t));
 }
 
-//
-// Tests basic initialization.
-//
-BOOST_AUTO_TEST_CASE(CreateBridgeFactory)
+class BridgeTester 
 {
-    UseIceStorm iceStorm;
-    try
+public:
+    BridgeTester(const TestEnvironmentPtr& env) :
+        mTestEnvironment(env)
+    {
+    }
+
+    TestEnvironmentPtr env() 
+    {
+        return mTestEnvironment;
+    }
+
+    //
+    // Tests simple bridge creation.
+    //
+    void createEmptyBridge()
     {
-        IceEnvironment bridgeEnv;
-        IceEnvironment testEnv;
         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"));
-
-            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);
-            mgrPrx->shutdown();
-            bridgeEnv.communicator()->waitForShutdown();
-            //
-            // Give IceStorm a chance to get the event to the listeners!
-            //
-            for(int i = 0; i < 3 && servant->stoppedCalls() < 1; ++i)
+            IceEnvironment testEnv(env()->properties());
+            try
             {
-                servant->wait(5000);
+                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"));
+
+                AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx mgrPrx = 
+                    AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx::checkedCast(testEnv.communicator()->propertyToProxy("TestBridge.Proxy"));
+                BOOST_CHECK(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));
+                bridge->shutdown();
+
+                BOOST_CHECK(servant->createCalls() == 1);
+            }
+            catch(const Ice::Exception& ex)
+            {
+                std::cerr << ex << std::endl;
+                BOOST_CHECK(false);
+            }
+            catch(...)
+            {
+                BOOST_CHECK(false);
             }
-            BOOST_CHECK(servant->stoppingCalls() == 1);
-        }
-        catch(const Ice::Exception& ex)
-        {
-            std::cerr << ex << std::endl;
-            BOOST_CHECK(false);
         }
         catch(...)
         {
             BOOST_CHECK(false);
         }
-    }
-    catch(...)
-    {
-        BOOST_CHECK(false);
-    }
-}
+    };
 
-//
-// Tests simple bridge creation.
-//
-BOOST_AUTO_TEST_CASE(CreateEmptyBridge)
-{
-    UseIceStorm iceStorm;
-    try
+    void simpleBridgingTest()
     {
-        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"));
-
-            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));
-            mgrPrx->shutdown();
-            bridgeEnv.communicator()->waitForShutdown();
-            //
-            // Give IceStorm a chance to get the event to the listeners!
-            //
-            for(int i = 0; i < 3 && servant->stoppedCalls() < 1; ++i)
+            IceEnvironment testEnv(env()->properties());
+            try
             {
-                servant->wait(5000);
+                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"));
+
+                AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx mgrPrx = 
+                    AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx::checkedCast(testEnv.communicator()->propertyToProxy("TestBridge.Proxy"));
+                BOOST_CHECK(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));
+                TestChannelWrapper channel(env()->properties());
+
+                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);
+                //
+                // Check for regression where the bridge was calling start on sessions.
+                //
+                channel.commands()->getlog(idA, log);
+                BOOST_CHECK(!find(log, "start"));
+                channel.commands()->getlog(idB, log);
+                BOOST_CHECK(!find(log, "start"));
+
+                a->start();
+                b->start();
+
+                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);
+                bridge->shutdown();
+
+                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);
             }
-            BOOST_CHECK(servant->stoppingCalls() == 1);
-            BOOST_CHECK(servant->stoppedCalls() == 1);
-            BOOST_CHECK(servant->createCalls() == 1);
-        }
-        catch(const Ice::Exception& ex)
-        {
-            std::cerr << ex << std::endl;
-            BOOST_CHECK(false);
         }
         catch(...)
         {
             BOOST_CHECK(false);
         }
-    }
-    catch(...)
-    {
-        BOOST_CHECK(false);
-    }
-}
+    };
 
-//
-// Employs the test channel driver to create a *live* test.
-//
-BOOST_AUTO_TEST_CASE(SimpleBridgingTest)
-{
-    UseIceStorm iceStorm;
-    try
+    void bridgeManagerListeners()
     {
-        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"));
-
-            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);
-            //
-            // Check for regression where the bridge was calling start on sessions.
-            //
-            channel.commands()->getlog(idA, log);
-            BOOST_CHECK(!find(log, "start"));
-            channel.commands()->getlog(idB, log);
-            BOOST_CHECK(!find(log, "start"));
-
-            a->start();
-            b->start();
-
-            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();
-            //
-            // Give IceStorm a chance to get the event to the listeners!
-            //
-            for(int i = 0; i < 3 && servant->stoppedCalls() < 1; ++i)
+            IceEnvironment testEnv(env()->properties());
+            TestChannelWrapper channel(env()->properties());
+            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"));
+
+                AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx mgrPrx = 
+                    AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx::checkedCast(testEnv.communicator()->propertyToProxy("TestBridge.Proxy"));
+                BOOST_CHECK(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));
+                servant->wait(5000);
+                BOOST_CHECK(servant->createCalls() == 1);
+                mgrPrx->removeListener(listenerPrx);
+                bridge = mgrPrx->createBridge(sessions, 0);
                 servant->wait(5000);
+                BOOST_CHECK(servant->createCalls() == 1);
+                mgrPrx->addListener(listenerPrx);
+                bridge = mgrPrx->createBridge(sessions, 0);
+                servant->wait(5000);
+                BOOST_CHECK(servant->createCalls() == 2);
+                bridge->shutdown();
+            }
+            catch(const Ice::Exception& ex)
+            {
+                std::cerr << ex << std::endl;
+                BOOST_CHECK(false);
+            }
+            catch(...)
+            {
+                BOOST_CHECK(false);
             }
-            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)
+        catch(...)
         {
-            std::cerr << ex << std::endl;
             BOOST_CHECK(false);
         }
-        catch(...)
+    };
+
+private:
+    TestEnvironmentPtr mTestEnvironment;
+};
+
+using namespace boost::unit_test;
+
+bool init_unit_test()
+{
+    boost::shared_ptr<BridgeTester> bridgeTester(new BridgeTester(globalTestEnvironment));
+    framework::master_test_suite().
+        add(BOOST_TEST_CASE(boost::bind(&BridgeTester::createEmptyBridge, bridgeTester)));
+    framework::master_test_suite().
+        add(BOOST_TEST_CASE(boost::bind(&BridgeTester::simpleBridgingTest, bridgeTester)));
+    framework::master_test_suite().
+        add(BOOST_TEST_CASE(boost::bind(&BridgeTester::bridgeManagerListeners, bridgeTester)));
+    return true;
+}
+
+class TestRunner : public IceUtil::Thread
+{
+public:
+    void run()
+    {
+        int argc = globalTestEnvironment->argc();
+        char** argv = globalTestEnvironment->argv();
+        ::boost::unit_test::unit_test_main(&init_unit_test, argc, argv);
+
+        Ice::InitializationData initData;
+        initData.properties = globalTestEnvironment->communicator()->getProperties();
+        Ice::CommunicatorPtr t = Ice::initialize(initData);
+        IceBox::ServiceManagerPrx mgr = IceBox::ServiceManagerPrx::checkedCast(t->propertyToProxy("IceBoxMgr.Proxy"));
+        if(mgr)
         {
-            BOOST_CHECK(false);
+            mgr->shutdown();
         }
     }
-    catch(...)
+};
+
+typedef IceUtil::Handle<TestRunner> TestRunnerPtr;
+
+class TestService : public IceBox::Service
+{
+public:
+    ~TestService()
     {
-        BOOST_CHECK(false);
     }
-}
 
+    void start(const std::string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args)
+    {
+        globalTestEnvironment = new TestEnvironment(communicator, args);
+        mRunner = new TestRunner;
+        mRunner->start();
+    }
 
-//
-// Employs the test channel driver to create a *live* test.
-//
-BOOST_AUTO_TEST_CASE(BridgeManagerListeners)
-{
-    UseIceStorm iceStorm;
-    try
+    void stop()
     {
-        IceEnvironment testEnv;
-        IceEnvironment bridgeEnv;
-        TestChannelDriver channel;
-        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"));
-
-            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));
-            servant->wait(5000);
-            BOOST_CHECK(servant->createCalls() == 1);
-            mgrPrx->removeListener(listenerPrx);
-            bridge = mgrPrx->createBridge(sessions, 0);
-            servant->wait(5000);
-            BOOST_CHECK(servant->createCalls() == 1);
-            mgrPrx->addListener(listenerPrx);
-            bridge = mgrPrx->createBridge(sessions, 0);
-            servant->wait(5000);
-            BOOST_CHECK(servant->createCalls() == 2);
-
-            mgrPrx->shutdown();
-            bridgeEnv.communicator()->waitForShutdown();
-            //
-            // Give IceStorm a chance to get the event to the listeners!
-            //
-            for(int i = 0; i < 3 && servant->stoppedCalls() < 1; ++i)
-            {
-                servant->wait(5000);
-            }
-            BOOST_CHECK(servant->stoppingCalls() == 1);
-            BOOST_CHECK(servant->stoppedCalls() == 1);
-        }
-        catch(const Ice::Exception& ex)
-        {
-            std::cerr << ex << std::endl;
-            BOOST_CHECK(false);
-        }
-        catch(...)
-        {
-            BOOST_CHECK(false);
-        }
     }
-    catch(...)
+
+private:
+    TestRunnerPtr mRunner;
+};
+
+extern "C" {
+    HYDRA_ICEBOX_EXPORT ::IceBox::Service* create(Ice::CommunicatorPtr communicator)
     {
-        BOOST_CHECK(false);
+        return new TestService;
     }
 }
diff --git a/test/TestCommandDriver.cpp b/test/TestCommandDriver.cpp
index 4f45af5..d08377a 100644
--- a/test/TestCommandDriver.cpp
+++ b/test/TestCommandDriver.cpp
@@ -11,7 +11,7 @@ TestCommandDriver::TestCommandDriver()
 {
 }
 
-void TestCommandDriver::setHandler(const CommandsPtr& cmdInterface)
+void TestCommandDriver::setHandler(const AsteriskSCF::TestChannel::V1::CommandsPrx& cmdInterface)
 {
     mCommands = cmdInterface;
 }
diff --git a/test/TestCommandDriver.h b/test/TestCommandDriver.h
index bb66cf3..61d9066 100644
--- a/test/TestCommandDriver.h
+++ b/test/TestCommandDriver.h
@@ -7,18 +7,19 @@
  */
 #pragma once
 
-#include <Commands.h>
+#include <CommandsIf.h>
+#include <IceUtil/Handle.h>
 
-class TestCommandDriver : public virtual CommandDriver
+class TestCommandDriver  : public IceUtil::Shared
 {
 public:
     TestCommandDriver();
 
-    void setHandler(const CommandsPtr& cmdInterface);
+    void setHandler(const AsteriskSCF::TestChannel::V1::CommandsPrx& cmdInterface);
 
-    CommandsPtr commands() { return  mCommands; }
+    AsteriskSCF::TestChannel::V1::CommandsPrx commands() { return  mCommands; }
 private:
-    CommandsPtr mCommands;
+    AsteriskSCF::TestChannel::V1::CommandsPrx mCommands;
 };
 
 typedef IceUtil::Handle<TestCommandDriver> TestCommandDriverPtr;
diff --git a/test/channel_driver b/test/channel_driver
index f32ea79..3b7128d 160000
--- a/test/channel_driver
+++ b/test/channel_driver
@@ -1 +1 @@
-Subproject commit f32ea798b60fff56d0f125912413dd7066ed313d
+Subproject commit 3b7128dd68b00ac105076983517f45d383777bec

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


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list