[hydra-commits] hydra/bridging.git branch "master" updated.
Commits to the Hydra project code repositories
hydra-commits at lists.digium.com
Tue Aug 10 06:33:18 CDT 2010
branch "master" has been updated
via b132a80fd47e8d7c305ce4c74eb1b2fa3f071a1f (commit)
from 9ee11387877c253fbb8c83d41be414a733d9b999 (commit)
Summary of changes:
src/BridgeImpl.cpp | 2 +-
test/TestBridging.cpp | 272 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 273 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit b132a80fd47e8d7c305ce4c74eb1b2fa3f071a1f
Author: Brent Eagles <beagles at digium.com>
Date: Tue Aug 10 09:01:12 2010 -0230
Added tests for factory state changes and missing EndpointAlreadyRegistered test.
diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index 3e8214f..e37b822 100644
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -81,7 +81,7 @@ void Hydra::BridgeService::BridgeImpl::addEndpoint(const Hydra::Core::Endpoint::
if(i != mEndpoints.end())
{
mLogger.getDebugStream() << __FUNCTION__ << ": endpoint with id " << ep->id->endpointManagerId << ":" << ep->id->deviceId << " already registered." << std::endl;
- throw Hydra::Core::Bridging::V1::EndpointAlreadyRegistered();
+ throw Hydra::Core::Bridging::V1::EndpointAlreadyRegistered(ep->id);
}
mEndpoints.push_back(newEndpoint);
mLogger.getDebugStream() << __FUNCTION__ << ": bridge " << current.adapter->getCommunicator()->identityToString(current.id) <<
diff --git a/test/TestBridging.cpp b/test/TestBridging.cpp
index 1b34009..d279959 100644
--- a/test/TestBridging.cpp
+++ b/test/TestBridging.cpp
@@ -738,6 +738,77 @@ BOOST_AUTO_TEST_CASE(BridgeAddEndpoint)
adapter->destroy();
}
+BOOST_AUTO_TEST_CASE(BridgeAddEndpointAlreadyRegistered)
+{
+ Ice::InitializationData initData;
+ initData.properties = Ice::createProperties(0);
+ initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
+ Ice::CommunicatorPtr comm = Ice::initialize(initData);
+ Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+ Ice::Current dummy;
+ dummy.adapter = adapter;
+ dummy.id = comm->stringToIdentity("testobject");
+ try
+ {
+ Hydra::Session::V1::SessionEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
+ p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+ p->id->endpointManagerId = "foo";
+ p->id->deviceId = "bar";
+ Hydra::Session::V1::SessionEndpointSeq eps;
+ eps.push_back(p);
+ p = new Hydra::Session::V1::SessionEndpoint;
+ p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+ p->id->endpointManagerId = "foo1";
+ p->id->deviceId = "bar";
+ eps.push_back(p);
+ p = new Hydra::Session::V1::SessionEndpoint;
+ p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+ p->id->endpointManagerId = "foo";
+ p->id->deviceId = "bar1";
+ eps.push_back(p);
+ p = new Hydra::Session::V1::SessionEndpoint;
+ p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+ p->id->endpointManagerId = "fooa";
+ p->id->deviceId = "bar";
+ Hydra::BridgeService::BridgeImplPtr bridge(new Hydra::BridgeService::BridgeImpl(p, eps, 0));
+ eps.insert(eps.begin(), p);
+ p = new Hydra::Session::V1::SessionEndpoint;
+ p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+ p->id->endpointManagerId = "foo";
+ p->id->deviceId = "bar";
+ try
+ {
+ bridge->addEndpoint(p, dummy);
+ }
+ catch(const Hydra::Core::Bridging::V1::EndpointAlreadyRegistered& ex)
+ {
+ BOOST_CHECK(ex.ep->endpointManagerId == "foo" && ex.ep->deviceId == "bar");
+ }
+
+ Hydra::Core::Endpoint::V1::EndpointSeq endpoints = bridge->listEndpoints(dummy);
+ BOOST_CHECK(endpoints.size() == 4);
+
+ //
+ // It so happens that we know the admin endpoint is inserted at the beginning of
+ // the result. If this changes, then so will the test.
+ //
+ Hydra::Core::Endpoint::V1::EndpointSeq::const_iterator j = endpoints.begin();
+ for(Hydra::Session::V1::SessionEndpointSeq::const_iterator i = eps.begin(); i != eps.end(); ++i, ++j)
+ {
+ BOOST_CHECK((*i)->id->endpointManagerId == (*j)->id->endpointManagerId);
+ BOOST_CHECK((*i)->id->deviceId == (*j)->id->deviceId);
+ Hydra::Session::V1::SessionEndpointPtr sp(Hydra::Session::V1::SessionEndpointPtr::dynamicCast(*j));
+ BOOST_CHECK(sp);
+ }
+ }
+ catch(...)
+ {
+ adapter->destroy();
+ throw;
+ }
+ adapter->destroy();
+}
+
BOOST_AUTO_TEST_CASE(BridgeAddInvalidEndpoint)
{
Ice::InitializationData initData;
@@ -1007,6 +1078,11 @@ BOOST_AUTO_TEST_CASE(BridgeRemoveEndpointInvalidId)
adapter->destroy();
}
+//
+// These are actually several very small test cases packed in one boost test case.
+// This simply checks to make sure that a bridge that is shutting down does
+// try to perform any additional requests.
+//
BOOST_AUTO_TEST_CASE(BridgeOperationsAfterShutdown)
{
Ice::InitializationData initData;
@@ -1106,3 +1182,199 @@ BOOST_AUTO_TEST_CASE(BridgeOperationsAfterShutdown)
}
adapter->destroy();
}
+
+//
+// These are actually several very small test cases packed in one boost test case.
+// This simply checks to make sure that a bridge that is in the process of being
+// destroy does not try to perform any additional requests.
+//
+BOOST_AUTO_TEST_CASE(BridgeOperationsAfterDestroy)
+{
+ Ice::InitializationData initData;
+ initData.properties = Ice::createProperties(0);
+ initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
+ Ice::CommunicatorPtr comm = Ice::initialize(initData);
+ Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+ Ice::Current dummy;
+ dummy.adapter = adapter;
+ dummy.id = comm->stringToIdentity("testobject");
+ try
+ {
+ Hydra::Session::V1::SessionEndpointSeq eps;
+ Hydra::BridgeService::BridgeImplPtr bridge(new Hydra::BridgeService::BridgeImpl(0, eps, 0));
+ bridge->destroy(dummy);
+ //
+ // Calling shutdown while in the process of shutting down is permitted but is a no-op.
+ //
+ BOOST_CHECK("Calling shutdown while in the process of shutting down" != 0);
+ try
+ {
+ bridge->listEndpoints(dummy);
+ BOOST_CHECK("should not have succeeded." == 0);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+ try
+ {
+ Hydra::Session::V1::SessionEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
+ p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+ p->id->endpointManagerId = "foo";
+ p->id->deviceId = "bar";
+ bridge->addEndpoint(p, dummy);
+ BOOST_CHECK("should not have succeeded." == 0);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+ try
+ {
+ Hydra::Session::V1::SessionEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
+ p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+ p->id->endpointManagerId = "foo";
+ p->id->deviceId = "bar";
+ bridge->removeEndpoint(p->id, dummy);
+ BOOST_CHECK("should not have succeeded." == 0);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+ try
+ {
+ bridge->destroy(dummy);
+ BOOST_CHECK("should not have succeeded." == 0);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+ try
+ {
+ Hydra::Core::Endpoint::V1::BaseEndpointPtr p(new Hydra::Core::Endpoint::V1::BaseEndpoint);
+ p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+ p->id->endpointManagerId = "foo";
+ p->id->deviceId = "bar";
+ bridge->addEndpoint(p, dummy);
+ BOOST_CHECK("should not have succeeded." == 0);
+ }
+ catch(const Hydra::Core::Bridging::V1::UnsupportedEndpoint&)
+ {
+ BOOST_CHECK("this occurs fo the time being" != 0);
+ }
+ catch(const Hydra::System::Component::V1::ShuttingDown&)
+ {
+ BOOST_CHECK("but this might happen in the future" != 0);
+ }
+ try
+ {
+ Hydra::Core::Endpoint::V1::BaseEndpointPtr p(new Hydra::Core::Endpoint::V1::BaseEndpoint);
+ bridge->addEndpoint(p, dummy);
+ BOOST_CHECK("should not have succeeded." == 0);
+ }
+ catch(const Hydra::Core::Endpoint::V1::InvalidEndpointId&)
+ {
+ BOOST_CHECK("this occurs fo the time being" != 0);
+ }
+ catch(const Hydra::System::Component::V1::ShuttingDown&)
+ {
+ BOOST_CHECK("but this might happen in the future" != 0);
+ }
+ try
+ {
+ Hydra::Core::Endpoint::V1::BaseEndpointPtr p(new Hydra::Core::Endpoint::V1::BaseEndpoint);
+ bridge->shutdown(dummy);
+ BOOST_CHECK("should not have succeeded." == 0);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+ }
+ catch(...)
+ {
+ adapter->destroy();
+ throw;
+ }
+ adapter->destroy();
+}
+
+BOOST_AUTO_TEST_CASE(BridgeFactorySuspendedState)
+{
+ Ice::InitializationData initData;
+ initData.properties = Ice::createProperties(0);
+ initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
+ Ice::CommunicatorPtr comm = Ice::initialize(initData);
+ Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+ Ice::Current dummy;
+ dummy.adapter = adapter;
+ dummy.id = comm->stringToIdentity("testobject");
+ try
+ {
+ Hydra::BridgeService::BridgeFactoryImplPtr factory(new Hydra::BridgeService::BridgeFactoryImpl(adapter));
+
+ try
+ {
+ factory->suspend(dummy);
+
+ //
+ // This should be ok.
+ //
+ factory->suspend(dummy);
+ try
+ {
+ Hydra::Core::Bridging::V1::BridgePrx b = factory->createBridge(0, Hydra::Core::Endpoint::V1::EndpointSeq(), 0, dummy);
+ BOOST_CHECK("Should not have succeeded" == 0);
+ }
+ catch(const Hydra::System::Component::V1::Suspended&)
+ {
+ BOOST_CHECK(true);
+ }
+ try
+ {
+ factory->shutdown(dummy);
+ BOOST_CHECK("Should not have succeeded" == 0);
+ }
+ catch(const Hydra::System::Component::V1::Suspended&)
+ {
+ BOOST_CHECK(true);
+ }
+ factory->resume(dummy);
+ factory->shutdown(dummy);
+ try
+ {
+ Hydra::Core::Bridging::V1::BridgePrx b = factory->createBridge(0, Hydra::Core::Endpoint::V1::EndpointSeq(), 0, dummy);
+ BOOST_CHECK("Should not have succeeded" == 0);
+ }
+ catch(const Hydra::System::Component::V1::ShuttingDown&)
+ {
+ BOOST_CHECK(true);
+ }
+ try
+ {
+ factory->suspend(dummy);
+ BOOST_CHECK("Should not have succeeded" == 0);
+ }
+ catch(const Hydra::System::Component::V1::ShuttingDown&)
+ {
+ BOOST_CHECK(true);
+ }
+ try
+ {
+ factory->resume(dummy);
+ BOOST_CHECK("Should not have succeeded" == 0);
+ }
+ catch(const Hydra::System::Component::V1::ShuttingDown&)
+ {
+ BOOST_CHECK(true);
+ }
+ }
+ catch(const Hydra::Core::Bridging::V1::UnsupportedEndpoint& x)
+ {
+ BOOST_CHECK(x.ep->endpointManagerId == "foo" && x.ep->deviceId == "bar");
+ }
+ }
+ catch(...)
+ {
+ adapter->destroy();
+ throw;
+ }
+ adapter->destroy();
+}
-----------------------------------------------------------------------
--
hydra/bridging.git
More information about the asterisk-scf-commits
mailing list