added DisplayPlaylistsMethod and its appendages
This commit is contained in:
parent
9de81aedc6
commit
39dd193d00
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Attic/StorageClientInterface.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -61,7 +61,7 @@ namespace Core {
|
|||
* An interface for storage clients.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class StorageClientInterface
|
||||
{
|
||||
|
@ -101,6 +101,16 @@ class StorageClientInterface
|
|||
deletePlaylist(Ptr<const UniqueId>::Ref id)
|
||||
throw (std::invalid_argument)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Return a list of all playlists in the playlist store.
|
||||
*
|
||||
* @param (none).
|
||||
* @return a vector containing the playlists.
|
||||
*/
|
||||
virtual Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
|
||||
getAllPlaylists(void) const throw () = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -132,3 +132,21 @@ TestStorageClient :: deletePlaylist(Ptr<const UniqueId>::Ref id)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Return a listing of all the playlists in the playlist store.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
|
||||
TestStorageClient :: getAllPlaylists(void) const
|
||||
throw ()
|
||||
{
|
||||
PlaylistMap::const_iterator it = playlistMap.begin();
|
||||
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
|
||||
playlistVector (new std::vector<Ptr<Playlist>::Ref>);
|
||||
|
||||
while (it != playlistMap.end()) {
|
||||
playlistVector->push_back(it->second); // TODO: check this
|
||||
++it;
|
||||
}
|
||||
|
||||
return playlistVector;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -67,7 +67,7 @@ using namespace LiveSupport::Core;
|
|||
* A dummy storage client, only used for test purposes.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class TestStorageClient :
|
||||
virtual public Configurable,
|
||||
|
@ -159,6 +159,16 @@ class TestStorageClient :
|
|||
virtual void
|
||||
deletePlaylist(Ptr<const UniqueId>::Ref id)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Return a list of all playlists in the playlist store.
|
||||
*
|
||||
* @param (none).
|
||||
* @return a vector containing the playlists.
|
||||
*/
|
||||
virtual Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
|
||||
getAllPlaylists(void) const throw ();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClientTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -144,3 +144,19 @@ TestStorageClientTest :: deletePlaylistTest(void)
|
|||
} catch (std::invalid_argument &e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Testing the getAllPlaylists method
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
TestStorageClientTest :: getAllPlaylistsTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlistVector =
|
||||
tsc->getAllPlaylists();
|
||||
CPPUNIT_ASSERT(playlistVector->size() == 1);
|
||||
|
||||
Ptr<Playlist>::Ref playlist = (*playlistVector)[0];
|
||||
CPPUNIT_ASSERT((int) (playlist->getId()->getId()) == 1);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClientTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -58,13 +58,14 @@ namespace Storage {
|
|||
* Unit test for the UploadPlaylistMetohd class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
* @see TestStorageClient
|
||||
*/
|
||||
class TestStorageClientTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(TestStorageClientTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST(getAllPlaylistsTest);
|
||||
CPPUNIT_TEST(deletePlaylistTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
|
@ -92,6 +93,14 @@ class TestStorageClientTest : public CPPUNIT_NS::TestFixture
|
|||
void
|
||||
deletePlaylistTest(void)
|
||||
throw (CPPUNIT_NS::Exception);
|
||||
/**
|
||||
* Testing getAllPlaylists().
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
getAllPlaylistsTest(void)
|
||||
throw (CPPUNIT_NS::Exception);
|
||||
|
||||
public:
|
||||
|
||||
|
|
Binary file not shown.
|
@ -21,7 +21,7 @@
|
|||
#
|
||||
#
|
||||
# Author : $Author: fgerlits $
|
||||
# Version : $Revision: 1.9 $
|
||||
# Version : $Revision: 1.10 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
|
||||
#
|
||||
# @configure_input@
|
||||
|
@ -118,7 +118,8 @@ SCHEDULER_OBJS = ${TMP_DIR}/SignalDispatcher.o \
|
|||
${TMP_DIR}/RescheduleMethod.o \
|
||||
${TMP_DIR}/ScheduleFactory.o \
|
||||
${TMP_DIR}/PostgresqlSchedule.o \
|
||||
${TMP_DIR}/DeletePlaylistMethod.o
|
||||
${TMP_DIR}/DeletePlaylistMethod.o \
|
||||
${TMP_DIR}/DisplayPlaylistsMethod.o
|
||||
|
||||
SCHEDULER_EXE_OBJS = ${SCHEDULER_OBJS} \
|
||||
${TMP_DIR}/main.o
|
||||
|
@ -140,6 +141,7 @@ TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \
|
|||
${TMP_DIR}/RescheduleMethodTest.o \
|
||||
${TMP_DIR}/PostgresqlScheduleTest.o \
|
||||
${TMP_DIR}/DeletePlaylistMethodTest.o \
|
||||
${TMP_DIR}/DisplayPlaylistsMethodTest.o \
|
||||
${TMP_DIR}/TestRunner.o
|
||||
TEST_RUNNER_LIBS = ${SCHEDULER_EXE_LIBS} -lcppunit -ldl
|
||||
|
||||
|
|
|
@ -0,0 +1,125 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/DisplayPlaylistsMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "LiveSupport/Core/StorageClientInterface.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "DisplayPlaylistsMethod.h"
|
||||
|
||||
using namespace boost;
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Storage;
|
||||
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of this XML-RPC method.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string DisplayPlaylistsMethod::methodName = "displayPlaylists";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the method and register it right away.
|
||||
*----------------------------------------------------------------------------*/
|
||||
DisplayPlaylistsMethod :: DisplayPlaylistsMethod (
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) throw()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert a vector of Playlists into an XML-RPC value.
|
||||
* This function returns an XML-RPC array of XML-RPC structures.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayPlaylistsMethod :: playlistVectorToXmlRpcValue(
|
||||
const Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlistVector,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ()
|
||||
{
|
||||
returnValue.setSize(playlistVector->size());
|
||||
// a call to setSize() makes sure it's an XML-RPC
|
||||
// array
|
||||
|
||||
std::vector<Ptr<Playlist>::Ref>::const_iterator it =
|
||||
playlistVector->begin();
|
||||
int arraySize = 0;
|
||||
while (it != playlistVector->end()) {
|
||||
Ptr<Playlist>::Ref playlist = *it;
|
||||
XmlRpc::XmlRpcValue returnStruct;
|
||||
returnStruct["id"] = (int) (playlist->getId()->getId());
|
||||
returnStruct["playlength"] = playlist->getPlaylength()->total_seconds();
|
||||
returnValue[arraySize++] = returnStruct;
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Execute the stop XML-RPC function call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ()
|
||||
{
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
|
||||
scf = StorageClientFactory::getInstance();
|
||||
storage = scf->getStorageClient();
|
||||
|
||||
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlistVector =
|
||||
storage->getAllPlaylists();
|
||||
|
||||
playlistVectorToXmlRpcValue(playlistVector, returnValue);
|
||||
}
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/DisplayPlaylistsMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef DisplayPlaylistsMethod_h
|
||||
#define DisplayPlaylistsMethod_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <XmlRpcServerMethod.h>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An XML-RPC method object to return a listing of the playlists contained
|
||||
* in the playlist store.
|
||||
*
|
||||
* The name of the method when called through XML-RPC is "displayPlaylists".
|
||||
* No input parameters are expected.
|
||||
*
|
||||
* The XML-RPC function returns an XML-RPC array, containing a structure
|
||||
* for each playlist in the playlist store. An array of size 0 means the
|
||||
* playlist store is empty. Each structure is as follows:
|
||||
* <ul>
|
||||
* <li>id - int - the unique id of the playlist</li>
|
||||
* <li>playlength - int - the playlist length of the playlist, in seconds
|
||||
* </li>
|
||||
* </ul>
|
||||
* In case of an error, a simple false value is returned.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The name of this method, as it will be registered into the
|
||||
* XML-RPC server.
|
||||
*/
|
||||
static const std::string methodName;
|
||||
|
||||
/**
|
||||
* Convert a vector of Playlists to an XML-RPC return value.
|
||||
*
|
||||
* @param playlistVector a list of Playlists.
|
||||
* @param returnValue the output parameter holding an XML-RPC
|
||||
* representation of the list of Playlists.
|
||||
*/
|
||||
void
|
||||
playlistVectorToXmlRpcValue(
|
||||
const Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlistVector,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ();
|
||||
|
||||
public:
|
||||
/**
|
||||
* A default constructor, for testing purposes.
|
||||
*/
|
||||
DisplayPlaylistsMethod(void) throw ()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constuctor that registers the method with the server right away.
|
||||
*
|
||||
* @param xmlRpcServer the XML-RPC server to register with.
|
||||
*/
|
||||
DisplayPlaylistsMethod(
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Execute the displayPlaylists command on the Scheduler daemon.
|
||||
*
|
||||
* @param parameters XML-RPC function call parameters
|
||||
* @param returnValue the return value of the call (out parameter)
|
||||
*/
|
||||
void
|
||||
execute( XmlRpc::XmlRpcValue & parameters,
|
||||
XmlRpc::XmlRpcValue & returnValue) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // DisplayPlaylistsMethod_h
|
||||
|
|
@ -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/DisplayPlaylistsMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "DisplayPlaylistsMethod.h"
|
||||
#include "DisplayPlaylistsMethodTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(DisplayPlaylistsMethodTest);
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the storage client factory.
|
||||
*/
|
||||
const std::string DisplayPlaylistsMethodTest::storageClientConfig =
|
||||
"etc/storageClient.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the connection manager factory.
|
||||
*/
|
||||
const std::string DisplayPlaylistsMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Configure a Configurable with an XML file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayPlaylistsMethodTest :: configure(
|
||||
Ptr<Configurable>::Ref configurable,
|
||||
const std::string fileName)
|
||||
throw (std::invalid_argument,
|
||||
xmlpp::exception)
|
||||
{
|
||||
Ptr<xmlpp::DomParser>::Ref parser(new xmlpp::DomParser(fileName, true));
|
||||
const xmlpp::Document * document = parser->get_document();
|
||||
const xmlpp::Element * root = document->get_root_node();
|
||||
|
||||
configurable->configure(*root);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayPlaylistsMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
configure(scf, storageClientConfig);
|
||||
|
||||
Ptr<ConnectionManagerFactory>::Ref cmf
|
||||
= ConnectionManagerFactory::getInstance();
|
||||
configure(cmf, connectionManagerConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayPlaylistsMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Just a very simple smoke test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayPlaylistsMethodTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<DisplayPlaylistsMethod>::Ref method(new DisplayPlaylistsMethod());
|
||||
XmlRpc::XmlRpcValue parameters;
|
||||
XmlRpc::XmlRpcValue result;
|
||||
XmlRpc::XmlRpcValue playlist;
|
||||
|
||||
method->execute(parameters, result);
|
||||
CPPUNIT_ASSERT(result.size() == 1);
|
||||
|
||||
playlist = result[0];
|
||||
CPPUNIT_ASSERT(((int) playlist["id"]) == 1);
|
||||
CPPUNIT_ASSERT(((int) playlist["playlength"]) == (60 * 60));
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/DisplayPlaylistsMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef DisplayPlaylistsMethodTest_h
|
||||
#define DisplayPlaylistsMethodTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the DisplayPlaylistsMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see DisplayPlaylistsMethod
|
||||
*/
|
||||
class DisplayPlaylistsMethodTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(DisplayPlaylistsMethodTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the storage client factory.
|
||||
*/
|
||||
static const std::string storageClientConfig;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the connection manager
|
||||
* factory.
|
||||
*/
|
||||
static const std::string connectionManagerConfig;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
* @param configurable configure this
|
||||
* @param fileName the name of the XML file to configure with.
|
||||
* @exception std::invalid_argument on configuration errors.
|
||||
* @exception xmlpp::exception on XML parsing errors.
|
||||
*/
|
||||
void
|
||||
configure(Ptr<Configurable>::Ref configurable,
|
||||
std::string fileName)
|
||||
throw (std::invalid_argument,
|
||||
xmlpp::exception);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // DisplayPlaylistsMethodTest_h
|
||||
|
Loading…
Reference in New Issue