added call to authentication server, as well as a new "sessionId" xml-rpc
parameter, to *everything*
This commit is contained in:
parent
a9fddab949
commit
e46a2192ce
|
@ -21,7 +21,7 @@
|
|||
#
|
||||
#
|
||||
# Author : $Author: fgerlits $
|
||||
# Version : $Revision: 1.23 $
|
||||
# Version : $Revision: 1.24 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
|
||||
#
|
||||
# @configure_input@
|
||||
|
@ -70,6 +70,12 @@ CORE_LIB_DIR = ${CORE_DIR}/lib
|
|||
CORE_LIB = livesupport_core
|
||||
CORE_LIB_FILE = ${CORE_LIB_DIR}/lib${CORE_LIB}.a
|
||||
|
||||
AUTHENTICATION_DIR = ${MODULES_DIR}/authentication
|
||||
AUTHENTICATION_INCLUDE_DIR = ${AUTHENTICATION_DIR}/include
|
||||
AUTHENTICATION_LIB_DIR = ${AUTHENTICATION_DIR}/lib
|
||||
AUTHENTICATION_LIB = livesupport_authentication
|
||||
AUTHENTICATION_LIB_FILE = ${AUTHENTICATION_LIB_DIR}/lib${AUTHENTICATION_LIB}.a
|
||||
|
||||
DB_DIR = ${MODULES_DIR}/db
|
||||
DB_INCLUDE_DIR = ${DB_DIR}/include
|
||||
DB_LIB_DIR = ${DB_DIR}/lib
|
||||
|
@ -82,6 +88,8 @@ STORAGE_LIB_DIR = ${STORAGE_DIR}/lib
|
|||
STORAGE_LIB = livesupport_storage
|
||||
STORAGE_LIB_FILE = ${STORAGE_LIB_DIR}/lib${STORAGE_LIB}.a
|
||||
|
||||
STORAGE_SERVER_DIR = ${MODULES_DIR}/storageServer
|
||||
|
||||
PLAYLIST_EXECUTOR_DIR = ${MODULES_DIR}/playlistExecutor
|
||||
PLAYLIST_EXECUTOR_INCLUDE_DIR = ${PLAYLIST_EXECUTOR_DIR}/include
|
||||
PLAYLIST_EXECUTOR_LIB_DIR = ${PLAYLIST_EXECUTOR_DIR}/lib
|
||||
|
@ -115,6 +123,7 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ \
|
|||
-I${BOOST_INCLUDE_DIR} \
|
||||
-I${LIBXMLPP_INCLUDE_DIR} \
|
||||
-I${CORE_INCLUDE_DIR} \
|
||||
-I${AUTHENTICATION_INCLUDE_DIR} \
|
||||
-I${DB_INCLUDE_DIR} \
|
||||
-I${STORAGE_INCLUDE_DIR} \
|
||||
-I${PLAYLIST_EXECUTOR_INCLUDE_DIR} \
|
||||
|
@ -122,6 +131,7 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ \
|
|||
-I${TMP_DIR}
|
||||
LDFLAGS = @LDFLAGS@ -L${USR_LIB_DIR} -L${HELIX_LIB_DIR} \
|
||||
-L${CORE_LIB_DIR} \
|
||||
-L${AUTHENTICATION_LIB_DIR} \
|
||||
-L${DB_LIB_DIR} \
|
||||
-L${STORAGE_LIB_DIR} \
|
||||
-L${PLAYLIST_EXECUTOR_LIB_DIR} \
|
||||
|
@ -164,7 +174,8 @@ SCHEDULER_OBJS = ${TMP_DIR}/SignalDispatcher.o \
|
|||
SCHEDULER_EXE_OBJS = ${SCHEDULER_OBJS} \
|
||||
${TMP_DIR}/main.o
|
||||
SCHEDULER_EXE_LIBS = -l${EVENT_SCHEDULER_LIB} -l${PLAYLIST_EXECUTOR_LIB} \
|
||||
-l${STORAGE_LIB} -l${DB_LIB} -l${CORE_LIB} \
|
||||
-l${STORAGE_LIB} -l${DB_LIB} -l${AUTHENTICATION_LIB} \
|
||||
-l${CORE_LIB} \
|
||||
${HELIX_LIBS} \
|
||||
-lodbc++ -lboost_date_time-gcc \
|
||||
-lxmlrpc++ -lssl -lxml++-1.0
|
||||
|
@ -231,12 +242,13 @@ depclean: clean
|
|||
${MAKE} -C ${PLAYLIST_EXECUTOR_DIR} clean
|
||||
${MAKE} -C ${STORAGE_DIR} clean
|
||||
${MAKE} -C ${DB_DIR} clean
|
||||
${MAKE} -C ${AUTHENTICATION_DIR} clean
|
||||
${MAKE} -C ${CORE_DIR} clean
|
||||
|
||||
distclean: clean docclean
|
||||
${RMDIR} ${TMP_DIR}/config* ${TMP_DIR}/autom4te*
|
||||
|
||||
check: all ${TEST_RUNNER} start run_tests stop
|
||||
check: all ${TEST_RUNNER} storage_server_init start run_tests stop
|
||||
|
||||
run_tests: ${TEST_RUNNER}
|
||||
LD_LIBRARY_PATH=${USR_LIB_DIR} ${TEST_RUNNER} \
|
||||
|
@ -259,11 +271,15 @@ uninstall: ${SCHEDULER_EXE}
|
|||
LD_LIBRARY_PATH=${USR_LIB_DIR} ${SCHEDULER_EXE} -c ${SCHEDULER_CFG} \
|
||||
uninstall
|
||||
|
||||
storage_server_init:
|
||||
${MAKE} -C ${STORAGE_SERVER_DIR}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Specific targets
|
||||
#-------------------------------------------------------------------------------
|
||||
${SCHEDULER_EXE}: ${CORE_LIB_FILE} ${DB_LIB_FILE} ${STORAGE_LIB_FILE} \
|
||||
${SCHEDULER_EXE}: ${CORE_LIB_FILE} ${AUTHENTICATION_LIB_FILE} ${DB_LIB_FILE} \
|
||||
${STORAGE_LIB_FILE} \
|
||||
${PLAYLIST_EXECUTOR_LIB_FILE} ${EVENT_SCHEDULER_LIB_FILE} \
|
||||
${SCHEDULER_EXE_OBJS}
|
||||
${CXX} ${LDFLAGS} -o $@ $^ ${SCHEDULER_EXE_LIBS}
|
||||
|
@ -274,7 +290,8 @@ ${TMP_DIR}:
|
|||
${DOXYGEN_DIR}:
|
||||
${MKDIR} ${DOXYGEN_DIR}
|
||||
|
||||
${TEST_RUNNER}: ${CORE_LIB_FILE} ${DB_LIB_FILE} ${STORAGE_LIB_FILE} \
|
||||
${TEST_RUNNER}: ${CORE_LIB_FILE} ${AUTHENTICATION_LIB_FILE} ${DB_LIB_FILE} \
|
||||
${STORAGE_LIB_FILE} \
|
||||
${PLAYLIST_EXECUTOR_LIB_FILE} ${EVENT_SCHEDULER_LIB_FILE} \
|
||||
${TEST_RUNNER_OBJS}
|
||||
${CXX} ${LDFLAGS} -o $@ ${TEST_RUNNER_OBJS} ${TEST_RUNNER_LIBS}
|
||||
|
@ -282,6 +299,9 @@ ${TEST_RUNNER}: ${CORE_LIB_FILE} ${DB_LIB_FILE} ${STORAGE_LIB_FILE} \
|
|||
${CORE_LIB_FILE}:
|
||||
${MAKE} -C ${CORE_DIR}
|
||||
|
||||
${AUTHENTICATION_LIB_FILE} :
|
||||
${MAKE} -C ${AUTHENTICATION_DIR}
|
||||
|
||||
${DB_LIB_FILE}:
|
||||
${MAKE} -C ${DB_DIR}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.5 $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -107,6 +107,17 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref playlistId;
|
||||
try{
|
||||
playlistId = XmlRpcTools::extractPlaylistId(parameters);
|
||||
|
@ -144,7 +155,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->getPlaylist(playlistId);
|
||||
playlist = storage->getPlaylist(sessionId, playlistId);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+5, "playlist not found",
|
||||
|
@ -161,7 +172,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
|
||||
Ptr<AudioClip>::Ref audioClip;
|
||||
try {
|
||||
audioClip = storage->getAudioClip(audioClipId);
|
||||
audioClip = storage->getAudioClip(sessionId, audioClipId);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+7, "audio clip does not exist",
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.5 $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -73,6 +73,8 @@ using namespace LiveSupport::Core;
|
|||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <li>playlistId - int - the unique id of the playlist.</li>
|
||||
* <li>audioClipId - int - the unique id of the audio clip to
|
||||
* be added.</li>
|
||||
|
@ -96,10 +98,11 @@ using namespace LiveSupport::Core;
|
|||
* <li>306 - playlist has not been opened for editing </li>
|
||||
* <li>307 - audio clip does not exist </li>
|
||||
* <li>308 - two audio clips at the same relative offset</li>
|
||||
* <li>322 - missing session ID argument </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.5 $
|
||||
* @version $Revision: 1.6 $
|
||||
*/
|
||||
class AddAudioClipToPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.5 $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,17 +46,18 @@
|
|||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "XmlRpcTools.h"
|
||||
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
#include "AddAudioClipToPlaylistMethod.h"
|
||||
#include "AddAudioClipToPlaylistMethodTest.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -78,6 +79,12 @@ const std::string AddAudioClipToPlaylistMethodTest::storageClientConfig =
|
|||
const std::string AddAudioClipToPlaylistMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string AddAudioClipToPlaylistMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -108,15 +115,19 @@ AddAudioClipToPlaylistMethodTest :: configure(
|
|||
void
|
||||
AddAudioClipToPlaylistMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
= StorageClientFactory::getInstance();
|
||||
configure(scf, storageClientConfig);
|
||||
|
||||
Ptr<ConnectionManagerFactory>::Ref cmf
|
||||
= ConnectionManagerFactory::getInstance();
|
||||
= ConnectionManagerFactory::getInstance();
|
||||
configure(cmf, connectionManagerConfig);
|
||||
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -124,6 +135,11 @@ AddAudioClipToPlaylistMethodTest :: setUp(void) throw ()
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = acf->getAuthenticationClient();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -133,6 +149,9 @@ AddAudioClipToPlaylistMethodTest :: setUp(void) throw ()
|
|||
void
|
||||
AddAudioClipToPlaylistMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -152,6 +171,7 @@ AddAudioClipToPlaylistMethodTest :: firstTest(void)
|
|||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
parameters["audioClipId"] = 10001;
|
||||
parameters["relativeOffset"] = 60*60;
|
||||
|
@ -166,6 +186,7 @@ AddAudioClipToPlaylistMethodTest :: firstTest(void)
|
|||
CPPUNIT_ASSERT((int)(result["errorCode"]) == 308);
|
||||
|
||||
parameters.clear();
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
parameters["audioClipId"] = 10001;
|
||||
parameters["relativeOffset"] = 90*60;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -61,7 +63,7 @@ using namespace LiveSupport::Core;
|
|||
* Unit test for the AddAudioClipToPlaylistMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see AddAudioClipToPlaylistMethod
|
||||
*/
|
||||
class AddAudioClipToPlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -81,6 +83,22 @@ class AddAudioClipToPlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
static const std::string connectionManagerConfig;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.4 $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -95,17 +95,35 @@ CreatePlaylistMethod :: CreatePlaylistMethod (
|
|||
* Execute the stop XML-RPC function call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||
CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ()
|
||||
{
|
||||
if (!rootParameter.valid() || rootParameter.size() != 1) {
|
||||
XmlRpcTools::markError(errorId+1, "invalid argument format",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
|
||||
scf = StorageClientFactory::getInstance();
|
||||
storage = scf->getStorageClient();
|
||||
|
||||
Ptr<Playlist>::Ref playlist = storage->createPlaylist();
|
||||
Ptr<Playlist>::Ref playlist = storage->createPlaylist(sessionId);
|
||||
|
||||
if (!playlist->setLockedForEditing(true)) { // this should never happen
|
||||
XmlRpcTools :: markError(errorId+1,
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.4 $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -68,6 +68,13 @@ using namespace LiveSupport::Core;
|
|||
*
|
||||
* The name of the method when called through XML-RPC is "createPlaylist".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* </ul>
|
||||
*
|
||||
* The XML-RPC function returns an XML-RPC structure, containing the following
|
||||
* fields:
|
||||
* <ul>
|
||||
|
@ -84,10 +91,11 @@ using namespace LiveSupport::Core;
|
|||
* The possible error codes are:
|
||||
* <ul>
|
||||
* <li>201 - could not open new playlist for editing</li>
|
||||
* <li>222 - missing session ID argument </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.4 $
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.7 $
|
||||
Version : $Revision: 1.8 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,6 +46,8 @@
|
|||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "CreatePlaylistMethod.h"
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
#include "CreatePlaylistMethodTest.h"
|
||||
|
@ -55,6 +57,8 @@ using namespace XmlRpc;
|
|||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -75,6 +79,12 @@ const std::string CreatePlaylistMethodTest::storageClientConfig =
|
|||
const std::string CreatePlaylistMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string CreatePlaylistMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -105,6 +115,7 @@ CreatePlaylistMethodTest :: configure(
|
|||
void
|
||||
CreatePlaylistMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
|
@ -114,6 +125,9 @@ CreatePlaylistMethodTest :: setUp(void) throw ()
|
|||
= ConnectionManagerFactory::getInstance();
|
||||
configure(cmf, connectionManagerConfig);
|
||||
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -121,6 +135,11 @@ CreatePlaylistMethodTest :: setUp(void) throw ()
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = acf->getAuthenticationClient();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -130,6 +149,9 @@ CreatePlaylistMethodTest :: setUp(void) throw ()
|
|||
void
|
||||
CreatePlaylistMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,6 +169,8 @@ CreatePlaylistMethodTest :: firstTest(void)
|
|||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
result.clear();
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
rootParameter[0] = parameter;
|
||||
method->execute(rootParameter, result);
|
||||
CPPUNIT_ASSERT(result.hasMember("id"));
|
||||
CPPUNIT_ASSERT(((int) result["playlength"]) == 0);
|
||||
|
@ -154,6 +178,7 @@ CreatePlaylistMethodTest :: firstTest(void)
|
|||
int playlistId = (int) result["id"];
|
||||
method.reset(new OpenPlaylistForEditingMethod());
|
||||
parameter.clear();
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["playlistId"] = playlistId;
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -61,7 +63,7 @@ using namespace LiveSupport::Core;
|
|||
* Unit test for the CreatePlaylistMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.3 $
|
||||
* @version $Revision: 1.4 $
|
||||
* @see CreatePlaylistMethod
|
||||
*/
|
||||
class CreatePlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -81,6 +83,22 @@ class CreatePlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
static const std::string connectionManagerConfig;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.4 $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -97,6 +97,17 @@ DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref playlistId;
|
||||
try{
|
||||
playlistId = XmlRpcTools::extractPlaylistId(parameters);
|
||||
|
@ -113,7 +124,7 @@ DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
= scf->getStorageClient();
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->getPlaylist(playlistId);
|
||||
playlist = storage->getPlaylist(sessionId, playlistId);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+3, "playlist not found",
|
||||
|
@ -128,7 +139,7 @@ DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
}
|
||||
|
||||
try {
|
||||
storage->deletePlaylist(playlistId);
|
||||
storage->deletePlaylist(sessionId, playlistId);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+5, "playlist could not be deleted",
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.4 $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -69,8 +69,10 @@ using namespace LiveSupport::Core;
|
|||
* The name of the method when called through XML-RPC is "deletePlaylist".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* member:
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <li>playlistId - int - the unique id of the playlist
|
||||
* to be deleted.</li>
|
||||
* </ul>
|
||||
|
@ -88,10 +90,11 @@ using namespace LiveSupport::Core;
|
|||
* <li>903 - playlist not found </li>
|
||||
* <li>904 - playlist is locked </li>
|
||||
* <li>905 - playlist could not be deleted </li>
|
||||
* <li>922 - missing session ID argument </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.4 $
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
class DeletePlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,6 +46,8 @@
|
|||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
#include "SavePlaylistMethod.h"
|
||||
|
||||
|
@ -56,6 +58,8 @@
|
|||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -76,6 +80,12 @@ const std::string DeletePlaylistMethodTest::storageClientConfig =
|
|||
const std::string DeletePlaylistMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string DeletePlaylistMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -106,6 +116,7 @@ DeletePlaylistMethodTest :: configure(
|
|||
void
|
||||
DeletePlaylistMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
|
@ -115,6 +126,9 @@ DeletePlaylistMethodTest :: setUp(void) throw ()
|
|||
= ConnectionManagerFactory::getInstance();
|
||||
configure(cmf, connectionManagerConfig);
|
||||
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -122,6 +136,11 @@ DeletePlaylistMethodTest :: setUp(void) throw ()
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = acf->getAuthenticationClient();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,6 +150,9 @@ DeletePlaylistMethodTest :: setUp(void) throw ()
|
|||
void
|
||||
DeletePlaylistMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -153,6 +175,7 @@ DeletePlaylistMethodTest :: firstTest(void)
|
|||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
// set up a structure for the parameters
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["playlistId"] = 1;
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
|
@ -189,6 +212,7 @@ DeletePlaylistMethodTest :: negativeTest(void)
|
|||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
// set up a structure for the parameters
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["playlistId"] = 9999;
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -62,7 +64,7 @@ using namespace LiveSupport::Core;
|
|||
*
|
||||
* @author $Author: maroy, fgerlits
|
||||
$
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see DeletePlaylistMethod
|
||||
*/
|
||||
class DeletePlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -83,6 +85,22 @@ class DeletePlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
static const std::string connectionManagerConfig;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -106,6 +106,17 @@ DisplayAudioClipMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref id;
|
||||
try{
|
||||
id = XmlRpcTools::extractAudioClipId(parameters);
|
||||
|
@ -124,7 +135,7 @@ DisplayAudioClipMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
|
||||
Ptr<AudioClip>::Ref audioClip;
|
||||
try {
|
||||
audioClip = storage->getAudioClip(id);
|
||||
audioClip = storage->getAudioClip(sessionId, id);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+3, "audio clip not found",
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -70,8 +70,10 @@ using namespace LiveSupport::Core;
|
|||
* The name of the method when called through XML-RPC is "displayAudioClip".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* member:
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <li>audioClipId - int - the unique id of the audio clip requested.</li>
|
||||
* </ul>
|
||||
*
|
||||
|
@ -94,10 +96,11 @@ using namespace LiveSupport::Core;
|
|||
* <li>601 - invalid argument format </li>
|
||||
* <li>602 - argument is not an audio clip ID </li>
|
||||
* <li>603 - audio clip not found </li>
|
||||
* <li>622 - missing session ID argument </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class DisplayAudioClipMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,6 +46,8 @@
|
|||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "DisplayAudioClipMethod.h"
|
||||
#include "DisplayAudioClipMethodTest.h"
|
||||
|
||||
|
@ -53,6 +55,8 @@
|
|||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -73,6 +77,12 @@ const std::string DisplayAudioClipMethodTest::storageClientConfig =
|
|||
const std::string DisplayAudioClipMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string DisplayAudioClipMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -103,6 +113,7 @@ DisplayAudioClipMethodTest :: configure(
|
|||
void
|
||||
DisplayAudioClipMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
|
@ -112,6 +123,9 @@ DisplayAudioClipMethodTest :: setUp(void) throw ()
|
|||
= ConnectionManagerFactory::getInstance();
|
||||
configure(cmf, connectionManagerConfig);
|
||||
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -119,6 +133,11 @@ DisplayAudioClipMethodTest :: setUp(void) throw ()
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = acf->getAuthenticationClient();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,6 +147,9 @@ DisplayAudioClipMethodTest :: setUp(void) throw ()
|
|||
void
|
||||
DisplayAudioClipMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -145,6 +167,7 @@ DisplayAudioClipMethodTest :: firstTest(void)
|
|||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
// set up a structure for the parameter
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["audioClipId"] = 10001;
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
|
@ -169,6 +192,7 @@ DisplayAudioClipMethodTest :: negativeTest(void)
|
|||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
// set up a structure for the parameter
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["audioClipId"] = 9999;
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -61,7 +63,7 @@ using namespace LiveSupport::Core;
|
|||
* Unit test for the DisplayAudioClipMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see DisplayAudioClipMethod
|
||||
*/
|
||||
class DisplayAudioClipMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -82,6 +84,22 @@ class DisplayAudioClipMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
static const std::string connectionManagerConfig;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipsMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -61,6 +61,11 @@ using namespace LiveSupport::Scheduler;
|
|||
*----------------------------------------------------------------------------*/
|
||||
const std::string DisplayAudioClipsMethod::methodName = "displayAudioClips";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The ID of this method for error reporting purposes.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const int DisplayAudioClipsMethod::errorId = 1800;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -76,15 +81,32 @@ DisplayAudioClipsMethod :: DisplayAudioClipsMethod (
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Execute the stop XML-RPC function call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayAudioClipsMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||
DisplayAudioClipsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ()
|
||||
{
|
||||
if (!rootParameter.valid() || rootParameter.size() != 1) {
|
||||
XmlRpcTools::markError(errorId+1, "invalid argument format",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
|
||||
|
@ -92,7 +114,7 @@ DisplayAudioClipsMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
|||
storage = scf->getStorageClient();
|
||||
|
||||
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref audioClipVector =
|
||||
storage->getAllAudioClips();
|
||||
storage->getAllAudioClips(sessionId);
|
||||
|
||||
XmlRpcTools::audioClipVectorToXmlRpcValue(audioClipVector, returnValue);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipsMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -72,7 +72,12 @@ using namespace LiveSupport::Core;
|
|||
*
|
||||
* The name of the method when called through XML-RPC is "displayAudioClips".
|
||||
*
|
||||
* No input parameters are expected.
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* </ul>
|
||||
*
|
||||
* The XML-RPC function returns an XML-RPC array, containing a structure
|
||||
* for each audio clip in the audio clip store. An array of size 0 means the
|
||||
|
@ -83,8 +88,19 @@ using namespace LiveSupport::Core;
|
|||
* </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>
|
||||
* The possible error codes are:
|
||||
* <ul>
|
||||
* <li>1822 - missing session ID argument </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class DisplayAudioClipsMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
@ -95,6 +111,11 @@ class DisplayAudioClipsMethod : public XmlRpc::XmlRpcServerMethod
|
|||
*/
|
||||
static const std::string methodName;
|
||||
|
||||
/**
|
||||
* The ID of this method for error reporting purposes.
|
||||
*/
|
||||
static const int errorId;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -47,6 +47,8 @@
|
|||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "DisplayAudioClipsMethod.h"
|
||||
#include "DisplayAudioClipsMethodTest.h"
|
||||
|
||||
|
@ -54,6 +56,8 @@
|
|||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -74,6 +78,12 @@ const std::string DisplayAudioClipsMethodTest::storageClientConfig =
|
|||
const std::string DisplayAudioClipsMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string DisplayAudioClipsMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -104,6 +114,7 @@ DisplayAudioClipsMethodTest :: configure(
|
|||
void
|
||||
DisplayAudioClipsMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
|
@ -113,6 +124,9 @@ DisplayAudioClipsMethodTest :: setUp(void) throw ()
|
|||
= ConnectionManagerFactory::getInstance();
|
||||
configure(cmf, connectionManagerConfig);
|
||||
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -120,6 +134,11 @@ DisplayAudioClipsMethodTest :: setUp(void) throw ()
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = acf->getAuthenticationClient();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,6 +148,9 @@ DisplayAudioClipsMethodTest :: setUp(void) throw ()
|
|||
void
|
||||
DisplayAudioClipsMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -141,11 +163,15 @@ DisplayAudioClipsMethodTest :: firstTest(void)
|
|||
{
|
||||
Ptr<DisplayAudioClipsMethod>::Ref method(new DisplayAudioClipsMethod());
|
||||
XmlRpc::XmlRpcValue parameter;
|
||||
XmlRpc::XmlRpcValue rootParameter;
|
||||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
XmlRpc::XmlRpcValue audioClip;
|
||||
|
||||
result.clear();
|
||||
method->execute(parameter, result);
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
rootParameter[0] = parameter;
|
||||
method->execute(rootParameter, result);
|
||||
CPPUNIT_ASSERT(result.size() == 2);
|
||||
|
||||
audioClip = result[0];
|
||||
|
@ -155,5 +181,5 @@ DisplayAudioClipsMethodTest :: firstTest(void)
|
|||
audioClip = result[1];
|
||||
CPPUNIT_ASSERT(int(audioClip["id"]) == 10002);
|
||||
CPPUNIT_ASSERT(int(audioClip["playlength"]) == 30 * 60);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -61,7 +63,7 @@ using namespace LiveSupport::Core;
|
|||
* Unit test for the DisplayAudioClipsMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see DisplayAudioClipsMethod
|
||||
*/
|
||||
class DisplayAudioClipsMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -81,6 +83,22 @@ class DisplayAudioClipsMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
static const std::string connectionManagerConfig;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -106,6 +106,17 @@ DisplayPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref id;
|
||||
try{
|
||||
id = XmlRpcTools::extractPlaylistId(parameters);
|
||||
|
@ -124,7 +135,7 @@ DisplayPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->getPlaylist(id);
|
||||
playlist = storage->getPlaylist(sessionId, id);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+3, "playlist not found",
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.4 $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -70,8 +70,10 @@ using namespace LiveSupport::Core;
|
|||
* The name of the method when called through XML-RPC is "displayPlaylist".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* member:
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <li>playlistId - int - the unique id of the playlist requested.</li>
|
||||
* </ul>
|
||||
*
|
||||
|
@ -94,10 +96,11 @@ using namespace LiveSupport::Core;
|
|||
* <li>1001 - invalid argument format </li>
|
||||
* <li>1002 - argument is not a playlist ID </li>
|
||||
* <li>1003 - playlist not found </li>
|
||||
* <li>1022 - missing session ID argument </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.4 $
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
class DisplayPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,6 +46,8 @@
|
|||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "DisplayPlaylistMethod.h"
|
||||
#include "DisplayPlaylistMethodTest.h"
|
||||
|
||||
|
@ -53,6 +55,8 @@
|
|||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -73,6 +77,12 @@ const std::string DisplayPlaylistMethodTest::storageClientConfig =
|
|||
const std::string DisplayPlaylistMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string DisplayPlaylistMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -103,6 +113,7 @@ DisplayPlaylistMethodTest :: configure(
|
|||
void
|
||||
DisplayPlaylistMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
|
@ -112,6 +123,9 @@ DisplayPlaylistMethodTest :: setUp(void) throw ()
|
|||
= ConnectionManagerFactory::getInstance();
|
||||
configure(cmf, connectionManagerConfig);
|
||||
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -119,6 +133,11 @@ DisplayPlaylistMethodTest :: setUp(void) throw ()
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = acf->getAuthenticationClient();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,6 +147,9 @@ DisplayPlaylistMethodTest :: setUp(void) throw ()
|
|||
void
|
||||
DisplayPlaylistMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -145,6 +167,7 @@ DisplayPlaylistMethodTest :: firstTest(void)
|
|||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
// set up a structure for the parameter
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["playlistId"] = 1;
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
|
@ -169,6 +192,7 @@ DisplayPlaylistMethodTest :: negativeTest(void)
|
|||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
// set up a structure for the parameter
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["playlistId"] = 9999;
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -60,8 +62,8 @@ using namespace LiveSupport::Core;
|
|||
/**
|
||||
* Unit test for the DisplayPlaylistMethod class.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see DisplayPlaylistMethod
|
||||
*/
|
||||
class DisplayPlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -82,6 +84,22 @@ class DisplayPlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
static const std::string connectionManagerConfig;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -61,6 +61,11 @@ using namespace LiveSupport::Scheduler;
|
|||
*----------------------------------------------------------------------------*/
|
||||
const std::string DisplayPlaylistsMethod::methodName = "displayPlaylists";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The ID of this method for error reporting purposes.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const int DisplayPlaylistsMethod::errorId = 1700;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -81,10 +86,28 @@ DisplayPlaylistsMethod :: DisplayPlaylistsMethod (
|
|||
* Execute the stop XML-RPC function call.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||
DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
||||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ()
|
||||
{
|
||||
if (!rootParameter.valid() || rootParameter.size() != 1) {
|
||||
XmlRpcTools::markError(errorId+1, "invalid argument format",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<StorageClientFactory>::Ref scf;
|
||||
Ptr<StorageClientInterface>::Ref storage;
|
||||
|
||||
|
@ -92,7 +115,7 @@ DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
|||
storage = scf->getStorageClient();
|
||||
|
||||
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlistVector =
|
||||
storage->getAllPlaylists();
|
||||
storage->getAllPlaylists(sessionId);
|
||||
|
||||
XmlRpcTools::playlistVectorToXmlRpcValue(playlistVector, returnValue);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.4 $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -72,7 +72,12 @@ using namespace LiveSupport::Core;
|
|||
*
|
||||
* The name of the method when called through XML-RPC is "displayPlaylists".
|
||||
*
|
||||
* No input parameters are expected.
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* </ul>
|
||||
*
|
||||
* 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
|
||||
|
@ -83,8 +88,19 @@ using namespace LiveSupport::Core;
|
|||
* </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>
|
||||
* The possible error codes are:
|
||||
* <ul>
|
||||
* <li>1722 - missing session ID argument </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.4 $
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
@ -95,6 +111,11 @@ class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod
|
|||
*/
|
||||
static const std::string methodName;
|
||||
|
||||
/**
|
||||
* The ID of this method for error reporting purposes.
|
||||
*/
|
||||
static const int errorId;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -47,6 +47,8 @@
|
|||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "DisplayPlaylistsMethod.h"
|
||||
#include "DisplayPlaylistsMethodTest.h"
|
||||
|
||||
|
@ -54,6 +56,8 @@
|
|||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -74,6 +78,12 @@ const std::string DisplayPlaylistsMethodTest::storageClientConfig =
|
|||
const std::string DisplayPlaylistsMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string DisplayPlaylistsMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -104,6 +114,7 @@ DisplayPlaylistsMethodTest :: configure(
|
|||
void
|
||||
DisplayPlaylistsMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
|
@ -113,6 +124,9 @@ DisplayPlaylistsMethodTest :: setUp(void) throw ()
|
|||
= ConnectionManagerFactory::getInstance();
|
||||
configure(cmf, connectionManagerConfig);
|
||||
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -120,6 +134,11 @@ DisplayPlaylistsMethodTest :: setUp(void) throw ()
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = acf->getAuthenticationClient();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,6 +148,9 @@ DisplayPlaylistsMethodTest :: setUp(void) throw ()
|
|||
void
|
||||
DisplayPlaylistsMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -141,11 +163,15 @@ DisplayPlaylistsMethodTest :: firstTest(void)
|
|||
{
|
||||
Ptr<DisplayPlaylistsMethod>::Ref method(new DisplayPlaylistsMethod());
|
||||
XmlRpc::XmlRpcValue parameters;
|
||||
XmlRpc::XmlRpcValue rootParameter;
|
||||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
XmlRpc::XmlRpcValue playlist;
|
||||
|
||||
result.clear();
|
||||
method->execute(parameters, result);
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
rootParameter[0] = parameters;
|
||||
method->execute(rootParameter, result);
|
||||
CPPUNIT_ASSERT(result.size() == 1);
|
||||
|
||||
playlist = result[0];
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -61,7 +63,7 @@ using namespace LiveSupport::Core;
|
|||
* Unit test for the DisplayPlaylistsMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see DisplayPlaylistsMethod
|
||||
*/
|
||||
class DisplayPlaylistsMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -81,6 +83,22 @@ class DisplayPlaylistsMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
static const std::string connectionManagerConfig;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -103,6 +103,17 @@ DisplayScheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<ptime>::Ref fromTime;
|
||||
try {
|
||||
fromTime = XmlRpcTools::extractFromTime(parameters);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.4 $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -74,8 +74,10 @@ using namespace LiveSupport::Core;
|
|||
* The name of the method when called through XML-RPC is "displaySchedule".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* member:
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <li>from - datetime - the start of the interval to list schedule from,
|
||||
* inclusive.</li>
|
||||
* <li>to - datetime - the end of the interval to list schedule from,
|
||||
|
@ -104,10 +106,11 @@ using namespace LiveSupport::Core;
|
|||
* <li>1101 - invalid argument format </li>
|
||||
* <li>1102 - missing or invalid 'from' argument </li>
|
||||
* <li>1103 - missing or invalid 'to' argument </li>
|
||||
* <li>1122 - missing session ID argument </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.4 $
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
class DisplayScheduleMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,6 +46,8 @@
|
|||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "ScheduleFactory.h"
|
||||
#include "UploadPlaylistMethod.h"
|
||||
#include "DisplayScheduleMethod.h"
|
||||
|
@ -56,6 +58,8 @@ using namespace std;
|
|||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -82,6 +86,12 @@ const std::string DisplayScheduleMethodTest::connectionManagerConfig =
|
|||
const std::string DisplayScheduleMethodTest::scheduleConfig =
|
||||
"etc/scheduleFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string DisplayScheduleMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -117,17 +127,21 @@ DisplayScheduleMethodTest :: setUp(void) throw ()
|
|||
= StorageClientFactory::getInstance();
|
||||
configure(scf, storageClientConfig);
|
||||
|
||||
Ptr<ConnectionManagerFactory>::Ref cmf
|
||||
= ConnectionManagerFactory::getInstance();
|
||||
Ptr<ConnectionManagerFactory>::Ref
|
||||
cmf = ConnectionManagerFactory::getInstance();
|
||||
configure(cmf, connectionManagerConfig);
|
||||
|
||||
Ptr<ScheduleFactory>::Ref sf = ScheduleFactory::getInstance();
|
||||
Ptr<ScheduleFactory>::Ref
|
||||
sf = ScheduleFactory::getInstance();
|
||||
configure(sf, scheduleConfig);
|
||||
|
||||
schedule = sf->getSchedule();
|
||||
schedule->install();
|
||||
|
||||
insertEntries();
|
||||
Ptr<AuthenticationClientFactory>::Ref
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
authentication = acf->getAuthenticationClient();
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -135,6 +149,12 @@ DisplayScheduleMethodTest :: setUp(void) throw ()
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
|
||||
insertEntries(); // this can only be called after sessionId is obtained
|
||||
}
|
||||
|
||||
|
||||
|
@ -145,6 +165,10 @@ void
|
|||
DisplayScheduleMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
schedule->uninstall();
|
||||
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -163,6 +187,7 @@ DisplayScheduleMethodTest :: firstTest(void)
|
|||
struct tm time;
|
||||
|
||||
// set up a structure for the parameters
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
time.tm_year = 2001;
|
||||
time.tm_mon = 11;
|
||||
time.tm_mday = 12;
|
||||
|
@ -200,6 +225,7 @@ DisplayScheduleMethodTest :: insertEntries(void)
|
|||
struct tm time;
|
||||
|
||||
// insert a playlist for 2004-07-31, at 10 o'clock
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
time.tm_year = 2004;
|
||||
time.tm_mon = 7;
|
||||
|
@ -214,6 +240,7 @@ DisplayScheduleMethodTest :: insertEntries(void)
|
|||
method->execute(rootParameter, result);
|
||||
|
||||
// insert a playlist for 2004-07-31, at 12 o'clock
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
time.tm_year = 2004;
|
||||
time.tm_mon = 7;
|
||||
|
@ -228,6 +255,7 @@ DisplayScheduleMethodTest :: insertEntries(void)
|
|||
method->execute(rootParameter, result);
|
||||
|
||||
// insert a playlist for 2004-07-31, at 14 o'clock
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
time.tm_year = 2004;
|
||||
time.tm_mon = 7;
|
||||
|
@ -258,6 +286,7 @@ DisplayScheduleMethodTest :: intervalTest(void)
|
|||
struct tm time;
|
||||
|
||||
// check for the interval 2004-07-31 between 9 and 11 o'clock
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
time.tm_year = 2004;
|
||||
time.tm_mon = 7;
|
||||
time.tm_mday = 31;
|
||||
|
@ -296,6 +325,7 @@ DisplayScheduleMethodTest :: intervalTest(void)
|
|||
CPPUNIT_ASSERT(time.tm_sec == 0);
|
||||
|
||||
// check for the interval 2004-07-31 between 9 and 13 o'clock
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
time.tm_year = 2004;
|
||||
time.tm_mon = 7;
|
||||
time.tm_mday = 31;
|
||||
|
@ -350,6 +380,7 @@ DisplayScheduleMethodTest :: intervalTest(void)
|
|||
CPPUNIT_ASSERT(time.tm_sec == 0);
|
||||
|
||||
// check for the interval 2004-07-31 between 8 and 9 o'clock
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
time.tm_year = 2004;
|
||||
time.tm_mon = 7;
|
||||
time.tm_mday = 31;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -60,8 +62,8 @@ using namespace LiveSupport::Core;
|
|||
/**
|
||||
* Unit test for the DisplayScheduleMethod class.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see DisplayScheduleMethod
|
||||
*/
|
||||
class DisplayScheduleMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -92,6 +94,22 @@ class DisplayScheduleMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
Ptr<ScheduleInterface>::Ref schedule;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GeneratePlayReportMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -103,6 +103,17 @@ GeneratePlayReportMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<ptime>::Ref fromTime;
|
||||
try {
|
||||
fromTime = XmlRpcTools::extractFromTime(parameters);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GeneratePlayReportMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -74,8 +74,10 @@ using namespace LiveSupport::Core;
|
|||
* The name of the method when called through XML-RPC is "generatePlayReport".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* member:
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <li>from - datetime - the start of the interval to give the playlog
|
||||
* from, inclusive.</li>
|
||||
* <li>to - datetime - the end of the interval to give the playlog
|
||||
|
@ -101,10 +103,11 @@ using namespace LiveSupport::Core;
|
|||
* <li>1501 - invalid argument format </li>
|
||||
* <li>1502 - missing or invalid 'from' argument </li>
|
||||
* <li>1503 - missing or invalid 'to' argument </li>
|
||||
* <li>1522 - missing session ID argument </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class GeneratePlayReportMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,6 +46,8 @@
|
|||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "PlayLogFactory.h"
|
||||
#include "UploadPlaylistMethod.h"
|
||||
#include "GeneratePlayReportMethod.h"
|
||||
|
@ -56,6 +58,8 @@ using namespace std;
|
|||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -82,6 +86,12 @@ const std::string GeneratePlayReportMethodTest::connectionManagerConfig =
|
|||
const std::string GeneratePlayReportMethodTest::playLogConfig =
|
||||
"etc/playLogFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string GeneratePlayReportMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -112,6 +122,7 @@ GeneratePlayReportMethodTest :: configure(
|
|||
void
|
||||
GeneratePlayReportMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
|
@ -129,6 +140,9 @@ GeneratePlayReportMethodTest :: setUp(void) throw ()
|
|||
|
||||
insertEntries();
|
||||
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -136,6 +150,11 @@ GeneratePlayReportMethodTest :: setUp(void) throw ()
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = acf->getAuthenticationClient();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -146,6 +165,10 @@ void
|
|||
GeneratePlayReportMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
playLog->uninstall();
|
||||
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -164,6 +187,7 @@ GeneratePlayReportMethodTest :: firstTest(void)
|
|||
struct tm time;
|
||||
|
||||
// set up a structure for the parameters
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
time.tm_year = 2001;
|
||||
time.tm_mon = 11;
|
||||
time.tm_mday = 12;
|
||||
|
@ -223,6 +247,7 @@ GeneratePlayReportMethodTest :: intervalTest(void)
|
|||
struct tm time;
|
||||
|
||||
// check for the interval 2004-10-26 between 13 and 15 o'clock
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
time.tm_year = 2004;
|
||||
time.tm_mon = 10;
|
||||
time.tm_mday = 26;
|
||||
|
@ -255,6 +280,7 @@ GeneratePlayReportMethodTest :: intervalTest(void)
|
|||
|
||||
|
||||
// check for the interval 2004-10-26 between 14 o'clock and 15:30
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
time.tm_year = 2004;
|
||||
time.tm_mon = 10;
|
||||
time.tm_mday = 26;
|
||||
|
@ -287,6 +313,7 @@ GeneratePlayReportMethodTest :: intervalTest(void)
|
|||
|
||||
|
||||
// check for the interval 2004-10-26 15:00 to 2012-08-01 midnight
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
time.tm_year = 2004;
|
||||
time.tm_mon = 10;
|
||||
time.tm_mday = 26;
|
||||
|
@ -328,6 +355,7 @@ GeneratePlayReportMethodTest :: intervalTest(void)
|
|||
|
||||
|
||||
// check for the interval 2004-10-26 16 o'clock to 2004-10-27 10 o'clock
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
time.tm_year = 2004;
|
||||
time.tm_mon = 10;
|
||||
time.tm_mday = 26;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -61,7 +63,7 @@ using namespace LiveSupport::Core;
|
|||
* Unit test for the GeneratePlayReportMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see GeneratePlayReportMethod
|
||||
*/
|
||||
class GeneratePlayReportMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -92,6 +94,22 @@ class GeneratePlayReportMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
Ptr<PlayLogInterface>::Ref playLog;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.8 $
|
||||
Version : $Revision: 1.9 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -107,6 +107,17 @@ OpenPlaylistForEditingMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref id;
|
||||
try{
|
||||
id = XmlRpcTools::extractPlaylistId(parameters);
|
||||
|
@ -125,7 +136,7 @@ OpenPlaylistForEditingMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->getPlaylist(id);
|
||||
playlist = storage->getPlaylist(sessionId, id);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+4, "playlist not found",
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.6 $
|
||||
Version : $Revision: 1.7 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -71,8 +71,10 @@ using namespace LiveSupport::Core;
|
|||
* "openPlaylistForEditing".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* member:
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <li>playlistId - int - the unique id of the playlist requested.</li>
|
||||
* </ul>
|
||||
*
|
||||
|
@ -95,9 +97,10 @@ using namespace LiveSupport::Core;
|
|||
* <li>102 - argument is not a playlist ID </li>
|
||||
* <li>104 - playlist not found </li>
|
||||
* <li>105 - could not open playlist </li>
|
||||
* <li>122 - missing session ID argument </li>
|
||||
* </ul>
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.6 $
|
||||
* @version $Revision: 1.7 $
|
||||
*/
|
||||
class OpenPlaylistForEditingMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.7 $
|
||||
Version : $Revision: 1.8 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,6 +46,7 @@
|
|||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "XmlRpcTools.h"
|
||||
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
|
@ -55,6 +56,8 @@
|
|||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -75,6 +78,12 @@ const std::string OpenPlaylistForEditingMethodTest::storageClientConfig =
|
|||
const std::string OpenPlaylistForEditingMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string OpenPlaylistForEditingMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -105,6 +114,7 @@ OpenPlaylistForEditingMethodTest :: configure(
|
|||
void
|
||||
OpenPlaylistForEditingMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
|
@ -114,6 +124,9 @@ OpenPlaylistForEditingMethodTest :: setUp(void) throw ()
|
|||
= ConnectionManagerFactory::getInstance();
|
||||
configure(cmf, connectionManagerConfig);
|
||||
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -121,6 +134,11 @@ OpenPlaylistForEditingMethodTest :: setUp(void) throw ()
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = acf->getAuthenticationClient();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -130,6 +148,9 @@ OpenPlaylistForEditingMethodTest :: setUp(void) throw ()
|
|||
void
|
||||
OpenPlaylistForEditingMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,6 +168,7 @@ OpenPlaylistForEditingMethodTest :: firstTest(void)
|
|||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["playlistId"] = 1;
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
|
@ -156,6 +178,7 @@ OpenPlaylistForEditingMethodTest :: firstTest(void)
|
|||
CPPUNIT_ASSERT((int) result["playlength"] == (90 * 60));
|
||||
|
||||
parameter.clear();
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["playlistId"] = 6376;
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
|
@ -166,6 +189,7 @@ OpenPlaylistForEditingMethodTest :: firstTest(void)
|
|||
CPPUNIT_ASSERT((const std::string) result["errorMessage"] ==
|
||||
"playlist not found");
|
||||
parameter.clear();
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["playlistId"] = 1;
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -61,7 +63,7 @@ using namespace LiveSupport::Core;
|
|||
* Unit test for the OpenPlaylistForEditingMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.3 $
|
||||
* @version $Revision: 1.4 $
|
||||
* @see OpenPlaylistForEditingMethod
|
||||
*/
|
||||
class OpenPlaylistForEditingMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -81,6 +83,22 @@ class OpenPlaylistForEditingMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
static const std::string connectionManagerConfig;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.2 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEvent.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -40,6 +40,7 @@
|
|||
#endif
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
#include "PlaylistEvent.h"
|
||||
|
||||
|
@ -70,6 +71,7 @@ PlaylistEvent :: PlaylistEvent(
|
|||
this->audioPlayer = audioPlayer;
|
||||
this->storage = storage;
|
||||
this->scheduleEntry = scheduleEntry;
|
||||
this->sessionId.reset(new SessionId("dummy session ID"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,7 +81,10 @@ PlaylistEvent :: PlaylistEvent(
|
|||
void
|
||||
PlaylistEvent :: initialize(void) throw (std::exception)
|
||||
{
|
||||
playlist = storage->acquirePlaylist(scheduleEntry->getPlaylistId());
|
||||
// some ugliness because getPlaylistId() returns a const pointer
|
||||
Ptr<UniqueId>::Ref playlistId(new UniqueId(scheduleEntry->getPlaylistId()
|
||||
->getId()));
|
||||
playlist = storage->acquirePlaylist(sessionId, playlistId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,7 +94,7 @@ PlaylistEvent :: initialize(void) throw (std::exception)
|
|||
void
|
||||
PlaylistEvent :: deInitialize(void) throw ()
|
||||
{
|
||||
storage->releasePlaylist(playlist);
|
||||
storage->releasePlaylist(sessionId, playlist);
|
||||
playlist.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.2 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEvent.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -68,8 +68,8 @@ using namespace LiveSupport::Scheduler;
|
|||
/**
|
||||
* A scheduled event for playing a playlist.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.2 $
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class PlaylistEvent : public virtual ScheduledEventInterface
|
||||
{
|
||||
|
@ -99,6 +99,11 @@ class PlaylistEvent : public virtual ScheduledEventInterface
|
|||
*/
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
|
||||
/**
|
||||
* The session ID used for authentication at the storage server.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEventContainerTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,6 +46,7 @@
|
|||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "PlaylistEventContainer.h"
|
||||
#include "PlaylistEventContainerTest.h"
|
||||
|
@ -58,6 +59,8 @@ using namespace LiveSupport::Db;
|
|||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::PlaylistExecutor;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -87,6 +90,12 @@ static const std::string storageClientConfigFileName = "etc/storageClient.xml";
|
|||
*/
|
||||
static const std::string scheduleConfigFileName = "etc/scheduleFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfigFileName =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -131,6 +140,14 @@ PlaylistEventContainerTest :: setUp(void) throw ()
|
|||
|
||||
schedule = scheduleFactory->getSchedule();
|
||||
|
||||
// get an authentication client
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
parser.reset(new xmlpp::DomParser(authenticationClientConfigFileName,
|
||||
true));
|
||||
acf->configure(*(parser->get_document()->get_root_node()));
|
||||
authentication = acf->getAuthenticationClient();
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
|
@ -141,6 +158,10 @@ PlaylistEventContainerTest :: setUp(void) throw ()
|
|||
|
||||
scheduleFactory->install();
|
||||
audioPlayer->initialize();
|
||||
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -157,6 +178,10 @@ PlaylistEventContainerTest :: tearDown(void) throw ()
|
|||
scheduleFactory.reset();
|
||||
storage.reset();
|
||||
audioPlayer.reset();
|
||||
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -189,7 +214,8 @@ PlaylistEventContainerTest :: scheduleTest(void)
|
|||
|
||||
// schedule playlist 1 at 10 seconds from now
|
||||
Ptr<UniqueId>::Ref playlistId(new UniqueId(1));
|
||||
Ptr<Playlist>::Ref playlist = storage->getPlaylist(playlistId);
|
||||
Ptr<Playlist>::Ref playlist = storage->getPlaylist(sessionId,
|
||||
playlistId);
|
||||
CPPUNIT_ASSERT(playlist.get());
|
||||
Ptr<ptime>::Ref now = TimeConversion::now();
|
||||
Ptr<ptime>::Ref from(new ptime(*now + seconds(10)));
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEventContainerTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -40,14 +40,16 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
#include "LiveSupport/Core/StorageClientInterface.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerInterface.h"
|
||||
#include "ScheduleInterface.h"
|
||||
#include "ScheduleFactory.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
|
@ -58,6 +60,7 @@ using namespace LiveSupport::Core;
|
|||
using namespace LiveSupport::PlaylistExecutor;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
|
@ -69,8 +72,8 @@ using namespace LiveSupport::Scheduler;
|
|||
/**
|
||||
* Unit test for the PlaylistEventContainer class
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see PlaylistEventContainer
|
||||
*/
|
||||
class PlaylistEventContainerTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -101,6 +104,16 @@ class PlaylistEventContainerTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
Ptr<ScheduleInterface>::Ref schedule;
|
||||
|
||||
/**
|
||||
* An authentication client.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -108,6 +108,17 @@ RemoveAudioClipFromPlaylistMethod :: execute(
|
|||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref playlistId;
|
||||
try{
|
||||
playlistId = XmlRpcTools::extractPlaylistId(parameters);
|
||||
|
@ -137,7 +148,7 @@ RemoveAudioClipFromPlaylistMethod :: execute(
|
|||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->getPlaylist(playlistId);
|
||||
playlist = storage->getPlaylist(sessionId, playlistId);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+4, "playlist does not exist",
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -73,6 +73,8 @@ using namespace LiveSupport::Core;
|
|||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <li>playlistId - int - the unique id of the playlist.</li>
|
||||
* <li>relativeOffset - int - the number of seconds between the
|
||||
* start of the playlist and the start of the audio clip
|
||||
|
@ -93,9 +95,10 @@ using namespace LiveSupport::Core;
|
|||
* <li>404 - playlist does not exist </li>
|
||||
* <li>405 - playlist has not been opened for editing </li>
|
||||
* <li>406 - no audio clip at the specified relative offset </li>
|
||||
* <li>422 - missing session ID argument </li>
|
||||
* </ul>
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class RemoveAudioClipFromPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,6 +46,7 @@
|
|||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "XmlRpcTools.h"
|
||||
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
|
@ -54,11 +55,11 @@
|
|||
|
||||
#include "RemoveAudioClipFromPlaylistMethodTest.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -77,9 +78,17 @@ const std::string RemoveAudioClipFromPlaylistMethodTest::storageClientConfig =
|
|||
/**
|
||||
* The name of the configuration file for the connection manager factory.
|
||||
*/
|
||||
const std::string RemoveAudioClipFromPlaylistMethodTest::connectionManagerConfig =
|
||||
const std::string
|
||||
RemoveAudioClipFromPlaylistMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string
|
||||
RemoveAudioClipFromPlaylistMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -110,6 +119,7 @@ RemoveAudioClipFromPlaylistMethodTest :: configure(
|
|||
void
|
||||
RemoveAudioClipFromPlaylistMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
|
@ -119,6 +129,9 @@ RemoveAudioClipFromPlaylistMethodTest :: setUp(void) thr
|
|||
= ConnectionManagerFactory::getInstance();
|
||||
configure(cmf, connectionManagerConfig);
|
||||
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -126,6 +139,11 @@ RemoveAudioClipFromPlaylistMethodTest :: setUp(void) thr
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = acf->getAuthenticationClient();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -135,6 +153,9 @@ RemoveAudioClipFromPlaylistMethodTest :: setUp(void) thr
|
|||
void
|
||||
RemoveAudioClipFromPlaylistMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -156,6 +177,7 @@ RemoveAudioClipFromPlaylistMethodTest :: firstTest(void)
|
|||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
parameters["audioClipId"] = 10001;
|
||||
parameters["relativeOffset"] = 90*60;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -61,7 +63,7 @@ using namespace LiveSupport::Core;
|
|||
* Unit test for the RemoveAudioClipFromPlaylistMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see RemoveAudioClipFromPlaylistMethod
|
||||
*/
|
||||
class RemoveAudioClipFromPlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -81,6 +83,22 @@ class RemoveAudioClipFromPlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
static const std::string connectionManagerConfig;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -100,6 +100,17 @@ RemoveFromScheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref entryId;
|
||||
try {
|
||||
entryId = XmlRpcTools::extractScheduleEntryId(parameters);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.4 $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -72,6 +72,8 @@ using namespace LiveSupport::Core;
|
|||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <li>scheduleEntryId - int - the id of the scheduled entry to remove</li>
|
||||
* </ul>
|
||||
*
|
||||
|
@ -84,12 +86,13 @@ using namespace LiveSupport::Core;
|
|||
* The possible error codes are:
|
||||
* <ul>
|
||||
* <li>1201 - invalid argument format </li>
|
||||
* <li>1202 - missing argument </li>
|
||||
* <li>1203 - not found </li>
|
||||
* <li>1202 - missing schedule entry ID argument </li>
|
||||
* <li>1203 - schedule entry not found </li>
|
||||
* <li>1222 - missing session ID argument </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.4 $
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
class RemoveFromScheduleMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -45,12 +45,16 @@
|
|||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "ScheduleFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "UploadPlaylistMethod.h"
|
||||
#include "RemoveFromScheduleMethod.h"
|
||||
#include "RemoveFromScheduleMethodTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -65,6 +69,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION(RemoveFromScheduleMethodTest);
|
|||
const std::string RemoveFromScheduleMethodTest::scheduleConfig =
|
||||
"etc/scheduleFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string RemoveFromScheduleMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -95,12 +105,17 @@ RemoveFromScheduleMethodTest :: configure(
|
|||
void
|
||||
RemoveFromScheduleMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
try {
|
||||
Ptr<ScheduleFactory>::Ref sf = ScheduleFactory::getInstance();
|
||||
configure(sf, scheduleConfig);
|
||||
|
||||
schedule = sf->getSchedule();
|
||||
schedule->install();
|
||||
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -108,6 +123,11 @@ RemoveFromScheduleMethodTest :: setUp(void) throw ()
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = acf->getAuthenticationClient();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -118,6 +138,10 @@ void
|
|||
RemoveFromScheduleMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
schedule->uninstall();
|
||||
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -140,6 +164,7 @@ RemoveFromScheduleMethodTest :: firstTest(void)
|
|||
Ptr<UniqueId>::Ref entryId;
|
||||
|
||||
// first schedule (upload) a playlist
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
time.tm_year = 2001;
|
||||
time.tm_mon = 11;
|
||||
|
@ -156,6 +181,7 @@ RemoveFromScheduleMethodTest :: firstTest(void)
|
|||
entryId.reset(new UniqueId(int(result["scheduleEntryId"])));
|
||||
|
||||
parameters.clear();
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["scheduleEntryId"] = int(entryId->getId());
|
||||
rootParameter[0] = parameters;
|
||||
|
||||
|
@ -180,6 +206,7 @@ RemoveFromScheduleMethodTest :: negativeTest(void)
|
|||
XmlRpc::XmlRpcValue result;
|
||||
Ptr<UniqueId>::Ref entryId(new UniqueId(9999));
|
||||
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["scheduleEntryId"] = int(entryId->getId());
|
||||
rootParameter[0] = parameters;
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -60,8 +62,8 @@ using namespace LiveSupport::Core;
|
|||
/**
|
||||
* Unit test for the RemoveFromScheduleMethod class.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see RemoveFromScheduleMethod
|
||||
*/
|
||||
class RemoveFromScheduleMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -81,6 +83,22 @@ class RemoveFromScheduleMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
Ptr<ScheduleInterface>::Ref schedule;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RescheduleMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -103,6 +103,17 @@ RescheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref entryId;
|
||||
try {
|
||||
entryId = XmlRpcTools::extractScheduleEntryId(parameters);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.4 $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RescheduleMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -72,6 +72,8 @@ using namespace LiveSupport::Core;
|
|||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <li>scheduleEntryId - int - the id of the schedule entry to reschedule
|
||||
* </li>
|
||||
* <li>playtime - datetime - the new playing time for the entry</li>
|
||||
|
@ -90,10 +92,11 @@ using namespace LiveSupport::Core;
|
|||
* <li>1303 - missing playtime argument </li>
|
||||
* <li>1304 - schedule entry not found </li>
|
||||
* <li>1305 - could not reschedule entry </li>
|
||||
* <li>1322 - missing session ID argument </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.4 $
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
class RescheduleMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RescheduleMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,14 +46,17 @@
|
|||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "ScheduleFactory.h"
|
||||
#include "UploadPlaylistMethod.h"
|
||||
#include "RescheduleMethod.h"
|
||||
#include "RescheduleMethodTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -68,6 +71,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION(RescheduleMethodTest);
|
|||
const std::string RescheduleMethodTest::scheduleConfig =
|
||||
"etc/scheduleFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string RescheduleMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -98,12 +107,17 @@ RescheduleMethodTest :: configure(
|
|||
void
|
||||
RescheduleMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
try {
|
||||
Ptr<ScheduleFactory>::Ref sf = ScheduleFactory::getInstance();
|
||||
configure(sf, scheduleConfig);
|
||||
|
||||
schedule = sf->getSchedule();
|
||||
schedule->install();
|
||||
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -111,6 +125,11 @@ RescheduleMethodTest :: setUp(void) throw ()
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = acf->getAuthenticationClient();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,6 +140,10 @@ void
|
|||
RescheduleMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
schedule->uninstall();
|
||||
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -141,6 +164,7 @@ RescheduleMethodTest :: firstTest(void)
|
|||
Ptr<UniqueId>::Ref entryId;
|
||||
|
||||
// let's upload something so we can reschedule it
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
time.tm_year = 2001;
|
||||
time.tm_mon = 11;
|
||||
|
@ -159,6 +183,7 @@ RescheduleMethodTest :: firstTest(void)
|
|||
|
||||
// now let's reschedule it
|
||||
parameters.clear();
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["scheduleEntryId"] = (int) entryId->getId();
|
||||
time.tm_year = 2001;
|
||||
time.tm_mon = 11;
|
||||
|
@ -175,6 +200,7 @@ RescheduleMethodTest :: firstTest(void)
|
|||
|
||||
// now let's reschedule unto itself, should fail
|
||||
parameters.clear();
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["scheduleEntryId"] = (int) entryId->getId();
|
||||
time.tm_year = 2001;
|
||||
time.tm_mon = 11;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RescheduleMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -60,8 +62,8 @@ using namespace LiveSupport::Core;
|
|||
/**
|
||||
* Unit test for the RescheduleMethod class.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see RescheduleMethod
|
||||
*/
|
||||
class RescheduleMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -80,6 +82,22 @@ class RescheduleMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
Ptr<ScheduleInterface>::Ref schedule;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -102,6 +102,17 @@ RevertEditedPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref id;
|
||||
try{
|
||||
id = XmlRpcTools::extractPlaylistId(parameters);
|
||||
|
@ -120,7 +131,7 @@ RevertEditedPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->getPlaylist(id);
|
||||
playlist = storage->getPlaylist(sessionId, id);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+3, "playlist not found",
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -71,8 +71,10 @@ using namespace LiveSupport::Core;
|
|||
* "revertEditedPlaylist".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* member:
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <li>playlistId - int - the unique id of the playlist requested.</li>
|
||||
* </ul>
|
||||
*
|
||||
|
@ -88,9 +90,10 @@ using namespace LiveSupport::Core;
|
|||
* <li>802 - argument is not a playlist ID </li>
|
||||
* <li>803 - playlist not found </li>
|
||||
* <li>804 - could not revert playlist </li>
|
||||
* <li>822 - missing session ID argument </li>
|
||||
* </ul>
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class RevertEditedPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,11 +46,12 @@
|
|||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
#include "RemoveAudioClipFromPlaylistMethod.h"
|
||||
#include "SavePlaylistMethod.h"
|
||||
|
||||
|
||||
#include "RevertEditedPlaylistMethod.h"
|
||||
#include "RevertEditedPlaylistMethodTest.h"
|
||||
|
||||
|
@ -58,6 +59,8 @@ using namespace std;
|
|||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -78,6 +81,12 @@ const std::string RevertEditedPlaylistMethodTest::storageClientConfig =
|
|||
const std::string RevertEditedPlaylistMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string RevertEditedPlaylistMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -108,6 +117,7 @@ RevertEditedPlaylistMethodTest :: configure(
|
|||
void
|
||||
RevertEditedPlaylistMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
|
@ -117,6 +127,9 @@ RevertEditedPlaylistMethodTest :: setUp(void) throw ()
|
|||
= ConnectionManagerFactory::getInstance();
|
||||
configure(cmf, connectionManagerConfig);
|
||||
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -124,6 +137,11 @@ RevertEditedPlaylistMethodTest :: setUp(void) throw ()
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = acf->getAuthenticationClient();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -133,6 +151,9 @@ RevertEditedPlaylistMethodTest :: setUp(void) throw ()
|
|||
void
|
||||
RevertEditedPlaylistMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -156,6 +177,7 @@ RevertEditedPlaylistMethodTest :: firstTest(void)
|
|||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
parameters["relativeOffset"] = 0;
|
||||
rootParameter[0] = parameters;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -61,7 +63,7 @@ using namespace LiveSupport::Core;
|
|||
* Unit test for the RevertEditedPlaylistMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see RevertEditedPlaylistMethod
|
||||
*/
|
||||
class RevertEditedPlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -81,6 +83,22 @@ class RevertEditedPlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
static const std::string connectionManagerConfig;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SavePlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -102,6 +102,17 @@ SavePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref id;
|
||||
try{
|
||||
id = XmlRpcTools::extractPlaylistId(parameters);
|
||||
|
@ -120,7 +131,7 @@ SavePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->getPlaylist(id);
|
||||
playlist = storage->getPlaylist(sessionId, id);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+3, "playlist not found",
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SavePlaylistMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -72,8 +72,10 @@ using namespace LiveSupport::Core;
|
|||
* "savePlaylist".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* member:
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <li>playlistId - int - the unique id of the playlist to save.</li>
|
||||
* </ul>
|
||||
*
|
||||
|
@ -89,9 +91,10 @@ using namespace LiveSupport::Core;
|
|||
* <li>702 - argument is not a playlist ID </li>
|
||||
* <li>703 - playlist not found </li>
|
||||
* <li>704 - could not save playlist </li>
|
||||
* <li>722 - missing session ID argument </li>
|
||||
* </ul>
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class SavePlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SavePlaylistMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,16 +46,18 @@
|
|||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
|
||||
#include "SavePlaylistMethod.h"
|
||||
#include "SavePlaylistMethodTest.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -76,6 +78,12 @@ const std::string SavePlaylistMethodTest::storageClientConfig =
|
|||
const std::string SavePlaylistMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string SavePlaylistMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -106,6 +114,7 @@ SavePlaylistMethodTest :: configure(
|
|||
void
|
||||
SavePlaylistMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
|
@ -115,6 +124,9 @@ SavePlaylistMethodTest :: setUp(void) throw ()
|
|||
= ConnectionManagerFactory::getInstance();
|
||||
configure(cmf, connectionManagerConfig);
|
||||
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -122,6 +134,11 @@ SavePlaylistMethodTest :: setUp(void) throw ()
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = acf->getAuthenticationClient();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,6 +148,9 @@ SavePlaylistMethodTest :: setUp(void) throw ()
|
|||
void
|
||||
SavePlaylistMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -149,6 +169,7 @@ SavePlaylistMethodTest :: firstTest(void)
|
|||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["playlistId"] = 9999;
|
||||
rootParameter[0] = parameter;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SavePlaylistMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -61,7 +63,7 @@ using namespace LiveSupport::Core;
|
|||
* Unit test for the SavePlaylistMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see SavePlaylistMethod
|
||||
*/
|
||||
class SavePlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -81,6 +83,22 @@ class SavePlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
static const std::string connectionManagerConfig;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonDisplayPlaylistTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -45,12 +45,15 @@
|
|||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "SchedulerDaemon.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "SchedulerDaemonDisplayPlaylistTest.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace XmlRpc;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -64,12 +67,36 @@ CPPUNIT_TEST_SUITE_REGISTRATION(SchedulerDaemonDisplayPlaylistTest);
|
|||
*/
|
||||
static const std::string configFileName = "etc/scheduler.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfigFileName =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Configure a Configurable with an XML file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonDisplayPlaylistTest :: 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
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -80,22 +107,36 @@ SchedulerDaemonDisplayPlaylistTest :: setUp(void) throw (
|
|||
|
||||
if (!daemon->isConfigured()) {
|
||||
try {
|
||||
std::auto_ptr<xmlpp::DomParser>
|
||||
parser(new xmlpp::DomParser(configFileName, true));
|
||||
const xmlpp::Document * document = parser->get_document();
|
||||
daemon->configure(*(document->get_root_node()));
|
||||
configure(daemon, configFileName);
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
CPPUNIT_FAIL("semantic error in scheduler configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
CPPUNIT_FAIL("error parsing scheduler configuration file");
|
||||
}
|
||||
}
|
||||
|
||||
daemon->install();
|
||||
// daemon->start();
|
||||
// sleep(5);
|
||||
|
||||
try {
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfigFileName);
|
||||
authentication = acf->getAuthenticationClient();
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("semantic error in authentication configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("error parsing authentication configuration file");
|
||||
}
|
||||
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -109,6 +150,10 @@ SchedulerDaemonDisplayPlaylistTest :: tearDown(void) throw (
|
|||
|
||||
// daemon->stop();
|
||||
daemon->uninstall();
|
||||
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -124,6 +169,7 @@ SchedulerDaemonDisplayPlaylistTest :: simpleTest(void)
|
|||
|
||||
XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
|
||||
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
|
||||
result.clear();
|
||||
|
@ -146,6 +192,7 @@ SchedulerDaemonDisplayPlaylistTest :: negativeTest(void)
|
|||
|
||||
XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
|
||||
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 9999;
|
||||
|
||||
result.clear();
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonDisplayPlaylistTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,11 +42,15 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -59,8 +63,8 @@ using namespace LiveSupport;
|
|||
/**
|
||||
* Unit test to test the displayPlaylist XML-RPC call.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see SchedulerDaemon
|
||||
*/
|
||||
class SchedulerDaemonDisplayPlaylistTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -70,6 +74,31 @@ class SchedulerDaemonDisplayPlaylistTest : public CPPUNIT_NS::TestFixture
|
|||
CPPUNIT_TEST(negativeTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
/**
|
||||
* An authentication client.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* 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,
|
||||
const std::string & fileName)
|
||||
throw (std::invalid_argument,
|
||||
xmlpp::exception);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonDisplayScheduleTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -45,11 +45,15 @@
|
|||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "SchedulerDaemon.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "SchedulerDaemonDisplayScheduleTest.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace XmlRpc;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -63,12 +67,36 @@ CPPUNIT_TEST_SUITE_REGISTRATION(SchedulerDaemonDisplayScheduleTest);
|
|||
*/
|
||||
static const std::string configFileName = "etc/scheduler.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfigFileName =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Configure a Configurable with an XML file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonDisplayScheduleTest :: 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
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -79,10 +107,7 @@ SchedulerDaemonDisplayScheduleTest :: setUp(void) throw (
|
|||
|
||||
if (!daemon->isConfigured()) {
|
||||
try {
|
||||
std::auto_ptr<xmlpp::DomParser>
|
||||
parser(new xmlpp::DomParser(configFileName, true));
|
||||
const xmlpp::Document * document = parser->get_document();
|
||||
daemon->configure(*(document->get_root_node()));
|
||||
configure(daemon, configFileName);
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
|
@ -95,6 +120,23 @@ SchedulerDaemonDisplayScheduleTest :: setUp(void) throw (
|
|||
daemon->install();
|
||||
// daemon->start();
|
||||
// sleep(5);
|
||||
|
||||
try {
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfigFileName);
|
||||
authentication = acf->getAuthenticationClient();
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("semantic error in authentication configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("error parsing authentication configuration file");
|
||||
}
|
||||
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -108,6 +150,10 @@ SchedulerDaemonDisplayScheduleTest :: tearDown(void) throw (
|
|||
|
||||
// daemon->stop();
|
||||
daemon->uninstall();
|
||||
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -126,6 +172,7 @@ SchedulerDaemonDisplayScheduleTest :: simpleTest(void)
|
|||
|
||||
// list the schedules for an interval (as the database is empty,
|
||||
// it's going to return an empty result set)
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
time.tm_year = 2044;
|
||||
time.tm_mon = 11;
|
||||
time.tm_mday = 12;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonDisplayScheduleTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,11 +42,15 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -59,8 +63,8 @@ using namespace LiveSupport;
|
|||
/**
|
||||
* Unit test to test the displaySchedule XML-RPC call.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see SchedulerDaemon
|
||||
*/
|
||||
class SchedulerDaemonDisplayScheduleTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -69,6 +73,31 @@ class SchedulerDaemonDisplayScheduleTest : public CPPUNIT_NS::TestFixture
|
|||
CPPUNIT_TEST(simpleTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
/**
|
||||
* An authentication client.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* 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,
|
||||
const std::string & fileName)
|
||||
throw (std::invalid_argument,
|
||||
xmlpp::exception);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonRemoveFromScheduleTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -45,12 +45,15 @@
|
|||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "SchedulerDaemon.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "SchedulerDaemonRemoveFromScheduleTest.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace XmlRpc;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -64,12 +67,36 @@ CPPUNIT_TEST_SUITE_REGISTRATION(SchedulerDaemonRemoveFromScheduleTest);
|
|||
*/
|
||||
static const std::string configFileName = "etc/scheduler.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfigFileName =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Configure a Configurable with an XML file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonRemoveFromScheduleTest :: 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
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -80,10 +107,7 @@ SchedulerDaemonRemoveFromScheduleTest :: setUp(void) thro
|
|||
|
||||
if (!daemon->isConfigured()) {
|
||||
try {
|
||||
std::auto_ptr<xmlpp::DomParser>
|
||||
parser(new xmlpp::DomParser(configFileName, true));
|
||||
const xmlpp::Document * document = parser->get_document();
|
||||
daemon->configure(*(document->get_root_node()));
|
||||
configure(daemon, configFileName);
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
|
@ -96,6 +120,23 @@ SchedulerDaemonRemoveFromScheduleTest :: setUp(void) thro
|
|||
daemon->install();
|
||||
// daemon->start();
|
||||
// sleep(5);
|
||||
|
||||
try {
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfigFileName);
|
||||
authentication = acf->getAuthenticationClient();
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("semantic error in authentication configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("error parsing authentication configuration file");
|
||||
}
|
||||
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -109,6 +150,10 @@ SchedulerDaemonRemoveFromScheduleTest :: tearDown(void) thro
|
|||
|
||||
// daemon->stop();
|
||||
daemon->uninstall();
|
||||
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -126,6 +171,7 @@ SchedulerDaemonRemoveFromScheduleTest :: simpleTest(void)
|
|||
XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
|
||||
|
||||
// first schedule a playlist, so that there is something to remove
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
time.tm_year = 2001;
|
||||
time.tm_mon = 11;
|
||||
|
@ -161,6 +207,7 @@ SchedulerDaemonRemoveFromScheduleTest :: negativeTest(void)
|
|||
|
||||
XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
|
||||
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["scheduleEntryId"] = 9999;
|
||||
|
||||
result.clear();
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonRemoveFromScheduleTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,11 +42,15 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -59,8 +63,8 @@ using namespace LiveSupport;
|
|||
/**
|
||||
* Unit test to test the removeFromSchedule XML-RPC call.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see SchedulerDaemon
|
||||
*/
|
||||
class SchedulerDaemonRemoveFromScheduleTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -70,6 +74,31 @@ class SchedulerDaemonRemoveFromScheduleTest : public CPPUNIT_NS::TestFixture
|
|||
CPPUNIT_TEST(negativeTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
/**
|
||||
* An authentication client.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* 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,
|
||||
const std::string & fileName)
|
||||
throw (std::invalid_argument,
|
||||
xmlpp::exception);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonRescheduleTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -45,11 +45,14 @@
|
|||
#include <XmlRpcValue.h>
|
||||
|
||||
#include "SchedulerDaemon.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "SchedulerDaemonRescheduleTest.h"
|
||||
|
||||
|
||||
using namespace XmlRpc;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -63,12 +66,36 @@ CPPUNIT_TEST_SUITE_REGISTRATION(SchedulerDaemonRescheduleTest);
|
|||
*/
|
||||
static const std::string configFileName = "etc/scheduler.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfigFileName =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Configure a Configurable with an XML file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonRescheduleTest :: 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
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -79,10 +106,7 @@ SchedulerDaemonRescheduleTest :: setUp(void) throw ()
|
|||
|
||||
if (!daemon->isConfigured()) {
|
||||
try {
|
||||
std::auto_ptr<xmlpp::DomParser>
|
||||
parser(new xmlpp::DomParser(configFileName, true));
|
||||
const xmlpp::Document * document = parser->get_document();
|
||||
daemon->configure(*(document->get_root_node()));
|
||||
configure(daemon, configFileName);
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
|
@ -95,6 +119,23 @@ SchedulerDaemonRescheduleTest :: setUp(void) throw ()
|
|||
daemon->install();
|
||||
// daemon->start();
|
||||
// sleep(5);
|
||||
|
||||
try {
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfigFileName);
|
||||
authentication = acf->getAuthenticationClient();
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("semantic error in authentication configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("error parsing authentication configuration file");
|
||||
}
|
||||
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -108,6 +149,10 @@ SchedulerDaemonRescheduleTest :: tearDown(void) throw ()
|
|||
|
||||
// daemon->stop();
|
||||
daemon->uninstall();
|
||||
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -125,6 +170,7 @@ SchedulerDaemonRescheduleTest :: simpleTest(void)
|
|||
XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
|
||||
|
||||
// first schedule a playlist, so that there is something to reschedule
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
time.tm_year = 2001;
|
||||
time.tm_mon = 11;
|
||||
|
@ -140,6 +186,7 @@ SchedulerDaemonRescheduleTest :: simpleTest(void)
|
|||
Ptr<UniqueId>::Ref entryId(new UniqueId(int(result["scheduleEntryId"])));
|
||||
|
||||
// now reschedule it
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["scheduleEntryId"] = (int) entryId->getId();
|
||||
time.tm_year = 2001;
|
||||
time.tm_mon = 11;
|
||||
|
@ -154,6 +201,7 @@ SchedulerDaemonRescheduleTest :: simpleTest(void)
|
|||
CPPUNIT_ASSERT(!result.hasMember("errorCode"));
|
||||
|
||||
// now reschedule it unto itself, should fail
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["scheduleEntryId"] = (int) entryId->getId();
|
||||
time.tm_year = 2001;
|
||||
time.tm_mon = 11;
|
||||
|
@ -181,6 +229,7 @@ SchedulerDaemonRescheduleTest :: negativeTest(void)
|
|||
|
||||
XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
|
||||
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["scheduleEntryId"] = 9999;
|
||||
|
||||
result.clear();
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonRescheduleTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,11 +42,15 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -59,8 +63,8 @@ using namespace LiveSupport;
|
|||
/**
|
||||
* Unit test to test the removeFromSchedule XML-RPC call.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see SchedulerDaemon
|
||||
*/
|
||||
class SchedulerDaemonRescheduleTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -70,6 +74,31 @@ class SchedulerDaemonRescheduleTest : public CPPUNIT_NS::TestFixture
|
|||
CPPUNIT_TEST(negativeTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
/**
|
||||
* An authentication client.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* 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,
|
||||
const std::string & fileName)
|
||||
throw (std::invalid_argument,
|
||||
xmlpp::exception);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.4 $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonUploadTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -47,12 +47,15 @@
|
|||
#include "XmlRpcTools.h"
|
||||
#include "LiveSupport/Core/UniqueId.h"
|
||||
#include "SchedulerDaemon.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "SchedulerDaemonUploadTest.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace XmlRpc;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -66,12 +69,36 @@ CPPUNIT_TEST_SUITE_REGISTRATION(SchedulerDaemonUploadTest);
|
|||
*/
|
||||
static const std::string configFileName = "etc/scheduler.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfigFileName =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Configure a Configurable with an XML file.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonUploadTest :: 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
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -82,10 +109,7 @@ SchedulerDaemonUploadTest :: setUp(void) throw ()
|
|||
|
||||
if (!daemon->isConfigured()) {
|
||||
try {
|
||||
std::auto_ptr<xmlpp::DomParser>
|
||||
parser(new xmlpp::DomParser(configFileName, true));
|
||||
const xmlpp::Document * document = parser->get_document();
|
||||
daemon->configure(*(document->get_root_node()));
|
||||
configure(daemon, configFileName);
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
|
@ -98,6 +122,23 @@ SchedulerDaemonUploadTest :: setUp(void) throw ()
|
|||
daemon->install();
|
||||
// daemon->start();
|
||||
// sleep(5);
|
||||
|
||||
try {
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfigFileName);
|
||||
authentication = acf->getAuthenticationClient();
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("semantic error in authentication configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("error parsing authentication configuration file");
|
||||
}
|
||||
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,6 +152,10 @@ SchedulerDaemonUploadTest :: tearDown(void) throw ()
|
|||
|
||||
// daemon->stop();
|
||||
daemon->uninstall();
|
||||
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,6 +173,7 @@ SchedulerDaemonUploadTest :: simpleTest(void)
|
|||
XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
|
||||
|
||||
// try to schedule playlist #1 for the time below
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
time.tm_year = 2001;
|
||||
time.tm_mon = 11;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonUploadTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,11 +42,15 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -59,8 +63,8 @@ using namespace LiveSupport;
|
|||
/**
|
||||
* Unit test to test the uploadPlaylist XML-RPC call.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see SchedulerDaemon
|
||||
*/
|
||||
class SchedulerDaemonUploadTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -69,6 +73,31 @@ class SchedulerDaemonUploadTest : public CPPUNIT_NS::TestFixture
|
|||
CPPUNIT_TEST(simpleTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
/**
|
||||
* An authentication client.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* 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,
|
||||
const std::string & fileName)
|
||||
throw (std::invalid_argument,
|
||||
xmlpp::exception);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -110,6 +110,17 @@ UpdateFadeInFadeOutMethod :: execute(
|
|||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref playlistId;
|
||||
try{
|
||||
playlistId = XmlRpcTools::extractPlaylistId(parameters);
|
||||
|
@ -161,7 +172,7 @@ UpdateFadeInFadeOutMethod :: execute(
|
|||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->getPlaylist(playlistId);
|
||||
playlist = storage->getPlaylist(sessionId, playlistId);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+6, "playlist does not exist",
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -73,6 +73,8 @@ using namespace LiveSupport::Core;
|
|||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <li>playlistId - int - the unique id of the playlist.</li>
|
||||
* <li>relativeOffset - int - the number of seconds between the
|
||||
* start of the playlist and the start of the audio clip
|
||||
|
@ -97,9 +99,10 @@ using namespace LiveSupport::Core;
|
|||
* <li>1606 - playlist does not exist </li>
|
||||
* <li>1607 - playlist has not been opened for editing </li>
|
||||
* <li>1608 - no audio clip at the specified relative offset </li>
|
||||
* <li>1622 - missing session ID argument </li>
|
||||
* </ul>
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class UpdateFadeInFadeOutMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,6 +46,7 @@
|
|||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "XmlRpcTools.h"
|
||||
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
|
@ -54,11 +55,11 @@
|
|||
|
||||
#include "UpdateFadeInFadeOutMethodTest.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -80,6 +81,12 @@ const std::string UpdateFadeInFadeOutMethodTest::storageClientConfig =
|
|||
const std::string UpdateFadeInFadeOutMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string UpdateFadeInFadeOutMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -110,6 +117,7 @@ UpdateFadeInFadeOutMethodTest :: configure(
|
|||
void
|
||||
UpdateFadeInFadeOutMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
|
@ -119,6 +127,9 @@ UpdateFadeInFadeOutMethodTest :: setUp(void) throw ()
|
|||
= ConnectionManagerFactory::getInstance();
|
||||
configure(cmf, connectionManagerConfig);
|
||||
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -126,6 +137,11 @@ UpdateFadeInFadeOutMethodTest :: setUp(void) throw ()
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = acf->getAuthenticationClient();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -135,6 +151,9 @@ UpdateFadeInFadeOutMethodTest :: setUp(void) throw ()
|
|||
void
|
||||
UpdateFadeInFadeOutMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -154,6 +173,7 @@ UpdateFadeInFadeOutMethodTest :: firstTest(void)
|
|||
rootParameter.setSize(1);
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
parameters["relativeOffset"] = 90*60;
|
||||
parameters["fadeIn"] = 0;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -61,7 +63,7 @@ using namespace LiveSupport::Core;
|
|||
* Unit test for the UpdateFadeInFadeOutMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see UpdateFadeInFadeOutMethod
|
||||
*/
|
||||
class UpdateFadeInFadeOutMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -81,6 +83,22 @@ class UpdateFadeInFadeOutMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
static const std::string connectionManagerConfig;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.6 $
|
||||
Version : $Revision: 1.7 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -106,6 +106,17 @@ UploadPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref playlistId;
|
||||
try {
|
||||
playlistId = XmlRpcTools::extractPlaylistId(parameters);
|
||||
|
@ -133,7 +144,7 @@ UploadPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->getPlaylist(playlistId);
|
||||
playlist = storage->getPlaylist(sessionId, playlistId);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+4, "playlist not found",
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.7 $
|
||||
Version : $Revision: 1.8 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -73,6 +73,8 @@ using namespace LiveSupport::Core;
|
|||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <li>playlistId - int, the id of the playlist to upload</li>
|
||||
* <li>playtime - the time when the playlist should be scheduled,
|
||||
* an ISO 8601 DateTime field</li>
|
||||
|
@ -99,10 +101,11 @@ using namespace LiveSupport::Core;
|
|||
* <li>1404 - playlist not found </li>
|
||||
* <li>1405 - timeframe not available </li>
|
||||
* <li>1406 - could not schedule playlist </li>
|
||||
* <li>1422 - missing session ID argument </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.7 $
|
||||
* @version $Revision: 1.8 $
|
||||
*/
|
||||
class UploadPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.5 $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,14 +46,17 @@
|
|||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "ScheduleFactory.h"
|
||||
|
||||
#include "UploadPlaylistMethod.h"
|
||||
#include "UploadPlaylistMethodTest.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
@ -80,6 +83,12 @@ const std::string UploadPlaylistMethodTest::connectionManagerConfig =
|
|||
const std::string UploadPlaylistMethodTest::scheduleConfig =
|
||||
"etc/scheduleFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string UploadPlaylistMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -110,6 +119,7 @@ UploadPlaylistMethodTest :: configure(
|
|||
void
|
||||
UploadPlaylistMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
|
@ -124,6 +134,10 @@ UploadPlaylistMethodTest :: setUp(void) throw ()
|
|||
|
||||
schedule = sf->getSchedule();
|
||||
schedule->install();
|
||||
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -131,6 +145,11 @@ UploadPlaylistMethodTest :: setUp(void) throw ()
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = acf->getAuthenticationClient();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -141,6 +160,10 @@ void
|
|||
UploadPlaylistMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
schedule->uninstall();
|
||||
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -159,6 +182,7 @@ UploadPlaylistMethodTest :: firstTest(void)
|
|||
struct tm time;
|
||||
|
||||
// set up a structure for the parameters
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
time.tm_year = 2001;
|
||||
time.tm_mon = 11;
|
||||
|
@ -190,6 +214,7 @@ UploadPlaylistMethodTest :: overlappingPlaylists(void)
|
|||
struct tm time;
|
||||
|
||||
// load the first playlist, this will succeed
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
time.tm_year = 2001;
|
||||
time.tm_mon = 11;
|
||||
|
@ -206,6 +231,7 @@ UploadPlaylistMethodTest :: overlappingPlaylists(void)
|
|||
|
||||
// try to load the same one, but in an overlapping time region
|
||||
// (we know that playlist with id 1 is 1 hour long)
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
time.tm_year = 2001;
|
||||
time.tm_mon = 11;
|
||||
|
@ -222,6 +248,7 @@ UploadPlaylistMethodTest :: overlappingPlaylists(void)
|
|||
CPPUNIT_ASSERT(int(result["errorCode"]) == 1405); // timeframe not available
|
||||
|
||||
// try to load the same one, but now in good timing
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
time.tm_year = 2001;
|
||||
time.tm_mon = 11;
|
||||
|
@ -237,6 +264,7 @@ UploadPlaylistMethodTest :: overlappingPlaylists(void)
|
|||
CPPUNIT_ASSERT(result.hasMember("scheduleEntryId"));
|
||||
|
||||
// try to load the same one, this time overlapping both previos instances
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
time.tm_year = 2001;
|
||||
time.tm_mon = 11;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.2 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -60,8 +62,8 @@ using namespace LiveSupport::Core;
|
|||
/**
|
||||
* Unit test for the UploadPlaylistMethod class.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.2 $
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.3 $
|
||||
* @see UploadPlaylistMethod
|
||||
*/
|
||||
class UploadPlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -92,6 +94,22 @@ class UploadPlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
Ptr<ScheduleInterface>::Ref schedule;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -107,6 +107,17 @@ ValidatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
}
|
||||
XmlRpc::XmlRpcValue parameters = rootParameter[0];
|
||||
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
try{
|
||||
sessionId = XmlRpcTools::extractSessionId(parameters);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+22,
|
||||
"missing session ID argument",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref playlistId;
|
||||
try{
|
||||
playlistId = XmlRpcTools::extractPlaylistId(parameters);
|
||||
|
@ -125,7 +136,7 @@ ValidatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
try {
|
||||
playlist = storage->getPlaylist(playlistId);
|
||||
playlist = storage->getPlaylist(sessionId, playlistId);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
XmlRpcTools::markError(errorId+3, "playlist does not exist",
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -70,8 +70,10 @@ using namespace LiveSupport::Core;
|
|||
* "validatePlaylist".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* member:
|
||||
* members:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* <li>playlistId - int - the unique id of the playlist.</li>
|
||||
* </ul>
|
||||
*
|
||||
|
@ -93,9 +95,10 @@ using namespace LiveSupport::Core;
|
|||
* <li>502 - missing playlist ID argument </li>
|
||||
* <li>503 - playlist does not exist </li>
|
||||
* <li>504 - playlist has not been opened for editing </li>
|
||||
* <li>522 - missing session ID argument </li>
|
||||
* </ul>
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class ValidatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,6 +46,7 @@
|
|||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "XmlRpcTools.h"
|
||||
|
||||
#include "OpenPlaylistForEditingMethod.h"
|
||||
|
@ -54,11 +55,11 @@
|
|||
|
||||
#include "ValidatePlaylistMethodTest.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace LiveSupport::Db;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
using namespace LiveSupport::Authentication;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
@ -80,6 +81,12 @@ const std::string ValidatePlaylistMethodTest::storageClientConfig =
|
|||
const std::string ValidatePlaylistMethodTest::connectionManagerConfig =
|
||||
"etc/connectionManagerFactory.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
const std::string ValidatePlaylistMethodTest::authenticationClientConfig =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -110,6 +117,7 @@ ValidatePlaylistMethodTest :: configure(
|
|||
void
|
||||
ValidatePlaylistMethodTest :: setUp(void) throw ()
|
||||
{
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
|
@ -119,6 +127,9 @@ ValidatePlaylistMethodTest :: setUp(void) throw ()
|
|||
= ConnectionManagerFactory::getInstance();
|
||||
configure(cmf, connectionManagerConfig);
|
||||
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
configure(acf, authenticationClientConfig);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
@ -126,6 +137,11 @@ ValidatePlaylistMethodTest :: setUp(void) throw ()
|
|||
} catch (std::exception &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
authentication = acf->getAuthenticationClient();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -135,6 +151,9 @@ ValidatePlaylistMethodTest :: setUp(void) throw ()
|
|||
void
|
||||
ValidatePlaylistMethodTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -157,6 +176,7 @@ ValidatePlaylistMethodTest :: firstTest(void)
|
|||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
result.clear();
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["playlistId"] = 275;
|
||||
rootParameter[0] = parameter;
|
||||
validatePlaylistMethod->execute(rootParameter, result);
|
||||
|
@ -165,6 +185,7 @@ ValidatePlaylistMethodTest :: firstTest(void)
|
|||
|
||||
result.clear();
|
||||
parameter.clear();
|
||||
parameter["sessionId"] = sessionId->getId();
|
||||
parameter["playlistId"] = 1;
|
||||
rootParameter[0] = parameter;
|
||||
openPlaylistMethod->execute(rootParameter, result);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
@ -61,7 +63,7 @@ using namespace LiveSupport::Core;
|
|||
* Unit test for the ValidatePlaylistMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see ValidatePlaylistMethod
|
||||
*/
|
||||
class ValidatePlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -81,6 +83,22 @@ class ValidatePlaylistMethodTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
static const std::string connectionManagerConfig;
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client
|
||||
* factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfig;
|
||||
|
||||
/**
|
||||
* The authentication client produced by the factory.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.9 $
|
||||
Version : $Revision: 1.10 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/XmlRpcTools.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -107,6 +107,11 @@ const std::string XmlRpcTools::fadeInName = "fadeIn";
|
|||
*----------------------------------------------------------------------------*/
|
||||
const std::string XmlRpcTools::fadeOutName = "fadeOut";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the session ID member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string XmlRpcTools::sessionIdName = "sessionId";
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
|
@ -504,3 +509,21 @@ XmlRpcTools :: playLogVectorToXmlRpcValue(
|
|||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Extract the session ID from an XML-RPC function call parameter
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<SessionId>::Ref
|
||||
XmlRpcTools :: extractSessionId(
|
||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
if (!xmlRpcValue.hasMember(sessionIdName)) {
|
||||
throw std::invalid_argument("missing session ID argument");
|
||||
}
|
||||
|
||||
Ptr<SessionId>::Ref id(new SessionId(xmlRpcValue[sessionIdName]));
|
||||
return id;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.9 $
|
||||
Version : $Revision: 1.10 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/XmlRpcTools.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -47,6 +47,7 @@
|
|||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
#include "PlayLogEntry.h"
|
||||
#include "ScheduleEntry.h"
|
||||
|
@ -72,7 +73,7 @@ using namespace LiveSupport::Core;
|
|||
* in the Scheduler.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.9 $
|
||||
* @version $Revision: 1.10 $
|
||||
*/
|
||||
class XmlRpcTools
|
||||
{
|
||||
|
@ -131,6 +132,12 @@ class XmlRpcTools
|
|||
*/
|
||||
static const std::string fadeOutName;
|
||||
|
||||
/**
|
||||
* The name of the sessionId member in the XML-RPC parameter
|
||||
* structure given as the input to an XmlRpcServerMethod.
|
||||
*/
|
||||
static const std::string sessionIdName;
|
||||
|
||||
/**
|
||||
* Convert a boost::posix_time::ptime to an XmlRpcValue
|
||||
*
|
||||
|
@ -378,6 +385,19 @@ class XmlRpcTools
|
|||
XmlRpc::XmlRpcValue & returnValue)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Extract the session ID from the XML-RPC parameters.
|
||||
*
|
||||
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||
* @return a SessionId that was found in the XML-RPC parameter.
|
||||
* @exception std::invalid_argument if there was no sessionId
|
||||
* member in xmlRpcValue
|
||||
*/
|
||||
static Ptr<SessionId>::Ref
|
||||
extractSessionId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
|
||||
};
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
|
Loading…
Reference in New Issue