[asterisk-scf-commits] asterisk-scf/integration/routing.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Mon Oct 11 09:50:35 CDT 2010
branch "master" has been updated
via 1a1ddca89e2f883682c8864e69e746cb7945da31 (commit)
via 8d21761d17d1e03d9ed53ca1725ea4da0c9a6629 (commit)
from faa1fcb0e0696e81ffbe5fe53aa1da0646a99ac7 (commit)
Summary of changes:
src/BasicRoutingServiceApp.cpp | 449 +++++++++++++------------
src/BridgeManagerAccessor.cpp | 146 ++++----
src/BridgeManagerAccessor.h | 12 +-
src/EndpointRegistry.cpp | 321 +++++++++---------
src/EndpointRegistry.h | 107 +++---
src/LuaScriptProcessor.cpp | 284 ++++++++--------
src/LuaScriptProcessor.h | 10 +-
src/RoutingAdmin.cpp | 27 +-
src/RoutingAdmin.h | 28 +-
src/RoutingServiceEventPublisher.cpp | 227 +++++++-------
src/RoutingServiceEventPublisher.h | 92 +++---
src/ScriptProcessor.h | 11 +-
src/SessionRouter.cpp | 459 +++++++++++++-------------
src/SessionRouter.h | 26 +-
test/MockBridge.cpp | 74 ++--
test/MockBridge.h | 41 ++--
test/MockBridgeManager.cpp | 24 +-
test/MockBridgeManager.h | 24 +-
test/MockEndpointLocator.cpp | 101 +++---
test/MockEndpointLocator.h | 28 +-
test/MockSession.cpp | 54 ++--
test/MockSession.h | 56 ++--
test/MockSessionEndpoint.cpp | 47 ++--
test/MockSessionEndpoint.h | 30 +-
test/SharedTestData.h | 43 ++--
test/TestRouting.cpp | 608 +++++++++++++++++-----------------
26 files changed, 1651 insertions(+), 1678 deletions(-)
- Log -----------------------------------------------------------------
commit 1a1ddca89e2f883682c8864e69e746cb7945da31
Author: Brent Eagles <beagles at digium.com>
Date: Mon Oct 11 12:19:04 2010 -0230
Style updates to test suite.
diff --git a/test/MockBridge.cpp b/test/MockBridge.cpp
index 034fbc6..7a27989 100644
--- a/test/MockBridge.cpp
+++ b/test/MockBridge.cpp
@@ -23,55 +23,55 @@ namespace RoutingTest
class BridgeSessionListener : public SessionListener
{
public:
- BridgeSessionListener(MockBridge *bridge)
- {
- }
+ BridgeSessionListener(MockBridge *bridge)
+ {
+ }
- // The listener overrides...
+ // The listener overrides...
- virtual void connected(const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const ::Ice::Current& = ::Ice::Current())
- {
- mBridge->connected(session);
- }
+ void connected(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, const Ice::Current&)
+ {
+ mBridge->connected(session);
+ }
- virtual void flashed(const ::AsteriskSCF::SessionCommunications::V1::SessionPrx&, const ::Ice::Current& = ::Ice::Current())
- {
- }
+ void flashed(const AsteriskSCF::SessionCommunications::V1::SessionPrx&, const Ice::Current&)
+ {
+ }
- virtual void held(const ::AsteriskSCF::SessionCommunications::V1::SessionPrx&, const ::Ice::Current& = ::Ice::Current())
- {
- }
+ void held(const AsteriskSCF::SessionCommunications::V1::SessionPrx&, const Ice::Current&)
+ {
+ }
- virtual void progressing(const ::AsteriskSCF::SessionCommunications::V1::SessionPrx&, const ::AsteriskSCF::SessionCommunications::V1::ResponseCodePtr&, const ::Ice::Current& = ::Ice::Current())
- {
- }
+ void progressing(const AsteriskSCF::SessionCommunications::V1::SessionPrx&, const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr&, const Ice::Current&)
+ {
+ }
- virtual void ringing(const ::AsteriskSCF::SessionCommunications::V1::SessionPrx&, const ::Ice::Current& = ::Ice::Current())
- {
- }
+ void ringing(const AsteriskSCF::SessionCommunications::V1::SessionPrx&, const Ice::Current&)
+ {
+ }
- virtual void stopped(const ::AsteriskSCF::SessionCommunications::V1::SessionPrx&, const ::AsteriskSCF::SessionCommunications::V1::ResponseCodePtr&, const ::Ice::Current& = ::Ice::Current())
- {
- }
+ void stopped(const AsteriskSCF::SessionCommunications::V1::SessionPrx&, const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr&, const Ice::Current&)
+ {
+ }
- virtual void unheld(const ::AsteriskSCF::SessionCommunications::V1::SessionPrx&, const ::Ice::Current& = ::Ice::Current())
- {
- }
+ void unheld(const AsteriskSCF::SessionCommunications::V1::SessionPrx&, const Ice::Current&)
+ {
+ }
private:
- MockBridge *mBridge;
+ MockBridge *mBridge;
};
typedef IceUtil::Handle<BridgeSessionListener> BridgeSessionListenerPtr;
-MockBridge::MockBridge(SessionSeq sessions, BridgeListenerPrx listener) : mSessions(sessions)
+MockBridge::MockBridge(const SessionSeq& sessions, const BridgeListenerPrx& listener) :
+ mSessions(sessions)
{
mListener = new BridgeSessionListener(this);
- Ice::ObjectPrx objectPrx = SharedTestData::instance.adapter_in->addWithUUID(mListener);
+ Ice::ObjectPrx objectPrx = SharedTestData::instance.adapterIn->addWithUUID(mListener);
SessionListenerPrx listenerPrx = SessionListenerPrx::checkedCast(objectPrx);
- SessionSeq::iterator s;
- for (s = mSessions.begin(); s != mSessions.end(); ++s)
+ for (SessionSeq::iterator s = mSessions.begin(); s != mSessions.end(); ++s)
{
(*s)->addListener(listenerPrx);
}
@@ -79,21 +79,21 @@ MockBridge::MockBridge(SessionSeq sessions, BridgeListenerPrx listener) : mSessi
MockBridge::~MockBridge()
{
- SharedTestData::instance.adapter_in->remove(SharedTestData::instance.communicator_in->stringToIdentity(mListener->ice_id()));
+ SharedTestData::instance.adapterIn->remove(SharedTestData::instance.communicatorIn->stringToIdentity(mListener->ice_id()));
}
-void MockBridge::addSessions(const SessionSeq& newSessions, const ::Ice::Current&)
+void MockBridge::addSessions(const SessionSeq& newSessions, const Ice::Current&)
{
mSessions.reserve( mSessions.size() + newSessions.size());
mSessions.insert( mSessions.end(), newSessions.begin(), newSessions.end());
}
-void MockBridge::connected(const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& session)
+void MockBridge::connected(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session)
{
- SharedTestData::instance.mConnected = true;
+ SharedTestData::instance.connected = true;
}
-}; // RoutingTest
-}; // AsteriskSCF
+} // RoutingTest
+} // AsteriskSCF
diff --git a/test/MockBridge.h b/test/MockBridge.h
index 940c611..705810d 100644
--- a/test/MockBridge.h
+++ b/test/MockBridge.h
@@ -22,32 +22,33 @@ typedef IceUtil::Handle<BridgeSessionListener> BridgeSessionListenerPtr;
class MockBridge : public AsteriskSCF::SessionCommunications::Bridging::V1::Bridge
{
public:
- MockBridge(AsteriskSCF::SessionCommunications::V1::SessionSeq sessions, AsteriskSCF::SessionCommunications::Bridging::V1::BridgeListenerPrx listener);
- ~MockBridge();
+ MockBridge(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions,
+ const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeListenerPrx& listener);
+ ~MockBridge();
- virtual void addSessions(const AsteriskSCF::SessionCommunications::V1::SessionSeq& newSessions, const ::Ice::Current&);
- virtual void destroy(const ::Ice::Current& ) {}
- virtual void removeSessions(const AsteriskSCF::SessionCommunications::V1::SessionSeq&, const ::Ice::Current&) {}
+ void addSessions(const AsteriskSCF::SessionCommunications::V1::SessionSeq& newSessions, const Ice::Current&);
+ void destroy(const Ice::Current& ) {}
+ void removeSessions(const AsteriskSCF::SessionCommunications::V1::SessionSeq&, const Ice::Current&) {}
- virtual AsteriskSCF::SessionCommunications::V1::SessionSeq listSessions(const ::Ice::Current&)
- {
- return mSessions;
- }
+ AsteriskSCF::SessionCommunications::V1::SessionSeq listSessions(const Ice::Current&)
+ {
+ return mSessions;
+ }
- virtual void shutdown(const ::Ice::Current&) {}
- virtual void addListener(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeListenerPrx&, const ::Ice::Current& ) {}
- virtual void removeListener(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeListenerPrx&, const ::Ice::Current& ) {}
+ void shutdown(const Ice::Current&) {}
+ void addListener(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeListenerPrx&, const Ice::Current& ) {}
+ void removeListener(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeListenerPrx&, const Ice::Current& ) {}
- void replaceSession(const AsteriskSCF::SessionCommunications::V1::SessionPrx& newSession,
- const AsteriskSCF::SessionCommunications::V1::SessionPrx& oldSession,
- const Ice::Current&) {}
+ void replaceSession(const AsteriskSCF::SessionCommunications::V1::SessionPrx& newSession,
+ const AsteriskSCF::SessionCommunications::V1::SessionPrx& oldSession,
+ const Ice::Current&) {}
- void connected(const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& session);
+ void connected(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session);
private:
- AsteriskSCF::SessionCommunications::V1::SessionSeq mSessions;
- BridgeSessionListenerPtr mListener;
+ AsteriskSCF::SessionCommunications::V1::SessionSeq mSessions;
+ BridgeSessionListenerPtr mListener;
};
-}; // RoutingTest
-}; // AsteriskSCF
+} // RoutingTest
+} // AsteriskSCF
diff --git a/test/MockBridgeManager.cpp b/test/MockBridgeManager.cpp
index 5f310a1..13a53de 100644
--- a/test/MockBridgeManager.cpp
+++ b/test/MockBridgeManager.cpp
@@ -21,32 +21,32 @@ namespace AsteriskSCF
namespace RoutingTest
{
-void MockBridgeManager::addListener(const BridgeManagerListenerPrx&, const ::Ice::Current& )
+void MockBridgeManager::addListener(const BridgeManagerListenerPrx&, const Ice::Current& )
{
}
-BridgePrx MockBridgeManager::createBridge(const SessionSeq& sessions, const BridgeListenerPrx& listener, const ::Ice::Current&)
+BridgePrx MockBridgeManager::createBridge(const SessionSeq& sessions, const BridgeListenerPrx& listener, const Ice::Current&)
{
- BridgePtr bridge = new MockBridge(sessions, listener);
- mBridgeServants.push_back(bridge);
+ BridgePtr bridge = new MockBridge(sessions, listener);
+ mBridgeServants.push_back(bridge);
- Ice::ObjectPrx objectPrx = SharedTestData::instance.adapter_in->addWithUUID(bridge);
- BridgePrx bridgePrx = BridgePrx::checkedCast(objectPrx);
- mBridges.push_back(bridgePrx);
+ Ice::ObjectPrx objectPrx = SharedTestData::instance.adapterIn->addWithUUID(bridge);
+ BridgePrx bridgePrx = BridgePrx::checkedCast(objectPrx);
+ mBridges.push_back(bridgePrx);
- return bridgePrx;
+ return bridgePrx;
}
-void MockBridgeManager::removeListener(const BridgeManagerListenerPrx&, const ::Ice::Current& )
+void MockBridgeManager::removeListener(const BridgeManagerListenerPrx&, const Ice::Current& )
{
}
-BridgeSeq MockBridgeManager::listBridges(const ::Ice::Current&)
+BridgeSeq MockBridgeManager::listBridges(const Ice::Current&)
{
- return mBridges;
+ return mBridges;
}
-void MockBridgeManager::shutdown(const ::Ice::Current&)
+void MockBridgeManager::shutdown(const Ice::Current&)
{
}
diff --git a/test/MockBridgeManager.h b/test/MockBridgeManager.h
index 2d402ca..dd26863 100644
--- a/test/MockBridgeManager.h
+++ b/test/MockBridgeManager.h
@@ -19,22 +19,22 @@ namespace RoutingTest
class MockBridgeManager : public AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManager
{
public:
- MockBridgeManager()
- {
- }
+ MockBridgeManager()
+ {
+ }
- virtual void addListener(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerListenerPrx&, const ::Ice::Current& );
- virtual AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx createBridge(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeListenerPrx& listener, const ::Ice::Current&);
- virtual void removeListener(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerListenerPrx&, const ::Ice::Current& );
- virtual AsteriskSCF::SessionCommunications::Bridging::V1::BridgeSeq listBridges(const ::Ice::Current& = ::Ice::Current());
- virtual void shutdown(const ::Ice::Current& = ::Ice::Current());
+ void addListener(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerListenerPrx&, const Ice::Current&);
+ AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx createBridge(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeListenerPrx& listener, const Ice::Current&);
+ void removeListener(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerListenerPrx&, const Ice::Current&);
+ AsteriskSCF::SessionCommunications::Bridging::V1::BridgeSeq listBridges(const Ice::Current&);
+ void shutdown(const ::Ice::Current&);
private:
- std::vector<AsteriskSCF::SessionCommunications::Bridging::V1::BridgePtr> mBridgeServants;
- AsteriskSCF::SessionCommunications::Bridging::V1::BridgeSeq mBridges;
+ std::vector<AsteriskSCF::SessionCommunications::Bridging::V1::BridgePtr> mBridgeServants;
+ AsteriskSCF::SessionCommunications::Bridging::V1::BridgeSeq mBridges;
};
typedef ::IceInternal::Handle<MockBridgeManager> MockBridgeManagerPtr;
-}; // RoutingTest
-}; // AsteriskSCF
+} // RoutingTest
+} // AsteriskSCF
diff --git a/test/MockEndpointLocator.cpp b/test/MockEndpointLocator.cpp
index 2b8b3fc..192b4dc 100644
--- a/test/MockEndpointLocator.cpp
+++ b/test/MockEndpointLocator.cpp
@@ -27,76 +27,73 @@ namespace AsteriskSCF
namespace RoutingTest
{
-AsteriskSCF::Core::Endpoint::V1::EndpointSeq MockEndpointLocator::lookup(const ::std::string& destination, const ::Ice::Current&)
+AsteriskSCF::Core::Endpoint::V1::EndpointSeq MockEndpointLocator::lookup(const string& destination, const Ice::Current&)
{
- AsteriskSCF::Core::Endpoint::V1::EndpointSeq endpoints;
- cout << "MockEndpointLocator::lookup() entered with destination = " << destination << endl << flush;
-
- for (EndpointIterator e=mEndpointPrxList.begin(); e!= mEndpointPrxList.end();++e)
- {
- cout << "MockEndpointLocator::lookup() comparing destination to " << (*e)->getId() << endl << flush;
-
- BaseEndpointPrx ep = *e;
- if ((*e)->getId() == destination)
- {
- cout << "MockEndpointLocator::lookup() found a match." << endl << flush;
- endpoints.push_back(ep);
- }
- }
-
- if (endpoints.size() == 0)
- {
- throw DestinationNotFoundException(destination);
- }
- return endpoints;
+ AsteriskSCF::Core::Endpoint::V1::EndpointSeq endpoints;
+ cout << "MockEndpointLocator::lookup() entered with destination = " << destination << endl << flush;
+
+ for (EndpointIterator e = mEndpointPrxList.begin(); e != mEndpointPrxList.end(); ++e)
+ {
+ cout << "MockEndpointLocator::lookup() comparing destination to " << (*e)->getId() << endl << flush;
+
+ BaseEndpointPrx ep = *e;
+ if ((*e)->getId() == destination)
+ {
+ cout << "MockEndpointLocator::lookup() found a match." << endl << flush;
+ endpoints.push_back(ep);
+ }
+ }
+
+ if (endpoints.size() == 0)
+ {
+ throw DestinationNotFoundException(destination);
+ }
+ return endpoints;
}
void MockEndpointLocator::perTestCleanup()
{
- vector<MockSessionEndpointPtr>::iterator i;
- for(i = mEndpoints.begin(); i != mEndpoints.end(); ++i)
- {
- (*i)->perTestCleanup();
- }
+ for(vector<MockSessionEndpointPtr>::iterator i = mEndpoints.begin(); i != mEndpoints.end(); ++i)
+ {
+ (*i)->perTestCleanup();
+ }
}
void MockEndpointLocator::clear()
{
- vector<MockSessionEndpointPtr>::iterator i;
- for(i = mEndpoints.begin(); i != mEndpoints.end(); ++i)
- {
- SharedTestData::instance.adapter_in->remove(SharedTestData::instance.communicator_in->stringToIdentity((*i)->ice_id()));
- }
-
- mEndpointPrxList.clear();
- mEndpoints.clear();
+ for(vector<MockSessionEndpointPtr>::iterator i = mEndpoints.begin(); i != mEndpoints.end(); ++i)
+ {
+ SharedTestData::instance.adapterIn->remove(SharedTestData::instance.communicatorIn->stringToIdentity((*i)->ice_id()));
+ }
+
+ mEndpointPrxList.clear();
+ mEndpoints.clear();
}
-MockSessionEndpointPtr MockEndpointLocator::addEndpoint(string id)
+MockSessionEndpointPtr MockEndpointLocator::addEndpoint(const string& id)
{
- MockSessionEndpointPtr endpoint = new MockSessionEndpoint(id);
- mEndpoints.push_back(endpoint);
- Ice::ObjectPrx prx = SharedTestData::instance.adapter_in->addWithUUID(endpoint);
- mEndpointPrxList.push_back(BaseEndpointPrx::checkedCast(prx));
- return endpoint;
+ MockSessionEndpointPtr endpoint = new MockSessionEndpoint(id);
+ mEndpoints.push_back(endpoint);
+ Ice::ObjectPrx prx = SharedTestData::instance.adapterIn->addWithUUID(endpoint);
+ mEndpointPrxList.push_back(BaseEndpointPrx::checkedCast(prx));
+ return endpoint;
}
/**
* Like lookup, but for the local channel we are simulating.
*/
-MockSessionEndpointPtr MockEndpointLocator::localLookup(string id)
+MockSessionEndpointPtr MockEndpointLocator::localLookup(const string& id)
{
- vector<MockSessionEndpointPtr>::iterator i;
- for(i = mEndpoints.begin(); i != mEndpoints.end(); ++i)
- {
- if ((*i)->getId() == id)
- {
- return (*i);
- }
- }
- return 0;
+ for(vector<MockSessionEndpointPtr>::iterator i = mEndpoints.begin(); i != mEndpoints.end(); ++i)
+ {
+ if ((*i)->getId(Ice::Current()) == id)
+ {
+ return (*i);
+ }
+ }
+ return 0;
}
-}; // RoutingTest
-}; // As
+} // RoutingTest
+} // As
diff --git a/test/MockEndpointLocator.h b/test/MockEndpointLocator.h
index 32f7075..600b5c9 100644
--- a/test/MockEndpointLocator.h
+++ b/test/MockEndpointLocator.h
@@ -22,25 +22,25 @@ namespace RoutingTest
class MockEndpointLocator : public AsteriskSCF::Core::Routing::V1::EndpointLocator
{
public:
- // Overrides
- virtual AsteriskSCF::Core::Endpoint::V1::EndpointSeq lookup(const ::std::string& destination, const ::Ice::Current&);
+ // Overrides
+ AsteriskSCF::Core::Endpoint::V1::EndpointSeq lookup(const std::string& destination, const Ice::Current&);
- // Implementation
- void perTestCleanup();
- void clear();
- MockSessionEndpointPtr addEndpoint(std::string id);
+ // Implementation
+ void perTestCleanup();
+ void clear();
+ MockSessionEndpointPtr addEndpoint(const std::string& id);
- /**
- * Like lookup, but for the local channel we are simulating.
- */
- MockSessionEndpointPtr localLookup(std::string id);
+ /**
+ * Like lookup, but for the local channel we are simulating.
+ */
+ MockSessionEndpointPtr localLookup(const std::string& id);
private:
- AsteriskSCF::Core::Endpoint::V1::EndpointSeq mEndpointPrxList;
- std::vector<MockSessionEndpointPtr> mEndpoints;
+ AsteriskSCF::Core::Endpoint::V1::EndpointSeq mEndpointPrxList;
+ std::vector<MockSessionEndpointPtr> mEndpoints;
};
typedef ::IceInternal::Handle<MockEndpointLocator> MockEndpointLocatorPtr;
-}; // RoutingTest
-}; // AsteriskSCF
+} // RoutingTest
+} // AsteriskSCF
diff --git a/test/MockSession.cpp b/test/MockSession.cpp
index db8d5ab..ec2289b 100644
--- a/test/MockSession.cpp
+++ b/test/MockSession.cpp
@@ -23,18 +23,17 @@ namespace RoutingTest
SessionInfoPtr MockSession::addListener(const SessionListenerPrx& listener, const Ice::Current&)
{
- mListeners.push_back(listener);
-
- return mSessionInfo;
+ mListeners.push_back(listener);
+
+ return mSessionInfo;
}
void MockSession::connect(const Ice::Current&)
{
- vector<SessionListenerPrx>::iterator i;
- for(i = mListeners.begin(); i != mListeners.end(); ++i)
- {
- (*i)->connected(mMyPrx);
- }
+ for(vector<SessionListenerPrx>::iterator i = mListeners.begin(); i != mListeners.end(); ++i)
+ {
+ (*i)->connected(mMyPrx);
+ }
}
void MockSession::flash(const Ice::Current&)
@@ -43,59 +42,58 @@ void MockSession::flash(const Ice::Current&)
SessionEndpointPrx MockSession::getEndpoint(const Ice::Current&)
{
- return mEndpointPrx;
+ return mEndpointPrx;
}
SessionInfoPtr MockSession::getInfo(const Ice::Current&)
{
- return mSessionInfo;
+ return mSessionInfo;
}
AsteriskSCF::Media::V1::SessionPrx MockSession::getMediaSession(const Ice::Current&)
{
- return 0;
+ return 0;
}
-void MockSession::hold(const ::Ice::Current&)
+void MockSession::hold(const Ice::Current&)
{
}
-void MockSession::progress(const ResponseCodePtr&, const ::Ice::Current&)
+void MockSession::progress(const ResponseCodePtr&, const Ice::Current&)
{
}
-void MockSession::removeListener(const SessionListenerPrx&, const ::Ice::Current&)
+void MockSession::removeListener(const SessionListenerPrx&, const Ice::Current&)
{
}
-void MockSession::ring(const ::Ice::Current&)
+void MockSession::ring(const Ice::Current&)
{
}
-void MockSession::start(const ::Ice::Current&)
+void MockSession::start(const Ice::Current&)
{
- cout << "Session started." << endl;
+ cout << "Session started." << endl;
- vector<SessionListenerPrx>::iterator i;
- for(i = mListeners.begin(); i != mListeners.end(); ++i)
- {
- // Auto-answer!
- (*i)->connected(mMyPrx);
- }
+ for(vector<SessionListenerPrx>::iterator i = mListeners.begin(); i != mListeners.end(); ++i)
+ {
+ // Auto-answer!
+ (*i)->connected(mMyPrx);
+ }
}
-void MockSession::stop(const ResponseCodePtr&, const ::Ice::Current&)
+void MockSession::stop(const ResponseCodePtr&, const Ice::Current&)
{
- cout << "Session stopped." << endl;
+ cout << "Session stopped." << endl;
}
-void MockSession::unhold(const ::Ice::Current&)
+void MockSession::unhold(const Ice::Current&)
{
}
-void MockSession::setProxy(SessionPrx sessionPrx)
+void MockSession::setProxy(const SessionPrx& sessionPrx)
{
- mMyPrx = sessionPrx;
+ mMyPrx = sessionPrx;
}
diff --git a/test/MockSession.h b/test/MockSession.h
index d3baf08..af6be79 100644
--- a/test/MockSession.h
+++ b/test/MockSession.h
@@ -18,40 +18,40 @@ namespace RoutingTest
class MockSession : public AsteriskSCF::SessionCommunications::V1::Session
{
public:
- MockSession(std::string sessionId, AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx endpointPrx)
- : mId(sessionId), mEndpointPrx(endpointPrx), mSessionInfo(new AsteriskSCF::SessionCommunications::V1::SessionInfo())
- {
- }
+ MockSession(const std::string& sessionId, const AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx& endpointPrx) :
+ mId(sessionId), mEndpointPrx(endpointPrx), mSessionInfo(new AsteriskSCF::SessionCommunications::V1::SessionInfo())
+ {
+ }
public:
- // Overrides
-
- virtual AsteriskSCF::SessionCommunications::V1::SessionInfoPtr addListener(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener, const Ice::Current&);
- virtual void connect(const Ice::Current&);
- virtual void flash(const Ice::Current&);
- virtual AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx getEndpoint(const Ice::Current&);
- virtual AsteriskSCF::SessionCommunications::V1::SessionInfoPtr getInfo(const Ice::Current&);
- virtual AsteriskSCF::Media::V1::SessionPrx getMediaSession(const Ice::Current&);
- virtual void hold(const ::Ice::Current&);
- virtual void progress(const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr&, const ::Ice::Current&);
- virtual void removeListener(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&, const ::Ice::Current&);
- virtual void ring(const ::Ice::Current&);
- virtual void start(const ::Ice::Current&);
- virtual void stop(const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr&, const ::Ice::Current&);
- virtual void unhold(const ::Ice::Current&);
+ // Overrides
+
+ AsteriskSCF::SessionCommunications::V1::SessionInfoPtr addListener(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener, const Ice::Current&);
+ void connect(const Ice::Current&);
+ void flash(const Ice::Current&);
+ AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx getEndpoint(const Ice::Current&);
+ AsteriskSCF::SessionCommunications::V1::SessionInfoPtr getInfo(const Ice::Current&);
+ AsteriskSCF::Media::V1::SessionPrx getMediaSession(const Ice::Current&);
+ void hold(const Ice::Current&);
+ void progress(const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr&, const Ice::Current&);
+ void removeListener(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&, const Ice::Current&);
+ void ring(const Ice::Current&);
+ void start(const Ice::Current&);
+ void stop(const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr&, const Ice::Current&);
+ void unhold(const Ice::Current&);
public:
- void setProxy(AsteriskSCF::SessionCommunications::V1::SessionPrx sessionPrx);
- const std::string& getId() const {return mId;}
+ void setProxy(const AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionPrx);
+ const std::string& getId() const {return mId;}
private:
- std::string mId;
- AsteriskSCF::SessionCommunications::V1::SessionPrx mMyPrx;
- AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx mEndpointPrx;
- std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx> mListeners;
- AsteriskSCF::SessionCommunications::V1::SessionInfoPtr mSessionInfo;
+ std::string mId;
+ AsteriskSCF::SessionCommunications::V1::SessionPrx mMyPrx;
+ AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx mEndpointPrx;
+ std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx> mListeners;
+ AsteriskSCF::SessionCommunications::V1::SessionInfoPtr mSessionInfo;
};
typedef IceUtil::Handle<MockSession> MockSessionPtr;
-}; // RoutingTest
-}; // AsteriskSCF
+} // RoutingTest
+} // AsteriskSCF
diff --git a/test/MockSessionEndpoint.cpp b/test/MockSessionEndpoint.cpp
index cf9da15..69f316e 100644
--- a/test/MockSessionEndpoint.cpp
+++ b/test/MockSessionEndpoint.cpp
@@ -22,46 +22,45 @@ namespace AsteriskSCF
namespace RoutingTest
{
-SessionPrx MockSessionEndpoint::createSession(const string& dest, const SessionListenerPrx& listener, const ::Ice::Current&)
+SessionPrx MockSessionEndpoint::createSession(const string& dest, const SessionListenerPrx& listener, const Ice::Current&)
{
- string sessionId = dest + "_" + mId + "_" + boost::lexical_cast<string>(++mCounter);
+ string sessionId = dest + "_" + mId + "_" + boost::lexical_cast<string>(++mCounter);
- BOOST_MESSAGE("SessionEndpoint creating session with Id = " + sessionId);
+ BOOST_MESSAGE("SessionEndpoint creating session with Id = " + sessionId);
- MockSessionPtr session = new MockSession(sessionId, mProxy);
- mSessions.push_back(session);
+ MockSessionPtr session = new MockSession(sessionId, mProxy);
+ mSessions.push_back(session);
- Ice::ObjectPrx prx = SharedTestData::instance.adapter_in->add(session, SharedTestData::instance.communicator_in->stringToIdentity(sessionId));
- SessionPrx sessionPrx = SessionPrx::checkedCast(prx);
- mSessionPrxList.push_back(sessionPrx);
+ Ice::ObjectPrx prx = SharedTestData::instance.adapterIn->add(session, SharedTestData::instance.communicatorIn->stringToIdentity(sessionId));
+ SessionPrx sessionPrx = SessionPrx::checkedCast(prx);
+ mSessionPrxList.push_back(sessionPrx);
- session->setProxy(sessionPrx);
+ session->setProxy(sessionPrx);
- return sessionPrx;
+ return sessionPrx;
}
-SessionSeq MockSessionEndpoint::getSessions(const ::Ice::Current&)
+SessionSeq MockSessionEndpoint::getSessions(const Ice::Current&)
{
- return mSessionPrxList;
+ return mSessionPrxList;
}
-void MockSessionEndpoint::setProxy(SessionEndpointPrx proxy)
+void MockSessionEndpoint::setProxy(const SessionEndpointPrx& proxy)
{
- mProxy = proxy;
+ mProxy = proxy;
}
void MockSessionEndpoint::perTestCleanup()
{
- vector<MockSessionPtr>::iterator i;
- for(i = mSessions.begin(); i != mSessions.end(); ++i)
- {
- string id = (*i)->getId();
- SharedTestData::instance.adapter_in->remove(SharedTestData::instance.communicator_in->stringToIdentity(id));
- }
-
- mSessions.clear();
+ for(vector<MockSessionPtr>::iterator i = mSessions.begin(); i != mSessions.end(); ++i)
+ {
+ string id = (*i)->getId();
+ SharedTestData::instance.adapterIn->remove(SharedTestData::instance.communicatorIn->stringToIdentity(id));
+ }
+
+ mSessions.clear();
}
-}; // RoutingTest
-}; // AsteriskSCF
+} // RoutingTest
+} // AsteriskSCF
diff --git a/test/MockSessionEndpoint.h b/test/MockSessionEndpoint.h
index 1daad6c..88d9a4f 100644
--- a/test/MockSessionEndpoint.h
+++ b/test/MockSessionEndpoint.h
@@ -19,31 +19,31 @@ namespace RoutingTest
/**
* A simple endpoint implemenation.
*/
- class MockSessionEndpoint : public AsteriskSCF::SessionCommunications::V1::SessionEndpoint
+class MockSessionEndpoint : public AsteriskSCF::SessionCommunications::V1::SessionEndpoint
{
public:
- // Constructors
- MockSessionEndpoint(const std::string& id) : mId(id), mCounter(0) {}
+ // Constructors
+ MockSessionEndpoint(const std::string& id) : mId(id), mCounter(0) {}
public:
- // Overrides
+ // Overrides
- virtual AsteriskSCF::SessionCommunications::V1::SessionPrx createSession(const std::string& dest, const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener, const ::Ice::Current& = ::Ice::Current());
- virtual AsteriskSCF::SessionCommunications::V1::SessionSeq getSessions(const ::Ice::Current&);
+ AsteriskSCF::SessionCommunications::V1::SessionPrx createSession(const std::string& dest, const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener, const Ice::Current&);
+ AsteriskSCF::SessionCommunications::V1::SessionSeq getSessions(const Ice::Current&);
public:
- // Implementation
+ // Implementation
- void setProxy(AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx proxy);
- std::string getId(const Ice::Current& = ::Ice::Current()) {return mId;}
- void perTestCleanup();
+ void setProxy(const AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx& proxy);
+ std::string getId(const Ice::Current&) {return mId;}
+ void perTestCleanup();
private:
- std::vector<MockSessionPtr> mSessions;
- std::vector<AsteriskSCF::SessionCommunications::V1::SessionPrx> mSessionPrxList;
- std::string mId;
- AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx mProxy;
- int mCounter;
+ std::vector<MockSessionPtr> mSessions;
+ std::vector<AsteriskSCF::SessionCommunications::V1::SessionPrx> mSessionPrxList;
+ std::string mId;
+ AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx mProxy;
+ int mCounter;
};
typedef IceUtil::Handle<MockSessionEndpoint> MockSessionEndpointPtr;
diff --git a/test/SharedTestData.h b/test/SharedTestData.h
index bbc4197..04a3dbc 100644
--- a/test/SharedTestData.h
+++ b/test/SharedTestData.h
@@ -24,36 +24,35 @@ namespace RoutingTest
/**
* Pseudo singleton for sharing data among test artifacts.
*/
-class SharedTestData
+struct SharedTestData
{
-public:
- static SharedTestData instance;
+ static SharedTestData instance;
- // Communicator for outgoing stuff.
- Ice::CommunicatorPtr communicator_out;
+ // Communicator for outgoing stuff.
+ Ice::CommunicatorPtr communicatorOut;
- // Communicator for incoming stuff. This is where we add the test servants.
- Ice::CommunicatorPtr communicator_in;
+ // Communicator for incoming stuff. This is where we add the test servants.
+ Ice::CommunicatorPtr communicatorIn;
- Ice::ObjectAdapterPtr adapter_in;
- Ice::ObjectAdapterPtr adapter_out;
+ Ice::ObjectAdapterPtr adapterIn;
+ Ice::ObjectAdapterPtr adapterOut;
- //A proxy to the actual routing service
- AsteriskSCF::Core::Routing::V1::LocatorRegistryPrx locatorRegistry;
- AsteriskSCF::SessionCommunications::V1::SessionRouterPrx sessionRouter;
+ //A proxy to the actual routing service
+ AsteriskSCF::Core::Routing::V1::LocatorRegistryPrx locatorRegistry;
+ AsteriskSCF::SessionCommunications::V1::SessionRouterPrx sessionRouter;
- // Our own EndpointLocator to server up endpoints to the RoutingService, emulating a channel.
- MockEndpointLocatorPtr mEndpointLocator;
- AsteriskSCF::Core::Routing::V1::EndpointLocatorPrx mEndpointLocatorPrx;
- AsteriskSCF::Core::Routing::V1::RegExSeq mRegExIds;
+ // Our own EndpointLocator to server up endpoints to the RoutingService, emulating a channel.
+ MockEndpointLocatorPtr endpointLocator;
+ AsteriskSCF::Core::Routing::V1::EndpointLocatorPrx endpointLocatorPrx;
+ AsteriskSCF::Core::Routing::V1::RegExSeq regExIds;
- AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx mServiceLocator;
- AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx mServiceLocatorManagement;
+ AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator;
+ AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx serviceLocatorManagement;
- MockBridgeManagerPtr mBridgeManager;
+ MockBridgeManagerPtr bridgeManager;
- bool mConnected;
+ bool connected;
};
-}; // RoutingTest
-}; // AsteriskSCF
+} // RoutingTest
+} // AsteriskSCF
diff --git a/test/TestRouting.cpp b/test/TestRouting.cpp
index d866b0a..ec82233 100644
--- a/test/TestRouting.cpp
+++ b/test/TestRouting.cpp
@@ -38,9 +38,9 @@ using namespace AsteriskSCF::RoutingTest;
struct ArgCacheType
{
public:
- int argc;
- char **argv;
- Ice::PropertiesPtr inheritedProps;
+ int argc;
+ char **argv;
+ Ice::PropertiesPtr inheritedProps;
};
static ArgCacheType mCachedArgs;
@@ -50,33 +50,29 @@ static ArgCacheType mCachedArgs;
class RoutingServiceTest : public IceBox::Service
{
public:
- void start(const std::string&,
- const Ice::CommunicatorPtr&,
- const Ice::StringSeq&);
- void stop();
+ void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&);
+ void stop();
};
void RoutingServiceTest::start(std::string const &name,
Ice::CommunicatorPtr const &communicator,
Ice::StringSeq const &args)
{
- std::vector<char const *> argv;
- argv.push_back(name.c_str());
- for (Ice::StringSeq::const_iterator i = args.begin();
- i != args.end();
- ++i)
- {
- argv.push_back(i->c_str());
- }
- // null terminated list
- argv.push_back(0);
-
- mCachedArgs.argc = argv.size() - 1;
- mCachedArgs.argv = (char**)&argv[0];
- mCachedArgs.inheritedProps = communicator->getProperties();
-
- int r = ::boost::unit_test::unit_test_main(&init_unit_test, mCachedArgs.argc, mCachedArgs.argv);
- exit(r);
+ std::vector<char const *> argv;
+ argv.push_back(name.c_str());
+ for (Ice::StringSeq::const_iterator i = args.begin(); i != args.end(); ++i)
+ {
+ argv.push_back(i->c_str());
+ }
+ // null terminated list
+ argv.push_back(0);
+
+ mCachedArgs.argc = argv.size() - 1;
+ mCachedArgs.argv = (char**)&argv[0];
+ mCachedArgs.inheritedProps = communicator->getProperties();
+
+ int r = ::boost::unit_test::unit_test_main(&init_unit_test, mCachedArgs.argc, mCachedArgs.argv);
+ exit(r);
}
void RoutingServiceTest::stop()
@@ -85,10 +81,10 @@ void RoutingServiceTest::stop()
extern "C"
{
- HYDRA_ICEBOX_EXPORT IceBox::Service* create(Ice::CommunicatorPtr communicator)
- {
- return new RoutingServiceTest;
- }
+ HYDRA_ICEBOX_EXPORT IceBox::Service* create(Ice::CommunicatorPtr communicator)
+ {
+ return new RoutingServiceTest;
+ }
}
/**
@@ -105,133 +101,133 @@ const string LocatorObjectId("TestLocator");
*/
struct GlobalIceFixture
{
- GlobalIceFixture()
- {
- BOOST_TEST_MESSAGE("Setting up Basic Rounting Service test fixture");
-
- ::boost::debug::detect_memory_leaks(false);
- ::boost::unit_test::unit_test_log.set_stream( std::cout );
-
- int status = 0;
- try
- {
- Ice::InitializationData initData;
- initData.properties = mCachedArgs.inheritedProps;
-
- // Set up incoming adapter. This is where we'll publish our proxies.
- SharedTestData::instance.communicator_in = Ice::initialize(initData);
-
- Ice::PropertiesPtr props = SharedTestData::instance.communicator_in->getProperties();
- SharedTestData::instance.adapter_in = SharedTestData::instance.communicator_in->createObjectAdapterWithEndpoints("TestRoutingAdapterIn", "default -p 10070");
-
- // Serve up our own EndpointLocator, since we're emulating a channel.
- MockEndpointLocator *locator = new MockEndpointLocator();
- SharedTestData::instance.mEndpointLocator = locator;
- SharedTestData::instance.adapter_in->add(SharedTestData::instance.mEndpointLocator, SharedTestData::instance.communicator_in->stringToIdentity(LocatorObjectId));
-
- SharedTestData::instance.adapter_in->activate();
-
- // Now that the adapter has been activated, get a local proxy to our EndpointLocator.
- Ice::ObjectPrx locatorObjectPrx = SharedTestData::instance.adapter_in->createDirectProxy(SharedTestData::instance.communicator_in->stringToIdentity(LocatorObjectId));
- SharedTestData::instance.mEndpointLocatorPrx = EndpointLocatorPrx::checkedCast(locatorObjectPrx);
-
- // Now set up outgoing adapter. This will be used for proxies we want to call out to the
- // the unit under test on.
- SharedTestData::instance.communicator_out = Ice::initialize(initData);
- SharedTestData::instance.adapter_out = SharedTestData::instance.communicator_out->createObjectAdapterWithEndpoints("TestRoutingAdapterOut", "default -p 10071");
-
- // Get ref to Routing Service so we can test it. Getting direct for now, but
- // need to test acquiring reference via ServiceLocator as well.
- Ice::PropertiesPtr communicatorProps = SharedTestData::instance.communicator_out->getProperties();
- string locatorProp = communicatorProps->getProperty("LocatorRegistry.Proxy");
- Ice::ObjectPrx locatorObj = SharedTestData::instance.communicator_out->propertyToProxy("LocatorRegistry.Proxy");
- SharedTestData::instance.locatorRegistry = LocatorRegistryPrx::checkedCast(locatorObj);
-
- // Get the ServiceLocator and ServiceLocator manager
-
-
- if (!SharedTestData::instance.locatorRegistry)
- {
- throw "Invalid LocatorRegistry";
- }
-
- Ice::ObjectPrx routerObj = SharedTestData::instance.communicator_out->propertyToProxy("SessionRouter.Proxy");
- SharedTestData::instance.sessionRouter = SessionRouterPrx::checkedCast(routerObj);
-
- if (!SharedTestData::instance.sessionRouter)
- {
- throw "Invalid SessionRouter";
- }
-
- PopulateEndpoints();
-
- RegisterWithServiceLocator();
- }
- catch (const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = 1;
- }
- catch (const char* msg)
- {
- cerr << msg << endl;
- status = 1;
- }
- } // end Fixture() constructor
-
- void RegisterWithServiceLocator()
- {
- // Get a proxy to the management interface for the Service Locator, so we can add
- // our mock BridgeManager to the system.
- SharedTestData::instance.mServiceLocatorManagement = ServiceLocatorManagementPrx::checkedCast(SharedTestData::instance.communicator_in->propertyToProxy("LocatorServiceManagement.Proxy"));
-
- if (SharedTestData::instance.mServiceLocatorManagement == 0)
- {
- cout << "Unable to obtain proxy to ServiceLocatorManagement interface. Check config file. Tests can't run without it. (not yet, anyway)" << endl;
- return;
- }
-
- SharedTestData::instance.mBridgeManager = new MockBridgeManager();
-
- Ice::ObjectPrx bridgeManagerObject = SharedTestData::instance.adapter_in->add(SharedTestData::instance.mBridgeManager, SharedTestData::instance.communicator_in->stringToIdentity(SharedTestData::instance.communicator_in->getProperties()->getProperty("BridgeManager.ServiceLocatorId")));
- BridgeManagerPrx bridgeManagerPrx = BridgeManagerPrx::checkedCast(bridgeManagerObject);
- ServiceManagementPrx management = ServiceManagementPrx::uncheckedCast(SharedTestData::instance.mServiceLocatorManagement->addService(bridgeManagerPrx, "BridgeService"));
-
- ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
- genericparams->category = BridgeServiceDiscoveryCategory;
- management->addLocatorParams(genericparams, "");
- }
-
- void PopulateEndpoints()
- {
- SharedTestData::instance.mEndpointLocator->clear();
-
- SharedTestData::instance.mEndpointLocator->addEndpoint("101");
- SharedTestData::instance.mEndpointLocator->addEndpoint("102");
- SharedTestData::instance.mEndpointLocator->addEndpoint("103");
-
- // Initialize the regular expressions for the ids that this channel will support.
- // Use two strings just for kicks.
- SharedTestData::instance.mRegExIds.push_back("101");
- SharedTestData::instance.mRegExIds.push_back("10[23]"); // 102 or 103
- }
-
- ~GlobalIceFixture()
- {
- BOOST_TEST_MESSAGE("Tearing down Routing Test global test fixture");
-
-
- if (SharedTestData::instance.communicator_in)
- {
- SharedTestData::instance.communicator_in->shutdown();
- SharedTestData::instance.communicator_in = 0;
- }
- if (SharedTestData::instance.communicator_out)
- {
- SharedTestData::instance.communicator_out->shutdown();
- SharedTestData::instance.communicator_out = 0;
- }
- }
+ GlobalIceFixture()
+ {
+ BOOST_TEST_MESSAGE("Setting up Basic Rounting Service test fixture");
+
+ ::boost::debug::detect_memory_leaks(false);
+ ::boost::unit_test::unit_test_log.set_stream( std::cout );
+
+ int status = 0;
+ try
+ {
+ Ice::InitializationData initData;
+ initData.properties = mCachedArgs.inheritedProps;
+
+ // Set up incoming adapter. This is where we'll publish our proxies.
+ SharedTestData::instance.communicatorIn = Ice::initialize(initData);
+
+ Ice::PropertiesPtr props = SharedTestData::instance.communicatorIn->getProperties();
+ SharedTestData::instance.adapterIn = SharedTestData::instance.communicatorIn->createObjectAdapterWithEndpoints("TestRoutingAdapterIn", "default -p 10070");
+
+ // 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));
+
+ SharedTestData::instance.adapterIn->activate();
+
+ // 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);
+
+ // Now set up outgoing adapter. This will be used for proxies we want to call out to the
+ // the unit under test on.
+ SharedTestData::instance.communicatorOut = Ice::initialize(initData);
+ SharedTestData::instance.adapterOut = SharedTestData::instance.communicatorOut->createObjectAdapterWithEndpoints("TestRoutingAdapterOut", "default -p 10071");
+
+ // Get ref to Routing Service so we can test it. Getting direct for now, but
+ // need to test acquiring reference via ServiceLocator as well.
+ Ice::PropertiesPtr communicatorProps = SharedTestData::instance.communicatorOut->getProperties();
+ string locatorProp = communicatorProps->getProperty("LocatorRegistry.Proxy");
+ Ice::ObjectPrx locatorObj = SharedTestData::instance.communicatorOut->propertyToProxy("LocatorRegistry.Proxy");
+ SharedTestData::instance.locatorRegistry = LocatorRegistryPrx::checkedCast(locatorObj);
+
+ // Get the ServiceLocator and ServiceLocator manager
+
+
+ if (!SharedTestData::instance.locatorRegistry)
+ {
+ throw "Invalid LocatorRegistry";
+ }
+
+ Ice::ObjectPrx routerObj = SharedTestData::instance.communicatorOut->propertyToProxy("SessionRouter.Proxy");
+ SharedTestData::instance.sessionRouter = SessionRouterPrx::checkedCast(routerObj);
+
+ if (!SharedTestData::instance.sessionRouter)
+ {
+ throw "Invalid SessionRouter";
+ }
+
+ PopulateEndpoints();
+
+ RegisterWithServiceLocator();
+ }
+ catch (const Ice::Exception& ex)
+ {
+ cerr << ex << endl;
+ status = 1;
+ }
+ catch (const char* msg)
+ {
+ cerr << msg << endl;
+ status = 1;
+ }
+ } // end Fixture() constructor
+
+ void RegisterWithServiceLocator()
+ {
+ // Get a proxy to the management interface for the Service Locator, so we can add
+ // our mock BridgeManager to the system.
+ SharedTestData::instance.serviceLocatorManagement = ServiceLocatorManagementPrx::checkedCast(SharedTestData::instance.communicatorIn->propertyToProxy("LocatorServiceManagement.Proxy"));
+
+ if (SharedTestData::instance.serviceLocatorManagement == 0)
+ {
+ cout << "Unable to obtain proxy to ServiceLocatorManagement interface. Check config file. Tests can't run without it. (not yet, anyway)" << endl;
+ return;
+ }
+
+ SharedTestData::instance.bridgeManager = new MockBridgeManager();
+
+ Ice::ObjectPrx bridgeManagerObject = SharedTestData::instance.adapterIn->add(SharedTestData::instance.bridgeManager, SharedTestData::instance.communicatorIn->stringToIdentity(SharedTestData::instance.communicatorIn->getProperties()->getProperty("BridgeManager.ServiceLocatorId")));
+ BridgeManagerPrx bridgeManagerPrx = BridgeManagerPrx::checkedCast(bridgeManagerObject);
+ ServiceManagementPrx management = ServiceManagementPrx::uncheckedCast(SharedTestData::instance.serviceLocatorManagement->addService(bridgeManagerPrx, "BridgeService"));
+
+ ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
+ genericparams->category = BridgeServiceDiscoveryCategory;
+ management->addLocatorParams(genericparams, "");
+ }
+
+ void PopulateEndpoints()
+ {
+ SharedTestData::instance.endpointLocator->clear();
+
+ SharedTestData::instance.endpointLocator->addEndpoint("101");
+ SharedTestData::instance.endpointLocator->addEndpoint("102");
+ SharedTestData::instance.endpointLocator->addEndpoint("103");
+
+ // Initialize the regular expressions for the ids that this channel will support.
+ // Use two strings just for kicks.
+ SharedTestData::instance.regExIds.push_back("101");
+ SharedTestData::instance.regExIds.push_back("10[23]"); // 102 or 103
+ }
+
+ ~GlobalIceFixture()
+ {
+ BOOST_TEST_MESSAGE("Tearing down Routing Test global test fixture");
+
+
+ if (SharedTestData::instance.communicatorIn)
+ {
+ SharedTestData::instance.communicatorIn->shutdown();
+ SharedTestData::instance.communicatorIn = 0;
+ }
+ if (SharedTestData::instance.communicatorOut)
+ {
+ SharedTestData::instance.communicatorOut->shutdown();
+ SharedTestData::instance.communicatorOut = 0;
+ }
+ }
private:
int mGlob;
};
@@ -241,43 +237,43 @@ BOOST_GLOBAL_FIXTURE(GlobalIceFixture);
struct PerTestFixture
{
public:
- PerTestFixture()
- {
- try
- {
- BOOST_TEST_MESSAGE("PerTestFixture initializing...");
-
- SharedTestData::instance.locatorRegistry->addEndpointLocator("TestChannel", SharedTestData::instance.mRegExIds, SharedTestData::instance.mEndpointLocatorPrx);
-
- BOOST_TEST_MESSAGE("PerTestFixture initialized.");
- }
- catch (...)
- {
- BOOST_TEST_MESSAGE("PerTestFixture can't add our endpoint locator to the Routing Service.");
- }
- }
-
- ~PerTestFixture()
- {
- try
- {
- BOOST_TEST_MESSAGE("PerTestFixture cleanup starting...");
-
- SharedTestData::instance.locatorRegistry->removeEndpointLocator("TestChannel");
- SharedTestData::instance.mEndpointLocator->perTestCleanup();
-
- BOOST_TEST_MESSAGE("PerTestFixture cleanup complete.");
- }
- catch(const std::exception &e)
- {
- BOOST_TEST_MESSAGE("PerTestFixture can't remove our endpoint locator from the Routing Service: ");
- BOOST_TEST_MESSAGE(e.what());
- }
- catch (...)
- {
- BOOST_TEST_MESSAGE("Unknown exception. PerTestFixture can't remove our endpoint locator from the Routing Service..");
- }
- }
+ PerTestFixture()
+ {
+ try
+ {
+ BOOST_TEST_MESSAGE("PerTestFixture initializing...");
+
+ SharedTestData::instance.locatorRegistry->addEndpointLocator("TestChannel", SharedTestData::instance.regExIds, SharedTestData::instance.endpointLocatorPrx);
+
+ BOOST_TEST_MESSAGE("PerTestFixture initialized.");
+ }
+ catch (...)
+ {
+ BOOST_TEST_MESSAGE("PerTestFixture can't add our endpoint locator to the Routing Service.");
+ }
+ }
+
+ ~PerTestFixture()
+ {
+ try
+ {
+ BOOST_TEST_MESSAGE("PerTestFixture cleanup starting...");
+
+ SharedTestData::instance.locatorRegistry->removeEndpointLocator("TestChannel");
+ SharedTestData::instance.endpointLocator->perTestCleanup();
+
+ BOOST_TEST_MESSAGE("PerTestFixture cleanup complete.");
+ }
+ catch(const std::exception &e)
+ {
+ BOOST_TEST_MESSAGE("PerTestFixture can't remove our endpoint locator from the Routing Service: ");
+ BOOST_TEST_MESSAGE(e.what());
+ }
+ catch (...)
+ {
+ BOOST_TEST_MESSAGE("Unknown exception. PerTestFixture can't remove our endpoint locator from the Routing Service..");
+ }
+ }
};
/**
@@ -285,33 +281,33 @@ public:
*/
BOOST_AUTO_TEST_CASE(AddAndRemoveEndpointLocator)
{
- bool addLocatorSucceeded(true);
- try
- {
- SharedTestData::instance.locatorRegistry->addEndpointLocator("TestChannel", SharedTestData::instance.mRegExIds, SharedTestData::instance.mEndpointLocatorPrx);
- }
- catch (...)
- {
- addLocatorSucceeded = false;
- BOOST_TEST_MESSAGE("Exception adding EndpointLocator.");
- }
-
- BOOST_CHECK(addLocatorSucceeded);
-
- bool removeLocatorSucceeded(true);
- try
- {
- SharedTestData::instance.locatorRegistry->removeEndpointLocator("TestChannel");
-
- }
- catch (...)
- {
- removeLocatorSucceeded = false;
- BOOST_TEST_MESSAGE("Exception removing EndpointLocator.");
- }
- BOOST_CHECK(removeLocatorSucceeded);
-
- BOOST_TEST_MESSAGE("Completed AddAndRemoveEndpointLocator test.");
+ bool addLocatorSucceeded(true);
+ try
+ {
+ SharedTestData::instance.locatorRegistry->addEndpointLocator("TestChannel", SharedTestData::instance.regExIds, SharedTestData::instance.endpointLocatorPrx);
+ }
+ catch (...)
+ {
+ addLocatorSucceeded = false;
+ BOOST_TEST_MESSAGE("Exception adding EndpointLocator.");
+ }
+
+ BOOST_CHECK(addLocatorSucceeded);
+
+ bool removeLocatorSucceeded(true);
+ try
+ {
+ SharedTestData::instance.locatorRegistry->removeEndpointLocator("TestChannel");
+
+ }
+ catch (...)
+ {
+ removeLocatorSucceeded = false;
+ BOOST_TEST_MESSAGE("Exception removing EndpointLocator.");
+ }
+ BOOST_CHECK(removeLocatorSucceeded);
+
+ BOOST_TEST_MESSAGE("Completed AddAndRemoveEndpointLocator test.");
}
@@ -322,34 +318,34 @@ BOOST_AUTO_TEST_CASE(AddAndRemoveEndpointLocator)
*/
BOOST_AUTO_TEST_CASE(AddEndpointLocatorTwice)
{
- bool addLocatorSucceeded(true);
- try
- {
- SharedTestData::instance.locatorRegistry->addEndpointLocator("TestChannel", SharedTestData::instance.mRegExIds, SharedTestData::instance.mEndpointLocatorPrx);
- SharedTestData::instance.locatorRegistry->addEndpointLocator("TestChannel", SharedTestData::instance.mRegExIds, SharedTestData::instance.mEndpointLocatorPrx);
- }
- catch (...)
- {
- addLocatorSucceeded = false;
- BOOST_TEST_MESSAGE("Exception adding EndpointLocator the second time.");
- }
-
- BOOST_CHECK(addLocatorSucceeded);
-
- bool removeLocatorSucceeded(true);
- try
- {
- SharedTestData::instance.locatorRegistry->removeEndpointLocator("TestChannel");
-
- }
- catch (...)
- {
- removeLocatorSucceeded = false;
- BOOST_TEST_MESSAGE("Exception removing EndpointLocator.");
- }
- BOOST_CHECK(removeLocatorSucceeded);
-
- BOOST_TEST_MESSAGE("Completed AddEndpointLocatorTwice test.");
+ bool addLocatorSucceeded(true);
+ try
+ {
+ SharedTestData::instance.locatorRegistry->addEndpointLocator("TestChannel", SharedTestData::instance.regExIds, SharedTestData::instance.endpointLocatorPrx);
+ SharedTestData::instance.locatorRegistry->addEndpointLocator("TestChannel", SharedTestData::instance.regExIds, SharedTestData::instance.endpointLocatorPrx);
+ }
+ catch (...)
+ {
+ addLocatorSucceeded = false;
+ BOOST_TEST_MESSAGE("Exception adding EndpointLocator the second time.");
+ }
+
+ BOOST_CHECK(addLocatorSucceeded);
+
+ bool removeLocatorSucceeded(true);
+ try
+ {
+ SharedTestData::instance.locatorRegistry->removeEndpointLocator("TestChannel");
+
+ }
+ catch (...)
+ {
+ removeLocatorSucceeded = false;
+ BOOST_TEST_MESSAGE("Exception removing EndpointLocator.");
+ }
+ BOOST_CHECK(removeLocatorSucceeded);
+
+ BOOST_TEST_MESSAGE("Completed AddEndpointLocatorTwice test.");
}
@@ -358,33 +354,33 @@ BOOST_AUTO_TEST_CASE(AddEndpointLocatorTwice)
*/
BOOST_FIXTURE_TEST_CASE(LookupOwnEndpoint, PerTestFixture)
{
- try
- {
- BOOST_TEST_MESSAGE("Looking up endpoint via Routing Service...");
- string lookupVal = "102";
- AsteriskSCF::Core::Endpoint::V1::EndpointSeq seq = SharedTestData::instance.locatorRegistry->lookup(lookupVal);
-
- BOOST_TEST_MESSAGE(" ...lookup completed.");
-
- BOOST_CHECK(seq.size() > 0);
- BOOST_CHECK(seq[0]->getId() == lookupVal);
- }
- catch(const IceUtil::Exception &ie)
- {
- bool IceException(false);
- string msg = "Exception looking up our own endpoint:";
- msg += ie.what();
- BOOST_TEST_MESSAGE(msg);
- BOOST_CHECK(IceException);
- }
- catch (...)
- {
- bool unknownException(false);
- BOOST_TEST_MESSAGE("Exception looking up our own endpoint.");
- BOOST_CHECK(unknownException);
- }
-
- BOOST_TEST_MESSAGE("Completed LookupOwnEndpoint test.");
+ try
+ {
+ BOOST_TEST_MESSAGE("Looking up endpoint via Routing Service...");
+ string lookupVal = "102";
+ AsteriskSCF::Core::Endpoint::V1::EndpointSeq seq = SharedTestData::instance.locatorRegistry->lookup(lookupVal);
+
+ BOOST_TEST_MESSAGE(" ...lookup completed.");
+
+ BOOST_CHECK(seq.size() > 0);
+ BOOST_CHECK(seq[0]->getId() == lookupVal);
+ }
+ catch(const IceUtil::Exception &ie)
+ {
+ bool IceException(false);
+ string msg = "Exception looking up our own endpoint:";
+ msg += ie.what();
+ BOOST_TEST_MESSAGE(msg);
+ BOOST_CHECK(IceException);
+ }
+ catch (...)
+ {
+ bool unknownException(false);
+ BOOST_TEST_MESSAGE("Exception looking up our own endpoint.");
+ BOOST_CHECK(unknownException);
+ }
+
+ BOOST_TEST_MESSAGE("Completed LookupOwnEndpoint test.");
}
@@ -393,36 +389,36 @@ BOOST_FIXTURE_TEST_CASE(LookupOwnEndpoint, PerTestFixture)
*/
BOOST_FIXTURE_TEST_CASE(RouteSession, PerTestFixture)
{
- try
- {
- BOOST_TEST_MESSAGE("Local lookup of an endpoint...");
-
- // Get our local 101 endpoint
- MockSessionEndpointPtr session101Endpoint = SharedTestData::instance.mEndpointLocator->localLookup("101");
-
- BOOST_TEST_MESSAGE("Creating a session on our test endpoint...");
- SessionPrx session = session101Endpoint->createSession("102", 0);
- BOOST_CHECK(session != 0);
-
- SharedTestData::instance.mConnected = false;
-
- BOOST_TEST_MESSAGE("Routing the session...");
- SharedTestData::instance.sessionRouter->routeSession(session, "102");
-
- BOOST_CHECK(SharedTestData::instance.mConnected);
- }
- catch(const IceUtil::Exception &ie)
- {
- bool IceException(false);
- string msg = "Exception routing session:";
- msg += ie.what();
- BOOST_TEST_MESSAGE(msg);
- BOOST_CHECK(IceException);
- }
- catch (...)
- {
- bool unknownException(false);
- BOOST_TEST_MESSAGE("Exception routing session.");
- BOOST_CHECK(unknownException);
- }
+ try
+ {
+ BOOST_TEST_MESSAGE("Local lookup of an endpoint...");
+
+ // Get our local 101 endpoint
+ MockSessionEndpointPtr session101Endpoint = SharedTestData::instance.endpointLocator->localLookup("101");
+
+ BOOST_TEST_MESSAGE("Creating a session on our test endpoint...");
+ SessionPrx session = session101Endpoint->createSession("102", 0, Ice::Current());
+ BOOST_CHECK(session != 0);
+
+ SharedTestData::instance.connected = false;
+
+ BOOST_TEST_MESSAGE("Routing the session...");
+ SharedTestData::instance.sessionRouter->routeSession(session, "102");
+
+ BOOST_CHECK(SharedTestData::instance.connected);
+ }
+ catch(const IceUtil::Exception &ie)
+ {
+ bool IceException(false);
+ string msg = "Exception routing session:";
+ msg += ie.what();
+ BOOST_TEST_MESSAGE(msg);
+ BOOST_CHECK(IceException);
+ }
+ catch (...)
+ {
+ bool unknownException(false);
+ BOOST_TEST_MESSAGE("Exception routing session.");
+ BOOST_CHECK(unknownException);
+ }
}
commit 8d21761d17d1e03d9ed53ca1725ea4da0c9a6629
Author: Brent Eagles <beagles at digium.com>
Date: Mon Oct 11 11:33:28 2010 -0230
Style updates.
diff --git a/src/BasicRoutingServiceApp.cpp b/src/BasicRoutingServiceApp.cpp
index 4ca3de5..e83fdcb 100644
--- a/src/BasicRoutingServiceApp.cpp
+++ b/src/BasicRoutingServiceApp.cpp
@@ -26,7 +26,6 @@
#include "logger.h"
using namespace std;
-using namespace AsteriskSCF::BasicRoutingService;
using namespace AsteriskSCF::SessionCommunications::V1;
using namespace AsteriskSCF::SessionCommunications::Bridging::V1;
using namespace AsteriskSCF::Core;
@@ -49,56 +48,60 @@ namespace BasicRoutingService
class BasicRoutingServiceApp : public IceBox::Service
{
public:
- BasicRoutingServiceApp() : mDone(false), mInitialized(false), mRunning(false) {}
- ~BasicRoutingServiceApp()
- {
- // Smart pointers do your thing.
- mSessionRouter = 0;
- mAdminInteface = 0;
- mComponentService = 0;
- mEndpointRegistry = 0;
- mBridgeManagerAccessor.reset();
- mEventPublisher = 0;
- }
-
- void resume();
- void suspend();
+ BasicRoutingServiceApp() :
+ mDone(false), mInitialized(false), mRunning(false)
+ {
+
+ }
+ ~BasicRoutingServiceApp()
+ {
+ // Smart pointers do your thing.
+ mSessionRouter = 0;
+ mAdminInteface = 0;
+ mComponentService = 0;
+ mEndpointRegistry = 0;
+ mBridgeManagerAccessor.reset();
+ mEventPublisher = 0;
+ // XXX unnecessary.
+ }
+
+ void resume();
+ void suspend();
public: // Overrides of IceBox::Service
- virtual void start(const string& name,
- const Ice::CommunicatorPtr& ic,
- const Ice::StringSeq& args);
- virtual void stop();
+ virtual void start(const string& name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq& args);
+ virtual void stop();
private:
- void initialize();
- void registerWithServiceLocator();
- void deregisterFromServiceLocator();
- void setCategory(Discovery::V1::ServiceManagementPrx serviceManagement, const string &category);
-
- bool mDone;
- std::string mAppName;
- ServiceLocatorManagementPrx mServiceLocatorManagement;
- ServiceLocatorPrx mServiceLocator;
-
- Discovery::V1::ServiceManagementPrx mRegistryLocatorManagement;
- Discovery::V1::ServiceManagementPrx mAdminManagement;
- Discovery::V1::ServiceManagementPrx mComponentServiceManagement;
- Discovery::V1::ServiceManagementPrx mSessionRouterManagement;
-
- // Our published interfaces.
- BasicSessionRouterPtr mSessionRouter;
- RoutingServiceAdminPtr mAdminInteface;
- ComponentServicePtr mComponentService;
- BridgeManagerAccessorPtr mBridgeManagerAccessor;
- RoutingEventsPtr mEventPublisher;
- EndpointRegistryPtr mEndpointRegistry;
-
- // Implementation
- Ice::ObjectAdapterPtr mAdapter;
- Ice::CommunicatorPtr mCommunicator;
- bool mRunning;
- bool mInitialized;
+ void initialize();
+ void registerWithServiceLocator();
+ void deregisterFromServiceLocator();
+ void setCategory(const Discovery::V1::ServiceManagementPrx& serviceManagement, const string& category);
+
+ bool mDone;
+ bool mInitialized;
+ bool mRunning;
+
+ std::string mAppName;
+ ServiceLocatorManagementPrx mServiceLocatorManagement;
+ ServiceLocatorPrx mServiceLocator;
+
+ Discovery::V1::ServiceManagementPrx mRegistryLocatorManagement;
+ Discovery::V1::ServiceManagementPrx mAdminManagement;
+ Discovery::V1::ServiceManagementPrx mComponentServiceManagement;
+ Discovery::V1::ServiceManagementPrx mSessionRouterManagement;
+
+ // Our published interfaces.
+ BasicSessionRouterPtr mSessionRouter;
+ RoutingServiceAdminPtr mAdminInteface;
+ ComponentServicePtr mComponentService;
+ BridgeManagerAccessorPtr mBridgeManagerAccessor;
+ RoutingEventsPtr mEventPublisher;
+ EndpointRegistryPtr mEndpointRegistry;
+
+ // Implementation
+ Ice::ObjectAdapterPtr mAdapter;
+ Ice::CommunicatorPtr mCommunicator;
};
static const string RegistryLocatorObjectId("RoutingServiceLocatorRegistry");
@@ -113,38 +116,41 @@ static const string SessionRouterObjectId("SessionRouter");
class ComponentServiceImpl : public ComponentService
{
public:
- ComponentServiceImpl(BasicRoutingServiceApp &app) : mApp(app) {}
+ ComponentServiceImpl(BasicRoutingServiceApp &app) :
+ mApp(app)
+ {
+ }
public: // Overrides of the ComponentService interface.
- virtual void suspend(const ::Ice::Current& = ::Ice::Current())
- {
- mApp.suspend();
- }
+ void suspend(const Ice::Current&)
+ {
+ mApp.suspend();
+ }
- virtual void resume(const ::Ice::Current& = ::Ice::Current())
- {
- mApp.resume();
- }
+ void resume(const Ice::Current&)
+ {
+ mApp.resume();
+ }
- virtual void shutdown(const ::Ice::Current& = ::Ice::Current())
- {
- mApp.stop();
- }
+ void shutdown(const Ice::Current&)
+ {
+ mApp.stop();
+ }
private:
- BasicRoutingServiceApp& mApp;
+ BasicRoutingServiceApp& mApp;
};
/**
* Helper function to add some parameters to one of our registered interfaces in the ServiceLocator, so that
* other components can look up our interfaces.
*/
-void BasicRoutingServiceApp::setCategory(Discovery::V1::ServiceManagementPrx serviceManagement, const string &category)
+void BasicRoutingServiceApp::setCategory(const Discovery::V1::ServiceManagementPrx& serviceManagement, const string& category)
{
- // Add category as a parameter to enable other components look this component up.
- ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
- genericparams->category = category;
- serviceManagement->addLocatorParams(genericparams, "");
+ // Add category as a parameter to enable other components look this component up.
+ ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams;
+ genericparams->category = category;
+ serviceManagement->addLocatorParams(genericparams, "");
}
/**
@@ -153,54 +159,54 @@ void BasicRoutingServiceApp::setCategory(Discovery::V1::ServiceManagementPrx ser
*/
void BasicRoutingServiceApp::registerWithServiceLocator()
{
- try
- {
- // Get a proxy to the management interface for the Service Locator, so we can add ourselves into the system discovery mechanisms.
- mServiceLocatorManagement = ServiceLocatorManagementPrx::checkedCast(mCommunicator->propertyToProxy("LocatorServiceManagement.Proxy"));
-
- if (mServiceLocatorManagement == 0)
- {
- lg(Error) << "Unable to obtain proxy to ServiceLocatorManagement interface. Check config file. This component can't be found until this is corrected.";
- return;
- }
-
- // Register our RoutingAdmin interface with the Service Locator.
- Ice::ObjectPrx adminObjectPrx = mAdapter->createDirectProxy(mCommunicator->stringToIdentity(RoutingAdminObjectId));
- RoutingServiceAdminPrx adminPrx = RoutingServiceAdminPrx::checkedCast(adminObjectPrx);
- string adminServiceGuid("BasicRoutingServiceAdmin"); // Should be unique for reporting.
- mAdminManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(adminPrx, adminServiceGuid));
-
- setCategory(mAdminManagement, Routing::V1::RoutingServiceAdminDiscoveryCategory);
-
- // Register our RegistryLocator interface with the Service Locator.
- Ice::ObjectPrx locatorObjectPrx = mAdapter->createDirectProxy(mCommunicator->stringToIdentity(RegistryLocatorObjectId));
- LocatorRegistryPrx locatorRegistryPrx = LocatorRegistryPrx::checkedCast(locatorObjectPrx);
- string locatorServiceGuid("BasicRoutingServiceRegistryLocator"); // Should be unique for reporting.
- mRegistryLocatorManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(locatorRegistryPrx, locatorServiceGuid));
-
- setCategory(mRegistryLocatorManagement, Routing::V1::RoutingServiceLocatorRegistryDiscoveryCategory);
-
- // Register the ComponentService interface with the Service Locator.
- Ice::ObjectPrx componentServiceObjectPrx = mAdapter->createDirectProxy(mCommunicator->stringToIdentity(ComponentServiceId));
- ComponentServicePrx componentServicePrx = ComponentServicePrx::checkedCast(componentServiceObjectPrx);
- string componentServiceGuid("BasicRoutingService"); // Should be unique for reporting.
- mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(componentServicePrx, componentServiceGuid));
-
- setCategory(mComponentServiceManagement, Routing::V1::ComponentServiceDiscoveryCategory);
-
- // Register the SessionRouter interface with the Service Locator.
- Ice::ObjectPrx sessionRouterObjectPrx = mAdapter->createDirectProxy(mCommunicator->stringToIdentity(SessionRouterObjectId));
- AsteriskSCF::SessionCommunications::V1::SessionRouterPrx sessionRouterPrx = AsteriskSCF::SessionCommunications::V1::SessionRouterPrx::checkedCast(sessionRouterObjectPrx);
- string sessionRouterGuid("SessionRouter"); // Should be unique
- mSessionRouterManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(sessionRouterPrx, sessionRouterGuid));
-
- setCategory(mSessionRouterManagement, Routing::V1::SessionRouterDiscoveryCategory);
-
- }
- catch(...)
- {
- lg(Error) << "Major problems in " << mAppName << " registerWithServiceLocator()";
- }
+ try
+ {
+ // Get a proxy to the management interface for the Service Locator, so we can add ourselves into the system discovery mechanisms.
+ mServiceLocatorManagement = ServiceLocatorManagementPrx::checkedCast(mCommunicator->propertyToProxy("LocatorServiceManagement.Proxy"));
+
+ if (mServiceLocatorManagement == 0)
+ {
+ lg(Error) << "Unable to obtain proxy to ServiceLocatorManagement interface. Check config file. This component can't be found until this is corrected.";
+ return;
+ }
+
+ // Register our RoutingAdmin interface with the Service Locator.
+ Ice::ObjectPrx adminObjectPrx = mAdapter->createDirectProxy(mCommunicator->stringToIdentity(RoutingAdminObjectId));
+ RoutingServiceAdminPrx adminPrx = RoutingServiceAdminPrx::checkedCast(adminObjectPrx);
+ string adminServiceGuid("BasicRoutingServiceAdmin"); // Should be unique for reporting.
+ mAdminManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(adminPrx, adminServiceGuid));
+
+ setCategory(mAdminManagement, Routing::V1::RoutingServiceAdminDiscoveryCategory);
+
+ // Register our RegistryLocator interface with the Service Locator.
+ Ice::ObjectPrx locatorObjectPrx = mAdapter->createDirectProxy(mCommunicator->stringToIdentity(RegistryLocatorObjectId));
+ LocatorRegistryPrx locatorRegistryPrx = LocatorRegistryPrx::checkedCast(locatorObjectPrx);
+ string locatorServiceGuid("BasicRoutingServiceRegistryLocator"); // Should be unique for reporting.
+ mRegistryLocatorManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(locatorRegistryPrx, locatorServiceGuid));
+
+ setCategory(mRegistryLocatorManagement, Routing::V1::RoutingServiceLocatorRegistryDiscoveryCategory);
+
+ // Register the ComponentService interface with the Service Locator.
+ Ice::ObjectPrx componentServiceObjectPrx = mAdapter->createDirectProxy(mCommunicator->stringToIdentity(ComponentServiceId));
+ ComponentServicePrx componentServicePrx = ComponentServicePrx::checkedCast(componentServiceObjectPrx);
+ string componentServiceGuid("BasicRoutingService"); // Should be unique for reporting.
+ mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(componentServicePrx, componentServiceGuid));
+
+ setCategory(mComponentServiceManagement, Routing::V1::ComponentServiceDiscoveryCategory);
+
+ // Register the SessionRouter interface with the Service Locator.
+ Ice::ObjectPrx sessionRouterObjectPrx = mAdapter->createDirectProxy(mCommunicator->stringToIdentity(SessionRouterObjectId));
+ AsteriskSCF::SessionCommunications::V1::SessionRouterPrx sessionRouterPrx = AsteriskSCF::SessionCommunications::V1::SessionRouterPrx::checkedCast(sessionRouterObjectPrx);
+ string sessionRouterGuid("SessionRouter"); // Should be unique
+ mSessionRouterManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(sessionRouterPrx, sessionRouterGuid));
+
+ setCategory(mSessionRouterManagement, Routing::V1::SessionRouterDiscoveryCategory);
+
+ }
+ catch(...)
+ {
+ lg(Error) << "Major problems in " << mAppName << " registerWithServiceLocator()";
+ }
}
/**
@@ -210,16 +216,16 @@ void BasicRoutingServiceApp::registerWithServiceLocator()
*/
void BasicRoutingServiceApp::deregisterFromServiceLocator()
{
- try
- {
- mRegistryLocatorManagement->unregister();
- mAdminManagement->unregister();
- mComponentServiceManagement->unregister();
- }
- catch(...)
- {
- lg(Error) << "Had trouble in deregisterFromServiceLocator().";
- }
+ try
+ {
+ mRegistryLocatorManagement->unregister();
+ mAdminManagement->unregister();
+ mComponentServiceManagement->unregister();
+ }
+ catch(...)
+ {
+ lg(Error) << "Had trouble in deregisterFromServiceLocator().";
+ }
}
/**
@@ -228,88 +234,86 @@ void BasicRoutingServiceApp::deregisterFromServiceLocator()
*/
void BasicRoutingServiceApp::initialize()
{
- try
- {
- // Create the adapter.
- mAdapter = mCommunicator->createObjectAdapter("BasicRoutingServiceAdapter");
-
- mEventPublisher = new RoutingServiceEventPublisher(mAdapter);
-
- // setup the logger
- ConfiguredIceLoggerPtr mIceLogger = createIceLogger(mAdapter);
- getLoggerFactory().setLogOutput(mIceLogger->getLogger());
-
- // Create and configure the EndpointRegistry.
- ScriptProcessor* scriptProcesor(new LuaScriptProcessor());
- mEndpointRegistry = new EndpointRegistry(scriptProcesor, mEventPublisher);
-
- // Publish the LocatorRegistry interface.
- mAdapter->add(mEndpointRegistry, mCommunicator->stringToIdentity(RegistryLocatorObjectId));
-
- // Create publish the SessionRouter interface.
- SessionRouter *rawSessionRouter(new SessionRouter(mAdapter, mEndpointRegistry, mEventPublisher));
- BasicSessionRouterPtr basicSessionPtr(rawSessionRouter);
- mSessionRouter = basicSessionPtr;
- mAdapter->add(rawSessionRouter, mCommunicator->stringToIdentity(SessionRouterObjectId));
-
- // Create and publish the Admin interface support.
- mAdminInteface = new RoutingAdmin(mEndpointRegistry);
- mAdapter->add(mAdminInteface, mCommunicator->stringToIdentity(RoutingAdminObjectId));
-
- // Create and publish the ComponentService interface.
- mComponentService = new ComponentServiceImpl(*this);
- mAdapter->add(mComponentService, mCommunicator->stringToIdentity(ComponentServiceId));
-
- mAdapter->activate();
-
- // Get a proxy to the interface for the Service Locator.
- mServiceLocator = ServiceLocatorPrx::checkedCast(mCommunicator->propertyToProxy("LocatorService.Proxy"));
-
- mInitialized = true;
- }
- catch(const Ice::Exception &exception)
- {
- lg(Error) << "Problems in " << mAppName << " initialization(): " << exception.what();
- }
-
-
- BridgeManagerAccessorPtr ptr(new BridgeManagerAccessor(mServiceLocator));
- mBridgeManagerAccessor = ptr;
- mSessionRouter->setBridgeManagerAccessor(mBridgeManagerAccessor);
-
- if (!mBridgeManagerAccessor->isInitialized())
- {
- lg(Debug) << "Probabaly safe to ignore ServiceNotFound during startup. Will attempt to locate Bridge Service again when it is needed.";
- }
+ try
+ {
+ // Create the adapter.
+ mAdapter = mCommunicator->createObjectAdapter("BasicRoutingServiceAdapter");
+
+ mEventPublisher = new RoutingServiceEventPublisher(mAdapter);
+
+ // setup the logger
+ ConfiguredIceLoggerPtr mIceLogger = createIceLogger(mAdapter);
+ getLoggerFactory().setLogOutput(mIceLogger->getLogger());
+
+ // Create and configure the EndpointRegistry.
+ ScriptProcessor* scriptProcesor(new LuaScriptProcessor());
+ mEndpointRegistry = new EndpointRegistry(scriptProcesor, mEventPublisher);
+
+ // Publish the LocatorRegistry interface.
+ mAdapter->add(mEndpointRegistry, mCommunicator->stringToIdentity(RegistryLocatorObjectId));
+
+ // Create publish the SessionRouter interface.
+ SessionRouter *rawSessionRouter(new SessionRouter(mAdapter, mEndpointRegistry, mEventPublisher));
+ BasicSessionRouterPtr basicSessionPtr(rawSessionRouter);
+ mSessionRouter = basicSessionPtr;
+ mAdapter->add(rawSessionRouter, mCommunicator->stringToIdentity(SessionRouterObjectId));
+
+ // Create and publish the Admin interface support.
+ mAdminInteface = new RoutingAdmin(mEndpointRegistry);
+ mAdapter->add(mAdminInteface, mCommunicator->stringToIdentity(RoutingAdminObjectId));
+
+ // Create and publish the ComponentService interface.
+ mComponentService = new ComponentServiceImpl(*this);
+ mAdapter->add(mComponentService, mCommunicator->stringToIdentity(ComponentServiceId));
+
+ mAdapter->activate();
+
+ // Get a proxy to the interface for the Service Locator.
+ mServiceLocator = ServiceLocatorPrx::checkedCast(mCommunicator->propertyToProxy("LocatorService.Proxy"));
+
+ mInitialized = true;
+ }
+ catch(const Ice::Exception &exception)
+ {
+ lg(Error) << "Problems in " << mAppName << " initialization(): " << exception.what();
+ }
+
+
+ BridgeManagerAccessorPtr ptr(new BridgeManagerAccessor(mServiceLocator));
+ mBridgeManagerAccessor = ptr;
+ mSessionRouter->setBridgeManagerAccessor(mBridgeManagerAccessor);
+
+ if (!mBridgeManagerAccessor->isInitialized())
+ {
+ lg(Debug) << "Probabaly safe to ignore ServiceNotFound during startup. Will attempt to locate Bridge Service again when it is needed.";
+ }
}
/**
* Implementation of the required IceBox::Service start method.
*/
-void BasicRoutingServiceApp::start(const string& name,
- const Ice::CommunicatorPtr& communicator,
- const Ice::StringSeq& args)
+void BasicRoutingServiceApp::start(const string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args)
{
- lg(Info) << "Starting...";
-
- mCommunicator = communicator;
- mAppName = name;
-
- if (!mInitialized)
- {
- initialize();
- }
- else
- {
- mAdapter->activate();
- }
-
- // Plug back into the Asterisk SCF discovery system so that the interfaces we provide
- // can be located.
- registerWithServiceLocator();
-
- mRunning = true;
- lg(Info) << "Started";
+ lg(Info) << "Starting...";
+
+ mCommunicator = communicator;
+ mAppName = name;
+
+ if (!mInitialized)
+ {
+ initialize();
+ }
+ else
+ {
+ mAdapter->activate();
+ }
+
+ // Plug back into the Asterisk SCF discovery system so that the interfaces we provide
... 2317 lines suppressed ...
--
asterisk-scf/integration/routing.git
More information about the asterisk-scf-commits
mailing list