From 65269691aa4e694078749739b2134fcde8865729 Mon Sep 17 00:00:00 2001 From: maroy Date: Mon, 2 Aug 2004 03:34:58 +0000 Subject: [PATCH] added XML-RPC function reschedule --- .../products/scheduler/etc/Makefile.in | 5 +- .../scheduler/src/PostgresqlSchedule.cxx | 117 ++++++++++- .../scheduler/src/PostgresqlSchedule.h | 39 +++- .../scheduler/src/PostgresqlScheduleTest.cxx | 65 +++++- .../scheduler/src/PostgresqlScheduleTest.h | 13 +- .../scheduler/src/RescheduleMethod.cxx | 174 ++++++++++++++++ .../products/scheduler/src/RescheduleMethod.h | 170 ++++++++++++++++ .../scheduler/src/RescheduleMethodTest.cxx | 191 ++++++++++++++++++ .../scheduler/src/RescheduleMethodTest.h | 134 ++++++++++++ .../products/scheduler/src/ScheduleEntry.h | 22 +- .../scheduler/src/ScheduleInterface.h | 33 ++- .../scheduler/src/SchedulerDaemon.cxx | 3 +- .../products/scheduler/src/SchedulerDaemon.h | 11 +- .../src/SchedulerDaemonRescheduleTest.cxx | 190 +++++++++++++++++ .../src/SchedulerDaemonRescheduleTest.h | 117 +++++++++++ 15 files changed, 1269 insertions(+), 15 deletions(-) create mode 100644 livesupport/products/scheduler/src/RescheduleMethod.cxx create mode 100644 livesupport/products/scheduler/src/RescheduleMethod.h create mode 100644 livesupport/products/scheduler/src/RescheduleMethodTest.cxx create mode 100644 livesupport/products/scheduler/src/RescheduleMethodTest.h create mode 100644 livesupport/products/scheduler/src/SchedulerDaemonRescheduleTest.cxx create mode 100644 livesupport/products/scheduler/src/SchedulerDaemonRescheduleTest.h diff --git a/livesupport/products/scheduler/etc/Makefile.in b/livesupport/products/scheduler/etc/Makefile.in index e9f5ef903..6e5463328 100644 --- a/livesupport/products/scheduler/etc/Makefile.in +++ b/livesupport/products/scheduler/etc/Makefile.in @@ -21,7 +21,7 @@ # # # Author : $Author: maroy $ -# Version : $Revision: 1.5 $ +# Version : $Revision: 1.6 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $ # # @configure_input@ @@ -113,6 +113,7 @@ SCHEDULER_OBJS = ${TMP_DIR}/SignalDispatcher.o \ ${TMP_DIR}/DisplayScheduleMethod.o \ ${TMP_DIR}/DisplayPlaylistMethod.o \ ${TMP_DIR}/RemoveFromScheduleMethod.o \ + ${TMP_DIR}/RescheduleMethod.o \ ${TMP_DIR}/ScheduleFactory.o \ ${TMP_DIR}/PostgresqlSchedule.o @@ -128,10 +129,12 @@ TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \ ${TMP_DIR}/SchedulerDaemonDisplayScheduleTest.o \ ${TMP_DIR}/SchedulerDaemonDisplayPlaylistTest.o \ ${TMP_DIR}/SchedulerDaemonRemoveFromScheduleTest.o \ + ${TMP_DIR}/SchedulerDaemonRescheduleTest.o \ ${TMP_DIR}/UploadPlaylistMethodTest.o \ ${TMP_DIR}/DisplayScheduleMethodTest.o \ ${TMP_DIR}/DisplayPlaylistMethodTest.o \ ${TMP_DIR}/RemoveFromScheduleMethodTest.o \ + ${TMP_DIR}/RescheduleMethodTest.o \ ${TMP_DIR}/PostgresqlScheduleTest.o \ ${TMP_DIR}/TestRunner.o TEST_RUNNER_LIBS = ${SCHEDULER_EXE_LIBS} -lcppunit -ldl diff --git a/livesupport/products/scheduler/src/PostgresqlSchedule.cxx b/livesupport/products/scheduler/src/PostgresqlSchedule.cxx index 81e30584d..34b9856a7 100644 --- a/livesupport/products/scheduler/src/PostgresqlSchedule.cxx +++ b/livesupport/products/scheduler/src/PostgresqlSchedule.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlSchedule.cxx,v $ ------------------------------------------------------------------------------*/ @@ -96,6 +96,21 @@ const std::string PostgresqlSchedule::isTimeframaAvailableStmt = const std::string PostgresqlSchedule::schedulePlaylistStmt = "INSERT INTO schedule(id, playlist, starts, ends) VALUES(?, ?, ?, ?)"; +/*------------------------------------------------------------------------------ + * The SQL statement for getting a schedule entry based on its id + * The parameters for this call are: entryId + * and returns the properties: id, playlist, starts, ends for the entry + *----------------------------------------------------------------------------*/ +const std::string PostgresqlSchedule::getScheduleEntryStmt = + "SELECT id, playlist, starts, ends FROM schedule WHERE id = ?"; + +/*------------------------------------------------------------------------------ + * The SQL statement for rescheduling a playlist (an UPDATE call). + * There parameters for this call are: new start, new end, id. + *----------------------------------------------------------------------------*/ +const std::string PostgresqlSchedule::reschedulePlaylistStmt = + "UPDATE schedule SET starts = ?, ends = ? WHERE id = ?"; + /*------------------------------------------------------------------------------ * The SQL statement for querying scheduled entries for a time interval * The parameters for this call are: from, to @@ -398,3 +413,103 @@ PostgresqlSchedule :: removeFromSchedule( } } + +/*------------------------------------------------------------------------------ + * Get a ScheduleEntry based on a schedule entry id. + *----------------------------------------------------------------------------*/ +Ptr::Ref +PostgresqlSchedule :: getScheduleEntry(Ptr::Ref entryId) + throw (std::invalid_argument) +{ + Ptr::Ref conn; + Ptr::Ref entry; + + try { + conn = cm->getConnection(); + Ptr::Ref pstmt(conn->prepareStatement( + getScheduleEntryStmt)); + pstmt->setInt(1, entryId->getId()); + + Ptr::Ref rs(pstmt->executeQuery()); + if (rs->next()) { + Ptr::Ref timestamp(new Timestamp()); + + Ptr::Ref id(new UniqueId(rs->getInt(1))); + Ptr::Ref playlistId(new UniqueId(rs->getInt(2))); + + *timestamp = rs->getTimestamp(3); + Ptr::Ref startTime = Conversion::timestampToPtime(timestamp); + + *timestamp = rs->getTimestamp(4); + Ptr::Ref endTime = Conversion::timestampToPtime(timestamp); + + entry.reset(new ScheduleEntry(id, playlistId, startTime, endTime)); + } + + cm->returnConnection(conn); + } catch (std::exception &e) { + if (conn) { + cm->returnConnection(conn); + } + // TODO: report error + return entry; + } + + if (!entry) { + throw std::invalid_argument("no schedule entry by the specified id"); + } + + return entry; +} + + +/*------------------------------------------------------------------------------ + * Reschedule an entry + *----------------------------------------------------------------------------*/ +void +PostgresqlSchedule :: reschedule(Ptr::Ref entryId, + Ptr::Ref playtime) + throw (std::invalid_argument) +{ + Ptr::Ref entry = getScheduleEntry(entryId); + + Ptr::Ref ends(new ptime((*playtime) + + *(entry->getPlaylength()))); + + if (!isTimeframeAvailable(playtime, ends)) { + throw std::invalid_argument("new playtime not available"); + } + + Ptr::Ref conn; + bool result = false; + + try { + conn = cm->getConnection(); + Ptr::Ref timestamp; + Ptr::Ref pstmt(conn->prepareStatement( + reschedulePlaylistStmt)); + + timestamp = Conversion::ptimeToTimestamp(playtime); + pstmt->setTimestamp(1, *timestamp); + + timestamp = Conversion::ptimeToTimestamp(ends); + pstmt->setTimestamp(2, *timestamp); + + pstmt->setInt(3, entryId->getId()); + + result = pstmt->executeUpdate() == 1; + + cm->returnConnection(conn); + } catch (std::exception &e) { + if (conn) { + cm->returnConnection(conn); + } + throw std::invalid_argument(e.what()); + } + + if (!result) { + throw std::invalid_argument("couldn't insert into database"); + } +} + + diff --git a/livesupport/products/scheduler/src/PostgresqlSchedule.h b/livesupport/products/scheduler/src/PostgresqlSchedule.h index d1add56cb..e04c21044 100644 --- a/livesupport/products/scheduler/src/PostgresqlSchedule.h +++ b/livesupport/products/scheduler/src/PostgresqlSchedule.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlSchedule.h,v $ ------------------------------------------------------------------------------*/ @@ -81,7 +81,7 @@ using namespace LiveSupport::Core; * * * @author $Author: maroy $ - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ class PostgresqlSchedule : public Configurable, public ScheduleInterface @@ -112,6 +112,16 @@ class PostgresqlSchedule : public Configurable, */ static const std::string schedulePlaylistStmt; + /** + * The SQL statement for rescheduling an entry. + */ + static const std::string reschedulePlaylistStmt; + + /** + * The SQL statement for getting a schedule entry based on its id + */ + static const std::string getScheduleEntryStmt; + /** * The SQL statement for getting the schedules for a time interval */ @@ -270,6 +280,31 @@ class PostgresqlSchedule : public Configurable, virtual void removeFromSchedule(Ptr::Ref entryId) throw (std::invalid_argument); + + /** + * Return a schedule entry for a specified id. + * + * @param entryId the id of the entry to get. + * @return the ScheduleEntry for the specified id. + * @exception std::invalid_argument if no entry by the specified + * id exists. + */ + virtual Ptr::Ref + getScheduleEntry(Ptr::Ref entryId) + throw (std::invalid_argument); + + /** + * Reschedule an event to a different time. + * + * @param entryId the id of the entry to reschedule. + * @param playtime the new time for the schedule. + * @exception std::invalid_argument if there is something already + * scheduled for the new duration. + */ + virtual void + reschedule(Ptr::Ref entryId, + Ptr::Ref playtime) + throw (std::invalid_argument); }; diff --git a/livesupport/products/scheduler/src/PostgresqlScheduleTest.cxx b/livesupport/products/scheduler/src/PostgresqlScheduleTest.cxx index 8df364bdf..20faec7e6 100644 --- a/livesupport/products/scheduler/src/PostgresqlScheduleTest.cxx +++ b/livesupport/products/scheduler/src/PostgresqlScheduleTest.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlScheduleTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -393,3 +393,66 @@ PostgresqlScheduleTest :: removeFromScheduleTest(void) } +/*------------------------------------------------------------------------------ + * Test rescheduling. + *----------------------------------------------------------------------------*/ +void +PostgresqlScheduleTest :: rescheduleTest(void) + throw (CPPUNIT_NS::Exception) +{ + // create a 1 hour long playlist + Ptr::Ref playlistId = UniqueId::generateId(); + Ptr::Ref playlength(new time_duration(1, 0, 0)); + Ptr::Ref playlist(new Playlist(playlistId, playlength)); + + Ptr::Ref from; + Ptr::Ref to; + + Ptr::Ref entryId1; + Ptr::Ref entryId2; + + Ptr::Ref entry; + + // at the very first, try to reschedule something not scheduled + bool gotException = false; + try { + entryId1.reset(new UniqueId(9999)); + from.reset(new ptime(time_from_string("2004-07-23 10:00:00"))); + schedule->reschedule(entryId1, from); + } catch (std::invalid_argument &e) { + gotException = true; + } + CPPUNIT_ASSERT(gotException); + + try { + // schedule our playlist for 2004-07-23, 10 o'clock + from.reset(new ptime(time_from_string("2004-07-23 10:00:00"))); + entryId1 = schedule->schedulePlaylist(playlist, from); + + // schedule our playlist for 2004-07-23, 12 o'clock + from.reset(new ptime(time_from_string("2004-07-23 12:00:00"))); + entryId2 = schedule->schedulePlaylist(playlist, from); + + // now let's reschedule the first to a valid timepoint + from.reset(new ptime(time_from_string("2004-07-23 08:00:00"))); + schedule->reschedule(entryId1, from); + entry = schedule->getScheduleEntry(entryId1); + CPPUNIT_ASSERT((bool) entry); + CPPUNIT_ASSERT(*(entry->getStartTime()) == *from); + + // try to reschedule the second one into the first, should fail + gotException = false; + try { + from.reset(new ptime(time_from_string("2004-07-23 08:30:00"))); + schedule->reschedule(entryId1, from); + } catch (std::invalid_argument &e) { + gotException = true; + } + CPPUNIT_ASSERT(gotException); + + } catch (std::invalid_argument &e) { + CPPUNIT_FAIL(e.what()); + } +} + + diff --git a/livesupport/products/scheduler/src/PostgresqlScheduleTest.h b/livesupport/products/scheduler/src/PostgresqlScheduleTest.h index 8ff216409..ca60ea7b8 100644 --- a/livesupport/products/scheduler/src/PostgresqlScheduleTest.h +++ b/livesupport/products/scheduler/src/PostgresqlScheduleTest.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlScheduleTest.h,v $ ------------------------------------------------------------------------------*/ @@ -64,7 +64,7 @@ using namespace LiveSupport::Core; * Unit test for the PostgresqlSchedule class. * * @author $Author: maroy $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @see PostgresqlSchedule */ class PostgresqlScheduleTest : public CPPUNIT_NS::TestFixture @@ -76,6 +76,7 @@ class PostgresqlScheduleTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST(getScheduleEntriesTest); CPPUNIT_TEST(scheduleEntryExistsTest); CPPUNIT_TEST(removeFromScheduleTest); + CPPUNIT_TEST(rescheduleTest); CPPUNIT_TEST_SUITE_END(); private: @@ -141,6 +142,14 @@ class PostgresqlScheduleTest : public CPPUNIT_NS::TestFixture void removeFromScheduleTest(void) throw (CPPUNIT_NS::Exception); + /** + * Schedule some playlists, then reschedule them. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + rescheduleTest(void) throw (CPPUNIT_NS::Exception); + public: /** diff --git a/livesupport/products/scheduler/src/RescheduleMethod.cxx b/livesupport/products/scheduler/src/RescheduleMethod.cxx new file mode 100644 index 000000000..784f37759 --- /dev/null +++ b/livesupport/products/scheduler/src/RescheduleMethod.cxx @@ -0,0 +1,174 @@ +/*------------------------------------------------------------------------------ + + 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/RescheduleMethod.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 "ScheduleInterface.h" +#include "ScheduleFactory.h" +#include "RescheduleMethod.h" + + +using namespace boost; +using namespace boost::posix_time; + +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 RescheduleMethod::methodName = "reschedule"; + +/*------------------------------------------------------------------------------ + * The name of the playlist id member in the XML-RPC parameter + * structure. + *----------------------------------------------------------------------------*/ +const std::string RescheduleMethod::scheduleEntryIdName = + "scheduleEntryId"; + +/*------------------------------------------------------------------------------ + * The name of the playtime member in the XML-RPC parameter + * structure. + *----------------------------------------------------------------------------*/ +const std::string RescheduleMethod::playtimeName = "playtime"; + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Construct the method and register it right away. + *----------------------------------------------------------------------------*/ +RescheduleMethod :: RescheduleMethod ( + Ptr::Ref xmlRpcServer) throw() + : XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get()) +{ +} + + +/*------------------------------------------------------------------------------ + * Extract the UniqueId from an XML-RPC function call parameter + *----------------------------------------------------------------------------*/ +Ptr::Ref +RescheduleMethod :: extractScheduleEntryId( + XmlRpc::XmlRpcValue & xmlRpcValue) + throw (std::invalid_argument) +{ + if (!xmlRpcValue.hasMember(scheduleEntryIdName)) { + throw std::invalid_argument("no playlist id in parameter structure"); + } + + Ptr::Ref id(new UniqueId((int) xmlRpcValue[scheduleEntryIdName])); + return id; +} + + +/*------------------------------------------------------------------------------ + * Extract the playtime from an XML-RPC function call parameter + *----------------------------------------------------------------------------*/ +Ptr::Ref +RescheduleMethod :: extractPlayschedule( + XmlRpc::XmlRpcValue & xmlRpcValue) + throw (std::invalid_argument) +{ + if (!xmlRpcValue.hasMember(playtimeName)) { + throw std::invalid_argument("no playtime in parameter structure"); + } + + struct tm tm = (struct tm) xmlRpcValue[playtimeName]; + gregorian::date date(tm.tm_year, tm.tm_mon, tm.tm_mday); + time_duration hours(tm.tm_hour, tm.tm_min, tm.tm_sec); + Ptr::Ref ptime(new ptime(date, hours)); + + return ptime; +} + + +/*------------------------------------------------------------------------------ + * Execute the upload playlist method XML-RPC function call. + *----------------------------------------------------------------------------*/ +void +RescheduleMethod :: execute(XmlRpc::XmlRpcValue & parameters, + XmlRpc::XmlRpcValue & returnValue) + throw () +{ + try { + if (!parameters.valid()) { + // TODO: mark error + returnValue = XmlRpc::XmlRpcValue(false); + return; + } + + Ptr::Ref entryId = extractScheduleEntryId(parameters[0]); + Ptr::Ref playschedule = extractPlayschedule(parameters[0]); + Ptr::Ref scheduleEntryId; + + Ptr::Ref sf = ScheduleFactory::getInstance(); + Ptr::Ref schedule = sf->getSchedule(); + + if (!schedule->scheduleEntryExists(entryId)) { + // TODO: mark error; + returnValue = XmlRpc::XmlRpcValue(false); + return; + } + + schedule->reschedule(entryId, playschedule); + + } catch (std::invalid_argument &e) { + // TODO: mark error + returnValue = XmlRpc::XmlRpcValue(false); + return; + } + + + returnValue = XmlRpc::XmlRpcValue(true); +} + diff --git a/livesupport/products/scheduler/src/RescheduleMethod.h b/livesupport/products/scheduler/src/RescheduleMethod.h new file mode 100644 index 000000000..adf6f4f85 --- /dev/null +++ b/livesupport/products/scheduler/src/RescheduleMethod.h @@ -0,0 +1,170 @@ +/*------------------------------------------------------------------------------ + + 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/RescheduleMethod.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef RescheduleMethod_h +#define RescheduleMethod_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" +#include "LiveSupport/Core/UniqueId.h" + + +namespace LiveSupport { +namespace Scheduler { + +using namespace LiveSupport; +using namespace LiveSupport::Core; + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * An XML-RPC method object to reschedule an already scheduled event. + * + * The name of the method when called through XML-RPC is "reschedule". + * The expected parameter is an XML-RPC structure, with the following + * members: + *
    + *
  • scheduleEntryId - int - the id of the schedule entry to reschedule + *
  • + *
  • playtime - datetime - the new playing time for the entry
  • + *
