changed PostgresqlSchedule::getScheduleEntries to return schedule entries

which started before the interval, but end in it, or after it.
This commit is contained in:
fgerlits 2005-03-18 13:22:14 +00:00
parent 9dd294a34d
commit 7acb1b1ada
5 changed files with 88 additions and 24 deletions

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $ Author : $Author: fgerlits $
Version : $Revision: 1.8 $ Version : $Revision: 1.9 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlSchedule.cxx,v $ 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 * The parameters for this call are: from, to
* and returns the properties: id, playlist, starts, ends for all * and returns the properties: id, playlist, starts, ends for all
* schedule entries between from and to, ordered by starts. * 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 = const std::string PostgresqlSchedule::getScheduleEntriesStmt =
"SELECT id, playlist, starts, ends FROM schedule WHERE " "SELECT id, playlist, starts, ends FROM schedule WHERE "
"(? <= starts) AND (starts < ?) " "(? < ends) AND (starts < ?) "
"ORDER BY starts"; "ORDER BY starts";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $ Author : $Author: fgerlits $
Version : $Revision: 1.6 $ Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlSchedule.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlSchedule.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -80,8 +80,8 @@ using namespace LiveSupport::Core;
* &lt;!ELEMENT postgresqlSchedule EMPTY &gt; * &lt;!ELEMENT postgresqlSchedule EMPTY &gt;
* </code></pre> * </code></pre>
* *
* @author $Author: maroy $ * @author $Author: fgerlits $
* @version $Revision: 1.6 $ * @version $Revision: 1.7 $
*/ */
class PostgresqlSchedule : public Configurable, class PostgresqlSchedule : public Configurable,
public ScheduleInterface public ScheduleInterface
@ -253,11 +253,11 @@ class PostgresqlSchedule : public Configurable,
/** /**
* Return the list of scheduled entries for a specified time interval. * 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, * @param fromTime the start of the time of the interval queried
* inclusive * @param toTime to end of the time of the interval queried
* @param toTime to end of the time of the interval queried,
* non-inclusive
* @return a vector of the scheduled entries for the time region. * @return a vector of the scheduled entries for the time region.
*/ */
virtual Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref virtual Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcDisplayScheduleTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -170,3 +170,60 @@ RpcDisplayScheduleTest :: simpleTest(void)
xmlRpcClient.close(); 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();
}

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ 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. * Unit test to test the displaySchedule XML-RPC call.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.3 $ * @version $Revision: 1.4 $
* @see SchedulerDaemon * @see SchedulerDaemon
*/ */
class RpcDisplayScheduleTest : public CPPUNIT_NS::TestFixture class RpcDisplayScheduleTest : public CPPUNIT_NS::TestFixture
{ {
CPPUNIT_TEST_SUITE(RpcDisplayScheduleTest); CPPUNIT_TEST_SUITE(RpcDisplayScheduleTest);
CPPUNIT_TEST(simpleTest); CPPUNIT_TEST(simpleTest);
CPPUNIT_TEST(faultTest);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
@ -89,6 +90,14 @@ class RpcDisplayScheduleTest : public CPPUNIT_NS::TestFixture
void void
simpleTest(void) throw (CPPUNIT_NS::Exception); 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: public:
/** /**

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $ Author : $Author: fgerlits $
Version : $Revision: 1.6 $ Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ScheduleInterface.h,v $ 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. * The generic interface for the component scheduling events.
* *
* @author $Author: maroy $ * @author $Author: fgerlits $
* @version $Revision: 1.6 $ * @version $Revision: 1.7 $
*/ */
class ScheduleInterface : virtual public Installable 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. * 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, * @param fromTime the start of the time of the interval queried
* inclusive * @param toTime to end of the time of the interval queried
* @param toTime to end of the time of the interval queried,
* non-inclusive
* @return a vector of the scheduled entries for the time region. * @return a vector of the scheduled entries for the time region.
*/ */
virtual Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref virtual Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref