[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 Aug 30 08:40:44 CDT 2010
branch "master" has been updated
via 0046e8c1667cfb82d308433b5d872ed29274eb19 (commit)
from 83183b7fa7f43fc7d5aa90b345f72278ddbfbd33 (commit)
Summary of changes:
test/TestBridging.cpp | 284 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 280 insertions(+), 4 deletions(-)
- Log -----------------------------------------------------------------
commit 0046e8c1667cfb82d308433b5d872ed29274eb19
Author: Brent Eagles <beagles at digium.com>
Date: Mon Aug 30 11:09:13 2010 -0230
Adding some termination callback tests.
diff --git a/test/TestBridging.cpp b/test/TestBridging.cpp
index 7514bdb..e05793e 100644
--- a/test/TestBridging.cpp
+++ b/test/TestBridging.cpp
@@ -158,7 +158,9 @@ public:
{
mCalled = true;
BOOST_TEST_MESSAGE("call request received");
- cb->connected(destination);
+ mCallback = cb;
+ mMyId = destination;
+ mCallback->connected(destination);
return true;
}
@@ -169,11 +171,106 @@ public:
BOOST_TEST_MESSAGE("terminate request received");
}
+ void hangup()
+ {
+ BOOST_TEST_MESSAGE("hanging up");
+ if(mMyId == 0)
+ {
+ mMyId = new Hydra::Core::Endpoint::V1::EndpointId;
+ mMyId->endpointManagerId = "dummy";
+ mMyId->destinationId = "dummy";
+ }
+ Hydra::Session::V1::ResponseCodePtr r = new Hydra::Session::V1::ResponseCode;
+ r->isdnCode = 0;
+ mCallback->terminated(mMyId, r);
+ }
+
+ bool called()
+ {
+ return mCalled;
+ }
+
+ bool terminated()
+ {
+ return mTerminated;
+ }
+
private:
bool mCalled;
bool mTerminated;
+ Hydra::Core::Endpoint::V1::EndpointIdPtr mMyId;
+ Hydra::Session::V1::SignalCallbackPrx mCallback;
};
+typedef IceUtil::Handle<CommandI> CommandIPtr;
+
+class CallbackI : public Hydra::Session::V1::SignalCallback
+{
+public:
+
+ CallbackI() :
+ mTerminated(0)
+ {
+ }
+
+ void ring(const Hydra::Core::Endpoint::V1::EndpointIdPtr& p, const Ice::Current&)
+ {
+ BOOST_TEST_MESSAGE(__FUNCTION__);
+ }
+
+ void connected(const Hydra::Core::Endpoint::V1::EndpointIdPtr& p, const Ice::Current&)
+ {
+ BOOST_TEST_MESSAGE(__FUNCTION__);
+ }
+
+ void terminated(const Hydra::Core::Endpoint::V1::EndpointIdPtr& p, const Hydra::Session::V1::ResponseCodePtr& r, const Ice::Current& current)
+ {
+ ++mTerminated;
+ BOOST_TEST_MESSAGE(__FUNCTION__);
+ }
+
+ void busy(const Hydra::Core::Endpoint::V1::EndpointIdPtr& p, const Ice::Current&)
+ {
+ BOOST_TEST_MESSAGE(__FUNCTION__);
+ }
+
+ void congestion(const Hydra::Core::Endpoint::V1::EndpointIdPtr& p, const Hydra::Session::V1::ResponseCodePtr& r, const Ice::Current&)
+ {
+ BOOST_TEST_MESSAGE(__FUNCTION__);
+ }
+
+ void hold(const Hydra::Core::Endpoint::V1::EndpointIdPtr& p, const Ice::Current&)
+ {
+ BOOST_TEST_MESSAGE(__FUNCTION__);
+ }
+
+ void unhold(const Hydra::Core::Endpoint::V1::EndpointIdPtr& p, const Ice::Current&)
+ {
+ BOOST_TEST_MESSAGE(__FUNCTION__);
+ }
+
+ void flash(const Hydra::Core::Endpoint::V1::EndpointIdPtr& p, const Ice::Current&)
+ {
+ BOOST_TEST_MESSAGE(__FUNCTION__);
+ }
+
+ void progress(const Hydra::Core::Endpoint::V1::EndpointIdPtr& p, const Hydra::Session::V1::ResponseCodePtr& r, const Ice::Current&)
+ {
+ BOOST_TEST_MESSAGE(__FUNCTION__);
+ }
+
+ unsigned long terminateReceived()
+ {
+ return mTerminated;
+ }
+
+protected:
+
+ unsigned long mTerminated;
+};
+
+typedef IceUtil::Handle<CallbackI> CallbackIPtr;
+
class BridgeEventSubscriberI : public Hydra::Core::Bridging::V1::BridgeEvents
{
public:
@@ -284,7 +381,6 @@ public:
return true;
}
};
-
typedef IceUtil::Handle<BridgeMonitorI> BridgeMonitorPtr;
@@ -1888,6 +1984,7 @@ BOOST_AUTO_TEST_CASE(BridgeEvents)
}
catch(...)
{
+ BOOST_CHECK(false);
adapter->destroy();
throw;
}
@@ -1931,13 +2028,192 @@ BOOST_AUTO_TEST_CASE(BridgeMonitor)
}
catch(...)
{
+ BOOST_CHECK(false);
adapter->destroy();
throw;
}
adapter->destroy();
}
-BOOST_AUTO_TEST_CASE(BridgeTerminateCallbackFromUA)
+BOOST_AUTO_TEST_CASE(BridgeTerminateCallbackFromUAEndpointAdded)
{
- BOOST_CHECK(true);
+ Ice::InitializationData initData;
+ initData.properties = Ice::createProperties(0);
+ initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 10000");
+ initData.properties->setProperty("Ice.ThreadPool.Server.Size", "5");
+ initData.properties->setProperty("Ice.Default.CollocationOptimized", "0");
+ Ice::CommunicatorPtr comm = Ice::initialize(initData);
+ Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+ adapter->activate();
+ Ice::Current dummy;
+ dummy.adapter = adapter;
+ dummy.id = comm->stringToIdentity("testobject");
+ try
+ {
+ Hydra::BridgeService::BridgeFactoryImplPtr factory(new Hydra::BridgeService::BridgeFactoryImpl(adapter, 0));
+ Hydra::Core::Endpoint::V1::BaseEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
+ p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+ p->id->endpointManagerId = "test";
+ p->id->destinationId = "adminId";
+ Hydra::Session::V1::SessionEndpointPtr::dynamicCast(p)->mediaSession = createTestSession(adapter, "testsession");
+ Hydra::Session::V1::SessionEndpointPtr::dynamicCast(p)->command = createTestCommand(adapter);
+
+ CallbackIPtr cb(new CallbackI);
+ Hydra::Session::V1::SessionEndpointPtr::dynamicCast(p)->callback = Hydra::Session::V1::SignalCallbackPrx::uncheckedCast(adapter->addWithUUID(cb));
+
+ Hydra::Core::Endpoint::V1::EndpointSeq eps;
+ Hydra::Core::Bridging::V1::BridgePrx b = factory->createBridge(p, eps, 0, dummy);
+
+ CommandIPtr cmd(new CommandI);
+ Hydra::Session::V1::SignalCommandsPrx cmdPrx = Hydra::Session::V1::SignalCommandsPrx::uncheckedCast(adapter->addWithUUID(cmd));
+ p = new Hydra::Session::V1::SessionEndpoint;
+ p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+ p->id->endpointManagerId = "test";
+ p->id->destinationId = "ua1";
+ Hydra::Session::V1::SessionEndpointPtr::dynamicCast(p)->mediaSession = createTestSession(adapter, "testsession");
+ Hydra::Session::V1::SessionEndpointPtr::dynamicCast(p)->command = cmdPrx;
+
+ try
+ {
+ b->addEndpoint(p);
+ cmd->hangup();
+ BOOST_CHECK(cb->terminateReceived() > 0);
+ }
+ catch(...)
+ {
+ BOOST_CHECK(false);
+ }
+ }
+ catch(...)
+ {
+ BOOST_CHECK(false);
+ adapter->destroy();
+ throw;
+ }
+ adapter->destroy();
+}
+
+BOOST_AUTO_TEST_CASE(BridgeTerminateCallbackFromUAInitialEps)
+{
+ Ice::InitializationData initData;
+ initData.properties = Ice::createProperties(0);
+ initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 10000");
+ initData.properties->setProperty("Ice.ThreadPool.Server.Size", "5");
+ initData.properties->setProperty("Ice.Default.CollocationOptimized", "0");
+ Ice::CommunicatorPtr comm = Ice::initialize(initData);
+ Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+ adapter->activate();
+ Ice::Current dummy;
+ dummy.adapter = adapter;
+ dummy.id = comm->stringToIdentity("testobject");
+ try
+ {
+ Hydra::BridgeService::BridgeFactoryImplPtr factory(new Hydra::BridgeService::BridgeFactoryImpl(adapter, 0));
+ Hydra::Core::Endpoint::V1::BaseEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
+ p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+ p->id->endpointManagerId = "test";
+ p->id->destinationId = "adminId";
+ Hydra::Session::V1::SessionEndpointPtr::dynamicCast(p)->mediaSession = createTestSession(adapter, "testsession");
+ Hydra::Session::V1::SessionEndpointPtr::dynamicCast(p)->command = createTestCommand(adapter);
+ Hydra::Core::Endpoint::V1::BaseEndpointPtr adminEp(p);
+
+ CallbackIPtr cb(new CallbackI);
+ Hydra::Session::V1::SessionEndpointPtr::dynamicCast(p)->callback = Hydra::Session::V1::SignalCallbackPrx::uncheckedCast(adapter->addWithUUID(cb));
+
+ Hydra::Core::Endpoint::V1::EndpointSeq eps;
+ CommandIPtr cmd(new CommandI);
+ Hydra::Session::V1::SignalCommandsPrx cmdPrx = Hydra::Session::V1::SignalCommandsPrx::uncheckedCast(adapter->addWithUUID(cmd));
+ p = new Hydra::Session::V1::SessionEndpoint;
+ p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+ p->id->endpointManagerId = "test";
+ p->id->destinationId = "ua1";
+ Hydra::Session::V1::SessionEndpointPtr::dynamicCast(p)->mediaSession = createTestSession(adapter, "testsession");
+ Hydra::Session::V1::SessionEndpointPtr::dynamicCast(p)->command = cmdPrx;
+ eps.push_back(p);
+
+ Hydra::Core::Bridging::V1::BridgePrx b = factory->createBridge(adminEp, eps, 0, dummy);
+
+ try
+ {
+ cmd->hangup();
+ BOOST_CHECK(cb->terminateReceived() > 0);
+ }
+ catch(...)
+ {
+ BOOST_CHECK(false);
+ }
+ }
+ catch(...)
+ {
+ BOOST_CHECK(false);
+ adapter->destroy();
+ throw;
+ }
+ adapter->destroy();
+}
+
+BOOST_AUTO_TEST_CASE(BridgeTerminateCallbackFromAdminEp)
+{
+ Ice::InitializationData initData;
+ initData.properties = Ice::createProperties(0);
+ initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 10000");
+ initData.properties->setProperty("Ice.ThreadPool.Server.Size", "5");
+ initData.properties->setProperty("Ice.Default.CollocationOptimized", "0");
+ Ice::CommunicatorPtr comm = Ice::initialize(initData);
+ Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+ adapter->activate();
+ Ice::Current dummy;
+ dummy.adapter = adapter;
+ dummy.id = comm->stringToIdentity("testobject");
+ try
+ {
+ Hydra::BridgeService::BridgeFactoryImplPtr factory(new Hydra::BridgeService::BridgeFactoryImpl(adapter, 0));
+ Hydra::Core::Endpoint::V1::BaseEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
+ p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+ p->id->endpointManagerId = "test";
+ p->id->destinationId = "adminId";
+ Hydra::Session::V1::SessionEndpointPtr::dynamicCast(p)->mediaSession = createTestSession(adapter, "testsession");
+ CommandIPtr adminCmd(new CommandI);
+ Hydra::Session::V1::SessionEndpointPtr::dynamicCast(p)->command = Hydra::Session::V1::SignalCommandsPrx::uncheckedCast(adapter->addWithUUID(adminCmd));
+ Hydra::Core::Endpoint::V1::BaseEndpointPtr adminEp(p);
+
+ CallbackIPtr adminCB(new CallbackI);
+ Hydra::Session::V1::SessionEndpointPtr::dynamicCast(p)->callback = Hydra::Session::V1::SignalCallbackPrx::uncheckedCast(adapter->addWithUUID(adminCB));
+
+ Hydra::Core::Endpoint::V1::EndpointSeq eps;
+ CommandIPtr cmd(new CommandI);
+ Hydra::Session::V1::SignalCommandsPrx cmdPrx = Hydra::Session::V1::SignalCommandsPrx::uncheckedCast(adapter->addWithUUID(cmd));
+ p = new Hydra::Session::V1::SessionEndpoint;
+ p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+ p->id->endpointManagerId = "test";
+ p->id->destinationId = "ua1";
+ Hydra::Session::V1::SessionEndpointPtr::dynamicCast(p)->mediaSession = createTestSession(adapter, "testsession");
+ Hydra::Session::V1::SessionEndpointPtr::dynamicCast(p)->command = cmdPrx;
+ CallbackIPtr cb(new CallbackI);
+ Hydra::Session::V1::SessionEndpointPtr::dynamicCast(p)->callback = Hydra::Session::V1::SignalCallbackPrx::uncheckedCast(adapter->addWithUUID(cb));
+ eps.push_back(p);
+
+ Hydra::Core::Bridging::V1::BridgePrx b = factory->createBridge(adminEp, eps, 0, dummy);
+
+ try
+ {
+ Hydra::Session::V1::SignalCallbackPrx bridgeCBPrx = Hydra::Session::V1::SignalCallbackPrx::checkedCast(b, "SignalCallback");
+ BOOST_CHECK(bridgeCBPrx);
+ bridgeCBPrx->terminated(adminEp->id, new Hydra::Session::V1::ResponseCode);
+ BOOST_CHECK(cb->terminateReceived() == 0);
+ BOOST_CHECK(cmd->terminated());
+ }
+ catch(const Ice::Exception& ex)
+ {
+ BOOST_TEST_MESSAGE(ex.what());
+ BOOST_CHECK(false);
+ }
+ }
+ catch(...)
+ {
+ BOOST_CHECK(false);
+ adapter->destroy();
+ throw;
+ }
+ adapter->destroy();
}
-----------------------------------------------------------------------
--
asterisk-scf/integration/bridging.git
More information about the asterisk-scf-commits
mailing list