+ * The return value is true if all went well, + * or a boolean false, if there were errors. + * + * @author $Author: maroy $ + * @version $Revision: 1.1 $ + */ +class RescheduleMethod : 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 name of the scheduled entry id member in the XML-RPC parameter + * structure. + */ + static const std::string scheduleEntryIdName; + + /** + * The name of the playtime member in the XML-RPC parameter + * structure. + */ + static const std::string playtimeName; + + /** + * Extract the schedule entry id from the XML-RPC parameters. + * + * @param xmlRpcValue the XML-RPC parameter to extract from. + * @return a UniqueId that was found in the XML-RPC parameter. + * @exception std::invalid_argument if there was no UniqueId + * in xmlRpcValue + */ + Ptr::Ref + extractScheduleEntryId(XmlRpc::XmlRpcValue & xmlRpcValue) + throw (std::invalid_argument); + + /** + * Extract the playtime from the XML-RPC parameters. + * + * @param xmlRpcValue the XML-RPC parameter to extract from. + * @return the playing time, as stored in the XML-RPC parameter + * @exception std::invalid_argument if there was no playtime + * in xmlRpcValue + */ + Ptr::Ref + extractPlayschedule(XmlRpc::XmlRpcValue & xmlRpcValue) + throw (std::invalid_argument); + + + public: + /** + * A default constructor, for testing purposes. + */ + RescheduleMethod(void) throw () + : XmlRpc::XmlRpcServerMethod(methodName) + { + } + + /** + * Constuctor that registers the method with the server right away. + * + * @param xmlRpcServer the XML-RPC server to register with. + */ + RescheduleMethod( + Ptr::Ref xmlRpcServer) + throw (); + + /** + * Execute the upload 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 (); +}; + + +/* ================================================= external data structures */ + + +/* ====================================================== function prototypes */ + + +} // namespace Scheduler +} // namespace LiveSupport + +#endif // RescheduleMethod_h + diff --git a/livesupport/products/scheduler/src/RescheduleMethodTest.cxx b/livesupport/products/scheduler/src/RescheduleMethodTest.cxx new file mode 100644 index 000000000..43f979caa --- /dev/null +++ b/livesupport/products/scheduler/src/RescheduleMethodTest.cxx @@ -0,0 +1,191 @@ +/*------------------------------------------------------------------------------ + + 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/RescheduleMethodTest.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 "LiveSupport/Db/ConnectionManagerFactory.h" +#include "LiveSupport/Storage/StorageClientFactory.h" +#include "ScheduleFactory.h" +#include "UploadPlaylistMethod.h" +#include "RescheduleMethod.h" +#include "RescheduleMethodTest.h" + + +using namespace LiveSupport::Db; +using namespace LiveSupport::Scheduler; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + +CPPUNIT_TEST_SUITE_REGISTRATION(RescheduleMethodTest); + +/** + * The name of the configuration file for the schedule factory. + */ +const std::string RescheduleMethodTest::scheduleConfig = + "etc/scheduleFactory.xml"; + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Configure a Configurable with an XML file. + *----------------------------------------------------------------------------*/ +void +RescheduleMethodTest :: 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 +RescheduleMethodTest :: setUp(void) throw () +{ + try { + Ptr::Ref sf = ScheduleFactory::getInstance(); + configure(sf, scheduleConfig); + + schedule = sf->getSchedule(); + schedule->install(); + } catch (std::invalid_argument &e) { + CPPUNIT_FAIL("semantic error in configuration file"); + } catch (xmlpp::exception &e) { + CPPUNIT_FAIL("error parsing configuration file"); + } catch (std::exception &e) { + CPPUNIT_FAIL(e.what()); + } +} + + +/*------------------------------------------------------------------------------ + * Clean up the test environment + *----------------------------------------------------------------------------*/ +void +RescheduleMethodTest :: tearDown(void) throw () +{ + schedule->uninstall(); +} + + +/*------------------------------------------------------------------------------ + * Just a very simple smoke test + *----------------------------------------------------------------------------*/ +void +RescheduleMethodTest :: firstTest(void) + throw (CPPUNIT_NS::Exception) +{ + Ptr::Ref uploadMethod(new UploadPlaylistMethod()); + Ptr::Ref rescheduleMethod(new RescheduleMethod()); + XmlRpc::XmlRpcValue rootParameter; + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + struct tm time; + Ptr::Ref entryId; + + // let's upload something so we can reschedule it + parameters["playlistId"] = 1; + time.tm_year = 2001; + time.tm_mon = 11; + time.tm_mday = 12; + time.tm_hour = 18; + time.tm_min = 31; + time.tm_sec = 1; + parameters["playtime"] = &time; + rootParameter[0] = parameters; + + uploadMethod->execute(rootParameter, result); + CPPUNIT_ASSERT(result.valid()); + entryId.reset(new UniqueId((int) result)); + + // now let's reschedule it + parameters.clear(); + result.clear(); + parameters["scheduleEntryId"] = (int) entryId->getId(); + time.tm_year = 2001; + time.tm_mon = 11; + time.tm_mday = 12; + time.tm_hour = 12; + time.tm_min = 31; + time.tm_sec = 1; + parameters["playtime"] = &time; + rootParameter[0] = parameters; + + rescheduleMethod->execute(rootParameter, result); + CPPUNIT_ASSERT(result.valid()); + CPPUNIT_ASSERT((bool) result); + + // now let's reschedule unto itself, should fail + parameters.clear(); + result.clear(); + parameters["scheduleEntryId"] = (int) entryId->getId(); + time.tm_year = 2001; + time.tm_mon = 11; + time.tm_mday = 12; + time.tm_hour = 12; + time.tm_min = 51; + time.tm_sec = 1; + parameters["playtime"] = &time; + rootParameter[0] = parameters; + + rescheduleMethod->execute(rootParameter, result); + CPPUNIT_ASSERT(result.valid()); + CPPUNIT_ASSERT(!((bool) result)); +} + diff --git a/livesupport/products/scheduler/src/RescheduleMethodTest.h b/livesupport/products/scheduler/src/RescheduleMethodTest.h new file mode 100644 index 000000000..7e854284a --- /dev/null +++ b/livesupport/products/scheduler/src/RescheduleMethodTest.h @@ -0,0 +1,134 @@ +/*------------------------------------------------------------------------------ + + 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/RescheduleMethodTest.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef RescheduleMethodTest_h +#define RescheduleMethodTest_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 for the RescheduleMethod class. + * + * @author $Author: maroy $ + * @version $Revision: 1.1 $ + * @see RescheduleMethod + */ +class RescheduleMethodTest : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(RescheduleMethodTest); + CPPUNIT_TEST(firstTest); + CPPUNIT_TEST_SUITE_END(); + + /** + * The name of the configuration file for the schedule factory. + */ + static const std::string scheduleConfig; + + /** + * The schedule used during the test. + */ + Ptr::Ref schedule; + + /** + * 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, + std::string fileName) + throw (std::invalid_argument, + xmlpp::exception); + + + 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 // RescheduleMethodTest_h + diff --git a/livesupport/products/scheduler/src/ScheduleEntry.h b/livesupport/products/scheduler/src/ScheduleEntry.h index 52b8787ef..12b37c2b9 100644 --- a/livesupport/products/scheduler/src/ScheduleEntry.h +++ b/livesupport/products/scheduler/src/ScheduleEntry.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/ScheduleEntry.h,v $ ------------------------------------------------------------------------------*/ @@ -68,7 +68,7 @@ using namespace LiveSupport::Core; * A scheduled event. * * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ class ScheduleEntry { @@ -93,6 +93,11 @@ class ScheduleEntry */ Ptr::Ref endTime; + /** + * The playling length of the event. + */ + Ptr::Ref playlength; + /** * The default constructor. */ @@ -121,6 +126,8 @@ class ScheduleEntry this->playlistId = playlistId; this->startTime = startTime; this->endTime = endTime; + + playlength.reset(new time_duration(*endTime - *startTime)); } /** @@ -166,6 +173,17 @@ class ScheduleEntry { return endTime; } + + /** + * Return the playlength of the schedule entry. + * + * @return the playing length of the schedule entry. + */ + Ptr::Ref + getPlaylength(void) const throw () + { + return playlength; + } }; diff --git a/livesupport/products/scheduler/src/ScheduleInterface.h b/livesupport/products/scheduler/src/ScheduleInterface.h index cc8b08be2..c42819242 100644 --- a/livesupport/products/scheduler/src/ScheduleInterface.h +++ b/livesupport/products/scheduler/src/ScheduleInterface.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ScheduleInterface.h,v $ ------------------------------------------------------------------------------*/ @@ -70,7 +70,7 @@ using namespace LiveSupport::Core; * The generic interface for the component scheduling events. * * @author $Author: maroy $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ class ScheduleInterface : virtual public Installable { @@ -93,7 +93,7 @@ class ScheduleInterface : virtual public Installable * @param playlist the playlist to schedule. * @param playtime the time to schedule the playlist for. * @return the id of the newly created playlist. - * @exception std::invalid_argument if the there is something + * @exception std::invalid_argument if there is something * already scheduled for the duration of the playlist. */ virtual Ptr::Ref @@ -140,6 +140,33 @@ class ScheduleInterface : virtual public Installable removeFromSchedule(Ptr::Ref entryId) throw (std::invalid_argument) = 0; + + /** + * Return a schedule entry for a specified id. + * + * @param entryId the id of the entry to get. + * @return the ScheduleEntry for the specified id. + * @exception std::invalid_argument if no entry by the specified + * id exists. + */ + virtual Ptr::Ref + getScheduleEntry(Ptr::Ref entryId) + throw (std::invalid_argument) + = 0; + + /** + * Reschedule an event to a different time. + * + * @param entryId the id of the entry to reschedule. + * @param playtime the new time for the schedule. + * @exception std::invalid_argument if there is something already + * scheduled for the new duration. + */ + virtual void + reschedule(Ptr::Ref entryId, + Ptr::Ref playtime) + throw (std::invalid_argument) + = 0; }; diff --git a/livesupport/products/scheduler/src/SchedulerDaemon.cxx b/livesupport/products/scheduler/src/SchedulerDaemon.cxx index 636e35f19..1d78afd3d 100644 --- a/livesupport/products/scheduler/src/SchedulerDaemon.cxx +++ b/livesupport/products/scheduler/src/SchedulerDaemon.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.cxx,v $ ------------------------------------------------------------------------------*/ @@ -166,6 +166,7 @@ SchedulerDaemon :: registerXmlRpcFunctions( xmlRpcServer->addMethod(displayScheduleMethod.get()); xmlRpcServer->addMethod(displayPlaylistMethod.get()); xmlRpcServer->addMethod(removeFromScheduleMethod.get()); + xmlRpcServer->addMethod(rescheduleMethod.get()); } diff --git a/livesupport/products/scheduler/src/SchedulerDaemon.h b/livesupport/products/scheduler/src/SchedulerDaemon.h index dcfec9c7f..f618fea57 100644 --- a/livesupport/products/scheduler/src/SchedulerDaemon.h +++ b/livesupport/products/scheduler/src/SchedulerDaemon.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.h,v $ ------------------------------------------------------------------------------*/ @@ -64,6 +64,7 @@ #include "DisplayScheduleMethod.h" #include "DisplayPlaylistMethod.h" #include "RemoveFromScheduleMethod.h" +#include "RescheduleMethod.h" #include "XmlRpcDaemon.h" @@ -119,7 +120,7 @@ using namespace LiveSupport::Core; * * * @author $Author: maroy $ - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ * @see ConnectionManagerFactory * @see StorageClientFactory * @see ScheduleFactory @@ -156,6 +157,11 @@ class SchedulerDaemon : public Installable, */ Ptr::Ref removeFromScheduleMethod; + /** + * The RescheduleMethod the daemon is providing. + */ + Ptr::Ref rescheduleMethod; + /** * Default constructor. */ @@ -166,6 +172,7 @@ class SchedulerDaemon : public Installable, displayScheduleMethod.reset(new DisplayScheduleMethod()); displayPlaylistMethod.reset(new DisplayPlaylistMethod()); removeFromScheduleMethod.reset(new RemoveFromScheduleMethod()); + rescheduleMethod.reset(new RescheduleMethod()); } protected: diff --git a/livesupport/products/scheduler/src/SchedulerDaemonRescheduleTest.cxx b/livesupport/products/scheduler/src/SchedulerDaemonRescheduleTest.cxx new file mode 100644 index 000000000..23a643abc --- /dev/null +++ b/livesupport/products/scheduler/src/SchedulerDaemonRescheduleTest.cxx @@ -0,0 +1,190 @@ +/*------------------------------------------------------------------------------ + + 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/SchedulerDaemonRescheduleTest.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 "SchedulerDaemonRescheduleTest.h" + + +using namespace XmlRpc; +using namespace LiveSupport::Scheduler; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + +CPPUNIT_TEST_SUITE_REGISTRATION(SchedulerDaemonRescheduleTest); + +/** + * The name of the configuration file for the scheduler daemon. + */ +static const std::string configFileName = "etc/scheduler.xml"; + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Set up the test environment + *----------------------------------------------------------------------------*/ +void +SchedulerDaemonRescheduleTest :: setUp(void) throw () +{ + Ptr::Ref daemon = SchedulerDaemon::getInstance(); + + if (!daemon->isConfigured()) { + try { + std::auto_ptr + parser(new xmlpp::DomParser(configFileName, true)); + const xmlpp::Document * document = parser->get_document(); + daemon->configure(*(document->get_root_node())); + } 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 +SchedulerDaemonRescheduleTest :: tearDown(void) throw () +{ + Ptr::Ref daemon = SchedulerDaemon::getInstance(); + +// daemon->stop(); + daemon->uninstall(); +} + + +/*------------------------------------------------------------------------------ + * A simple smoke test. + *----------------------------------------------------------------------------*/ +void +SchedulerDaemonRescheduleTest :: simpleTest(void) + throw (CPPUNIT_NS::Exception) +{ + XmlRpcValue parameters; + XmlRpcValue result; + struct tm time; + + XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + // first schedule a playlist, so that there is something to reschedule + parameters["playlistId"] = 1; + time.tm_year = 2001; + time.tm_mon = 11; + time.tm_mday = 12; + time.tm_hour = 10; + time.tm_min = 0; + time.tm_sec = 0; + parameters["playtime"] = &time; + + xmlRpcClient.execute("uploadPlaylist", parameters, result); + CPPUNIT_ASSERT(result.valid()); + + Ptr::Ref entryId(new UniqueId((int) result)); + + // now reschedule it + parameters["scheduleEntryId"] = (int) entryId->getId(); + time.tm_year = 2001; + time.tm_mon = 11; + time.tm_mday = 12; + time.tm_hour = 8; + time.tm_min = 0; + time.tm_sec = 0; + parameters["playtime"] = &time; + + xmlRpcClient.execute("reschedule", parameters, result); + CPPUNIT_ASSERT(result.valid()); + CPPUNIT_ASSERT(((bool)result) == true); + + // now reschedule it unto itself, should fail + parameters["scheduleEntryId"] = (int) entryId->getId(); + time.tm_year = 2001; + time.tm_mon = 11; + time.tm_mday = 12; + time.tm_hour = 8; + time.tm_min = 30; + time.tm_sec = 0; + parameters["playtime"] = &time; + + xmlRpcClient.execute("reschedule", parameters, result); + CPPUNIT_ASSERT(result.valid()); + CPPUNIT_ASSERT(((bool)result) == false); +} + + +/*------------------------------------------------------------------------------ + * A simple negative test. + *----------------------------------------------------------------------------*/ +void +SchedulerDaemonRescheduleTest :: negativeTest(void) + throw (CPPUNIT_NS::Exception) +{ + XmlRpcValue parameters; + XmlRpcValue result; + + XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + parameters["scheduleEntryId"] = 9999; + + xmlRpcClient.execute("removeFromSchedule", parameters, result); + CPPUNIT_ASSERT(result.valid()); + CPPUNIT_ASSERT(((bool)result) == false); +} + diff --git a/livesupport/products/scheduler/src/SchedulerDaemonRescheduleTest.h b/livesupport/products/scheduler/src/SchedulerDaemonRescheduleTest.h new file mode 100644 index 000000000..5c57d6500 --- /dev/null +++ b/livesupport/products/scheduler/src/SchedulerDaemonRescheduleTest.h @@ -0,0 +1,117 @@ +/*------------------------------------------------------------------------------ + + 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/SchedulerDaemonRescheduleTest.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef SchedulerDaemonRescheduleTest_h +#define SchedulerDaemonRescheduleTest_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; + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * Unit test to test the removeFromSchedule XML-RPC call. + * + * @author $Author: maroy $ + * @version $Revision: 1.1 $ + * @see SchedulerDaemon + */ +class SchedulerDaemonRescheduleTest : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(SchedulerDaemonRescheduleTest); + CPPUNIT_TEST(simpleTest); + CPPUNIT_TEST(negativeTest); + CPPUNIT_TEST_SUITE_END(); + + protected: + + /** + * Simple smoke test. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + simpleTest(void) throw (CPPUNIT_NS::Exception); + + /** + * Simple negative test. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + negativeTest(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 // SchedulerDaemonRescheduleTest_h +