From 2b60d95a9cde6982cbd6557c1171ba765ed36dce Mon Sep 17 00:00:00 2001 From: maroy Date: Wed, 1 Dec 2004 23:33:33 +0000 Subject: [PATCH] added getVersion XML-RPC method --- .../products/scheduler/etc/Makefile.in | 13 +- .../scheduler/src/GetVersionMethod.cxx | 98 +++++++++++ .../products/scheduler/src/GetVersionMethod.h | 142 ++++++++++++++++ .../scheduler/src/GetVersionMethodTest.cxx | 112 +++++++++++++ .../scheduler/src/GetVersionMethodTest.h | 111 +++++++++++++ .../scheduler/src/SchedulerDaemon.cxx | 6 +- .../products/scheduler/src/SchedulerDaemon.h | 14 +- .../src/SchedulerDaemonGetVersionTest.cxx | 154 ++++++++++++++++++ .../src/SchedulerDaemonGetVersionTest.h | 124 ++++++++++++++ 9 files changed, 766 insertions(+), 8 deletions(-) create mode 100644 livesupport/products/scheduler/src/GetVersionMethod.cxx create mode 100644 livesupport/products/scheduler/src/GetVersionMethod.h create mode 100644 livesupport/products/scheduler/src/GetVersionMethodTest.cxx create mode 100644 livesupport/products/scheduler/src/GetVersionMethodTest.h create mode 100644 livesupport/products/scheduler/src/SchedulerDaemonGetVersionTest.cxx create mode 100644 livesupport/products/scheduler/src/SchedulerDaemonGetVersionTest.h diff --git a/livesupport/products/scheduler/etc/Makefile.in b/livesupport/products/scheduler/etc/Makefile.in index 693aa70b4..ae4a1ebfe 100644 --- a/livesupport/products/scheduler/etc/Makefile.in +++ b/livesupport/products/scheduler/etc/Makefile.in @@ -20,8 +20,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # -# Author : $Author: fgerlits $ -# Version : $Revision: 1.29 $ +# Author : $Author: maroy $ +# Version : $Revision: 1.30 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $ # # @configure_input@ @@ -34,6 +34,7 @@ MKDIR = mkdir -p RM = rm -f RMDIR = rm -rf DOXYGEN = doxygen +KILLALL = killall #------------------------------------------------------------------------------- # Basic directory and file definitions @@ -148,6 +149,7 @@ SCHEDULER_OBJS = ${TMP_DIR}/SignalDispatcher.o \ ${TMP_DIR}/XmlRpcDaemon.o \ ${TMP_DIR}/SchedulerDaemon.o \ ${TMP_DIR}/XmlRpcTools.o \ + ${TMP_DIR}/GetVersionMethod.o \ ${TMP_DIR}/UploadPlaylistMethod.o \ ${TMP_DIR}/DisplayScheduleMethod.o \ ${TMP_DIR}/DisplayPlaylistMethod.o \ @@ -192,6 +194,8 @@ TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \ ${TMP_DIR}/RpcRemoveFromScheduleTest.o \ ${TMP_DIR}/RpcRescheduleTest.o \ ${TMP_DIR}/XmlRpcToolsTest.o \ + ${TMP_DIR}/GetVersionMethodTest.o \ + ${TMP_DIR}/SchedulerDaemonGetVersionTest.o \ ${TMP_DIR}/UploadPlaylistMethodTest.o \ ${TMP_DIR}/DisplayScheduleMethodTest.o \ ${TMP_DIR}/DisplayPlaylistMethodTest.o \ @@ -280,6 +284,11 @@ run: ${SCHEDULER_EXE} storage_server_init: # ${MAKE} -C ${STORAGE_SERVER_DIR} +kill: + ${KILLALL} scheduler + sleep 2 + ${KILLALL} -9 scheduler + #------------------------------------------------------------------------------- # Specific targets diff --git a/livesupport/products/scheduler/src/GetVersionMethod.cxx b/livesupport/products/scheduler/src/GetVersionMethod.cxx new file mode 100644 index 000000000..94d280836 --- /dev/null +++ b/livesupport/products/scheduler/src/GetVersionMethod.cxx @@ -0,0 +1,98 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + LiveSupport is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author: maroy $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GetVersionMethod.cxx,v $ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#ifdef HAVE_TIME_H +#include +#else +#error need time.h +#endif + + +#include + +#include "XmlRpcTools.h" + +#include "GetVersionMethod.h" + + +using namespace LiveSupport; +using namespace LiveSupport::Core; + +using namespace LiveSupport::Scheduler; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + +/*------------------------------------------------------------------------------ + * The name of this XML-RPC method. + *----------------------------------------------------------------------------*/ +const std::string GetVersionMethod::methodName = "getVersion"; + + +/*------------------------------------------------------------------------------ + * The version string. + *----------------------------------------------------------------------------*/ +const std::string GetVersionMethod::versionStr = + "Scheduler Daemon (" PACKAGE_VERSION ")"; + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Construct the method and register it right away. + *----------------------------------------------------------------------------*/ +GetVersionMethod :: GetVersionMethod ( + Ptr::Ref xmlRpcServer) throw () + : XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get()) +{ +} + + +/*------------------------------------------------------------------------------ + * Execute the stop XML-RPC function call. + *----------------------------------------------------------------------------*/ +void +GetVersionMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException) +{ + returnValue["version"] = versionStr; +} + diff --git a/livesupport/products/scheduler/src/GetVersionMethod.h b/livesupport/products/scheduler/src/GetVersionMethod.h new file mode 100644 index 000000000..d5603cd26 --- /dev/null +++ b/livesupport/products/scheduler/src/GetVersionMethod.h @@ -0,0 +1,142 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + LiveSupport is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author: maroy $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GetVersionMethod.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef GetVersionMethod_h +#define GetVersionMethod_h + +#ifndef __cplusplus +#error This is a C++ include file +#endif + + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include +#include +#include +#include +#include + +#include "LiveSupport/Core/Ptr.h" + + +namespace LiveSupport { +namespace Scheduler { + +using namespace LiveSupport; +using namespace LiveSupport::Core; + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * An XML-RPC method object to return the version string for the + * scheduler daemon. + * + * The name of the method when called through XML-RPC is "getVersion". + * + * There are no expected parameters for this method. + * + * The XML-RPC function returns an XML-RPC structure, containing the following + * fields: + *
    + *
  • version - string - the version string of the Scheduler Daemon + *
  • + *
