[asterisk-scf-commits] asterisk-scf/integration/media_format_ulaw.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Oct 5 10:42:49 CDT 2010


branch "master" has been updated
       via  d983a3d5872450c3c7eed2cd6970326ecd3c9339 (commit)
      from  4413253a7ec783b83e697da5b41e6ca552c0f659 (commit)

Summary of changes:
 CMakeLists.txt                     |    2 +-
 cmake                              |    2 +-
 config/test_component.config.in    |   20 +++++++++++
 config/test_media_format_ulaw.conf |    2 +
 src/CMakeLists.txt                 |    4 +-
 src/MediaFormatULAW.cpp            |   67 +++++++++++++++++++----------------
 test/CMakeLists.txt                |   10 ++++-
 test/TestMediaFormatULAW.cpp       |   47 +++++++++++++++++++++++++
 8 files changed, 117 insertions(+), 37 deletions(-)
 create mode 100644 config/test_component.config.in


- Log -----------------------------------------------------------------
commit d983a3d5872450c3c7eed2cd6970326ecd3c9339
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Oct 5 12:45:58 2010 -0300

    Convert everything to be an IceBox service.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d4878a8..e3611e4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,7 +12,7 @@
 cmake_minimum_required(VERSION 2.6)
 
 # Include common Hydra build infrastructure
-include(cmake/Hydra_v4.cmake)
+include(cmake/AsteriskSCF.cmake)
 
 # This project is C++ based and requires a minimum of 3.4
 hydra_project(media_format_ulaw 3.4 CXX)
diff --git a/cmake b/cmake
index 8a93352..e9cf9f2 160000
--- a/cmake
+++ b/cmake
@@ -1 +1 @@
-Subproject commit 8a9335238af711324d93ca91c799a37545647fa3
+Subproject commit e9cf9f2e6dd03fe7bc39c363d72812aceed28367
diff --git a/config/test_component.config.in b/config/test_component.config.in
new file mode 100644
index 0000000..4ae5648
--- /dev/null
+++ b/config/test_component.config.in
@@ -0,0 +1,20 @@
+# This is a configuration file used in conjunction with the media_format_ulaw test driver
+
+# media_format_ulaw Configuration
+#
+IceBox.Service.MediaFormatULAW=media_format_ulaw:create --Ice.Config=config/test_media_format_ulaw.conf
+
+# Adapter parameters for this component
+MediaFormatULAWAdapter.Endpoints=default
+
+# A proxy to the service locator management service
+ServiceLocatorManagementProxy=LocatorServiceManagement:tcp -p 4422
+
+# A proxy to the service locator service
+ServiceLocatorProxy=LocatorService:tcp -p 4411
+
+#
+# media_rtp_pjmedia_test Configuration
+#
+IceBox.Service.MediaFormatULAWTest=media_format_ulaw_test:create --Ice.Config=config/test_component.config --report_sink=${CMAKE_BINARY_DIR}/media_format_ulaw_test-result.xml --report_format=XML --report_level=detailed
+
diff --git a/config/test_media_format_ulaw.conf b/config/test_media_format_ulaw.conf
index 56ce801..538250e 100644
--- a/config/test_media_format_ulaw.conf
+++ b/config/test_media_format_ulaw.conf
@@ -1,5 +1,7 @@
 # This is a configuration file used in conjunction with the ulaw media format test driver
 
+IceBox.Service.MediaFormatULAW=media_format_ulaw:create --Ice.Config=config/test_media_format_ulaw.conf
+
 # Adapter parameters for this component
 MediaFormatULAWAdapter.Endpoints=default
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 73c8772..c66c5f2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -11,5 +11,5 @@ hydra_component_add_slice(media_format_ulaw ServiceLocatorIf)
 hydra_component_add_slice(media_format_ulaw MediaIf)
 hydra_component_add_slice(media_format_ulaw ComponentServiceIf)
 hydra_component_add_file(media_format_ulaw MediaFormatULAW.cpp)
-hydra_component_build_standalone(media_format_ulaw)
-hydra_component_install(media_format_ulaw RUNTIME bin "Media Format ULAW." Media)
+hydra_component_build_icebox(media_format_ulaw)
+#hydra_component_install(media_format_ulaw RUNTIME bin "Media Format ULAW." Media)
diff --git a/src/MediaFormatULAW.cpp b/src/MediaFormatULAW.cpp
index 2422ed2..de8ff0e 100644
--- a/src/MediaFormatULAW.cpp
+++ b/src/MediaFormatULAW.cpp
@@ -7,6 +7,7 @@
  */
 
 #include <Ice/Ice.h>
