diff --git a/livesupport/modules/storage/src/WebStorageClient.cxx b/livesupport/modules/storage/src/WebStorageClient.cxx index fc2b1bb88..6153a7e3c 100644 --- a/livesupport/modules/storage/src/WebStorageClient.cxx +++ b/livesupport/modules/storage/src/WebStorageClient.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.34 $ + Version : $Revision: 1.35 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $ ------------------------------------------------------------------------------*/ @@ -1875,6 +1875,8 @@ WebStorageClient :: reset(void) throw XmlRpcMethodResponseException(eMsg.str()); } + editedPlaylists.clear(); + XmlRpcValue audioClipArray = result[resetStorageAudioClipResultParamName]; audioClipIds.reset(new std::vector::Ref>); diff --git a/livesupport/products/scheduler/etc/Makefile.in b/livesupport/products/scheduler/etc/Makefile.in index acddb32b2..740aea5f4 100644 --- a/livesupport/products/scheduler/etc/Makefile.in +++ b/livesupport/products/scheduler/etc/Makefile.in @@ -21,7 +21,7 @@ # # # Author : $Author: fgerlits $ -# Version : $Revision: 1.49 $ +# Version : $Revision: 1.50 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $ # # @configure_input@ @@ -225,21 +225,28 @@ TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \ ${TMP_DIR}/DisplayPlaylistsMethodTest.o \ ${TMP_DIR}/RpcDisplayPlaylistsTest.o \ ${TMP_DIR}/OpenPlaylistForEditingMethodTest.o \ + ${TMP_DIR}/RpcOpenPlaylistForEditingTest.o \ ${TMP_DIR}/CreatePlaylistMethodTest.o \ ${TMP_DIR}/RpcCreatePlaylistTest.o \ ${TMP_DIR}/AddAudioClipToPlaylistMethodTest.o \ ${TMP_DIR}/RpcAddAudioClipToPlaylistTest.o \ ${TMP_DIR}/RemoveAudioClipFromPlaylistMethodTest.o \ + ${TMP_DIR}/RpcRemoveAudioClipFromPlaylistTest.o \ ${TMP_DIR}/ValidatePlaylistMethodTest.o \ + ${TMP_DIR}/RpcValidatePlaylistTest.o \ ${TMP_DIR}/DisplayAudioClipMethodTest.o \ ${TMP_DIR}/RpcDisplayAudioClipTest.o \ ${TMP_DIR}/DisplayAudioClipsMethodTest.o \ ${TMP_DIR}/RpcDisplayAudioClipsTest.o \ ${TMP_DIR}/SavePlaylistMethodTest.o \ + ${TMP_DIR}/RpcSavePlaylistTest.o \ ${TMP_DIR}/RevertEditedPlaylistMethodTest.o \ + ${TMP_DIR}/RpcRevertEditedPlaylistTest.o \ ${TMP_DIR}/PostgresqlPlayLogTest.o \ ${TMP_DIR}/GeneratePlayReportMethodTest.o \ + ${TMP_DIR}/RpcGeneratePlayReportTest.o \ ${TMP_DIR}/UpdateFadeInFadeOutMethodTest.o \ + ${TMP_DIR}/RpcUpdateFadeInFadeOutTest.o \ ${TMP_DIR}/PlaylistEventContainerTest.o \ ${TMP_DIR}/PlaylistEventTest.o TEST_RUNNER_LIBS = ${SCHEDULER_EXE_LIBS} -lcppunit -ldl diff --git a/livesupport/products/scheduler/etc/authenticationClient.xml b/livesupport/products/scheduler/etc/authenticationClient.xml index 7a1580f07..f13840213 100644 --- a/livesupport/products/scheduler/etc/authenticationClient.xml +++ b/livesupport/products/scheduler/etc/authenticationClient.xml @@ -4,15 +4,16 @@ - - - - - + + + + + ]> - - - + + + diff --git a/livesupport/products/scheduler/etc/storageClient.xml b/livesupport/products/scheduler/etc/storageClient.xml index 9ad61269a..557ce5a2a 100644 --- a/livesupport/products/scheduler/etc/storageClient.xml +++ b/livesupport/products/scheduler/etc/storageClient.xml @@ -3,48 +3,18 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + ]> - - - - - - - - - - - - + + + diff --git a/livesupport/products/scheduler/src/RpcAddAudioClipToPlaylistTest.cxx b/livesupport/products/scheduler/src/RpcAddAudioClipToPlaylistTest.cxx index f4b04ac65..b5cef19d7 100644 --- a/livesupport/products/scheduler/src/RpcAddAudioClipToPlaylistTest.cxx +++ b/livesupport/products/scheduler/src/RpcAddAudioClipToPlaylistTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.11 $ + Version : $Revision: 1.12 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcAddAudioClipToPlaylistTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -106,10 +106,11 @@ void RpcAddAudioClipToPlaylistTest :: firstTest(void) throw (CPPUNIT_NS::Exception) { - XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); XmlRpc::XmlRpcValue parameters; XmlRpc::XmlRpcValue result; + XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = "0000000000000001"; parameters["audioClipId"] = "0000000000010001"; diff --git a/livesupport/products/scheduler/src/RpcDisplayPlaylistTest.cxx b/livesupport/products/scheduler/src/RpcDisplayPlaylistTest.cxx index df9119b7b..295e8c642 100644 --- a/livesupport/products/scheduler/src/RpcDisplayPlaylistTest.cxx +++ b/livesupport/products/scheduler/src/RpcDisplayPlaylistTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.10 $ + Version : $Revision: 1.11 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcDisplayPlaylistTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -48,11 +48,6 @@ using namespace LiveSupport::Scheduler; CPPUNIT_TEST_SUITE_REGISTRATION(RpcDisplayPlaylistTest); -/** - * The name of the configuration file for the scheduler daemon. - */ -static const std::string configFileName = "etc/scheduler.xml"; - /* =============================================== local function prototypes */ diff --git a/livesupport/products/scheduler/src/RpcGeneratePlayReportTest.cxx b/livesupport/products/scheduler/src/RpcGeneratePlayReportTest.cxx new file mode 100644 index 000000000..6d06c78f9 --- /dev/null +++ b/livesupport/products/scheduler/src/RpcGeneratePlayReportTest.cxx @@ -0,0 +1,379 @@ +/*------------------------------------------------------------------------------ + + 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: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcGeneratePlayReportTest.cxx,v $ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#include +#include +#include + +#include "LiveSupport/Core/UniqueId.h" +#include "SchedulerDaemon.h" +#include "PlayLogFactory.h" + +#include "RpcGeneratePlayReportTest.h" + + +using namespace LiveSupport::Core; +using namespace LiveSupport::Scheduler; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + +CPPUNIT_TEST_SUITE_REGISTRATION(RpcGeneratePlayReportTest); + +/** + * 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 +RpcGeneratePlayReportTest :: setUp(void) throw () +{ + Ptr::Ref daemon = SchedulerDaemon::getInstance(); + + if (!daemon->isConfigured()) { + try { + Ptr::Ref parser(new xmlpp::DomParser( + configFileName, true)); + const xmlpp::Document * document = parser->get_document(); + const xmlpp::Element * root = document->get_root_node(); + daemon->configure(*root); + } 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(); + insertEntries(); + + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + parameters["login"] = "root"; + parameters["password"] = "q"; + CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("sessionId")); + + xmlRpcClient.close(); + + sessionId.reset(new SessionId(std::string(result["sessionId"]))); +} + + +/*------------------------------------------------------------------------------ + * Clean up the test environment + *----------------------------------------------------------------------------*/ +void +RpcGeneratePlayReportTest :: tearDown(void) throw () +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + parameters["sessionId"] = sessionId->getId(); + CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + xmlRpcClient.close(); + + Ptr::Ref daemon = SchedulerDaemon::getInstance(); + daemon->uninstall(); +} + + +/*------------------------------------------------------------------------------ + * Insert some entries into the play log + *----------------------------------------------------------------------------*/ +void +RpcGeneratePlayReportTest :: insertEntries(void) + throw () +{ + Ptr::Ref plf = PlayLogFactory::getInstance(); + Ptr::Ref playLog = plf->getPlayLog(); + + Ptr::Ref audioClipId(new UniqueId(10001)); + Ptr::Ref timestamp(new ptime(time_from_string( + "2004-10-26 14:00:00"))); + playLog->addPlayLogEntry(audioClipId, timestamp); + + audioClipId.reset(new UniqueId(10017)); + timestamp.reset(new ptime(time_from_string("2004-10-26 15:30:00"))); + playLog->addPlayLogEntry(audioClipId, timestamp); + + audioClipId.reset(new UniqueId(10003)); + timestamp.reset(new ptime(time_from_string("2004-10-27 10:01:00"))); + playLog->addPlayLogEntry(audioClipId, timestamp); +} + + +/*------------------------------------------------------------------------------ + * Just a very simple smoke test + *----------------------------------------------------------------------------*/ +void +RpcGeneratePlayReportTest :: firstTest(void) + throw (CPPUNIT_NS::Exception) +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + struct tm time; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + // set up a structure for the parameters + parameters["sessionId"] = sessionId->getId(); + time.tm_year = 101; // 2001 + time.tm_mon = 10; // November + time.tm_mday = 12; + time.tm_hour = 18; + time.tm_min = 31; + time.tm_sec = 1; + parameters["from"] = &time; + time.tm_year = 101; // 2001 + time.tm_mon = 10; // November + time.tm_mday = 12; + time.tm_hour = 19; + time.tm_min = 31; + time.tm_sec = 1; + parameters["to"] = &time; + + CPPUNIT_ASSERT(xmlRpcClient.execute("generatePlayReport", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.size() == 0); + + xmlRpcClient.close(); +} + + +/*------------------------------------------------------------------------------ + * Look at some intervals and check against test data + *----------------------------------------------------------------------------*/ +void +RpcGeneratePlayReportTest :: intervalTest(void) + throw (CPPUNIT_NS::Exception) +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + struct tm time; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + // check for the interval 2004-10-26 between 13 and 15 o'clock + parameters["sessionId"] = sessionId->getId(); + time.tm_year = 104; // 2004 + time.tm_mon = 9; // October + time.tm_mday = 26; + time.tm_hour = 13; + time.tm_min = 0; + time.tm_sec = 0; + parameters["from"] = &time; + time.tm_year = 104; // 2004 + time.tm_mon = 9; // October + time.tm_mday = 26; + time.tm_hour = 15; + time.tm_min = 0; + time.tm_sec = 0; + parameters["to"] = &time; + + CPPUNIT_ASSERT(xmlRpcClient.execute("generatePlayReport", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + // check the returned values + CPPUNIT_ASSERT(result.size() == 1); + CPPUNIT_ASSERT(result[0].hasMember("audioClipId")); + CPPUNIT_ASSERT(result[0]["audioClipId"].getType() + == XmlRpc::XmlRpcValue::TypeString); + UniqueId newAudioClipId = UniqueId(std::string(result[0]["audioClipId"])); + CPPUNIT_ASSERT(newAudioClipId.getId() == 10001); + + CPPUNIT_ASSERT(result[0].hasMember("timestamp")); + CPPUNIT_ASSERT(result[0]["timestamp"].getType() + == XmlRpc::XmlRpcValue::TypeDateTime); + time = result[0]["timestamp"]; + CPPUNIT_ASSERT(time.tm_year == 104); // 2004 + CPPUNIT_ASSERT(time.tm_mon == 9); // October + CPPUNIT_ASSERT(time.tm_mday == 26); + CPPUNIT_ASSERT(time.tm_hour == 14); + CPPUNIT_ASSERT(time.tm_min == 0); + CPPUNIT_ASSERT(time.tm_sec == 0); + + + // check for the interval 2004-10-26 between 14 o'clock and 15:30 + parameters["sessionId"] = sessionId->getId(); + time.tm_year = 104; // 2004 + time.tm_mon = 9; // October + time.tm_mday = 26; + time.tm_hour = 14; + time.tm_min = 0; + time.tm_sec = 0; + parameters["from"] = &time; + time.tm_year = 104; // 2004 + time.tm_mon = 9; // October + time.tm_mday = 26; + time.tm_hour = 15; + time.tm_min = 30; + time.tm_sec = 0; + parameters["to"] = &time; + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("generatePlayReport", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + // check the returned values + CPPUNIT_ASSERT(result.size() == 1); + CPPUNIT_ASSERT(result[0].hasMember("audioClipId")); + CPPUNIT_ASSERT(result[0]["audioClipId"].getType() + == XmlRpc::XmlRpcValue::TypeString); + newAudioClipId = UniqueId(std::string(result[0]["audioClipId"])); + CPPUNIT_ASSERT(newAudioClipId.getId() == 10001); + + CPPUNIT_ASSERT(result[0].hasMember("timestamp")); + CPPUNIT_ASSERT(result[0]["timestamp"].getType() + == XmlRpc::XmlRpcValue::TypeDateTime); + time = result[0]["timestamp"]; + CPPUNIT_ASSERT(time.tm_year == 104); // 2004 + CPPUNIT_ASSERT(time.tm_mon == 9); // October + CPPUNIT_ASSERT(time.tm_mday == 26); + CPPUNIT_ASSERT(time.tm_hour == 14); + CPPUNIT_ASSERT(time.tm_min == 0); + CPPUNIT_ASSERT(time.tm_sec == 0); + + + // check for the interval 2004-10-26 15:00 to 2012-08-01 midnight + parameters["sessionId"] = sessionId->getId(); + time.tm_year = 104; // 2004 + time.tm_mon = 9; // October + time.tm_mday = 26; + time.tm_hour = 15; + time.tm_min = 30; + time.tm_sec = 0; + parameters["from"] = &time; + time.tm_year = 112; // 2012 + time.tm_mon = 7; // August + time.tm_mday = 1; + time.tm_hour = 0; + time.tm_min = 0; + time.tm_sec = 0; + parameters["to"] = &time; + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("generatePlayReport", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + // check the returned values + CPPUNIT_ASSERT(result.size() == 2); + CPPUNIT_ASSERT(result[0].hasMember("audioClipId")); + CPPUNIT_ASSERT(result[0]["audioClipId"].getType() + == XmlRpc::XmlRpcValue::TypeString); + newAudioClipId = UniqueId(std::string(result[0]["audioClipId"])); + CPPUNIT_ASSERT(newAudioClipId.getId() == 10017); + + CPPUNIT_ASSERT(result[0].hasMember("timestamp")); + CPPUNIT_ASSERT(result[0]["timestamp"].getType() + == XmlRpc::XmlRpcValue::TypeDateTime); + time = result[0]["timestamp"]; + CPPUNIT_ASSERT(time.tm_year == 104); // 2004 + CPPUNIT_ASSERT(time.tm_mon == 9); // October + CPPUNIT_ASSERT(time.tm_mday == 26); + CPPUNIT_ASSERT(time.tm_hour == 15); + CPPUNIT_ASSERT(time.tm_min == 30); + CPPUNIT_ASSERT(time.tm_sec == 0); + + CPPUNIT_ASSERT(result[1].hasMember("audioClipId")); + CPPUNIT_ASSERT(result[1]["audioClipId"].getType() + == XmlRpc::XmlRpcValue::TypeString); + newAudioClipId = UniqueId(std::string(result[1]["audioClipId"])); + CPPUNIT_ASSERT(newAudioClipId.getId() == 10003); + + CPPUNIT_ASSERT(result[1].hasMember("timestamp")); + CPPUNIT_ASSERT(result[1]["timestamp"].getType() + == XmlRpc::XmlRpcValue::TypeDateTime); + time = result[1]["timestamp"]; + CPPUNIT_ASSERT(time.tm_year == 104); // 2004 + CPPUNIT_ASSERT(time.tm_mon == 9); // October + CPPUNIT_ASSERT(time.tm_mday == 27); + CPPUNIT_ASSERT(time.tm_hour == 10); + CPPUNIT_ASSERT(time.tm_min == 01); + CPPUNIT_ASSERT(time.tm_sec == 0); + + + // check for the interval 2004-10-26 16 o'clock to 2004-10-27 10 o'clock + parameters["sessionId"] = sessionId->getId(); + time.tm_year = 104; // 2004 + time.tm_mon = 9; // October + time.tm_mday = 26; + time.tm_hour = 16; + time.tm_min = 0; + time.tm_sec = 0; + parameters["from"] = &time; + time.tm_year = 104; // 2004 + time.tm_mon = 9; // October + time.tm_mday = 27; + time.tm_hour = 10; + time.tm_min = 0; + time.tm_sec = 0; + parameters["to"] = &time; + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("generatePlayReport", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + // check the returned values + CPPUNIT_ASSERT(result.size() == 0); + + xmlRpcClient.close(); +} + diff --git a/livesupport/products/scheduler/src/RpcGeneratePlayReportTest.h b/livesupport/products/scheduler/src/RpcGeneratePlayReportTest.h new file mode 100644 index 000000000..b217bbcec --- /dev/null +++ b/livesupport/products/scheduler/src/RpcGeneratePlayReportTest.h @@ -0,0 +1,133 @@ +/*------------------------------------------------------------------------------ + + 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: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcGeneratePlayReportTest.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef RpcGeneratePlayReportTest_h +#define RpcGeneratePlayReportTest_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/Ptr.h" +#include "LiveSupport/Core/SessionId.h" + + +namespace LiveSupport { +namespace Scheduler { + +using namespace LiveSupport::Core; + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * Unit test for the GeneratePlayReportMethod class. + * + * @author $Author: fgerlits $ + * @version $Revision: 1.1 $ + * @see GeneratePlayReportMethod + */ +class RpcGeneratePlayReportTest : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(RpcGeneratePlayReportTest); + CPPUNIT_TEST(firstTest); + CPPUNIT_TEST(intervalTest); + CPPUNIT_TEST_SUITE_END(); + + private: + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + + /** + * Insert some entries into the play log to provide test data. + */ + void + insertEntries(void) throw (); + + protected: + + /** + * A simple test. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + firstTest(void) throw (CPPUNIT_NS::Exception); + + /** + * Look at some intervals, and check them against the test data. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + intervalTest(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 // RpcGeneratePlayReportTest_h + diff --git a/livesupport/products/scheduler/src/RpcOpenPlaylistForEditingTest.cxx b/livesupport/products/scheduler/src/RpcOpenPlaylistForEditingTest.cxx new file mode 100644 index 000000000..db6d651b3 --- /dev/null +++ b/livesupport/products/scheduler/src/RpcOpenPlaylistForEditingTest.cxx @@ -0,0 +1,155 @@ +/*------------------------------------------------------------------------------ + + 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: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcOpenPlaylistForEditingTest.cxx,v $ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#include +#include +#include + +#include "SchedulerDaemon.h" + +#include "RpcOpenPlaylistForEditingTest.h" + + +using namespace LiveSupport::Core; +using namespace LiveSupport::Scheduler; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + +CPPUNIT_TEST_SUITE_REGISTRATION(RpcOpenPlaylistForEditingTest); + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Set up the test environment + *----------------------------------------------------------------------------*/ +void +RpcOpenPlaylistForEditingTest :: setUp(void) throw () +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + parameters["login"] = "root"; + parameters["password"] = "q"; + CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("sessionId")); + + xmlRpcClient.close(); + + sessionId.reset(new SessionId(std::string(result["sessionId"]))); +} + + +/*------------------------------------------------------------------------------ + * Clean up the test environment + *----------------------------------------------------------------------------*/ +void +RpcOpenPlaylistForEditingTest :: tearDown(void) throw () +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + parameters["sessionId"] = sessionId->getId(); + CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + xmlRpcClient.close(); +} + + +/*------------------------------------------------------------------------------ + * Just a very simple smoke test + *----------------------------------------------------------------------------*/ +void +RpcOpenPlaylistForEditingTest :: firstTest(void) + throw (CPPUNIT_NS::Exception) +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + parameters["sessionId"] = sessionId->getId(); + parameters["playlistId"] = "0000000000000001"; + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("openPlaylistForEditing", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("id")); + CPPUNIT_ASSERT(result["id"].getType() == XmlRpc::XmlRpcValue::TypeString); + CPPUNIT_ASSERT(std::string(result["id"]) == "0000000000000001"); + + CPPUNIT_ASSERT(result.hasMember("playlength")); + CPPUNIT_ASSERT(result["playlength"].getType() + == XmlRpc::XmlRpcValue::TypeInt); + CPPUNIT_ASSERT(int(result["playlength"]) == 90 * 60); + + parameters.clear(); + parameters["sessionId"] = sessionId->getId(); + parameters["playlistId"] = "0000000000009999"; + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("openPlaylistForEditing", + parameters, result)); + CPPUNIT_ASSERT_MESSAGE("allowed to open non-existent playlist", + xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("faultCode")); + CPPUNIT_ASSERT(int(result["faultCode"]) == 104); // could not open playlist + + parameters.clear(); + parameters["sessionId"] = sessionId->getId(); + parameters["playlistId"] = "0000000000000001"; + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("openPlaylistForEditing", + parameters, result)); + CPPUNIT_ASSERT_MESSAGE("allowed to open the same playlist twice", + xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("faultCode")); + CPPUNIT_ASSERT(int(result["faultCode"]) == 104); // could not open playlist + + xmlRpcClient.close(); +} diff --git a/livesupport/products/scheduler/src/RpcOpenPlaylistForEditingTest.h b/livesupport/products/scheduler/src/RpcOpenPlaylistForEditingTest.h new file mode 100644 index 000000000..a448d89fa --- /dev/null +++ b/livesupport/products/scheduler/src/RpcOpenPlaylistForEditingTest.h @@ -0,0 +1,118 @@ +/*------------------------------------------------------------------------------ + + 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: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcOpenPlaylistForEditingTest.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef RpcOpenPlaylistForEditingTest_h +#define RpcOpenPlaylistForEditingTest_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/Ptr.h" +#include "LiveSupport/Core/SessionId.h" + + +namespace LiveSupport { +namespace Scheduler { + +using namespace LiveSupport::Core; + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * Unit test for the OpenPlaylistForEditingMethod class. + * + * @author $Author: fgerlits $ + * @version $Revision: 1.1 $ + * @see OpenPlaylistForEditingMethod + */ +class RpcOpenPlaylistForEditingTest : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(RpcOpenPlaylistForEditingTest); + CPPUNIT_TEST(firstTest); + CPPUNIT_TEST_SUITE_END(); + + private: + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + + 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 // RpcOpenPlaylistForEditingTest_h + diff --git a/livesupport/products/scheduler/src/RpcRemoveAudioClipFromPlaylistTest.cxx b/livesupport/products/scheduler/src/RpcRemoveAudioClipFromPlaylistTest.cxx new file mode 100644 index 000000000..ac67428d6 --- /dev/null +++ b/livesupport/products/scheduler/src/RpcRemoveAudioClipFromPlaylistTest.cxx @@ -0,0 +1,153 @@ +/*------------------------------------------------------------------------------ + + 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: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcRemoveAudioClipFromPlaylistTest.cxx,v $ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#include +#include +#include + +#include "SchedulerDaemon.h" + +#include "RpcRemoveAudioClipFromPlaylistTest.h" + + +using namespace LiveSupport::Core; +using namespace LiveSupport::Scheduler; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + +CPPUNIT_TEST_SUITE_REGISTRATION(RpcRemoveAudioClipFromPlaylistTest); + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Set up the test environment + *----------------------------------------------------------------------------*/ +void +RpcRemoveAudioClipFromPlaylistTest :: setUp(void) throw () +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + parameters["login"] = "root"; + parameters["password"] = "q"; + CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("sessionId")); + + xmlRpcClient.close(); + + sessionId.reset(new SessionId(std::string(result["sessionId"]))); +} + + +/*------------------------------------------------------------------------------ + * Clean up the test environment + *----------------------------------------------------------------------------*/ +void +RpcRemoveAudioClipFromPlaylistTest :: tearDown(void) throw () +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + parameters["sessionId"] = sessionId->getId(); + CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + xmlRpcClient.close(); +} + + +/*------------------------------------------------------------------------------ + * Just a very simple smoke test + *----------------------------------------------------------------------------*/ +void +RpcRemoveAudioClipFromPlaylistTest :: firstTest(void) + throw (CPPUNIT_NS::Exception) +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + parameters["sessionId"] = sessionId->getId(); + parameters["playlistId"] = "0000000000000001"; + parameters["audioClipId"] = "0000000000010001"; + parameters["relativeOffset"] = 90*60; + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("removeAudioClipFromPlaylist", + parameters, result)); + CPPUNIT_ASSERT_MESSAGE("allowed to edit playlist without opening it first", + xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("faultCode")); + CPPUNIT_ASSERT(int(result["faultCode"]) == 405); // not open for editing + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("openPlaylistForEditing", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("removeAudioClipFromPlaylist", + parameters, result)); + CPPUNIT_ASSERT_MESSAGE( + "allowed to remove non-existent audio clip from playlist", + xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("faultCode")); + CPPUNIT_ASSERT(int(result["faultCode"]) == 406); + // no audio clip at this rel offset + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("addAudioClipToPlaylist", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("removeAudioClipFromPlaylist", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + xmlRpcClient.close(); +} diff --git a/livesupport/products/scheduler/src/RpcRemoveAudioClipFromPlaylistTest.h b/livesupport/products/scheduler/src/RpcRemoveAudioClipFromPlaylistTest.h new file mode 100644 index 000000000..7deccea4d --- /dev/null +++ b/livesupport/products/scheduler/src/RpcRemoveAudioClipFromPlaylistTest.h @@ -0,0 +1,118 @@ +/*------------------------------------------------------------------------------ + + 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: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcRemoveAudioClipFromPlaylistTest.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef RpcRemoveAudioClipFromPlaylistTest_h +#define RpcRemoveAudioClipFromPlaylistTest_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/Ptr.h" +#include "LiveSupport/Core/SessionId.h" + + +namespace LiveSupport { +namespace Scheduler { + +using namespace LiveSupport::Core; + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * Unit test for the RemoveAudioClipFromPlaylistMethod class. + * + * @author $Author: fgerlits $ + * @version $Revision: 1.1 $ + * @see RemoveAudioClipFromPlaylistMethod + */ +class RpcRemoveAudioClipFromPlaylistTest : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(RpcRemoveAudioClipFromPlaylistTest); + CPPUNIT_TEST(firstTest); + CPPUNIT_TEST_SUITE_END(); + + private: + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + + 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 // RpcRemoveAudioClipFromPlaylistTest_h + diff --git a/livesupport/products/scheduler/src/RpcRevertEditedPlaylistTest.cxx b/livesupport/products/scheduler/src/RpcRevertEditedPlaylistTest.cxx new file mode 100644 index 000000000..58a74ebd3 --- /dev/null +++ b/livesupport/products/scheduler/src/RpcRevertEditedPlaylistTest.cxx @@ -0,0 +1,167 @@ +/*------------------------------------------------------------------------------ + + 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: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcRevertEditedPlaylistTest.cxx,v $ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#include +#include +#include + +#include "SchedulerDaemon.h" + +#include "RpcRevertEditedPlaylistTest.h" + + +using namespace LiveSupport::Core; +using namespace LiveSupport::Scheduler; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + +CPPUNIT_TEST_SUITE_REGISTRATION(RpcRevertEditedPlaylistTest); + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Set up the test environment + *----------------------------------------------------------------------------*/ +void +RpcRevertEditedPlaylistTest :: setUp(void) throw () +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + parameters["login"] = "root"; + parameters["password"] = "q"; + CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("sessionId")); + + xmlRpcClient.close(); + + sessionId.reset(new SessionId(std::string(result["sessionId"]))); +} + + +/*------------------------------------------------------------------------------ + * Clean up the test environment + *----------------------------------------------------------------------------*/ +void +RpcRevertEditedPlaylistTest :: tearDown(void) throw () +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + parameters["sessionId"] = sessionId->getId(); + CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + xmlRpcClient.close(); +} + + +/*------------------------------------------------------------------------------ + * Just a very simple smoke test + *----------------------------------------------------------------------------*/ +void +RpcRevertEditedPlaylistTest :: firstTest(void) + throw (CPPUNIT_NS::Exception) +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + parameters["sessionId"] = sessionId->getId(); + parameters["playlistId"] = "0000000000000001"; + parameters["relativeOffset"] = 0; + + CPPUNIT_ASSERT(xmlRpcClient.execute("revertEditedPlaylist", + parameters, result)); + CPPUNIT_ASSERT_MESSAGE("allowed to revert playlist without saving it first", + xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("faultCode")); + CPPUNIT_ASSERT(int(result["faultCode"]) == 804); // no saved copy + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("openPlaylistForEditing", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("removeAudioClipFromPlaylist", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + result.clear(); // can't remove it twice + CPPUNIT_ASSERT(xmlRpcClient.execute("removeAudioClipFromPlaylist", + parameters, result)); + CPPUNIT_ASSERT_MESSAGE("allowed to remove the same playlist element twice", + xmlRpcClient.isFault()); + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("revertEditedPlaylist", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + result.clear(); // but now we can again + CPPUNIT_ASSERT(xmlRpcClient.execute("removeAudioClipFromPlaylist", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("savePlaylist", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("revertEditedPlaylist", + parameters, result)); + CPPUNIT_ASSERT_MESSAGE( + "allowed to revert playlist after discarding saved copy", + xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("faultCode")); + CPPUNIT_ASSERT(int(result["faultCode"]) == 804); // no saved copy + + xmlRpcClient.close(); +} + diff --git a/livesupport/products/scheduler/src/RpcRevertEditedPlaylistTest.h b/livesupport/products/scheduler/src/RpcRevertEditedPlaylistTest.h new file mode 100644 index 000000000..05b9306ee --- /dev/null +++ b/livesupport/products/scheduler/src/RpcRevertEditedPlaylistTest.h @@ -0,0 +1,118 @@ +/*------------------------------------------------------------------------------ + + 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: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcRevertEditedPlaylistTest.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef RpcRevertEditedPlaylistTest_h +#define RpcRevertEditedPlaylistTest_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/Ptr.h" +#include "LiveSupport/Core/SessionId.h" + + +namespace LiveSupport { +namespace Scheduler { + +using namespace LiveSupport::Core; + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * Unit test for the RevertEditedPlaylistMethod class. + * + * @author $Author: fgerlits $ + * @version $Revision: 1.1 $ + * @see RevertEditedPlaylistMethod + */ +class RpcRevertEditedPlaylistTest : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(RpcRevertEditedPlaylistTest); + CPPUNIT_TEST(firstTest); + CPPUNIT_TEST_SUITE_END(); + + private: + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + + 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 // RpcRevertEditedPlaylistTest_h + diff --git a/livesupport/products/scheduler/src/RpcSavePlaylistTest.cxx b/livesupport/products/scheduler/src/RpcSavePlaylistTest.cxx new file mode 100644 index 000000000..272569177 --- /dev/null +++ b/livesupport/products/scheduler/src/RpcSavePlaylistTest.cxx @@ -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: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcSavePlaylistTest.cxx,v $ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#include +#include +#include + +#include "SchedulerDaemon.h" + +#include "RpcSavePlaylistTest.h" + + +using namespace LiveSupport::Core; +using namespace LiveSupport::Scheduler; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + +CPPUNIT_TEST_SUITE_REGISTRATION(RpcSavePlaylistTest); + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Set up the test environment + *----------------------------------------------------------------------------*/ +void +RpcSavePlaylistTest :: setUp(void) throw () +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + parameters["login"] = "root"; + parameters["password"] = "q"; + CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("sessionId")); + + xmlRpcClient.close(); + + sessionId.reset(new SessionId(std::string(result["sessionId"]))); +} + + +/*------------------------------------------------------------------------------ + * Clean up the test environment + *----------------------------------------------------------------------------*/ +void +RpcSavePlaylistTest :: tearDown(void) throw () +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + parameters["sessionId"] = sessionId->getId(); + CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + xmlRpcClient.close(); +} + + +/*------------------------------------------------------------------------------ + * Just a very simple smoke test + *----------------------------------------------------------------------------*/ +void +RpcSavePlaylistTest :: firstTest(void) + throw (CPPUNIT_NS::Exception) +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + parameters["sessionId"] = sessionId->getId(); + parameters["playlistId"] = "0000000000009999"; + + CPPUNIT_ASSERT(xmlRpcClient.execute("savePlaylist", + parameters, result)); + CPPUNIT_ASSERT_MESSAGE("allowed to save non-existent playlist", + xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("faultCode")); + CPPUNIT_ASSERT(int(result["faultCode"]) == 703); // playlist not found + + parameters["playlistId"] = "0000000000000001"; + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("openPlaylistForEditing", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + CPPUNIT_ASSERT(xmlRpcClient.execute("savePlaylist", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("savePlaylist", parameters, result)); + CPPUNIT_ASSERT_MESSAGE("allowed to save playlist twice", + xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("faultCode")); + CPPUNIT_ASSERT(int(result["faultCode"]) == 705); // could not save playlist + + xmlRpcClient.close(); +} + diff --git a/livesupport/products/scheduler/src/RpcSavePlaylistTest.h b/livesupport/products/scheduler/src/RpcSavePlaylistTest.h new file mode 100644 index 000000000..7e49f85bd --- /dev/null +++ b/livesupport/products/scheduler/src/RpcSavePlaylistTest.h @@ -0,0 +1,119 @@ +/*------------------------------------------------------------------------------ + + 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: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcSavePlaylistTest.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef RpcSavePlaylistTest_h +#define RpcSavePlaylistTest_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/Ptr.h" +#include "LiveSupport/Core/SessionId.h" + + +namespace LiveSupport { +namespace Scheduler { + +using namespace LiveSupport::Core; + + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * Unit test for the SavePlaylistMethod class. + * + * @author $Author: fgerlits $ + * @version $Revision: 1.1 $ + * @see SavePlaylistMethod + */ +class RpcSavePlaylistTest : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(RpcSavePlaylistTest); + CPPUNIT_TEST(firstTest); + CPPUNIT_TEST_SUITE_END(); + + private: + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + + 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 // RpcSavePlaylistTest_h + diff --git a/livesupport/products/scheduler/src/RpcUpdateFadeInFadeOutTest.cxx b/livesupport/products/scheduler/src/RpcUpdateFadeInFadeOutTest.cxx new file mode 100644 index 000000000..377e54277 --- /dev/null +++ b/livesupport/products/scheduler/src/RpcUpdateFadeInFadeOutTest.cxx @@ -0,0 +1,159 @@ +/*------------------------------------------------------------------------------ + + 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: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcUpdateFadeInFadeOutTest.cxx,v $ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#include +#include +#include + +#include "RpcUpdateFadeInFadeOutTest.h" + + +using namespace LiveSupport::Core; +using namespace LiveSupport::Scheduler; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + +CPPUNIT_TEST_SUITE_REGISTRATION(RpcUpdateFadeInFadeOutTest); + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Set up the test environment + *----------------------------------------------------------------------------*/ +void +RpcUpdateFadeInFadeOutTest :: setUp(void) throw () +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + parameters["login"] = "root"; + parameters["password"] = "q"; + CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("sessionId")); + + xmlRpcClient.close(); + + sessionId.reset(new SessionId(std::string(result["sessionId"]))); +} + + +/*------------------------------------------------------------------------------ + * Clean up the test environment + *----------------------------------------------------------------------------*/ +void +RpcUpdateFadeInFadeOutTest :: tearDown(void) throw () +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + parameters["sessionId"] = sessionId->getId(); + CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + xmlRpcClient.close(); +} + + +/*------------------------------------------------------------------------------ + * Just a very simple smoke test + *----------------------------------------------------------------------------*/ +void +RpcUpdateFadeInFadeOutTest :: firstTest(void) + throw (CPPUNIT_NS::Exception) +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + parameters["sessionId"] = sessionId->getId(); + parameters["playlistId"] = "0000000000000001"; + parameters["relativeOffset"] = 90*60; + parameters["fadeIn"] = 0; + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("updateFadeInFadeOut", + parameters, result)); + CPPUNIT_ASSERT_MESSAGE("did not notice missing fade out parameter", + xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("faultCode")); + CPPUNIT_ASSERT(int(result["faultCode"]) == 1605); // missing fade out + + parameters["fadeOut"] = 2100; + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("updateFadeInFadeOut", + parameters, result)); + CPPUNIT_ASSERT_MESSAGE( + "allowed update fade info without opening playlist first", + xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("faultCode")); + CPPUNIT_ASSERT(int(result["faultCode"]) == 1607); // not open for editing + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("openPlaylistForEditing", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("updateFadeInFadeOut", + parameters, result)); + CPPUNIT_ASSERT_MESSAGE( + "allowed update fade info for non-existent playlist element", + xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("faultCode")); + CPPUNIT_ASSERT(int(result["faultCode"]) == 1608); + // no audio clip at this rel offset + + parameters["relativeOffset"] = 0; + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("updateFadeInFadeOut", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + xmlRpcClient.close(); +} diff --git a/livesupport/products/scheduler/src/RpcUpdateFadeInFadeOutTest.h b/livesupport/products/scheduler/src/RpcUpdateFadeInFadeOutTest.h new file mode 100644 index 000000000..75a350710 --- /dev/null +++ b/livesupport/products/scheduler/src/RpcUpdateFadeInFadeOutTest.h @@ -0,0 +1,118 @@ +/*------------------------------------------------------------------------------ + + 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: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcUpdateFadeInFadeOutTest.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef RpcUpdateFadeInFadeOutTest_h +#define RpcUpdateFadeInFadeOutTest_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/Ptr.h" +#include "LiveSupport/Core/SessionId.h" + + +namespace LiveSupport { +namespace Scheduler { + +using namespace LiveSupport::Core; + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * Unit test for the UpdateFadeInFadeOutMethod class. + * + * @author $Author: fgerlits $ + * @version $Revision: 1.1 $ + * @see UpdateFadeInFadeOutMethod + */ +class RpcUpdateFadeInFadeOutTest : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(RpcUpdateFadeInFadeOutTest); + CPPUNIT_TEST(firstTest); + CPPUNIT_TEST_SUITE_END(); + + private: + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + + 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 // RpcUpdateFadeInFadeOutTest_h + diff --git a/livesupport/products/scheduler/src/RpcValidatePlaylistTest.cxx b/livesupport/products/scheduler/src/RpcValidatePlaylistTest.cxx new file mode 100644 index 000000000..caa079b24 --- /dev/null +++ b/livesupport/products/scheduler/src/RpcValidatePlaylistTest.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: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcValidatePlaylistTest.cxx,v $ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#include +#include +#include + +#include "SchedulerDaemon.h" + +#include "RpcValidatePlaylistTest.h" + + +using namespace LiveSupport::Core; +using namespace LiveSupport::Scheduler; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + +CPPUNIT_TEST_SUITE_REGISTRATION(RpcValidatePlaylistTest); + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Set up the test environment + *----------------------------------------------------------------------------*/ +void +RpcValidatePlaylistTest :: setUp(void) throw () +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + parameters["login"] = "root"; + parameters["password"] = "q"; + CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("sessionId")); + + xmlRpcClient.close(); + + sessionId.reset(new SessionId(std::string(result["sessionId"]))); +} + + +/*------------------------------------------------------------------------------ + * Clean up the test environment + *----------------------------------------------------------------------------*/ +void +RpcValidatePlaylistTest :: tearDown(void) throw () +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + parameters["sessionId"] = sessionId->getId(); + CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + xmlRpcClient.close(); +} + + +/*------------------------------------------------------------------------------ + * Just a very simple smoke test + *----------------------------------------------------------------------------*/ +void +RpcValidatePlaylistTest :: firstTest(void) + throw (CPPUNIT_NS::Exception) +{ + XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue result; + + XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + parameters["sessionId"] = sessionId->getId(); + parameters["playlistId"] = "0000000000009999"; + CPPUNIT_ASSERT(xmlRpcClient.execute("validatePlaylist", + parameters, result)); + CPPUNIT_ASSERT_MESSAGE("allowed to validate non-existent playlist", + xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("faultCode")); + CPPUNIT_ASSERT(int(result["faultCode"]) == 503); // no such playlist + + result.clear(); + parameters.clear(); + parameters["sessionId"] = sessionId->getId(); + parameters["playlistId"] = "0000000000000001"; + CPPUNIT_ASSERT(xmlRpcClient.execute("openPlaylistForEditing", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("validatePlaylist", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("valid")); + CPPUNIT_ASSERT(bool(result["valid"])); + + result.clear(); + parameters["relativeOffset"] = 0; + CPPUNIT_ASSERT(xmlRpcClient.execute("removeAudioClipFromPlaylist", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + + result.clear(); + CPPUNIT_ASSERT(xmlRpcClient.execute("validatePlaylist", + parameters, result)); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("valid")); + CPPUNIT_ASSERT(result["valid"].getType() + == XmlRpc::XmlRpcValue::TypeBoolean); + CPPUNIT_ASSERT(!bool(result["valid"])); // has a gap at the beginning + + xmlRpcClient.close(); +} diff --git a/livesupport/products/scheduler/src/RpcValidatePlaylistTest.h b/livesupport/products/scheduler/src/RpcValidatePlaylistTest.h new file mode 100644 index 000000000..9530bf2c9 --- /dev/null +++ b/livesupport/products/scheduler/src/RpcValidatePlaylistTest.h @@ -0,0 +1,119 @@ +/*------------------------------------------------------------------------------ + + 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: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcValidatePlaylistTest.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef RpcValidatePlaylistTest_h +#define RpcValidatePlaylistTest_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/Ptr.h" +#include "LiveSupport/Core/SessionId.h" + + +namespace LiveSupport { +namespace Scheduler { + +using namespace LiveSupport::Core; + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * Unit test for the ValidatePlaylistMethod class. + * + * @author $Author: fgerlits $ + * @version $Revision: 1.1 $ + * @see ValidatePlaylistMethod + */ +class RpcValidatePlaylistTest : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(RpcValidatePlaylistTest); + CPPUNIT_TEST(firstTest); + CPPUNIT_TEST_SUITE_END(); + + private: + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + + 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 // RpcValidatePlaylistTest_h +