+ * + * There are no possible internal error condititons for this function. + * + * @author $Author: maroy $ + * @version $Revision: 1.1 $ + */ +class GetVersionMethod : public XmlRpc::XmlRpcServerMethod +{ + private: + /** + * The name of this method, as it will be registered into the + * XML-RPC server. + */ + static const std::string methodName; + + /** + * The version string, returned by this method. + */ + static const std::string versionStr; + + + public: + /** + * A default constructor, for testing purposes. + */ + GetVersionMethod(void) throw () + : XmlRpc::XmlRpcServerMethod(methodName) + { + } + + /** + * Constuctor that registers the method with the server right away. + * + * @param xmlRpcServer the XML-RPC server to register with. + */ + GetVersionMethod( + Ptr::Ref xmlRpcServer) + throw (); + + /** + * Execute the create playlist command on the Scheduler daemon. + * + * @param parameters XML-RPC function call parameters + * @param returnValue the return value of the call (out parameter) + */ + void + execute( XmlRpc::XmlRpcValue & parameters, + XmlRpc::XmlRpcValue & returnValue) + throw (XmlRpc::XmlRpcException); +}; + + +/* ================================================= external data structures */ + + +/* ====================================================== function prototypes */ + + +} // namespace Scheduler +} // namespace LiveSupport + +#endif // GetVersionMethod_h + diff --git a/livesupport/products/scheduler/src/GetVersionMethodTest.cxx b/livesupport/products/scheduler/src/GetVersionMethodTest.cxx new file mode 100644 index 000000000..0fb349559 --- /dev/null +++ b/livesupport/products/scheduler/src/GetVersionMethodTest.cxx @@ -0,0 +1,112 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + LiveSupport is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author: maroy $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GetVersionMethodTest.cxx,v $ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#if HAVE_UNISTD_H +#include +#else +#error "Need unistd.h" +#endif + + +#include +#include +#include + +#include "GetVersionMethod.h" +#include "GetVersionMethodTest.h" + +using namespace LiveSupport::Scheduler; + + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + +CPPUNIT_TEST_SUITE_REGISTRATION(GetVersionMethodTest); + +/** + * The persumed version string. + */ +static const std::string versionStr = "Scheduler Daemon (" PACKAGE_VERSION ")"; + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Set up the test environment + *----------------------------------------------------------------------------*/ +void +GetVersionMethodTest :: setUp(void) throw () +{ +} + + +/*------------------------------------------------------------------------------ + * Clean up the test environment + *----------------------------------------------------------------------------*/ +void +GetVersionMethodTest :: tearDown(void) throw () +{ +} + + +/*------------------------------------------------------------------------------ + * Just a very simple smoke test + *----------------------------------------------------------------------------*/ +void +GetVersionMethodTest :: firstTest(void) + throw (CPPUNIT_NS::Exception) +{ + Ptr::Ref method(new GetVersionMethod()); + XmlRpc::XmlRpcValue rootParameter; + XmlRpc::XmlRpcValue result; + + result.clear(); + try { + method->execute(rootParameter, result); + } catch (XmlRpc::XmlRpcException &e) { + std::stringstream eMsg; + eMsg << "XML-RPC method returned error: " << e.getCode() + << " - " << e.getMessage(); + CPPUNIT_FAIL(eMsg.str()); + } + CPPUNIT_ASSERT(result.hasMember("version")); + CPPUNIT_ASSERT(result["version"] == versionStr); +} + diff --git a/livesupport/products/scheduler/src/GetVersionMethodTest.h b/livesupport/products/scheduler/src/GetVersionMethodTest.h new file mode 100644 index 000000000..551003a6d --- /dev/null +++ b/livesupport/products/scheduler/src/GetVersionMethodTest.h @@ -0,0 +1,111 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + LiveSupport is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author: maroy $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GetVersionMethodTest.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef GetVersionMethodTest_h +#define GetVersionMethodTest_h + +#ifndef __cplusplus +#error This is a C++ include file +#endif + + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include + +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" + +namespace LiveSupport { +namespace Scheduler { + +using namespace LiveSupport; +using namespace LiveSupport::Core; + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * Unit test for the GetVersionMethod class. + * + * @author $Author: maroy $ + * @version $Revision: 1.1 $ + * @see GetVersionMethod + */ +class GetVersionMethodTest : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(GetVersionMethodTest); + CPPUNIT_TEST(firstTest); + CPPUNIT_TEST_SUITE_END(); + + protected: + + /** + * A simple test. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + firstTest(void) throw (CPPUNIT_NS::Exception); + + public: + + /** + * Set up the environment for the test case. + */ + void + setUp(void) throw (); + + /** + * Clean up the environment after the test case. + */ + void + tearDown(void) throw (); +}; + + +/* ================================================= external data structures */ + + +/* ====================================================== function prototypes */ + + +} // namespace Scheduler +} // namespace LiveSupport + +#endif // GetVersionMethodTest_h + diff --git a/livesupport/products/scheduler/src/SchedulerDaemon.cxx b/livesupport/products/scheduler/src/SchedulerDaemon.cxx index e3a1e7709..8051ac378 100644 --- a/livesupport/products/scheduler/src/SchedulerDaemon.cxx +++ b/livesupport/products/scheduler/src/SchedulerDaemon.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: fgerlits $ - Version : $Revision: 1.10 $ + Author : $Author: maroy $ + Version : $Revision: 1.11 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.cxx,v $ ------------------------------------------------------------------------------*/ @@ -101,6 +101,7 @@ static const std::string xmlRpcDaemonConfElement = "xmlRpcDaemon"; SchedulerDaemon :: SchedulerDaemon (void) throw () : XmlRpcDaemon() { + getVersionMethod.reset(new GetVersionMethod()); uploadPlaylistMethod.reset(new UploadPlaylistMethod()); displayScheduleMethod.reset(new DisplayScheduleMethod()); displayPlaylistMethod.reset(new DisplayPlaylistMethod()); @@ -208,6 +209,7 @@ SchedulerDaemon :: registerXmlRpcFunctions( Ptr::Ref xmlRpcServer) throw (std::logic_error) { + xmlRpcServer->addMethod(getVersionMethod.get()); xmlRpcServer->addMethod(uploadPlaylistMethod.get()); xmlRpcServer->addMethod(displayScheduleMethod.get()); xmlRpcServer->addMethod(displayPlaylistMethod.get()); diff --git a/livesupport/products/scheduler/src/SchedulerDaemon.h b/livesupport/products/scheduler/src/SchedulerDaemon.h index 4194f5355..bb8eec1d7 100644 --- a/livesupport/products/scheduler/src/SchedulerDaemon.h +++ b/livesupport/products/scheduler/src/SchedulerDaemon.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: fgerlits $ - Version : $Revision: 1.9 $ + Author : $Author: maroy $ + Version : $Revision: 1.10 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.h,v $ ------------------------------------------------------------------------------*/ @@ -62,6 +62,7 @@ #include "LiveSupport/Core/Configurable.h" #include "LiveSupport/PlaylistExecutor/AudioPlayerInterface.h" #include "LiveSupport/EventScheduler/EventScheduler.h" +#include "GetVersionMethod.h" #include "UploadPlaylistMethod.h" #include "DisplayScheduleMethod.h" #include "DisplayPlaylistMethod.h" @@ -125,8 +126,8 @@ using namespace LiveSupport::PlaylistExecutor; * scheduleFactory,xmlRpcDaemon) > * * - * @author $Author: fgerlits $ - * @version $Revision: 1.9 $ + * @author $Author: maroy $ + * @version $Revision: 1.10 $ * @see ConnectionManagerFactory * @see StorageClientFactory * @see ScheduleFactory @@ -153,6 +154,11 @@ class SchedulerDaemon : public Installable, */ Ptr::Ref audioPlayer; + /** + * The getVersion the daemon is providing. + */ + Ptr::Ref getVersionMethod; + /** * The uploadPlaylistMethod the daemon is providing. */ diff --git a/livesupport/products/scheduler/src/SchedulerDaemonGetVersionTest.cxx b/livesupport/products/scheduler/src/SchedulerDaemonGetVersionTest.cxx new file mode 100644 index 000000000..f823c8345 --- /dev/null +++ b/livesupport/products/scheduler/src/SchedulerDaemonGetVersionTest.cxx @@ -0,0 +1,154 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + LiveSupport is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author: maroy $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonGetVersionTest.cxx,v $ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#if HAVE_UNISTD_H +#include +#else +#error "Need unistd.h" +#endif + + +#include +#include +#include + +#include "SchedulerDaemon.h" +#include "SchedulerDaemonGetVersionTest.h" + +using namespace std; +using namespace XmlRpc; +using namespace LiveSupport::Core; +using namespace LiveSupport::Scheduler; + + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + +CPPUNIT_TEST_SUITE_REGISTRATION(SchedulerDaemonGetVersionTest); + +/** + * The name of the configuration file for the scheduler daemon. + */ +static const std::string configFileName = "etc/scheduler.xml"; + +/** + * The persumed version string. + */ +static const std::string versionStr = "Scheduler Daemon (" PACKAGE_VERSION ")"; + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Configure a Configurable with an XML file. + *----------------------------------------------------------------------------*/ +void +SchedulerDaemonGetVersionTest :: configure( + Ptr::Ref configurable, + const std::string & fileName) + throw (std::invalid_argument, + xmlpp::exception) +{ + Ptr::Ref parser(new xmlpp::DomParser(fileName, true)); + const xmlpp::Document * document = parser->get_document(); + const xmlpp::Element * root = document->get_root_node(); + + configurable->configure(*root); +} + + +/*------------------------------------------------------------------------------ + * Set up the test environment + *----------------------------------------------------------------------------*/ +void +SchedulerDaemonGetVersionTest :: setUp(void) throw () +{ + Ptr::Ref daemon = SchedulerDaemon::getInstance(); + + if (!daemon->isConfigured()) { + try { + configure(daemon, configFileName); + } catch (std::invalid_argument &e) { + std::cerr << e.what() << std::endl; + CPPUNIT_FAIL("semantic error in configuration file"); + } catch (xmlpp::exception &e) { + std::cerr << e.what() << std::endl; + CPPUNIT_FAIL("error parsing configuration file"); + } + } + + daemon->install(); +// daemon->start(); +// sleep(5); +} + + +/*------------------------------------------------------------------------------ + * Clean up the test environment + *----------------------------------------------------------------------------*/ +void +SchedulerDaemonGetVersionTest :: tearDown(void) throw () +{ + Ptr::Ref daemon = SchedulerDaemon::getInstance(); + +// daemon->stop(); + daemon->uninstall(); +} + + +/*------------------------------------------------------------------------------ + * Test a simple upload. + *----------------------------------------------------------------------------*/ +void +SchedulerDaemonGetVersionTest :: simpleTest(void) + throw (CPPUNIT_NS::Exception) +{ + XmlRpcValue parameters; + XmlRpcValue result; + + XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + result.clear(); + xmlRpcClient.execute("getVersion", parameters, result); + CPPUNIT_ASSERT(!result.hasMember("errorCode")); + CPPUNIT_ASSERT(result.hasMember("version")); + CPPUNIT_ASSERT(result["version"] == versionStr); +} + diff --git a/livesupport/products/scheduler/src/SchedulerDaemonGetVersionTest.h b/livesupport/products/scheduler/src/SchedulerDaemonGetVersionTest.h new file mode 100644 index 000000000..c7af66b60 --- /dev/null +++ b/livesupport/products/scheduler/src/SchedulerDaemonGetVersionTest.h @@ -0,0 +1,124 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + LiveSupport is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author: maroy $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonGetVersionTest.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef SchedulerDaemonGetVersionTest_h +#define SchedulerDaemonGetVersionTest_h + +#ifndef __cplusplus +#error This is a C++ include file +#endif + + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include + +namespace LiveSupport { +namespace Scheduler { + +using namespace LiveSupport; +using namespace LiveSupport::Core; + + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * Unit test to test the getVersion XML-RPC call. + * + * @author $Author: maroy $ + * @version $Revision: 1.1 $ + * @see SchedulerDaemon + */ +class SchedulerDaemonGetVersionTest : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(SchedulerDaemonGetVersionTest); + CPPUNIT_TEST(simpleTest); + CPPUNIT_TEST_SUITE_END(); + + private: + /** + * Configure a configurable with an XML file. + * + * @param configurable configure this + * @param fileName the name of the XML file to configure with. + * @exception std::invalid_argument on configuration errors. + * @exception xmlpp::exception on XML parsing errors. + */ + void + configure(Ptr::Ref configurable, + const std::string & fileName) + throw (std::invalid_argument, + xmlpp::exception); + + protected: + + /** + * Simple test for playlist uploading. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + simpleTest(void) throw (CPPUNIT_NS::Exception); + + public: + + /** + * Set up the environment for the test case. + */ + void + setUp(void) throw (); + + /** + * Clean up the environment after the test case. + */ + void + tearDown(void) throw (); +}; + + +/* ================================================= external data structures */ + + +/* ====================================================== function prototypes */ + + +} // namespace Scheduler +} // namespace LiveSupport + +#endif // SchedulerDaemonGetVersionTest_h +