+#include <IceBox/IceBox.h>
 
 #include "Core/Discovery/ServiceLocatorIf.h"
 #include "Media/MediaIf.h"
@@ -91,16 +92,21 @@ public:
 };
 
 /**
- * Implementation of the Ice::Application class
+ * Implementation of the IceBox::Service class
  */
-class MediaFormatULAWApp : public Ice::Application
+class MediaFormatULAWApp : public IceBox::Service
 {
 public:
-	int run(int, char*[]);
-	void interruptCallback(int);
+        void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&);
+	void stop();
 
 private:
 	/**
+	 * Object adapter everything is associated with.
+	 */
+	Ice::ObjectAdapterPtr mAdapter;
+
+	/**
 	 * A proxy to the service locator manager for the media format interface.
 	 */
 	ServiceManagementPrx mServiceManagement;
@@ -146,7 +152,7 @@ public:
 	 */
 	virtual void shutdown(const ::Ice::Current&)
 	{
-		mApplication.interruptCallback(EXIT_SUCCESS);
+		// TODO: Implement
 	}
 
 private:
@@ -163,74 +169,73 @@ private:
 };
 
 /**
- * Main entry point for our ulaw media format component.
+ * Implementation of the IceBox::Service::start method.
  */
-int main(int argc, char* argv[])
-{
-	MediaFormatULAWApp app;
-	app.callbackOnInterrupt();
-	return app.main(argc, argv);
-}
-
-/**
- * Overload of the Ice::Application::run method.
- */
-int MediaFormatULAWApp::run(int argc, char* argv[])
+void MediaFormatULAWApp::start(const std::string&, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq&)
 {
 	cout << "Initializing ulaw media format component" << endl;
 
-	Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("MediaFormatULAWAdapter");
+	mAdapter = communicator->createObjectAdapter("MediaFormatULAWAdapter");
 
 	/* Instantiate an implementation of the media format service which will provide ulaw media format classes. */
 	MediaFormatServicePtr MediaFormatService = new MediaFormatServiceImpl();
 
 	/* Now that we have the above we can add it to the object adapter and eventually the service locator, yahoo! */
-	MediaFormatServicePrx MediaFormatServiceProxy = MediaFormatServicePrx::uncheckedCast(adapter->addWithUUID(MediaFormatService));
+	MediaFormatServicePrx MediaFormatServiceProxy = MediaFormatServicePrx::uncheckedCast(mAdapter->addWithUUID(MediaFormatService));
 
 	/* Instantiate an implementation of the service locator parameters comparator service which will help the service locator
 	 * find us. */
 	ServiceLocatorParamsComparePtr ServiceLocatorParamsCompareService = new ServiceLocatorParamsCompareImpl();
 
 	/* Yet another thing to add to the object adapter and eventually the service locator... */
-	ServiceLocatorParamsComparePrx ServiceLocatorParamsCompareProxy = ServiceLocatorParamsComparePrx::uncheckedCast(adapter->addWithUUID(ServiceLocatorParamsCompareService));
+	ServiceLocatorParamsComparePrx ServiceLocatorParamsCompareProxy = ServiceLocatorParamsComparePrx::uncheckedCast(mAdapter->addWithUUID(ServiceLocatorParamsCompareService));
 
-	adapter->activate();
+	mAdapter->activate();
 
 	cout << "Activated ulaw media format component." << endl;
 
 	/* To the service locator management interface we gooooooooooo. */
-	ServiceLocatorManagementPrx management = ServiceLocatorManagementPrx::checkedCast(communicator()->propertyToProxy("ServiceLocatorManagementProxy"));
+	ServiceLocatorManagementPrx management = ServiceLocatorManagementPrx::checkedCast(communicator->propertyToProxy("ServiceLocatorManagementProxy"));
 
 	/* The comparator already has a UUID from when we added it to the object adapter so add it using that */
 	management->addCompare(ServiceLocatorParamsCompareProxy->ice_getIdentity().name, ServiceLocatorParamsCompareProxy);
 
 	/* Boom! In we go as a service. */
-	ServiceManagementPrx mServiceManagement = ServiceManagementPrx::uncheckedCast(management->addService(MediaFormatServiceProxy, "media_format_ulaw"));
+	mServiceManagement = ServiceManagementPrx::uncheckedCast(management->addService(MediaFormatServiceProxy, "media_format_ulaw"));
 
 	/* One must provide a component service to manage us, if someone wants to */
 	ComponentServicePtr ComponentService = new ComponentServiceImpl(*this, mServiceManagement);
-	ComponentServicePrx ComponentServiceProxy = ComponentServicePrx::uncheckedCast(adapter->addWithUUID(ComponentService));
+	ComponentServicePrx ComponentServiceProxy = ComponentServicePrx::uncheckedCast(mAdapter->addWithUUID(ComponentService));
 
 	/* Let's add the component service to the service locator first */
-	ServiceManagementPrx mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(management->addService(ComponentServiceProxy, "media_format_ulaw"));
+	mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(management->addService(ComponentServiceProxy, "media_format_ulaw"));
 	ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
 	genericparams->category = "Component/media_format_ulaw";
 	mComponentServiceManagement->addLocatorParams(genericparams, "");
 
+	cout << "Registered ulaw component service" << endl;
+
 	/* Now we can add some parameters to help find the actual media format service. */
 	genericparams->category = "media_format";
 	mServiceManagement->addLocatorParams(genericparams, ServiceLocatorParamsCompareProxy->ice_getIdentity().name);
 
-	/* Welp we are now in the service locator... they can find us! */
-	communicator()->waitForShutdown();
-
-	return EXIT_SUCCESS;
+	cout << "Registered ulaw format service" << endl;
 }
 
