[asterisk-scf-commits] asterisk-scf/release/media_operations_core.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Aug 15 17:15:10 CDT 2011


branch "master" has been updated
       via  011901f570507bc0cc82c867c94e9c03c9573ba6 (commit)
      from  b7163f64c77deaa71cfaeacaee00e70d9e53c474 (commit)

Summary of changes:
 .../MediaOperationsCore/MediaOperationsCoreIf.ice  |   55 ++++++++
 test/TestMediaOperations.cpp                       |  137 ++++++++++++++++++++
 2 files changed, 192 insertions(+), 0 deletions(-)
 create mode 100644 slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice
 create mode 100644 test/TestMediaOperations.cpp


- Log -----------------------------------------------------------------
commit 011901f570507bc0cc82c867c94e9c03c9573ba6
Author: Mark Michelson <mmichelson at digium.com>
Date:   Mon Aug 15 17:15:25 2011 -0500

    Add in state replication types and initial test code.
    
    I had to stop short on the test-writing because I realized I hadn't
    yet written a custom service locator comparator in the media operations
    core so that a specific operation could be found.

diff --git a/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice b/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice
new file mode 100644
index 0000000..344a9ec
--- /dev/null
+++ b/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice
@@ -0,0 +1,55 @@
+/*
+ * 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
+
+module AsteriskSCF
+{
+
+module Replication
+{
+
+module MediaOperationsCore
+{
+
+["visitor"] local class MediaOperationsCoreStateItemVisitor;
+
+["visitor:MediaOperationsCoreStateItemVisitor"] class MediaOperationsCoreStateItem
+{
+}
+
+class MediaOperationFactoryStateItem
+{
+    Ice::Identity id;
+}
+
+/**
+ * All media operations will need
+ * to replicate their own ID, as well
+ * as their source and sink IDs. Any
+ * operation that has more state to
+ * replicate can create a subclass of this
+ */
+class MediaOperationStateItem
+{
+    Ice::Identity operationId;
+    Ice::Identity sourceId;
+    Ice::Identity sinkId;
+}
+
+}; /* end module MediaOperationsCore */
+}; /* end module Replication */
+}; /* end module AsteriskSCF */
diff --git a/test/TestMediaOperations.cpp b/test/TestMediaOperations.cpp
new file mode 100644
index 0000000..6f12b73
--- /dev/null
+++ b/test/TestMediaOperations.cpp
@@ -0,0 +1,137 @@
+/*
+ * 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.
+ */
+
+
+class MediaOperationsCoreTest : public IceBox::Service
+{
+    void start(const std::string&,
+        const Ice::CommunicatorPtr&,
+        const Ice::StringSeq&);
+    void stop();
+};
+
+/* Cache the command line arguments so that Ice can be initialized within the global fixture. */
+struct ArgCacheType
+{
+public:
+    int argc;
+    char **argv;
+};
+static ArgCacheType mCachedArgs;
+
+struct SharedTestData
+{
+public:
+    Ice::CommunicatorPtr communicator;
+    ServiceLocatorPrx locator;
+};
+
+static SharedTestData Testbed;
+
+struct GlobalIceFixture
+{
+    GlobalIceFixture()
+    {
+        BOOST_TEST_MESSAGE("Setting up media operations core test fixture");
+
+        ::boost::debug::detect_memory_leaks(false);
+        ::boost::unit_test::unit_test_log.set_stream( std::cout );
+
+        int status = 0;
+        try
+        {
+            Testbed.communicator = Ice::initialize(mCachedArgs.argc, mCachedArgs.argv);
+            Testbed.adapter = 
+                Testbed.communicator->createObjectAdapterWithEndpoints("Adapter", "default");
+            Testbed.adapter->activate();
+            Testbed.locator = ServiceLocatorPrx::checkedCast(Testbed.communicator->stringToProxy("LocatorService:tcp -p 4411"));
+
+            if (!Testbed.locator) {
+                throw "Invalid service locator proxy";
+            }
+        }
+        catch (const Ice::Exception& ex)
+        {
+            std::cerr << ex << std::endl;
+            status = 1;
+        }
+        catch (...)
+        {
+            std::cerr << "Some non-Ice exception got encaughtened." << std::endl;
+            status = 1;
+        }
+    }
+
+    ~GlobalIceFixture()
+    {
+        BOOST_TEST_MESSAGE("Tearing down media operations core test fixture");
+
+        if (Testbed.communicator)
+        {
+            Testbed.communicator->shutdown();
+            Testbed.communicator = 0;
+        }
+    }
+};
+
+BOOST_GLOBAL_FIXTURE(GlobalIceFixture);
+
+BOOST_AUTO_TEST_CASE(FindUlawAlawFactory)
+{
+    try
+    {
+        MediaOperationAttributes ulaw2alaw;
+        ulaw2alaw.inputFormat = new G711uLAW();
+        ulaw2alaw.outputFormat = new G711aLAW();
+        MediaOperationServiceLocatorParamsPtr params = new MediaOperationServiceLocatorParams();
+        params->attributes.push_back(ulaw2alaw);
+    }
+    catch
+}
+
+void MediaOperationsCoreTest::start(const std::string& name,
+        const Ice::CommunicatorPtr&,
+        const Ice::StringSeq& args)
+{
+    std::vector<const char *> 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());
+        mCachedArgs.argc++;
+    }
+    // null terminated list
+    argv.push_back((const char *) 0);
+
+    mCachedArgs.argv = (char**)&argv[0];
+    int r = ::boost::unit_test::unit_test_main(&init_unit_test, mCachedArgs.argc, mCachedArgs.argv);
+    exit(r);
+}
+
+void MediaOperationsCoreTest::stop()
+{
+}
+
+extern "C"
+{
+ASTSCF_DLL_EXPORT IceBox::Service* create(Ice::CommunicatorPtr)
+{
+    return new MediaOperationsCoreTest;
+}
+}

-----------------------------------------------------------------------


-- 
asterisk-scf/release/media_operations_core.git



More information about the asterisk-scf-commits mailing list