added XmlRpcTools utility class
implemented createPlaylist and openPlaylistForEditing methods
This commit is contained in:
parent
e21003f101
commit
a815a437d9
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
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.3 $
|
||||
* @version $Revision: 1.4 $
|
||||
*/
|
||||
class StorageClientInterface
|
||||
{
|
||||
|
@ -111,6 +111,15 @@ class StorageClientInterface
|
|||
virtual Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
|
||||
getAllPlaylists(void) const throw () = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new playlist.
|
||||
*
|
||||
* @return the newly created playlist.
|
||||
*/
|
||||
virtual Ptr<Playlist>::Ref
|
||||
createPlaylist() throw () = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -33,8 +33,11 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include "TestStorageClient.h"
|
||||
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Storage;
|
||||
|
@ -144,9 +147,32 @@ TestStorageClient :: getAllPlaylists(void) const
|
|||
playlistVector (new std::vector<Ptr<Playlist>::Ref>);
|
||||
|
||||
while (it != playlistMap.end()) {
|
||||
playlistVector->push_back(it->second); // TODO: check this
|
||||
playlistVector->push_back(it->second);
|
||||
++it;
|
||||
}
|
||||
|
||||
return playlistVector;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Create a new playlist.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Playlist>::Ref
|
||||
TestStorageClient :: createPlaylist() throw ()
|
||||
{
|
||||
// generate a new UniqueId -- TODO: fix UniqueId to make sure
|
||||
// this is really unique; not checked here!
|
||||
Ptr<UniqueId>::Ref playlistId =
|
||||
Ptr<UniqueId>::Ref(UniqueId :: generateId());
|
||||
|
||||
Ptr<time_duration>::Ref playLength =
|
||||
Ptr<time_duration>::Ref(new time_duration(0,0,0));
|
||||
|
||||
Ptr<Playlist>::Ref playlist =
|
||||
Ptr<Playlist>::Ref(new Playlist(playlistId, playLength));
|
||||
|
||||
playlistMap[playlistId->getId()] = playlist;
|
||||
|
||||
return playlist;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
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.3 $
|
||||
* @version $Revision: 1.4 $
|
||||
*/
|
||||
class TestStorageClient :
|
||||
virtual public Configurable,
|
||||
|
@ -169,6 +169,15 @@ class TestStorageClient :
|
|||
virtual Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
|
||||
getAllPlaylists(void) const throw ();
|
||||
|
||||
|
||||
/**
|
||||
* Create a new playlist.
|
||||
*
|
||||
* @return the newly created playlist.
|
||||
*/
|
||||
virtual Ptr<Playlist>::Ref
|
||||
createPlaylist() throw ();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClientTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -160,3 +160,16 @@ TestStorageClientTest :: getAllPlaylistsTest(void)
|
|||
Ptr<Playlist>::Ref playlist = (*playlistVector)[0];
|
||||
CPPUNIT_ASSERT((int) (playlist->getId()->getId()) == 1);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Testing the createPlaylist method
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
TestStorageClientTest :: createPlaylistTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<Playlist>::Ref playlist = tsc->createPlaylist();
|
||||
|
||||
CPPUNIT_ASSERT(tsc->existsPlaylist(playlist->getId()));
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClientTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -58,7 +58,7 @@ namespace Storage {
|
|||
* Unit test for the UploadPlaylistMetohd class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.3 $
|
||||
* @version $Revision: 1.4 $
|
||||
* @see TestStorageClient
|
||||
*/
|
||||
class TestStorageClientTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -67,6 +67,7 @@ class TestStorageClientTest : public CPPUNIT_NS::TestFixture
|
|||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST(getAllPlaylistsTest);
|
||||
CPPUNIT_TEST(deletePlaylistTest);
|
||||
CPPUNIT_TEST(createPlaylistTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
@ -101,6 +102,14 @@ class TestStorageClientTest : public CPPUNIT_NS::TestFixture
|
|||
void
|
||||
getAllPlaylistsTest(void)
|
||||
throw (CPPUNIT_NS::Exception);
|
||||
/**
|
||||
* Testing createPlaylist().
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
createPlaylistTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#
|
||||
#
|
||||
# Author : $Author: fgerlits $
|
||||
# Version : $Revision: 1.10 $
|
||||
# Version : $Revision: 1.11 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
|
||||
#
|
||||
# @configure_input@
|
||||
|
@ -111,6 +111,7 @@ LDFLAGS = @LDFLAGS@ -L${USR_LIB_DIR} \
|
|||
SCHEDULER_OBJS = ${TMP_DIR}/SignalDispatcher.o \
|
||||
${TMP_DIR}/XmlRpcDaemon.o \
|
||||
${TMP_DIR}/SchedulerDaemon.o \
|
||||
${TMP_DIR}/XmlRpcTools.o \
|
||||
${TMP_DIR}/UploadPlaylistMethod.o \
|
||||
${TMP_DIR}/DisplayScheduleMethod.o \
|
||||
${TMP_DIR}/DisplayPlaylistMethod.o \
|
||||
|
@ -119,7 +120,9 @@ SCHEDULER_OBJS = ${TMP_DIR}/SignalDispatcher.o \
|
|||
${TMP_DIR}/ScheduleFactory.o \
|
||||
${TMP_DIR}/PostgresqlSchedule.o \
|
||||
${TMP_DIR}/DeletePlaylistMethod.o \
|
||||
${TMP_DIR}/DisplayPlaylistsMethod.o
|
||||
${TMP_DIR}/DisplayPlaylistsMethod.o \
|
||||
${TMP_DIR}/CreatePlaylistMethod.o \
|
||||
${TMP_DIR}/OpenPlaylistForEditingMethod.o
|
||||
|
||||
SCHEDULER_EXE_OBJS = ${SCHEDULER_OBJS} \
|
||||
${TMP_DIR}/main.o
|
||||
|
@ -134,6 +137,7 @@ TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \
|
|||
${TMP_DIR}/SchedulerDaemonDisplayPlaylistTest.o \
|
||||
${TMP_DIR}/SchedulerDaemonRemoveFromScheduleTest.o \
|
||||
${TMP_DIR}/SchedulerDaemonRescheduleTest.o \
|
||||
${TMP_DIR}/XmlRpcToolsTest.o \
|
||||
${TMP_DIR}/UploadPlaylistMethodTest.o \
|
||||
${TMP_DIR}/DisplayScheduleMethodTest.o \
|
||||
${TMP_DIR}/DisplayPlaylistMethodTest.o \
|
||||
|
@ -142,6 +146,8 @@ TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \
|
|||
${TMP_DIR}/PostgresqlScheduleTest.o \
|
||||
${TMP_DIR}/DeletePlaylistMethodTest.o \
|
||||
${TMP_DIR}/DisplayPlaylistsMethodTest.o \
|
||||
${TMP_DIR}/CreatePlaylistMethodTest.o \
|
||||
${TMP_DIR}/OpenPlaylistForEditingMethodTest.o \
|
||||
${TMP_DIR}/TestRunner.o
|
||||
TEST_RUNNER_LIBS = ${SCHEDULER_EXE_LIBS} -lcppunit -ldl
|
||||
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/CreatePlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#else
|
||||
#error need time.h
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "LiveSupport/Core/StorageClientInterface.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "ScheduleInterface.h"
|
||||
#include "ScheduleFactory.h"
|
||||
#include "XmlRpcTools.h"
|
||||
|
||||
#include "CreatePlaylistMethod.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 CreatePlaylistMethod::methodName = "createPlaylist";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the method and register it right away.
|
||||
*----------------------------------------------------------------------------*/
|
||||
CreatePlaylistMethod :: CreatePlaylistMethod (
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) throw()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Execute the stop XML-RPC function call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ()
|
||||
{
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
|
||||
scf = StorageClientFactory::getInstance();
|
||||
storage = scf->getStorageClient();
|
||||
|
||||
Ptr<Playlist>::Ref playlist = storage->createPlaylist();
|
||||
|
||||
XmlRpcTools :: playlistToXmlRpcValue(playlist, returnValue);
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/CreatePlaylistMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef CreatePlaylistMethod_h
|
||||
#define CreatePlaylistMethod_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 <XmlRpcServerMethod.h>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An XML-RPC method object to create a new playlist in the playlist store.
|
||||
*
|
||||
* The name of the method when called through XML-RPC is "createPlaylist".
|
||||
*
|
||||
* The XML-RPC function returns an XML-RPC structure, containing the following
|
||||
* fields:
|
||||
* <ul>
|
||||
* <li>id - int - the unique id of the new playlist</li>
|
||||
* <li>playlength - int - the playlist length of the playlist, in seconds
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The name of this method, as it will be registered into the
|
||||
* XML-RPC server.
|
||||
*/
|
||||
static const std::string methodName;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* A default constructor, for testing purposes.
|
||||
*/
|
||||
CreatePlaylistMethod(void) throw ()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constuctor that registers the method with the server right away.
|
||||
*
|
||||
* @param xmlRpcServer the XML-RPC server to register with.
|
||||
*/
|
||||
CreatePlaylistMethod(
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Execute the create playlist command on the Scheduler daemon.
|
||||
*
|
||||
* @param parameters XML-RPC function call parameters
|
||||
* @param returnValue the return value of the call (out parameter)
|
||||
*/
|
||||
void
|
||||
execute( XmlRpc::XmlRpcValue & parameters,
|
||||
XmlRpc::XmlRpcValue & returnValue) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // CreatePlaylistMethod_h
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/CreatePlaylistMethodTest.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 <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "CreatePlaylistMethod.h"
|
||||
#include "CreatePlaylistMethodTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(CreatePlaylistMethodTest);
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the storage client factory.
|
||||
*/
|
||||
const std::string CreatePlaylistMethodTest::storageClientConfig =
|
||||
"etc/storageClient.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the connection manager factory.
|
||||
*/
|
||||
const std::string CreatePlaylistMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Configure a Configurable with an XML file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
CreatePlaylistMethodTest :: 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
|
||||
CreatePlaylistMethodTest :: 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
|
||||
CreatePlaylistMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Just a very simple smoke test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
CreatePlaylistMethodTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<CreatePlaylistMethod>::Ref method(new CreatePlaylistMethod());
|
||||
XmlRpc::XmlRpcValue parameter;
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
method->execute(parameter, result);
|
||||
CPPUNIT_ASSERT(result.hasMember("id"));
|
||||
CPPUNIT_ASSERT(((int) result["playlength"]) == 0);
|
||||
}
|
|
@ -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/CreatePlaylistMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef CreatePlaylistMethodTest_h
|
||||
#define CreatePlaylistMethodTest_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 CreatePlaylistMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see CreatePlaylistMethod
|
||||
*/
|
||||
class CreatePlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(CreatePlaylistMethodTest);
|
||||
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 // CreatePlaylistMethodTest_h
|
||||
|
|
@ -0,0 +1,149 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/OpenPlaylistForEditingMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#else
|
||||
#error need time.h
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "LiveSupport/Core/StorageClientInterface.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "ScheduleInterface.h"
|
||||
#include "ScheduleFactory.h"
|
||||
#include "XmlRpcTools.h"
|
||||
|
||||
#include "OpenPlaylistForEditingMethod.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 OpenPlaylistForEditingMethod::methodName = "openPlaylistForEditing";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The ID of this method for error reporting purposes.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const int OpenPlaylistForEditingMethod::errorId = 1000;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Construct the method and register it right away.
|
||||
*----------------------------------------------------------------------------*/
|
||||
OpenPlaylistForEditingMethod :: OpenPlaylistForEditingMethod (
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) throw()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Execute the stop XML-RPC function call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
OpenPlaylistForEditingMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ()
|
||||
{
|
||||
if (!parameters.valid()) {
|
||||
XmlRpcTools::markError(errorId+1, "invalid argument format",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref id;
|
||||
try{
|
||||
id = XmlRpcTools::extractPlaylistId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+2, "argument is not a playlist ID",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
|
||||
scf = StorageClientFactory::getInstance();
|
||||
storage = scf->getStorageClient();
|
||||
|
||||
if (!storage->existsPlaylist(id)) {
|
||||
XmlRpcTools::markError(errorId+3, "playlist does not exist",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->getPlaylist(id);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+4, "could not open playlist",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playlist->setLockedForEditing(true)) {
|
||||
XmlRpcTools::markError(errorId+5, "playlist cannot be edited",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
XmlRpcTools::playlistToXmlRpcValue(playlist, returnValue);
|
||||
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/OpenPlaylistForEditingMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef OpenPlaylistForEditingMethod_h
|
||||
#define OpenPlaylistForEditingMethod_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 <XmlRpcServerMethod.h>
|
||||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* An XML-RPC method object to open a playlist (specified by its playlist id)
|
||||
* for editing.
|
||||
*
|
||||
* The name of the method when called through XML-RPC is
|
||||
* "openPlaylistForEditing".
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* member:
|
||||
* <ul>
|
||||
* <li>playlistId - int - the unique id of the playlist requested.</li>
|
||||
* </ul>
|
||||
*
|
||||
* The XML-RPC function returns an XML-RPC structure, containing the following
|
||||
* fields:
|
||||
* <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, an XML-RPC structure is returned, with the following
|
||||
* fields:
|
||||
* <ul>
|
||||
* <li>errorCode - int - the id of the error condition</li>
|
||||
* <li>errorMessage - string - a description of the error</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
class OpenPlaylistForEditingMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The name of this method, as it will be registered into the
|
||||
* XML-RPC server.
|
||||
*/
|
||||
static const std::string methodName;
|
||||
|
||||
/**
|
||||
* The ID of this method for error reporting purposes.
|
||||
*/
|
||||
static const int errorId;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* A default constructor, for testing purposes.
|
||||
*/
|
||||
OpenPlaylistForEditingMethod(void) throw ()
|
||||
: XmlRpc::XmlRpcServerMethod(methodName)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constuctor that registers the method with the server right away.
|
||||
*
|
||||
* @param xmlRpcServer the XML-RPC server to register with.
|
||||
*/
|
||||
OpenPlaylistForEditingMethod(
|
||||
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Execute the display schedule 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 // OpenPlaylistForEditingMethod_h
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/OpenPlaylistForEditingMethodTest.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 <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "XmlRpcTools.h"
|
||||
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
#include "OpenPlaylistForEditingMethodTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(OpenPlaylistForEditingMethodTest);
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the storage client factory.
|
||||
*/
|
||||
const std::string OpenPlaylistForEditingMethodTest::storageClientConfig =
|
||||
"etc/storageClient.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the connection manager factory.
|
||||
*/
|
||||
const std::string OpenPlaylistForEditingMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Configure a Configurable with an XML file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
OpenPlaylistForEditingMethodTest :: 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
|
||||
OpenPlaylistForEditingMethodTest :: 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
|
||||
OpenPlaylistForEditingMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Just a very simple smoke test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
OpenPlaylistForEditingMethodTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<OpenPlaylistForEditingMethod>::Ref
|
||||
method(new OpenPlaylistForEditingMethod());
|
||||
XmlRpc::XmlRpcValue parameter;
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
parameter["playlistId"] = 1;
|
||||
|
||||
method->execute(parameter, result);
|
||||
CPPUNIT_ASSERT((int) result["id"] == 1);
|
||||
CPPUNIT_ASSERT((int) result["playlength"] == (60 * 60));
|
||||
|
||||
parameter.clear();
|
||||
result.clear();
|
||||
parameter["playlistId"] = 6376;
|
||||
|
||||
// no such playlist
|
||||
method->execute(parameter, result);
|
||||
CPPUNIT_ASSERT((int) result["errorCode"] == 1003);
|
||||
CPPUNIT_ASSERT((const std::string) result["errorMessage"] ==
|
||||
"playlist does not exist");
|
||||
parameter.clear();
|
||||
result.clear();
|
||||
parameter["playlistId"] = 1;
|
||||
|
||||
// should not allow to open the same playlist for editing again
|
||||
method->execute(parameter, result);
|
||||
CPPUNIT_ASSERT((int) result["errorCode"] == 1005);
|
||||
CPPUNIT_ASSERT((const std::string) result["errorMessage"] ==
|
||||
"playlist cannot be edited");
|
||||
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/OpenPlaylistForEditingMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef OpenPlaylistForEditingMethodTest_h
|
||||
#define OpenPlaylistForEditingMethodTest_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 OpenPlaylistForEditingMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see OpenPlaylistForEditingMethod
|
||||
*/
|
||||
class OpenPlaylistForEditingMethodTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(OpenPlaylistForEditingMethodTest);
|
||||
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 // OpenPlaylistForEditingMethodTest_h
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/Attic/XmlRpcTools.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#else
|
||||
#error need time.h
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "XmlRpcTools.h"
|
||||
|
||||
|
||||
using namespace boost;
|
||||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the playlistId member in the XML-RPC parameter
|
||||
* structure.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string XmlRpcTools::playlistIdName = "playlistId";
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Extract the UniqueId from an XML-RPC function call parameter
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<UniqueId>::Ref
|
||||
XmlRpcTools :: extractPlaylistId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
if (!xmlRpcValue.hasMember(playlistIdName)) {
|
||||
throw std::invalid_argument("no playlist id in parameter structure");
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref id(new UniqueId((int) xmlRpcValue[playlistIdName]));
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert a Playlist to an XmlRpcValue
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcTools :: playlistToXmlRpcValue(
|
||||
Ptr<const Playlist>::Ref playlist,
|
||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw ()
|
||||
{
|
||||
xmlRpcValue["id"] = (int) (playlist->getId()->getId());
|
||||
xmlRpcValue["playlength"] = playlist->getPlaylength()->total_seconds();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert an error code, error message pair to an XmlRpcValue
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcTools :: markError(int errorCode, const std::string errorMessage,
|
||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw ()
|
||||
{
|
||||
xmlRpcValue["errorCode"] = errorCode;
|
||||
xmlRpcValue["errorMessage"] = errorMessage;
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/Attic/XmlRpcTools.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef XmlRpcTools_h
|
||||
#define XmlRpcTools_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 <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* A toolbox for converting between inner representations of classes
|
||||
* and XmlRpcValues. Used by almost all XmlRpcServerMethod subclasses
|
||||
* in the Scheduler.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
class XmlRpcTools
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* The name of the playlistId member in the XML-RPC parameter
|
||||
* structure given as the input to an XmlRpcServerMethod.
|
||||
*/
|
||||
static const std::string playlistIdName;
|
||||
|
||||
/**
|
||||
* Extract the playlist id from the XML-RPC parameters.
|
||||
*
|
||||
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||
* @return a UniqueId that was found in the XML-RPC parameter.
|
||||
* @exception std::invalid_argument if there was no UniqueId
|
||||
* in xmlRpcValue
|
||||
*/
|
||||
static Ptr<UniqueId>::Ref
|
||||
extractPlaylistId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Convert a Playlist to an XmlRpcValue
|
||||
*
|
||||
* @param playlist the Playlist to convert.
|
||||
* @param xmlRpcValue the output parameter holding the value of
|
||||
* the conversion.
|
||||
*/
|
||||
static void
|
||||
playlistToXmlRpcValue(Ptr<const Playlist>::Ref playlist,
|
||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Convert an error code, message pair to an XmlRpcValue
|
||||
*
|
||||
* @param playlist the Playlist to convert.
|
||||
* @param xmlRpcValue the output parameter holding the value of
|
||||
* the conversion.
|
||||
*/
|
||||
static void
|
||||
markError(int errorCode, const std::string errorMessage,
|
||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw ();
|
||||
|
||||
};
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // XmlRpcTools_h
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/Attic/XmlRpcToolsTest.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 <XmlRpcValue.h>
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "XmlRpcTools.h"
|
||||
#include "XmlRpcToolsTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
using namespace std;
|
||||
using namespace XmlRpc;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(XmlRpcToolsTest);
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the playlist.
|
||||
*/
|
||||
const std::string configFileName = "etc/playlist.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Configure a Configurable with an XML file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcToolsTest :: configure(
|
||||
Ptr<Configurable>::Ref configurable,
|
||||
const std::string fileName)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
try {
|
||||
Ptr<xmlpp::DomParser>::Ref parser(
|
||||
new xmlpp::DomParser(configFileName, true));
|
||||
const xmlpp::Document * document = parser->get_document();
|
||||
const xmlpp::Element * root = document->get_root_node();
|
||||
|
||||
configurable->configure(*root);
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcToolsTest :: setUp(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcToolsTest :: tearDown(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Just a very simple smoke test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcToolsTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
XmlRpcValue xmlRpcPlaylist;
|
||||
Ptr<Playlist>::Ref playlist = Ptr<Playlist>::Ref(new Playlist);
|
||||
|
||||
// set up a playlist instance
|
||||
configure(playlist, configFileName);
|
||||
|
||||
// run the packing method
|
||||
XmlRpcTools :: playlistToXmlRpcValue(playlist, xmlRpcPlaylist);
|
||||
|
||||
CPPUNIT_ASSERT(((int) xmlRpcPlaylist["id"]) == 1);
|
||||
CPPUNIT_ASSERT(((int) xmlRpcPlaylist["playlength"]) == (90 * 60));
|
||||
|
||||
XmlRpcValue xmlRpcPlaylistId;
|
||||
Ptr<UniqueId>::Ref playlistId;
|
||||
int randomNumber = rand();
|
||||
|
||||
xmlRpcPlaylistId["playlistId"] = randomNumber;
|
||||
|
||||
// run the unpacking method
|
||||
try {
|
||||
playlistId = XmlRpcTools :: extractPlaylistId(xmlRpcPlaylistId);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT((int)(playlistId->getId()) == randomNumber);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Testint markError()
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcToolsTest :: errorTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
XmlRpcValue xmlRpcValue;
|
||||
|
||||
XmlRpcTools :: markError(42, "this is an error", xmlRpcValue);
|
||||
CPPUNIT_ASSERT((int) xmlRpcValue["errorCode"] == 42);
|
||||
CPPUNIT_ASSERT((const std::string) xmlRpcValue["errorMessage"] ==
|
||||
"this is an error");
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,130 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/Attic/XmlRpcToolsTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef XmlRpcToolsTest_h
|
||||
#define XmlRpcToolsTest_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 XmlRpcTools class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see XmlRpcTools
|
||||
*/
|
||||
class XmlRpcToolsTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(XmlRpcToolsTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
* @param configurable configure this
|
||||
* @param fileName the name of the XML file to configure with.
|
||||
* @exception CPPUNIT_NS::Exception on XML parsing errors.
|
||||
*/
|
||||
void
|
||||
configure(Ptr<Configurable>::Ref configurable,
|
||||
std::string fileName)
|
||||
throw (CPPUNIT_NS::Exception);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Testing the method for error message packaging.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
errorTest(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 // XmlRpcToolsTest_h
|
||||
|
Loading…
Reference in New Issue