diff --git a/livesupport/products/scheduler/src/PostgresqlSchedule.cxx b/livesupport/products/scheduler/src/PostgresqlSchedule.cxx index a7acb3fd3..57d122563 100644 --- a/livesupport/products/scheduler/src/PostgresqlSchedule.cxx +++ b/livesupport/products/scheduler/src/PostgresqlSchedule.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.8 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.9 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlSchedule.cxx,v $ ------------------------------------------------------------------------------*/ @@ -116,12 +116,10 @@ const std::string PostgresqlSchedule::reschedulePlaylistStmt = * The parameters for this call are: from, to * and returns the properties: id, playlist, starts, ends for all * schedule entries between from and to, ordered by starts. - * TODO: the below query only lists entries starting inside [from:to[ - * but what about entries starting before, but flowing into [from:to[ ? *----------------------------------------------------------------------------*/ const std::string PostgresqlSchedule::getScheduleEntriesStmt = "SELECT id, playlist, starts, ends FROM schedule WHERE " - "(? <= starts) AND (starts < ?) " + "(? < ends) AND (starts < ?) " "ORDER BY starts"; /*------------------------------------------------------------------------------ diff --git a/livesupport/products/scheduler/src/PostgresqlSchedule.h b/livesupport/products/scheduler/src/PostgresqlSchedule.h index 60aa52397..3a94eb8d5 100644 --- a/livesupport/products/scheduler/src/PostgresqlSchedule.h +++ b/livesupport/products/scheduler/src/PostgresqlSchedule.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.6 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlSchedule.h,v $ ------------------------------------------------------------------------------*/ @@ -80,8 +80,8 @@ using namespace LiveSupport::Core; * <!ELEMENT postgresqlSchedule EMPTY > * * - * @author $Author: maroy $ - * @version $Revision: 1.6 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.7 $ */ class PostgresqlSchedule : public Configurable, public ScheduleInterface @@ -253,11 +253,11 @@ class PostgresqlSchedule : public Configurable, /** * Return the list of scheduled entries for a specified time interval. + * It returns all entries which intersect the interval (i.e., start + * before toTime, and end later than fromTime). * - * @param fromTime the start of the time of the interval queried, - * inclusive - * @param toTime to end of the time of the interval queried, - * non-inclusive + * @param fromTime the start of the time of the interval queried + * @param toTime to end of the time of the interval queried * @return a vector of the scheduled entries for the time region. */ virtual Ptr::Ref> >::Ref diff --git a/livesupport/products/scheduler/src/RpcDisplayScheduleTest.cxx b/livesupport/products/scheduler/src/RpcDisplayScheduleTest.cxx index 1ee4205a0..8a7d27656 100644 --- a/livesupport/products/scheduler/src/RpcDisplayScheduleTest.cxx +++ b/livesupport/products/scheduler/src/RpcDisplayScheduleTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcDisplayScheduleTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -170,3 +170,60 @@ RpcDisplayScheduleTest :: simpleTest(void) xmlRpcClient.close(); } + +/*------------------------------------------------------------------------------ + * Testing some error conditions. + *----------------------------------------------------------------------------*/ +void +RpcDisplayScheduleTest :: faultTest(void) + throw (CPPUNIT_NS::Exception) +{ + XmlRpcValue parameters; + XmlRpcValue result; + + XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + + result.clear(); + xmlRpcClient.execute("displaySchedule", parameters, result); + CPPUNIT_ASSERT(xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("faultCode")); + CPPUNIT_ASSERT(int(result["faultCode"]) == 1101); + + parameters.clear(); + parameters["sessionId"] = sessionId->getId(); + parameters["from"] = "the beginning"; + parameters["to"] = "the end"; + + result.clear(); + xmlRpcClient.execute("displaySchedule", parameters, result); + CPPUNIT_ASSERT(xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.hasMember("faultCode")); + CPPUNIT_ASSERT(int(result["faultCode"]) == 1102); +/* + struct tm time; + + parameters.clear(); + parameters["sessionId"] = sessionId->getId(); + time.tm_year = 2044; + time.tm_mon = 11; + time.tm_mday = 12; + time.tm_hour = 10; + time.tm_min = 0; + time.tm_sec = 0; + parameters["from"] = &time; + time.tm_year = 2044; + time.tm_mon = 11; + time.tm_mday = 12; + time.tm_hour = 11; + time.tm_min = 0; + time.tm_sec = 0; + parameters["to"] = &time; + + result.clear(); + xmlRpcClient.execute("displaySchedule", parameters, result); + CPPUNIT_ASSERT(!xmlRpcClient.isFault()); + CPPUNIT_ASSERT(result.size() == 0); +*/ + xmlRpcClient.close(); +} + diff --git a/livesupport/products/scheduler/src/RpcDisplayScheduleTest.h b/livesupport/products/scheduler/src/RpcDisplayScheduleTest.h index f2ba35f1c..722203fff 100644 --- a/livesupport/products/scheduler/src/RpcDisplayScheduleTest.h +++ b/livesupport/products/scheduler/src/RpcDisplayScheduleTest.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcDisplayScheduleTest.h,v $ ------------------------------------------------------------------------------*/ @@ -63,13 +63,14 @@ using namespace LiveSupport::Core; * Unit test to test the displaySchedule XML-RPC call. * * @author $Author: fgerlits $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @see SchedulerDaemon */ class RpcDisplayScheduleTest : public CPPUNIT_NS::TestFixture { CPPUNIT_TEST_SUITE(RpcDisplayScheduleTest); CPPUNIT_TEST(simpleTest); + CPPUNIT_TEST(faultTest); CPPUNIT_TEST_SUITE_END(); private: @@ -89,6 +90,14 @@ class RpcDisplayScheduleTest : public CPPUNIT_NS::TestFixture void simpleTest(void) throw (CPPUNIT_NS::Exception); + /** + * Test some error conditions. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + faultTest(void) throw (CPPUNIT_NS::Exception); + public: /** diff --git a/livesupport/products/scheduler/src/ScheduleInterface.h b/livesupport/products/scheduler/src/ScheduleInterface.h index f2679316b..14605b261 100644 --- a/livesupport/products/scheduler/src/ScheduleInterface.h +++ b/livesupport/products/scheduler/src/ScheduleInterface.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.6 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ScheduleInterface.h,v $ ------------------------------------------------------------------------------*/ @@ -69,8 +69,8 @@ using namespace LiveSupport::Core; /** * The generic interface for the component scheduling events. * - * @author $Author: maroy $ - * @version $Revision: 1.6 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.7 $ */ class ScheduleInterface : virtual public Installable { @@ -104,11 +104,11 @@ class ScheduleInterface : virtual public Installable /** * Return the list of scheduled entries for a specified time interval. + * It returns all entries which intersect the interval (i.e., start + * before toTime, and end later than fromTime). * - * @param fromTime the start of the time of the interval queried, - * inclusive - * @param toTime to end of the time of the interval queried, - * non-inclusive + * @param fromTime the start of the time of the interval queried + * @param toTime to end of the time of the interval queried * @return a vector of the scheduled entries for the time region. */ virtual Ptr::Ref> >::Ref