[asterisk-scf-commits] asterisk-scf/release/routing.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Feb 9 10:29:41 CST 2012


branch "master" has been updated
       via  1944bc82a8b2682bfb048f3b5ddf495971062f42 (commit)
      from  1d5be561dd2dd3a4fbfd671f797c31fc13731052 (commit)

Summary of changes:
 test/TestRouting.cpp |  171 ++++++++++++++++++++++----------------------------
 1 files changed, 76 insertions(+), 95 deletions(-)


- Log -----------------------------------------------------------------
commit 1944bc82a8b2682bfb048f3b5ddf495971062f42
Author: David M. Lee <dlee at digium.com>
Date:   Thu Feb 9 10:28:36 2012 -0600

    Pass exceptions on up to the test framework.
    
    Fixes set-but-not-used errors.

diff --git a/test/TestRouting.cpp b/test/TestRouting.cpp
index 5ef24cf..0f87888 100644
--- a/test/TestRouting.cpp
+++ b/test/TestRouting.cpp
@@ -65,124 +65,105 @@ struct GlobalIceFixture
         ::boost::debug::detect_memory_leaks(false);
         ::boost::unit_test::unit_test_log.set_stream( std::cout );
 
-        int status = 0;
-        try
-        {
-            // Set up incoming adapter. This is where we'll publish our proxies.
-            SharedTestData::instance.communicatorIn = IceBoxTestEnv.communicator;
-
-            Ice::PropertiesPtr props = SharedTestData::instance.communicatorIn->getProperties();
-            SharedTestData::instance.adapterIn = SharedTestData::instance.communicatorIn->createObjectAdapterWithEndpoints("TestRoutingAdapterIn", "default -h 127.0.0.1 -p 10070");
+        // Set up incoming adapter. This is where we'll publish our proxies.
+        SharedTestData::instance.communicatorIn = IceBoxTestEnv.communicator;
 
-            // Serve up our own EndpointLocator, since we're emulating a channel.
-            MockEndpointLocator *locator = new MockEndpointLocator();
-            SharedTestData::instance.endpointLocator = locator;
-            SharedTestData::instance.adapterIn->add(SharedTestData::instance.endpointLocator, SharedTestData::instance.communicatorIn->stringToIdentity(LocatorObjectId));
+        Ice::PropertiesPtr props = SharedTestData::instance.communicatorIn->getProperties();
+        SharedTestData::instance.adapterIn = SharedTestData::instance.communicatorIn->createObjectAdapterWithEndpoints("TestRoutingAdapterIn", "default -h 127.0.0.1 -p 10070");
 
-            SharedTestData::instance.adapterIn->activate();
+        // Serve up our own EndpointLocator, since we're emulating a channel.
+        MockEndpointLocator *locator = new MockEndpointLocator();
+        SharedTestData::instance.endpointLocator = locator;
+        SharedTestData::instance.adapterIn->add(SharedTestData::instance.endpointLocator, SharedTestData::instance.communicatorIn->stringToIdentity(LocatorObjectId));
 
-            // Now that the adapter has been activated, get a local proxy to our EndpointLocator.
-            Ice::ObjectPrx locatorObjectPrx = SharedTestData::instance.adapterIn->createDirectProxy(SharedTestData::instance.communicatorIn->stringToIdentity(LocatorObjectId));
-            SharedTestData::instance.endpointLocatorPrx = EndpointLocatorPrx::checkedCast(locatorObjectPrx);
+        SharedTestData::instance.adapterIn->activate();
 
-            // Now set up outgoing adapter. This will be used for proxies we want to call out to the
-            // the unit under test on.
-            Ice::InitializationData initData;
-            initData.properties = IceBoxTestEnv.communicator->getProperties();
-            SharedTestData::instance.communicatorOut = Ice::initialize(initData);
-            SharedTestData::instance.adapterOut = SharedTestData::instance.communicatorOut->createObjectAdapterWithEndpoints("TestRoutingAdapterOut", "default -h 127.0.0.1 -p 10071");
+        // Now that the adapter has been activated, get a local proxy to our EndpointLocator.
+        Ice::ObjectPrx locatorObjectPrx = SharedTestData::instance.adapterIn->createDirectProxy(SharedTestData::instance.communicatorIn->stringToIdentity(LocatorObjectId));
+        SharedTestData::instance.endpointLocatorPrx = EndpointLocatorPrx::checkedCast(locatorObjectPrx);
 
-            // Get ref to Routing Service's ComponentService interface. 
-            Ice::ObjectPrx componentObj = SharedTestData::instance.communicatorOut->propertyToProxy("RoutingComponent.Proxy");
-            SharedTestData::instance.componentService = ComponentServicePrx::uncheckedCast(componentObj);
+        // Now set up outgoing adapter. This will be used for proxies we want to call out to the
+        // the unit under test on.
+        Ice::InitializationData initData;
+        initData.properties = IceBoxTestEnv.communicator->getProperties();
+        SharedTestData::instance.communicatorOut = Ice::initialize(initData);
+        SharedTestData::instance.adapterOut = SharedTestData::instance.communicatorOut->createObjectAdapterWithEndpoints("TestRoutingAdapterOut", "default -h 127.0.0.1 -p 10071");
 
-            if (!SharedTestData::instance.componentService)
-            {
-                throw "Invalid ComponentService";
-            }
+        // Get ref to Routing Service's ComponentService interface. 
+        Ice::ObjectPrx componentObj = SharedTestData::instance.communicatorOut->propertyToProxy("RoutingComponent.Proxy");
+        SharedTestData::instance.componentService = ComponentServicePrx::uncheckedCast(componentObj);
 
-            SharedTestData::instance.componentTest = ComponentTestPrx::checkedCast(SharedTestData::instance.componentService, AsteriskSCF::System::Component::V1::ComponentTestFacet);
-            if (SharedTestData::instance.componentTest == 0)
-            {
-                BOOST_TEST_MESSAGE("No Component Test facet available. Some tests may be skipped.");
-            }
+        if (!SharedTestData::instance.componentService)
+        {
+            throw "Invalid ComponentService";
+        }
 
-            // Get ref to Routing Service EndpointLocator so we can test it. Getting direct for now, but
-            // need to test acquiring reference via ServiceLocator as well.
-            Ice::ObjectPrx locatorObj = SharedTestData::instance.communicatorOut->propertyToProxy("LocatorRegistry.Proxy");
-            SharedTestData::instance.locatorRegistry = LocatorRegistryPrx::uncheckedCast(locatorObj);
+        SharedTestData::instance.componentTest = ComponentTestPrx::checkedCast(SharedTestData::instance.componentService, AsteriskSCF::System::Component::V1::ComponentTestFacet);
+        if (SharedTestData::instance.componentTest == 0)
+        {
+            BOOST_TEST_MESSAGE("No Component Test facet available. Some tests may be skipped.");
+        }
 
-            if (!SharedTestData::instance.locatorRegistry)
-            {
-                throw "Invalid LocatorRegistry";
-            }
+        // Get ref to Routing Service EndpointLocator so we can test it. Getting direct for now, but
+        // need to test acquiring reference via ServiceLocator as well.
+        Ice::ObjectPrx locatorObj = SharedTestData::instance.communicatorOut->propertyToProxy("LocatorRegistry.Proxy");
+        SharedTestData::instance.locatorRegistry = LocatorRegistryPrx::uncheckedCast(locatorObj);
 
-            // Get ref to Backup Routing Services EndpointLocator we can test it. 
-            Ice::ObjectPrx locatorObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupLocatorRegistry.Proxy");
-            SharedTestData::instance.backupLocatorRegistry = LocatorRegistryPrx::uncheckedCast(locatorObj2);
+        if (!SharedTestData::instance.locatorRegistry)
+        {
+            throw "Invalid LocatorRegistry";
+        }
 
-            if (!SharedTestData::instance.backupLocatorRegistry)
-            {
-                throw "Invalid Backup LocatorRegistry";
-            }
+        // Get ref to Backup Routing Services EndpointLocator we can test it.
+        Ice::ObjectPrx locatorObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupLocatorRegistry.Proxy");
+        SharedTestData::instance.backupLocatorRegistry = LocatorRegistryPrx::uncheckedCast(locatorObj2);
 
-            // Get a ref to the SessionRouter interface and cache it for testing.
-            Ice::ObjectPrx routerObj = SharedTestData::instance.communicatorOut->propertyToProxy("SessionRouter.Proxy");
-            SharedTestData::instance.sessionRouter = SessionRouterPrx::checkedCast(routerObj);
+        if (!SharedTestData::instance.backupLocatorRegistry)
+        {
+            throw "Invalid Backup LocatorRegistry";
+        }
 
-            if (!SharedTestData::instance.sessionRouter)
-            {
-                throw "Invalid SessionRouter";
-            }
+        // Get a ref to the SessionRouter interface and cache it for testing.
+        Ice::ObjectPrx routerObj = SharedTestData::instance.communicatorOut->propertyToProxy("SessionRouter.Proxy");
+        SharedTestData::instance.sessionRouter = SessionRouterPrx::checkedCast(routerObj);
 
-            // Get a ref to the Backup SessionRouter interface and cache it for testing.
-            Ice::ObjectPrx routerObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupSessionRouter.Proxy");
-            SharedTestData::instance.backupSessionRouter = SessionRouterPrx::checkedCast(routerObj2);
+        if (!SharedTestData::instance.sessionRouter)
+        {
+            throw "Invalid SessionRouter";
+        }
 
-            if (!SharedTestData::instance.backupSessionRouter)
-            {
-                throw "Invalid Backup SessionRouter";
-            }
+        // Get a ref to the Backup SessionRouter interface and cache it for testing.
+        Ice::ObjectPrx routerObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupSessionRouter.Proxy");
+        SharedTestData::instance.backupSessionRouter = SessionRouterPrx::checkedCast(routerObj2);
 
-            // Get a ref to the Replica interface and cache it for testing.
-            Ice::ObjectPrx replicaObj = SharedTestData::instance.communicatorOut->propertyToProxy("Replica.Proxy");
-            SharedTestData::instance.serviceReplicaMgmt = ReplicaPrx::checkedCast(replicaObj);
+        if (!SharedTestData::instance.backupSessionRouter)
+        {
+            throw "Invalid Backup SessionRouter";
+        }
 
-            if (!SharedTestData::instance.serviceReplicaMgmt)
-            {
-                throw "Invalid Replica";
-            }
+        // Get a ref to the Replica interface and cache it for testing.
+        Ice::ObjectPrx replicaObj = SharedTestData::instance.communicatorOut->propertyToProxy("Replica.Proxy");
+        SharedTestData::instance.serviceReplicaMgmt = ReplicaPrx::checkedCast(replicaObj);
 
-            // Note: This would be done by Pacemaker-initiated script in the real system. Something
-            // external must activate one of the sevice instances. 
-            SharedTestData::instance.serviceReplicaMgmt->activate();
+        if (!SharedTestData::instance.serviceReplicaMgmt)
+        {
+            throw "Invalid Replica";
+        }
 
-            // Get a ref to the Replica interface and cache it for testing.
-            Ice::ObjectPrx replicaObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupReplica.Proxy");
-            SharedTestData::instance.backupServiceReplicaMgmt = ReplicaPrx::checkedCast(replicaObj2);
+        // Note: This would be done by Pacemaker-initiated script in the real system. Something
+        // external must activate one of the sevice instances.
+        SharedTestData::instance.serviceReplicaMgmt->activate();
 
-            if (!SharedTestData::instance.backupServiceReplicaMgmt)
-            {
-                throw "Invalid Backup Replica";
-            }
+        // Get a ref to the Replica interface and cache it for testing.
+        Ice::ObjectPrx replicaObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupReplica.Proxy");
+        SharedTestData::instance.backupServiceReplicaMgmt = ReplicaPrx::checkedCast(replicaObj2);
 
-            RegisterWithServiceLocator();
-        }
-        catch (const Ice::Exception& ex)
+        if (!SharedTestData::instance.backupServiceReplicaMgmt)
         {
-            cerr << ex << endl;
-            status = 1;
-        }
-        catch (const std::exception& ex)
-        {
-            cerr << ex.what() << endl;
-            status = 1;
-        }
-        catch (const char* msg)
-        {
-            cerr << msg << endl;
-            status = 1;
+            throw "Invalid Backup Replica";
         }
+
+        RegisterWithServiceLocator();
     } // end Fixture() constructor
 
     void RegisterWithServiceLocator()

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


-- 
asterisk-scf/release/routing.git



More information about the asterisk-scf-commits mailing list