[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "bridge-cookies" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Thu Jul 14 15:39:22 CDT 2011
branch "bridge-cookies" has been updated
via 42b192cf46f6b2a34dd99b8b1a434fdcd560e923 (commit)
via ee1803bfa821ea572c9e7dfe0f3079255b680543 (commit)
via ff05f2ec1837ee2587acf610a0ac4e6fd05bebbc (commit)
from 3c7658a6b05a45adfcd11963e9851eb7c7213c24 (commit)
Summary of changes:
config/test_bridging.conf | 1 +
src/BridgeImpl.cpp | 5 +-
src/Service.cpp | 39 +++---
test/BridgeListenerI.cpp | 62 ++++++---
test/BridgeListenerI.h | 12 ++
test/CMakeLists.txt | 2 +
test/TestBridging.cpp | 304 +++++++++++++++++++++++++++++++++++++++++++++
test/TestCookieIf.ice | 54 ++++++++
8 files changed, 438 insertions(+), 41 deletions(-)
create mode 100644 test/TestCookieIf.ice
- Log -----------------------------------------------------------------
commit 42b192cf46f6b2a34dd99b8b1a434fdcd560e923
Author: Brent Eagles <beagles at digium.com>
Date: Thu Jul 14 18:05:13 2011 -0230
Adding some component tests for cookie support. These tests may also do a fair
job of testing unsliceable support, but I'm not at all sure that this is the
case as everything is run in a single process.
Also added a workaround in the bridge service for an issue which prevent the
test suite from running. This is *not* a desirable state of affairs. I think
that there will be a better solution once the pending changes to service
discovery are completed.
diff --git a/config/test_bridging.conf b/config/test_bridging.conf
index e88f751..4e19d47 100644
--- a/config/test_bridging.conf
+++ b/config/test_bridging.conf
@@ -105,6 +105,7 @@ ServiceLocatorLocalAdapter.Endpoints=tcp -p 4412
#
LocatorService.Proxy=LocatorService:default -p 4411
ServiceLocatorManagementProxy=LocatorServiceManagement:tcp -p 4422
+LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4422
#
# The IceBox entries for loading the services.
diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index c5c646f..a9cd9e1 100755
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -850,7 +850,10 @@ void BridgeImpl::setCookies(const BridgeCookies& cookies, const Ice::Current& cu
boost::unique_lock<boost::shared_mutex> lock(mLock);
for (BridgeCookies::const_iterator i = cookies.begin(); i != cookies.end(); ++i)
{
- mState->cookies[(*i)->ice_id()] = (*i);
+ if ((*i))
+ {
+ mState->cookies[(*i)->ice_id()] = (*i);
+ }
}
if (!cookies.empty())
{
diff --git a/test/BridgeListenerI.cpp b/test/BridgeListenerI.cpp
index 16dcfc1..222995f 100644
--- a/test/BridgeListenerI.cpp
+++ b/test/BridgeListenerI.cpp
@@ -16,6 +16,7 @@
#include "BridgeListenerI.h"
using namespace AsteriskSCF::BridgingTest;
+using namespace std;
BridgeListenerI::BridgeListenerI() :
mShuttingDown(false),
@@ -23,31 +24,39 @@ BridgeListenerI::BridgeListenerI() :
{
}
-void BridgeListenerI::sessionsAdded(const AsteriskSCF::SessionCommunications::V1::BridgePrx&, const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions,
- const AsteriskSCF::SessionCommunications::V1::BridgeCookies&, const Ice::Current&)
+void BridgeListenerI::sessionsAdded(const AsteriskSCF::SessionCommunications::V1::BridgePrx&,
+ const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions,
+ const AsteriskSCF::SessionCommunications::V1::BridgeCookies& cookies, const Ice::Current&)
{
+ updateCookieMap("sessionsAdded", cookies);
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mAddMonitor);
- mAdded.insert(mAdded.end(), sessions.begin(), sessions.end());
+ mAdded =sessions;
mAddMonitor.notify();
}
-void BridgeListenerI::sessionsRemoved(const AsteriskSCF::SessionCommunications::V1::BridgePrx&, const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions,
- const AsteriskSCF::SessionCommunications::V1::BridgeCookies&, const Ice::Current&)
+void BridgeListenerI::sessionsRemoved(const AsteriskSCF::SessionCommunications::V1::BridgePrx&,
+ const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions,
+ const AsteriskSCF::SessionCommunications::V1::BridgeCookies& cookies, const Ice::Current&)
{
+ updateCookieMap("sessionsRemoved", cookies);
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mRemoveMonitor);
- mRemoved.insert(mRemoved.end(), sessions.begin(), sessions.end());
+ mRemoved = sessions;
mRemoveMonitor.notify();
}
void BridgeListenerI::stopping(const AsteriskSCF::SessionCommunications::V1::BridgePrx&,
- const AsteriskSCF::SessionCommunications::V1::BridgeCookies&, const Ice::Current&)
+ const AsteriskSCF::SessionCommunications::V1::BridgeCookies& cookies, const Ice::Current&)
{
+ updateCookieMap("stopping", cookies);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mStateMonitor);
mShuttingDown = true;
+ mStateMonitor.notify();
}
void BridgeListenerI::stopped(const AsteriskSCF::SessionCommunications::V1::BridgePrx&,
- const AsteriskSCF::SessionCommunications::V1::BridgeCookies&, const Ice::Current&)
+ const AsteriskSCF::SessionCommunications::V1::BridgeCookies& cookies, const Ice::Current&)
{
+ updateCookieMap("stopped", cookies);
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mStateMonitor);
mStopped = true;
mStateMonitor.notify();
@@ -57,6 +66,7 @@ bool BridgeListenerI::resetShuttingDown()
{
bool result = mShuttingDown;
mShuttingDown = false;
+ mCookieMap.clear();
return result;
}
@@ -64,6 +74,7 @@ bool BridgeListenerI::resetStopped()
{
bool result = mStopped;
mStopped = false;
+ mCookieMap.clear();
return result;
}
@@ -71,30 +82,26 @@ bool BridgeListenerI::waitForAdded(unsigned long milliseconds, AsteriskSCF::Sess
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mAddMonitor);
bool waitResult = mAddMonitor.timedWait(IceUtil::Time::milliSeconds(milliseconds));
- if(waitResult && mAdded.size() > 0)
- {
- added = mAdded;
- return true;
- }
- return false;
+ added = mAdded;
+ mAdded.clear();
+ return !added.empty();
}
bool BridgeListenerI::waitForRemoved(unsigned long milliseconds, AsteriskSCF::SessionCommunications::V1::SessionSeq& removed)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mRemoveMonitor);
bool waitResult = mRemoveMonitor.timedWait(IceUtil::Time::milliSeconds(milliseconds));
- if(waitResult && mRemoved.size() > 0)
- {
- removed = mRemoved;
- return true;
- }
- return false;
+ removed = mRemoved;
+ mRemoved.clear();
+ return !removed.empty();
+
}
bool BridgeListenerI::waitForStopped(unsigned long milliseconds)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mStateMonitor);
- return mStateMonitor.timedWait(IceUtil::Time::milliSeconds(milliseconds));
+ mStateMonitor.timedWait(IceUtil::Time::milliSeconds(milliseconds));
+ return mStopped;
}
size_t BridgeListenerI::addedCount()
@@ -106,3 +113,16 @@ size_t BridgeListenerI::removedCount()
{
return mRemoved.size();
}
+
+CookieMap BridgeListenerI::getCookieMap()
+{
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mCookieMapMonitor);
+ return mCookieMap;
+}
+
+void BridgeListenerI::updateCookieMap(const string& operation,
+ const AsteriskSCF::SessionCommunications::V1::BridgeCookies& cookies)
+{
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mCookieMapMonitor);
+ mCookieMap[operation] = cookies;
+}
diff --git a/test/BridgeListenerI.h b/test/BridgeListenerI.h
index 4b40eff..881de6b 100644
--- a/test/BridgeListenerI.h
+++ b/test/BridgeListenerI.h
@@ -16,11 +16,14 @@
#pragma once
#include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.h>
+#include <map>
+#include <string>
namespace AsteriskSCF
{
namespace BridgingTest
{
+typedef std::map<std::string, AsteriskSCF::SessionCommunications::V1::BridgeCookies> CookieMap;
class BridgeListenerI : public AsteriskSCF::SessionCommunications::V1::BridgeListener
{
@@ -46,6 +49,8 @@ public:
size_t addedCount();
size_t removedCount();
+ CookieMap getCookieMap();
+
private:
bool mShuttingDown;
bool mStopped;
@@ -53,10 +58,17 @@ private:
IceUtil::Monitor<IceUtil::Mutex> mAddMonitor;
IceUtil::Monitor<IceUtil::Mutex> mRemoveMonitor;
IceUtil::Monitor<IceUtil::Mutex> mStateMonitor;
+
+ IceUtil::Monitor<IceUtil::Mutex> mCookieMapMonitor;
+ CookieMap mCookieMap;
+
AsteriskSCF::SessionCommunications::V1::SessionSeq mAdded;
AsteriskSCF::SessionCommunications::V1::SessionSeq mRemoved;
bool mSessionsAdded;
bool mSessionsRemoved;
+
+ void updateCookieMap(const std::string& operation,
+ const AsteriskSCF::SessionCommunications::V1::BridgeCookies& cookies);
};
typedef IceUtil::Handle<BridgeListenerI> BridgeListenerPtr;
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index a9de994..6f2f1af 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -6,7 +6,9 @@ include_directories(../src)
astscf_slice_include_collection(TEST_CHANNEL)
astscf_component_init(bridge_component_test)
+astscf_slice_collection(LOCAL PATH "${CMAKE_CURRENT_SOURCE_DIR}")
astscf_component_add_slices(bridge_component_test TEST_CHANNEL AsteriskSCF/TestChannel/CommandsIf.ice)
+astscf_component_add_slices(bridge_component_test LOCAL TestCookieIf.ice)
astscf_component_add_files(bridge_component_test TestBridging.cpp)
astscf_component_add_files(bridge_component_test BridgeListenerI.h)
astscf_component_add_files(bridge_component_test BridgeListenerI.cpp)
diff --git a/test/TestBridging.cpp b/test/TestBridging.cpp
index 82edf8d..38ecc55 100644
--- a/test/TestBridging.cpp
+++ b/test/TestBridging.cpp
@@ -28,6 +28,8 @@
#include "TestCommandDriver.h"
#include "../src/ServiceUtil.h"
+#include "TestCookieIf.h"
+
#include <Ice/Ice.h>
#include <IceBox/IceBox.h>
@@ -39,12 +41,108 @@ using namespace AsteriskSCF::BridgingTest;
using namespace AsteriskSCF::SessionCommunications::V1;
using namespace AsteriskSCF::Core::Discovery::V1;
using namespace AsteriskSCF::Core::Routing::V1;
+using namespace AsteriskSCFTest;
using namespace std;
/* Cache the command line arguments so that Ice can be initialized within the global fixture. */
namespace
{
+BridgeCookies bakeTestCookies()
+{
+ BridgeCookies result;
+ TestCookieAPtr aCookie = new TestCookieA;
+ aCookie->astring = "I'm just a simple test cookie";
+ result.push_back(aCookie);
+
+ TestCookieBPtr bCookie = new TestCookieB;
+ bCookie->blong = 0xdeadbeef;
+ result.push_back(bCookie);
+
+ TestCookieDerivedFromBPtr derivedFromB = new TestCookieDerivedFromB;
+ derivedFromB->blong = 0xfeeffeef;
+ derivedFromB->bstring = "What the hex?";
+ result.push_back(derivedFromB);
+
+ TestNestedPtr nested1 = new TestNested;
+ nested1->baseString = "simple nested";
+
+ TestNestedDerivedPtr derivedNested= new TestNestedDerived;
+ derivedNested->baseString = "slightly less simple nested";
+ derivedNested->derivedLong = 42;
+
+ NestedTestSeq nestedObjs;
+ nestedObjs.push_back(nested1);
+ nestedObjs.push_back(derivedNested);
+ TestCookieCPtr cCookie = new TestCookieC;
+ cCookie->gettingALittleCrazyArentWe = nestedObjs;
+ result.push_back(cCookie);
+ return result;
+}
+
+void tasteCookies(const BridgeCookies& cookies, bool a, bool b, bool c, bool d)
+{
+ int count = 0;
+ if (a)
+ {
+ ++count;
+ }
+ if (b)
+ {
+ ++count;
+ }
+ if (c)
+ {
+ ++count;
+ }
+ if (d)
+ {
+ ++count;
+ }
+ BOOST_REQUIRE(cookies.size() == count);
+ for (BridgeCookies::const_iterator i = cookies.begin(); i != cookies.end(); ++i)
+ {
+ BridgeCookiePtr cookie = *i;
+ if (cookie->ice_id() == TestCookieA::ice_staticId())
+ {
+ a = !a;
+ BOOST_REQUIRE(TestCookieAPtr::dynamicCast(cookies[0])->astring == "I'm just a simple test cookie");
+ }
+ else if (cookie->ice_id() == TestCookieB::ice_staticId())
+ {
+ b = !b;
+ BOOST_REQUIRE(TestCookieBPtr::dynamicCast(cookies[1])->blong == 0xdeadbeef);
+ }
+ else if (cookie->ice_id() == TestCookieDerivedFromB::ice_staticId())
+ {
+ c = !c;
+ BOOST_REQUIRE(TestCookieDerivedFromBPtr::dynamicCast(cookie)->blong == 0xfeeffeef);
+ BOOST_REQUIRE(TestCookieDerivedFromBPtr::dynamicCast(cookie)->bstring == "What the hex?");
+ }
+ else if (cookie->ice_id() == TestCookieC::ice_staticId())
+ {
+ d = !d;
+ NestedTestSeq nestedObjs = TestCookieCPtr::dynamicCast(cookie)->gettingALittleCrazyArentWe;
+ BOOST_REQUIRE(nestedObjs.size() == 2);
+ BOOST_REQUIRE(nestedObjs[0]->ice_id() == TestNested::ice_staticId());
+ BOOST_REQUIRE(TestNestedPtr::dynamicCast(nestedObjs[0])->baseString == "simple nested");
+ BOOST_REQUIRE(nestedObjs[1]->ice_id() == TestNestedDerived::ice_staticId());
+ BOOST_REQUIRE(TestNestedDerivedPtr::dynamicCast(nestedObjs[1])->baseString == "slightly less simple nested");
+ BOOST_REQUIRE(TestNestedDerivedPtr::dynamicCast(nestedObjs[1])->derivedLong == 42);
+ }
+ }
+
+ BOOST_REQUIRE(!a);
+ BOOST_REQUIRE(!b);
+ BOOST_REQUIRE(!c);
+ BOOST_REQUIRE(!d);
+}
+
+void tasteCookies(const BridgeCookies& cookies)
+{
+ tasteCookies(cookies, true, true, true, true);
+}
+
void propGetSet(const Ice::PropertiesPtr& p, const string& propertyName, const string& value)
{
p->setProperty(propertyName, p->getPropertyWithDefault(propertyName, value));
@@ -852,6 +950,208 @@ public:
}
}
+ //
+ // The following tests validate the operation of the bridge cookie API and the corresponding listener
+ // interface. The listener apis are evaluated for each method, but only once (for adding). After
+ // that the getCookies is used to confirm the end result. We duplicate the tests that include replication
+ // to verify that replication of the cookies is occurring also.
+ //
+
+ void simpleCookieAddTest()
+ {
+ try
+ {
+ IceEnvironment testEnv(env()->properties());
+ try
+ {
+ Ice::ObjectAdapterPtr testAdapter = testEnv.communicator()->createObjectAdapter("TestUtilAdapter");
+ testAdapter->activate();
+ BridgeManagerListenerIPtr servant = new BridgeManagerListenerI;
+ AsteriskSCF::SessionCommunications::V1::BridgeManagerListenerPrx listenerPrx;
+ addServant(listenerPrx, testAdapter, servant, testEnv.strToIdent(IceUtil::generateUUID()));
+
+ AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx mgrPrx = env()->primaryBridgeManager();
+ BOOST_CHECK(mgrPrx);
+ mgrPrx->addListener(listenerPrx);
+ BOOST_CHECK(servant->stoppingCalls() == 0);
+ BOOST_CHECK(servant->stoppedCalls() == 0);
+ BOOST_CHECK(servant->createCalls() == 0);
+ AsteriskSCF::SessionCommunications::V1::SessionSeq sessions;
+ AsteriskSCF::SessionCommunications::V1::BridgePrx bridge(mgrPrx->createBridge(sessions, 0));
+ TestChannelWrapper channel(env()->properties());
+
+ AsteriskSCF::SessionCommunications::V1::SessionPrx a = channel.getSession("311");
+ AsteriskSCF::SessionCommunications::V1::SessionPrx b = channel.getSession("312");
+ sessions.push_back(a);
+ sessions.push_back(b);
+ //
+ // precondition checks for test validity.
+ //
+ std::string idA = testEnv.communicator()->identityToString(a->ice_getIdentity());
+ std::string idB = testEnv.communicator()->identityToString(b->ice_getIdentity());
+ std::vector<std::string> log;
+ channel.commands()->getlog(idA, log);
+ BOOST_CHECK(!find(log, "start"));
+ channel.commands()->getlog(idB, log);
+ BOOST_CHECK(!find(log, "start"));
+ BridgeCookies cookies = bakeTestCookies();
+ bridge->setCookies(cookies);
+ AsteriskSCF::BridgingTest::BridgeListenerPtr bridgeListener = new BridgeListenerI;
+ AsteriskSCF::SessionCommunications::V1::BridgeListenerPrx bridgeListenerPrx;
+ addServant(bridgeListenerPrx, testAdapter, bridgeListener, testEnv.strToIdent(IceUtil::generateUUID()));
+ bridge->addListener(bridgeListenerPrx);
+
+ AsteriskSCF::SessionCommunications::V1::SessionSeq eventSessions;
+ bridge->addSessions(sessions);
+ BOOST_REQUIRE(bridgeListener->waitForAdded(5000, eventSessions));
+ CookieMap cookieMap = bridgeListener->getCookieMap();
+ BOOST_REQUIRE(!cookieMap.empty());
+ BOOST_REQUIRE(!eventSessions.empty());
+
+ BOOST_REQUIRE(cookieMap.find("sessionsAdded") != cookieMap.end());
+ BridgeCookies returnedCookies = cookieMap["sessionsAdded"];
+ tasteCookies(returnedCookies);
+
+ sessions.clear();
+ sessions.push_back(b);
+ eventSessions.clear();
+ bridge->removeSessions(sessions);
+ BOOST_REQUIRE(bridgeListener->waitForRemoved(5000, eventSessions));
+ cookieMap = bridgeListener->getCookieMap();
+ BOOST_REQUIRE(!cookieMap.empty());
+ BOOST_REQUIRE(cookieMap.find("sessionsRemoved") != cookieMap.end());
+ returnedCookies = cookieMap["sessionsRemoved"];
+ tasteCookies(returnedCookies);
+
+ BOOST_REQUIRE(bridgeListener->waitForStopped(5000));
+ cookieMap = bridgeListener->getCookieMap();
+ BOOST_REQUIRE(cookieMap.find("stopping") != cookieMap.end());
+ returnedCookies = cookieMap["stopping"];
+ tasteCookies(returnedCookies);
+ BOOST_REQUIRE(cookieMap.find("stopped") != cookieMap.end());
+ returnedCookies = cookieMap["stopped"];
+ BOOST_REQUIRE(!returnedCookies.empty());
+ tasteCookies(returnedCookies);
+ returnedCookies = bridge->getCookies(cookies);
+ tasteCookies(returnedCookies);
+
+ }
+ catch (const Ice::Exception& ex)
+ {
+ std::ostringstream msg;
+ msg << "Unexpected Ice exception " << ex.what();
+ BOOST_FAIL(msg.str());
+ }
+ catch (...)
+ {
+ BOOST_FAIL("Unexpected exception");
+ }
+ }
+ catch (...)
+ {
+ BOOST_FAIL("Unexpected exception");
+ }
+ }
+
+ void cookieAddRemoveTest()
+ {
+ try
+ {
+ IceEnvironment testEnv(env()->properties());
+ try
+ {
+ Ice::ObjectAdapterPtr testAdapter = testEnv.communicator()->createObjectAdapter("TestUtilAdapter");
+ testAdapter->activate();
+ BridgeManagerListenerIPtr servant = new BridgeManagerListenerI;
+ AsteriskSCF::SessionCommunications::V1::BridgeManagerListenerPrx listenerPrx;
+ addServant(listenerPrx, testAdapter, servant, testEnv.strToIdent(IceUtil::generateUUID()));
+
+ AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx mgrPrx = env()->primaryBridgeManager();
+ BOOST_CHECK(mgrPrx);
+ mgrPrx->addListener(listenerPrx);
+ BOOST_CHECK(servant->stoppingCalls() == 0);
+ BOOST_CHECK(servant->stoppedCalls() == 0);
+ BOOST_CHECK(servant->createCalls() == 0);
+ AsteriskSCF::SessionCommunications::V1::SessionSeq sessions;
+ AsteriskSCF::SessionCommunications::V1::BridgePrx bridge(mgrPrx->createBridge(sessions, 0));
+ TestChannelWrapper channel(env()->properties());
+
+ AsteriskSCF::SessionCommunications::V1::SessionPrx a = channel.getSession("311");
+ AsteriskSCF::SessionCommunications::V1::SessionPrx b = channel.getSession("312");
+ sessions.push_back(a);
+ sessions.push_back(b);
+ //
+ // precondition checks for test validity.
+ //
+ std::string idA = testEnv.communicator()->identityToString(a->ice_getIdentity());
+ std::string idB = testEnv.communicator()->identityToString(b->ice_getIdentity());
+ std::vector<std::string> log;
+ channel.commands()->getlog(idA, log);
+ BOOST_CHECK(!find(log, "start"));
+ channel.commands()->getlog(idB, log);
+ BOOST_CHECK(!find(log, "start"));
+ BridgeCookies cookies = bakeTestCookies();
+ bridge->setCookies(cookies);
+ AsteriskSCF::BridgingTest::BridgeListenerPtr bridgeListener = new BridgeListenerI;
+ AsteriskSCF::SessionCommunications::V1::BridgeListenerPrx bridgeListenerPrx;
+ addServant(bridgeListenerPrx, testAdapter, bridgeListener, testEnv.strToIdent(IceUtil::generateUUID()));
+ bridge->addListener(bridgeListenerPrx);
+
+ AsteriskSCF::SessionCommunications::V1::SessionSeq eventSessions;
+ bridge->addSessions(sessions);
+ BOOST_REQUIRE(bridgeListener->waitForAdded(5000, eventSessions));
+ CookieMap cookieMap = bridgeListener->getCookieMap();
+ BOOST_REQUIRE(!cookieMap.empty());
+ BOOST_REQUIRE(!eventSessions.empty());
+
+ BOOST_REQUIRE(cookieMap.find("sessionsAdded") != cookieMap.end());
+ BridgeCookies returnedCookies = cookieMap["sessionsAdded"];
+ tasteCookies(returnedCookies);
+ BridgeCookies toRemove;
+ toRemove.push_back(cookies[1]);
+ bridge->removeCookies(toRemove);
+
+ sessions.clear();
+ sessions.push_back(b);
+ eventSessions.clear();
+ bridge->removeSessions(sessions);
+ BOOST_REQUIRE(bridgeListener->waitForRemoved(5000, eventSessions));
+ cookieMap = bridgeListener->getCookieMap();
+ BOOST_REQUIRE(!cookieMap.empty());
+ BOOST_REQUIRE(cookieMap.find("sessionsRemoved") != cookieMap.end());
+ returnedCookies = cookieMap["sessionsRemoved"];
+ tasteCookies(returnedCookies, true, false, true, true);
+
+ BOOST_REQUIRE(bridgeListener->waitForStopped(5000));
+ cookieMap = bridgeListener->getCookieMap();
+ BOOST_REQUIRE(cookieMap.find("stopping") != cookieMap.end());
+ returnedCookies = cookieMap["stopping"];
+ tasteCookies(returnedCookies, true, false, true, true);
+ BOOST_REQUIRE(cookieMap.find("stopped") != cookieMap.end());
+ returnedCookies = cookieMap["stopped"];
+ BOOST_REQUIRE(!returnedCookies.empty());
+ tasteCookies(returnedCookies, true, false, true, true);
+ cookies.erase(cookies.begin() +1);
+ returnedCookies = bridge->getCookies(cookies);
+ tasteCookies(returnedCookies, true, false, true, true);
+ }
+ catch (const Ice::Exception& ex)
+ {
+ std::ostringstream msg;
+ msg << "Unexpected Ice exception " << ex.what();
+ BOOST_FAIL(msg.str());
+ }
+ catch (...)
+ {
+ BOOST_FAIL("Unexpected exception");
+ }
+ }
+ catch (...)
+ {
+ BOOST_FAIL("Unexpected exception");
+ }
+ }
+
private:
TestEnvironmentPtr mTestEnvironment;
};
@@ -875,6 +1175,10 @@ bool init_unit_test()
add(BOOST_TEST_CASE(boost::bind(&BridgeTester::testReplaceSession, bridgeTester)));
framework::master_test_suite().
add(BOOST_TEST_CASE(boost::bind(&BridgeTester::testBridgeManagerListenerReplication, bridgeTester)));
+ framework::master_test_suite().
+ add(BOOST_TEST_CASE(boost::bind(&BridgeTester::simpleCookieAddTest, bridgeTester)));
+ framework::master_test_suite().
+ add(BOOST_TEST_CASE(boost::bind(&BridgeTester::cookieAddRemoveTest, bridgeTester)));
return true;
}
diff --git a/test/TestCookieIf.ice b/test/TestCookieIf.ice
new file mode 100644
index 0000000..dbd46ad
--- /dev/null
+++ b/test/TestCookieIf.ice
@@ -0,0 +1,54 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+#pragma once
+
+#include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.ice>
+
+module AsteriskSCFTest
+{
+unsliceable class TestCookieA extends AsteriskSCF::SessionCommunications::V1::BridgeCookie
+{
+ string astring;
+};
+
+unsliceable class TestCookieB extends AsteriskSCF::SessionCommunications::V1::BridgeCookie
+{
+ long blong;
+};
+
+unsliceable class TestCookieDerivedFromB extends TestCookieB
+{
+ string bstring;
+};
+
+unsliceable class TestNested
+{
+ string baseString;
+};
+
+unsliceable class TestNestedDerived extends TestNested
+{
+ long derivedLong;
+};
+
+sequence<TestNested> NestedTestSeq;
+
+unsliceable class TestCookieC extends AsteriskSCF::SessionCommunications::V1::BridgeCookie
+{
+ NestedTestSeq gettingALittleCrazyArentWe;
+};
+
+}; /* End of module AsteriskSCFTest */
commit ee1803bfa821ea572c9e7dfe0f3079255b680543
Merge: 3c7658a ff05f2e
Author: Brent Eagles <beagles at digium.com>
Date: Thu Jul 14 15:49:05 2011 -0230
Merge branch 'master' of ../../../regression/gitall/bridging into bridge-cookies
commit ff05f2ec1837ee2587acf610a0ac4e6fd05bebbc
Author: Brent Eagles <beagles at digium.com>
Date: Thu Jul 14 15:47:27 2011 -0230
Discovered that the reason for the test falure is that the test needed the ability to access multiple bridge component instances through discovery.
It worked until the service was fixed to only register a service with the service locator if it is active. Something else will need to be done
here obviously.
diff --git a/src/Service.cpp b/src/Service.cpp
index f0379d4..73aeb19 100644
--- a/src/Service.cpp
+++ b/src/Service.cpp
@@ -278,26 +278,27 @@ void BridgingApp::start(const std::string& name, const Ice::CommunicatorPtr& com
manager->activate();
}
- if (!onStandby)
+ //
+ // This was only set if the service was not active, but I think this may change with the changes to the discovery params
+ // and being able to specify ids.
+ //
+ bool registered = false;
+ try
{
- bool registered = false;
- try
- {
- ServiceLocatorParamsPtr parameters(new ServiceLocatorParams);
- parameters->category = BridgeServiceDiscoveryCategory;
- mLocator =
- new LocatorRegistrationWrapper<BridgeManagerPrx>(communicator, serviceLocatorManagementProperty, bridgeManagerPrx,
- adapterName, parameters);
- registered = mLocator->registerService();
- }
- catch (const Ice::Exception&)
- {
- }
- if (!registered)
- {
- mRegisterThread = new RegisterThread<BridgeManagerPrx>(mLocator);
- mRegisterThread->start();
- }
+ ServiceLocatorParamsPtr parameters(new ServiceLocatorParams);
+ parameters->category = BridgeServiceDiscoveryCategory;
+ mLocator =
+ new LocatorRegistrationWrapper<BridgeManagerPrx>(communicator, serviceLocatorManagementProperty, bridgeManagerPrx,
+ adapterName, parameters);
+ registered = mLocator->registerService();
+ }
+ catch (const Ice::Exception&)
+ {
+ }
+ if (!registered)
+ {
+ mRegisterThread = new RegisterThread<BridgeManagerPrx>(mLocator);
+ mRegisterThread->start();
}
//
// TODO: We need to know whether or not to activate!
-----------------------------------------------------------------------
--
asterisk-scf/integration/bridging.git
More information about the asterisk-scf-commits
mailing list