-void MediaFormatULAWApp::interruptCallback(int val)
+/**
+ * Implementation of the IceBox::Service::stop method.
+ */
+void MediaFormatULAWApp::stop()
 {
 	/* When all is said and done we have to leave the party */
 	mComponentServiceManagement->unregister();
 	mServiceManagement->unregister();
-	_exit(EXIT_SUCCESS);
+}
+
+extern "C"
+{
+	IceBox::Service* create(Ice::CommunicatorPtr communicator)
+	{
+		return new MediaFormatULAWApp;
+	}
 }
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 691e017..447f865 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -10,5 +10,11 @@ hydra_component_init(media_format_ulaw_test CXX)
 hydra_component_add_file(media_format_ulaw_test TestMediaFormatULAW.cpp)
 hydra_component_add_slice(media_format_ulaw_test MediaIf)
 hydra_component_add_boost_libraries(media_format_ulaw_test unit_test_framework)
-hydra_component_build_standalone(media_format_ulaw_test)
-hydra_component_install(media_format_ulaw_test RUNTIME bin "Media Format ULAW Test Driver." Core)
+hydra_component_build_icebox(media_format_ulaw_test)
+#hydra_component_install(media_format_ulaw_test RUNTIME bin "Media Format ULAW Test Driver." Core)
+
+icebox_add_test(media_format_ulaw_test config/test_component.config)
+
+# Copy our test config file to make it available in the test directory.
+# CMake does a bit of search-and-replace, as well.
+configure_file(../config/test_component.config.in ${CMAKE_CURRENT_BINARY_DIR}/config/test_component.config)
diff --git a/test/TestMediaFormatULAW.cpp b/test/TestMediaFormatULAW.cpp
index b883b94..8e8841f 100644
--- a/test/TestMediaFormatULAW.cpp
+++ b/test/TestMediaFormatULAW.cpp
@@ -14,6 +14,7 @@
 #include <boost/test/debug.hpp>
 
 #include <Ice/Ice.h>
+#include <IceBox/IceBox.h>
 
 #include "Core/Discovery/ServiceLocatorIf.h"
 #include "Media/MediaIf.h"
@@ -22,6 +23,18 @@ using namespace std;
 using namespace AsteriskSCF::Core::Discovery::V1;
 using namespace AsteriskSCF::Media::V1;
 
+/**
+ * Test service, for loading into icebox
+ */
+class MediaFormatULAWTest : public IceBox::Service
+{
+public:
+	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
 {
@@ -222,3 +235,37 @@ BOOST_AUTO_TEST_CASE(ConfirmUlawMediaFormatContents)
 
 	BOOST_CHECK(valid);
 }
+
+void MediaFormatULAWTest::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];
+
+	int r = ::boost::unit_test::unit_test_main(&init_unit_test, mCachedArgs.argc, mCachedArgs.argv);
+	exit(r);
+}
+
+void MediaFormatULAWTest::stop()
+{
+}
+
+extern "C"
+{
+	IceBox::Service* create(Ice::CommunicatorPtr communicator)
+	{
+		return new MediaFormatULAWTest;
+	}
+}

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


-- 
asterisk-scf/integration/media_format_ulaw.git



More information about the asterisk-scf-commits mailing list