[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "retry_deux" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Wed Apr 11 10:25:31 CDT 2012
branch "retry_deux" has been updated
via 6f81de838f89479afdf7883efd7f27c3e0df3a36 (commit)
from 6dc85291730636e40a52f954cf6479e9a2447968 (commit)
Summary of changes:
test/ReplicationUnitTests.cpp | 191 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 191 insertions(+), 0 deletions(-)
create mode 100644 test/ReplicationUnitTests.cpp
- Log -----------------------------------------------------------------
commit 6f81de838f89479afdf7883efd7f27c3e0df3a36
Author: Brent Eagles <beagles at digium.com>
Date: Wed Apr 11 12:55:02 2012 -0230
Simple start to replication listener test driver.
diff --git a/test/ReplicationUnitTests.cpp b/test/ReplicationUnitTests.cpp
new file mode 100644
index 0000000..d7afaf6
--- /dev/null
+++ b/test/ReplicationUnitTests.cpp
@@ -0,0 +1,191 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010-2011, 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.
+ */
+
+#define BOOST_TEST_MODULE "Bridge replication implementation unit test"
+#include <boost/test/unit_test.hpp>
+#include <boost/bind.hpp>
+#include <boost/test/debug.hpp>
+#include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.h>
+#include <AsteriskSCF/Media/MediaIf.h>
+#include <AsteriskSCF/Logger.h>
+#include <Ice/Ice.h>
+#include <IceUtil/UUID.h>
+#include <set>
+#include <vector>
+#include <AsteriskSCF/Operations/OperationContext.h>
+#include <AsteriskSCF/Operations/OperationMonitor.h>
+#include <AsteriskSCF/CollocatedIceStorm/CollocatedIceStorm.h>
+
+#include "../src/BridgeManagerImpl.h"
+#include "../src/BridgePartyIdExtensionPoint.h"
+#include "../src/BridgeReplicationContext.h"
+#include "../src/BridgeReplicatorStateListenerI.h"
+
+using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::SessionCommunications::V1;
+using namespace AsteriskSCF::Replication::BridgeService::V1;
+using namespace AsteriskSCF::BridgeService;
+using namespace std;
+
+struct IceStormInitializer
+{
+ IceStormInitializer()
+ {
+ Ice::PropertiesPtr props = Ice::createProperties();
+ props->setProperty("BridgeUT.IceStorm.InstanceName", "BridgeUT");
+ props->setProperty("BridgeUT.IceStorm.TopicManager.Endpoints", "default -p 60632");
+ props->setProperty("BridgeUT.IceStorm.Publish.Endpoints", "default -p 61632");
+ props->setProperty("BridgeUT.IceStorm.Transient", "1");
+ collocatedIceStorm = new AsteriskSCF::CollocatedIceStorm::CollocatedIceStorm("BridgeUT", props);
+ }
+
+ AsteriskSCF::CollocatedIceStorm::CollocatedIceStormPtr collocatedIceStorm;
+} global;
+
+
+/**
+ * Set of unit tests focusing on the actions taken when receiving replication updates.
+ * Tests of published updates are covered through the TestBridging component test.
+ */
+
+class IceEnvironment
+{
+public:
+ IceEnvironment()
+ {
+ //
+ // NOTE: for the moment, the communicator is really a placeholder so doesn't require configuration.
+ //
+ Ice::StringSeq noArgs;
+ mCommunicator = Ice::initialize(noArgs);
+ //
+ // A bit of a nuisance but necessary for the bridge component's listener managers.
+ //
+ mCommunicator->getProperties()->setProperty("TopicManager.Proxy",
+ global.collocatedIceStorm->createTopicManagerProxy(mCommunicator)->ice_toString());
+
+ mAdapter = mCommunicator->createObjectAdapterWithEndpoints("UTAdapter", "default");
+ }
+
+ Ice::CommunicatorPtr communicator()
+ {
+ return mCommunicator;
+ }
+
+ Ice::ObjectAdapterPtr adapter() const
+ {
+ return mAdapter;
+ }
+
+ ~IceEnvironment()
+ {
+ try
+ {
+ mCommunicator->destroy();
+ }
+ catch (...)
+ {
+ std::cerr << "exception on destroy!" << std::endl;
+ }
+ }
+
+ Ice::Identity strToIdent(const std::string& s)
+ {
+ return mCommunicator->stringToIdentity(s);
+ }
+
+ AsteriskSCF::System::Logging::Logger logger() const
+ {
+ return getLoggerFactory().getLogger("AsteriskSCF.BridgeService.UnitTests");
+ }
+
+
+private:
+ Ice::CommunicatorPtr mCommunicator;
+ Ice::ObjectAdapterPtr mAdapter;
+};
+
+struct Fixture
+{
+ IceEnvironment environment;
+};
+
+
+//
+// First thing to get the replicator working is to create a functioning BridgeManagerServant.
+//
+
+BridgeManagerServantPtr createBridgeManagerServant(const IceEnvironment& iceEnv)
+{
+ BridgePartyIdExtensionPointPtr partyIdExtensionPoint = createPartyIdExtensionPoint(iceEnv.adapter(),
+ iceEnv.logger());
+ BridgeReplicationContextPtr replicationContext(new BridgeReplicationContext(
+ AsteriskSCF::Replication::STANDBY_IN_REPLICA_GROUP));
+ return createBridgeManager(iceEnv.adapter(), "test.bridge.manager", partyIdExtensionPoint,
+ replicationContext, iceEnv.logger());
+}
+
+ReplicatorListenerPtr createReplicatorListener(const BridgeManagerServantPtr& bridgeManager,
+ const AsteriskSCF::System::Logging::Logger& logger)
+{
+ return createStateListener(logger, bridgeManager);
+}
+
+BOOST_FIXTURE_TEST_CASE(replicateBridge, Fixture)
+{
+ try
+ {
+ BridgeManagerServantPtr bridgeManager(createBridgeManagerServant(environment));
+ ReplicatorListenerPtr replicatorListener(createReplicatorListener(bridgeManager, environment.logger()));
+ AsteriskSCF::System::V1::OperationContextPtr context(AsteriskSCF::Operations::createContext());
+ ReplicatedStateItemSeq updates;
+ BridgeStateItemPtr bridgeData(new BridgeStateItem);
+ bridgeData->key = "b";
+ bridgeData->serial = 101;
+ bridgeData->bridgeId = "one.bridge.across.troubled.waters";
+ bridgeData->runningState = Running;
+ bridgeData->mediaReplicationPolicy = Replicate;
+ bridgeData->originatingContext = context;
+ updates.clear();
+ updates.push_back(bridgeData);
+ replicatorListener->stateSet(AsteriskSCF::Operations::createContext(), updates);
+
+ vector<BridgeServantPtr> bridges = bridgeManager->getBridges();
+ BOOST_CHECK(bridges.size() == 1);
+
+ typedef AsteriskSCF::Operations::AMDContextResultData<AsteriskSCF::SessionCommunications::V1::BridgePrx,
+ AMD_BridgeManager_createBridgePtr> CreateBridgeContextData;
+ typedef boost::shared_ptr<CreateBridgeContextData> CreateBridgeContextDataPtr;
+
+ CreateBridgeContextDataPtr ctxtPtr(new CreateBridgeContextData); // Implements the AMD interface.
+ bridgeManager->createBridge_async(ctxtPtr->getProxy(), context,
+ SessionPrx(), SessionSeq(), BridgeListenerPrx(), 0, 0, Ice::Current());
+ BridgePrx result = ctxtPtr->getResult();
+ BOOST_CHECK(result->ice_getIdentity() ==
+ environment.communicator()->stringToIdentity("one.bridge.across.troubled.waters"));
+ }
+ catch (const std::exception& ex)
+ {
+ BOOST_MESSAGE(std::string(ex.what()) + " thrown");
+ throw;
+ }
+}
+
+BOOST_FIXTURE_TEST_CASE(replicateAddSessions, Fixture)
+{
+}
+
+
-----------------------------------------------------------------------
--
asterisk-scf/integration/bridging.git
More information about the asterisk-scf-commits
mailing list