added login, logout and resetStorage XML-RPC methods to scheduler daemon;

fixed the existing 'Rpc...Test's, and added some more
This commit is contained in:
fgerlits 2005-01-31 19:51:25 +00:00
parent d78879f893
commit 2d4c16a1d3
41 changed files with 1600 additions and 1524 deletions

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.19 $
Version : $Revision: 1.20 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/AudioClip.h,v $
------------------------------------------------------------------------------*/
@ -87,7 +87,7 @@ using namespace boost::posix_time;
* xmlns:xbmf="http://www.streamonthefly.org/xbmf"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
* <dc:title >File Title txt</dc:title>
* <dcterms:extent >123</dcterms:extent>
* <dcterms:extent >00:02:30.000000</dcterms:extent>
* ...
* </metadata>
* </audioClip>
@ -124,7 +124,7 @@ using namespace boost::posix_time;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.19 $
* @version $Revision: 1.20 $
*/
class AudioClip : public Configurable,
public Playable

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Attic/TagConversion.h,v $
------------------------------------------------------------------------------*/
@ -65,7 +65,7 @@ using namespace LiveSupport::Core;
*
* For a description of these metadata tag standards, see
* http://www.id3.org/id3v2.4.0-frames.txt
* and http://dublincore.org/documents/dces/.
* and http://dublincore.org/documents/dcmi-terms/.
*
* This object has to be configured with an XML configuration element
* called tagConversionTable. This may look like the following:
@ -79,12 +79,17 @@ using namespace LiveSupport::Core;
* &lt;tag&gt;
* &lt;id3&gt;Artist&lt;/id3&gt;
* &lt;id3&gt;TPE1&lt;/id3&gt;
* &lt;dc&gt;dcterms:extent&lt;/dc&gt;
* &lt;dc&gt;dc:creator&lt;/dc&gt;
* &lt;/tag&gt;
* ...
* &lt;/tagConversionTable&gt;
* </code></pre>
*
*
* The id3 tag names in the table should be one of the id3v1 tag names
* Artist, Title, Album, Comment, Genre, Year, Track, or one of the
* four-letter id3v2 tag abbreviations, e.g., TLEN (length) or
* TOPE (original performer) etc.
*
* Note that more than one id3 tag name can map to the same dc tag name.
*
* The DTD for the above element is:
@ -92,12 +97,12 @@ using namespace LiveSupport::Core;
* <pre><code>
* &lt;!ELEMENT tagConversionTable (tag*) &gt;
* &lt;!ATTLIST tag (id3+, dc) &gt;
* &lt;!ATTLIST id3 (#CDATA) &gt;
* &lt;!ATTLIST dc (#CDATA) &gt;
* &lt;!ATTLIST id3 (#PCDATA) &gt;
* &lt;!ATTLIST dc (#PCDATA) &gt;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @version $Revision: 1.3 $
*/
class TagConversion
{

View 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/modules/core/include/LiveSupport/Core/XmlRpcTools.h,v $
------------------------------------------------------------------------------*/
@ -73,8 +73,8 @@ using namespace LiveSupport::Core;
* and XmlRpcValues. Used by almost all XmlRpcServerMethod subclasses
* in the Scheduler.
*
* @author $Author: maroy $
* @version $Revision: 1.2 $
* @author $Author: fgerlits $
* @version $Revision: 1.3 $
*/
class XmlRpcTools
{
@ -455,6 +455,30 @@ class XmlRpcTools
extractSessionId(XmlRpc::XmlRpcValue & xmlRpcValue)
throw (std::invalid_argument);
/**
* Extract the login name from the XML-RPC parameters.
*
* @param xmlRpcValue the XML-RPC parameter to extract from.
* @return a std::string that was found in the XML-RPC parameter.
* @exception std::invalid_argument if there was no login
* member in xmlRpcValue
*/
static Ptr<std::string>::Ref
extractLoginName(XmlRpc::XmlRpcValue & xmlRpcValue)
throw (std::invalid_argument);
/**
* Extract the password from the XML-RPC parameters.
*
* @param xmlRpcValue the XML-RPC parameter to extract from.
* @return a std::string that was found in the XML-RPC parameter.
* @exception std::invalid_argument if there was no sessionId
* member in xmlRpcValue
*/
static Ptr<std::string>::Ref
extractPassword(XmlRpc::XmlRpcValue & xmlRpcValue)
throw (std::invalid_argument);
};
/* ================================================= external data structures */

View 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/modules/core/src/XmlRpcTools.cxx,v $
------------------------------------------------------------------------------*/
@ -119,6 +119,16 @@ static const std::string fadeOutName = "fadeOut";
*----------------------------------------------------------------------------*/
static const std::string sessionIdName = "sessionId";
/*------------------------------------------------------------------------------
* The name of the login name member in the XML-RPC parameter structure
*----------------------------------------------------------------------------*/
static const std::string loginName = "login";
/*------------------------------------------------------------------------------
* The name of the password member in the XML-RPC parameter structure
*----------------------------------------------------------------------------*/
static const std::string passwordName = "password";
/* ================================================ local constants & macros */
@ -663,9 +673,8 @@ XmlRpcTools :: playLogEntryToXmlRpcValue(
*----------------------------------------------------------------------------*/
void
XmlRpcTools :: playLogVectorToXmlRpcValue(
Ptr<const std::vector<Ptr<PlayLogEntry>::Ref> >::Ref
playLogVector,
XmlRpc::XmlRpcValue & returnValue)
Ptr<const std::vector<Ptr<PlayLogEntry>::Ref> >::Ref playLogVector,
XmlRpc::XmlRpcValue & returnValue)
throw ()
{
returnValue.setSize(playLogVector->size());
@ -704,3 +713,43 @@ XmlRpcTools :: extractSessionId(
return id;
}
/*------------------------------------------------------------------------------
* Extract the login name from an XML-RPC function call parameter
*----------------------------------------------------------------------------*/
Ptr<std::string>::Ref
XmlRpcTools :: extractLoginName(
XmlRpc::XmlRpcValue & xmlRpcValue)
throw (std::invalid_argument)
{
if (!xmlRpcValue.hasMember(loginName)
|| xmlRpcValue[loginName].getType()
!= XmlRpc::XmlRpcValue::TypeString) {
throw std::invalid_argument("missing or bad login name argument");
}
Ptr<std::string>::Ref loginName(new std::string(
xmlRpcValue[loginName] ));
return loginName;
}
/*------------------------------------------------------------------------------
* Extract the password from an XML-RPC function call parameter
*----------------------------------------------------------------------------*/
Ptr<std::string>::Ref
XmlRpcTools :: extractPassword(
XmlRpc::XmlRpcValue & xmlRpcValue)
throw (std::invalid_argument)
{
if (!xmlRpcValue.hasMember(passwordName)
|| xmlRpcValue[passwordName].getType()
!= XmlRpc::XmlRpcValue::TypeString) {
throw std::invalid_argument("missing or bad password argument");
}
Ptr<std::string>::Ref password(new std::string(
xmlRpcValue[passwordName] ));
return password;
}

View File

@ -21,7 +21,7 @@
#
#
# Author : $Author: fgerlits $
# Version : $Revision: 1.48 $
# Version : $Revision: 1.49 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
#
# @configure_input@
@ -186,7 +186,10 @@ SCHEDULER_OBJS = ${TMP_DIR}/SignalDispatcher.o \
${TMP_DIR}/GeneratePlayReportMethod.o \
${TMP_DIR}/UpdateFadeInFadeOutMethod.o \
${TMP_DIR}/PlaylistEventContainer.o \
${TMP_DIR}/PlaylistEvent.o
${TMP_DIR}/PlaylistEvent.o \
${TMP_DIR}/ResetStorageMethod.o \
${TMP_DIR}/LoginMethod.o \
${TMP_DIR}/LogoutMethod.o
SCHEDULER_EXE_OBJS = ${SCHEDULER_OBJS} \
@ -201,31 +204,37 @@ SCHEDULER_EXE_LIBS = -l${EVENT_SCHEDULER_LIB} -l${PLAYLIST_EXECUTOR_LIB} \
TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \
${TMP_DIR}/TestRunner.o \
${TMP_DIR}/SchedulerDaemonTest.o \
${TMP_DIR}/RpcUploadPlaylistTest.o \
${TMP_DIR}/RpcDisplayScheduleTest.o \
${TMP_DIR}/RpcDisplayPlaylistTest.o \
${TMP_DIR}/RpcRemoveFromScheduleTest.o \
${TMP_DIR}/RpcRescheduleTest.o \
${TMP_DIR}/RpcAddAudioClipToPlaylistTest.o \
${TMP_DIR}/ResetStorageMethodTest.o \
${TMP_DIR}/GetSchedulerTimeMethodTest.o \
${TMP_DIR}/RpcGetSchedulerTimeTest.o \
${TMP_DIR}/GetVersionMethodTest.o \
${TMP_DIR}/RpcGetVersionTest.o \
${TMP_DIR}/UploadPlaylistMethodTest.o \
${TMP_DIR}/RpcUploadPlaylistTest.o \
${TMP_DIR}/DisplayScheduleMethodTest.o \
${TMP_DIR}/DisplayPlaylistMethodTest.o \
${TMP_DIR}/RpcDisplayScheduleTest.o \
${TMP_DIR}/RemoveFromScheduleMethodTest.o \
${TMP_DIR}/RpcRemoveFromScheduleTest.o \
${TMP_DIR}/RescheduleMethodTest.o \
${TMP_DIR}/RpcRescheduleTest.o \
${TMP_DIR}/PostgresqlScheduleTest.o \
${TMP_DIR}/DeletePlaylistMethodTest.o \
${TMP_DIR}/RpcDeletePlaylistTest.o \
${TMP_DIR}/DisplayPlaylistMethodTest.o \
${TMP_DIR}/RpcDisplayPlaylistTest.o \
${TMP_DIR}/DisplayPlaylistsMethodTest.o \
${TMP_DIR}/RpcDisplayPlaylistsTest.o \
${TMP_DIR}/OpenPlaylistForEditingMethodTest.o \
${TMP_DIR}/CreatePlaylistMethodTest.o \
${TMP_DIR}/RpcCreatePlaylistTest.o \
${TMP_DIR}/AddAudioClipToPlaylistMethodTest.o \
${TMP_DIR}/RpcAddAudioClipToPlaylistTest.o \
${TMP_DIR}/RemoveAudioClipFromPlaylistMethodTest.o \
${TMP_DIR}/ValidatePlaylistMethodTest.o \
${TMP_DIR}/DisplayAudioClipMethodTest.o \
${TMP_DIR}/RpcDisplayAudioClipTest.o \
${TMP_DIR}/DisplayAudioClipsMethodTest.o \
${TMP_DIR}/RpcDisplayAudioClipsTest.o \
${TMP_DIR}/SavePlaylistMethodTest.o \
${TMP_DIR}/RevertEditedPlaylistMethodTest.o \
${TMP_DIR}/PostgresqlPlayLogTest.o \

View File

@ -0,0 +1,124 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/LoginMethod.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
#include "LiveSupport/Core/XmlRpcTools.h"
#include "LoginMethod.h"
using namespace LiveSupport::Authentication;
using namespace LiveSupport::Scheduler;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/*------------------------------------------------------------------------------
* The name of this XML-RPC method.
*----------------------------------------------------------------------------*/
const std::string LoginMethod::methodName = "login";
/*------------------------------------------------------------------------------
* The ID of this method for error reporting purposes.
*----------------------------------------------------------------------------*/
const int LoginMethod::errorId = 2000;
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Construct the method and register it right away.
*----------------------------------------------------------------------------*/
LoginMethod :: LoginMethod (
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) throw()
: XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
{
}
/*------------------------------------------------------------------------------
* Execute the XML-RPC function call.
* (Overrides 'execute' in XmlRpcServerMethod.)
*----------------------------------------------------------------------------*/
void
LoginMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException)
{
if (!rootParameter.valid() || rootParameter.size() != 1) {
XmlRpcTools::markError(errorId+1, "invalid argument format",
returnValue);
return;
}
XmlRpc::XmlRpcValue parameters = rootParameter[0];
Ptr<std::string>::Ref loginName;
try{
loginName = XmlRpcTools::extractLoginName(parameters);
} catch (XmlRpcException &e) {
XmlRpcTools::markError(errorId+2, "missing login argument",
returnValue);
return;
}
Ptr<std::string>::Ref password;
try{
password = XmlRpcTools::extractPassword(parameters);
} catch (XmlRpcException &e) {
XmlRpcTools::markError(errorId+3, "missing password argument",
returnValue);
return;
}
Ptr<AuthenticationClientFactory>::Ref
acf = AuthenticationClientFactory::getInstance();
Ptr<AuthenticationClientInterface>::Ref
authentication = acf->getAuthenticationClient();
Ptr<SessionId>::Ref sessionId;
try {
sessionId = authentication->login(*loginName, *password);
} catch (XmlRpcException &e) {
std::string eMsg = "authentication login() returned error:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+4, eMsg, returnValue);
return;
}
XmlRpcTools::sessionIdToXmlRpcValue(sessionId, returnValue);
}

View File

@ -0,0 +1,150 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/LoginMethod.h,v $
------------------------------------------------------------------------------*/
#ifndef LoginMethod_h
#define LoginMethod_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h"
namespace LiveSupport {
namespace Scheduler {
using namespace LiveSupport::Core;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* An XML-RPC method object to log in using the authentication server.
*
* The name of the method when called through XML-RPC is "login".
*
* The expected parameter is an XML-RPC structure, with the following
* members:
* <ul>
* <li>login - string - the login name </li>
* <li>password - string - the password. </li>
* </ul>
*
* The XML-RPC function returns an XML-RPC structure, containing the following
* fields:
* <ul>
* <li>sessionId - string - a new session ID. </li>
* </ul>
*
* In case of an error, a standard XML-RPC fault response is generated,
* and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* possible errors are:
* <ul>
* <li>2001 - invalid argument format </li>
* <li>2002 - missing login argument </li>
* <li>2003 - missing password argument </li>
* <li>2004 - the authentication server reported an error </li>
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.1 $
*/
class LoginMethod : public XmlRpc::XmlRpcServerMethod
{
private:
/**
* The name of this method, as it will be registered into the
* XML-RPC server.
*/
static const std::string methodName;
/**
* The ID of this method for error reporting purposes.
*/
static const int errorId;
public:
/**
* A default constructor, for testing purposes.
*/
LoginMethod(void) throw ()
: XmlRpc::XmlRpcServerMethod(methodName)
{
}
/**
* Constuctor that registers the method with the server right away.
*
* @param xmlRpcServer the XML-RPC server to register with.
*/
LoginMethod(
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
throw ();
/**
* Execute the login command on the Scheduler daemon.
*
* @param parameters XML-RPC function call parameters
* @param returnValue the return value of the call (out parameter)
*/
void
execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace Scheduler
} // namespace LiveSupport
#endif // LoginMethod_h

View File

@ -0,0 +1,112 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/LogoutMethod.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
#include "LiveSupport/Core/XmlRpcTools.h"
#include "LogoutMethod.h"
using namespace LiveSupport::Authentication;
using namespace LiveSupport::Scheduler;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/*------------------------------------------------------------------------------
* The name of this XML-RPC method.
*----------------------------------------------------------------------------*/
const std::string LogoutMethod::methodName = "logout";
/*------------------------------------------------------------------------------
* The ID of this method for error reporting purposes.
*----------------------------------------------------------------------------*/
const int LogoutMethod::errorId = 2100;
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Construct the method and register it right away.
*----------------------------------------------------------------------------*/
LogoutMethod :: LogoutMethod (
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) throw()
: XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
{
}
/*------------------------------------------------------------------------------
* Execute the XML-RPC function call.
* (Overrides 'execute' in XmlRpcServerMethod.)
*----------------------------------------------------------------------------*/
void
LogoutMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException)
{
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 (XmlRpcException &e) {
XmlRpcTools::markError(errorId+20, "missing logout argument",
returnValue);
return;
}
Ptr<AuthenticationClientFactory>::Ref
acf = AuthenticationClientFactory::getInstance();
Ptr<AuthenticationClientInterface>::Ref
authentication = acf->getAuthenticationClient();
try {
authentication->logout(sessionId);
} catch (XmlRpcException &e) {
std::string eMsg = "authentication logout() returned error:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+4, eMsg, returnValue);
return;
}
}

View File

@ -0,0 +1,142 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/LogoutMethod.h,v $
------------------------------------------------------------------------------*/
#ifndef LogoutMethod_h
#define LogoutMethod_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h"
namespace LiveSupport {
namespace Scheduler {
using namespace LiveSupport::Core;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* An XML-RPC method object to log out from the authentication server.
*
* The name of the method when called through XML-RPC is "logout".
*
* The expected parameter is an XML-RPC structure, with the following
* members:
* <ul>
* <li>sessionId - string - the session ID returned by login. </li>
* </ul>
*
* In case of an error, a standard XML-RPC fault response is generated,
* and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* possible errors are:
* <ul>
* <li>2101 - invalid argument format </li>
* <li>2120 - missing session ID argument </li>
* <li>2104 - the authentication server reported an error </li>
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.1 $
*/
class LogoutMethod : public XmlRpc::XmlRpcServerMethod
{
private:
/**
* The name of this method, as it will be registered into the
* XML-RPC server.
*/
static const std::string methodName;
/**
* The ID of this method for error reporting purposes.
*/
static const int errorId;
public:
/**
* A default constructor, for testing purposes.
*/
LogoutMethod(void) throw ()
: XmlRpc::XmlRpcServerMethod(methodName)
{
}
/**
* Constuctor that registers the method with the server right away.
*
* @param xmlRpcServer the XML-RPC server to register with.
*/
LogoutMethod(
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
throw ();
/**
* Execute the logout command on the Scheduler daemon.
*
* @param parameters XML-RPC function call parameters
* @param returnValue the return value of the call (out parameter)
*/
void
execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace Scheduler
} // namespace LiveSupport
#endif // LogoutMethod_h

View File

@ -0,0 +1,100 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ResetStorageMethod.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include "LiveSupport/Storage/StorageClientInterface.h"
#include "LiveSupport/Storage/StorageClientFactory.h"
#include "LiveSupport/Core/XmlRpcTools.h"
#include "ResetStorageMethod.h"
using namespace LiveSupport::Storage;
using namespace LiveSupport::Scheduler;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/*------------------------------------------------------------------------------
* The name of this XML-RPC method.
*----------------------------------------------------------------------------*/
const std::string ResetStorageMethod::methodName = "resetStorage";
/*------------------------------------------------------------------------------
* The ID of this method for error reporting purposes.
*----------------------------------------------------------------------------*/
const int ResetStorageMethod::errorId = 3000;
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Construct the method and register it right away.
*----------------------------------------------------------------------------*/
ResetStorageMethod :: ResetStorageMethod (
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer) throw()
: XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
{
}
/*------------------------------------------------------------------------------
* Execute the XML-RPC function call.
* (Overrides 'execute' in XmlRpcServerMethod.)
*----------------------------------------------------------------------------*/
void
ResetStorageMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException)
{
Ptr<StorageClientFactory>::Ref scf
= StorageClientFactory::getInstance();
Ptr<StorageClientInterface>::Ref storage
= scf->getStorageClient();
try {
storage->reset();
} catch (XmlRpcException &e) {
std::string eMsg = "storage reset() returned error:\n";
eMsg += e.what();
XmlRpcTools::markError(errorId+1, eMsg, returnValue);
return;
}
}

View File

@ -0,0 +1,136 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ResetStorageMethod.h,v $
------------------------------------------------------------------------------*/
#ifndef ResetStorageMethod_h
#define ResetStorageMethod_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <XmlRpcServerMethod.h>
#include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include "LiveSupport/Core/Ptr.h"
namespace LiveSupport {
namespace Scheduler {
using namespace LiveSupport::Core;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* An XML-RPC method object to reset the storage to its initial value.
*
* The name of the method when called through XML-RPC is "resetStorage".
*
* No parameters are required, and normally nothing is returned.
*
* In case of an error, a standard XML-RPC fault response is generated,
* and a {&nbsp;faultCode, faultString&nbsp;} structure is returned. The
* possible errors are:
* <ul>
* <li>3001 - storage client reported an error </li>
* </ul>
*
* @author $Author: fgerlits $
* @version $Revision: 1.1 $
*/
class ResetStorageMethod : public XmlRpc::XmlRpcServerMethod
{
private:
/**
* The name of this method, as it will be registered into the
* XML-RPC server.
*/
static const std::string methodName;
/**
* The ID of this method for error reporting purposes.
*/
static const int errorId;
public:
/**
* A default constructor, for testing purposes.
*/
ResetStorageMethod(void) throw ()
: XmlRpc::XmlRpcServerMethod(methodName)
{
}
/**
* Constuctor that registers the method with the server right away.
*
* @param xmlRpcServer the XML-RPC server to register with.
*/
ResetStorageMethod(
Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
throw ();
/**
* Execute the reset storage command on the Scheduler daemon.
*
* @param parameters XML-RPC function call parameters
* @param returnValue the return value of the call (out parameter)
*/
void
execute( XmlRpc::XmlRpcValue & parameters,
XmlRpc::XmlRpcValue & returnValue)
throw (XmlRpc::XmlRpcException);
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace Scheduler
} // namespace LiveSupport
#endif // ResetStorageMethod_h

View File

@ -0,0 +1,148 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ResetStorageMethodTest.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#include <XmlRpcClient.h>
#include <XmlRpcValue.h>
#include "ResetStorageMethodTest.h"
using namespace LiveSupport::Scheduler;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
CPPUNIT_TEST_SUITE_REGISTRATION(ResetStorageMethodTest);
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Set up the test environment
*----------------------------------------------------------------------------*/
void
ResetStorageMethodTest :: setUp(void) throw ()
{
}
/*------------------------------------------------------------------------------
* Clean up the test environment
*----------------------------------------------------------------------------*/
void
ResetStorageMethodTest :: tearDown(void) throw ()
{
}
#include <iostream>
/*------------------------------------------------------------------------------
* Just a very simple smoke test
*----------------------------------------------------------------------------*/
void
ResetStorageMethodTest :: firstTest(void)
throw (CPPUNIT_NS::Exception)
{
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
parameters.clear();
parameters["login"] = "root";
parameters["password"] = "q";
result.clear();
CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("sessionId"));
std::string sessionId = std::string(result["sessionId"]);
parameters.clear();
parameters["sessionId"] = sessionId;
parameters["playlistId"] = "0000000000000001";
result.clear();
CPPUNIT_ASSERT(xmlRpcClient.execute("displayPlaylist", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("id"));
parameters.clear();
parameters["sessionId"] = sessionId;
parameters["playlistId"] = "0000000000000001";
result.clear();
CPPUNIT_ASSERT(xmlRpcClient.execute("deletePlaylist", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
parameters.clear();
parameters["sessionId"] = sessionId;
parameters["playlistId"] = "0000000000000001";
result.clear();
CPPUNIT_ASSERT(xmlRpcClient.execute("displayPlaylist", parameters, result));
CPPUNIT_ASSERT(xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("faultCode"));
CPPUNIT_ASSERT(int(result["faultCode"]) == 1003);
result.clear();
CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
parameters["login"] = "root";
parameters["password"] = "q";
CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("sessionId"));
sessionId = std::string(result["sessionId"]);
parameters.clear();
parameters["sessionId"] = sessionId;
parameters["playlistId"] = "0000000000000001";
result.clear();
CPPUNIT_ASSERT(xmlRpcClient.execute("displayPlaylist", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("id"));
parameters.clear();
parameters["sessionId"] = sessionId;
result.clear();
CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
xmlRpcClient.close();
}

View File

@ -0,0 +1,108 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ResetStorageMethodTest.h,v $
------------------------------------------------------------------------------*/
#ifndef ResetStorageMethodTest_h
#define ResetStorageMethodTest_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <cppunit/extensions/HelperMacros.h>
namespace LiveSupport {
namespace Scheduler {
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* Unit test for the ResetStorageMethod class.
*
* @author $Author: maroy, fgerlits
$
* @version $Revision: 1.1 $
* @see ResetStorageMethod
*/
class ResetStorageMethodTest : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE(ResetStorageMethodTest);
CPPUNIT_TEST(firstTest);
CPPUNIT_TEST_SUITE_END();
protected:
/**
* A simple test.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
firstTest(void) throw (CPPUNIT_NS::Exception);
public:
/**
* Set up the environment for the test case.
*/
void
setUp(void) throw ();
/**
* Clean up the environment after the test case.
*/
void
tearDown(void) throw ();
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace Scheduler
} // namespace LiveSupport
#endif // ResetStorageMethodTest_h

View File

@ -22,41 +22,23 @@
Author : $Author: fgerlits $
Version : $Revision: 1.10 $
Version : $Revision: 1.11 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcAddAudioClipToPlaylistTest.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#else
#error "Need unistd.h"
#endif
#include <string>
#include <iostream>
#include <XmlRpcClient.h>
#include <XmlRpcValue.h>
#include "SchedulerDaemon.h"
#include "LiveSupport/Storage/StorageClientFactory.h"
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
#include "LiveSupport/Core/XmlRpcTools.h"
#include "OpenPlaylistForEditingMethod.h"
#include "AddAudioClipToPlaylistMethod.h"
#include "RpcAddAudioClipToPlaylistTest.h"
using namespace std;
using namespace LiveSupport::Storage;
using namespace LiveSupport::Authentication;
using namespace LiveSupport::Core;
using namespace LiveSupport::Scheduler;
/* =================================================== local data structures */
@ -66,103 +48,35 @@ using namespace LiveSupport::Scheduler;
CPPUNIT_TEST_SUITE_REGISTRATION(RpcAddAudioClipToPlaylistTest);
/**
* The name of the configuration file for the scheduler daemon.
*/
static const std::string schedulerDaemonConfig =
"etc/scheduler.xml";
/**
* The name of the configuration file for the storage client factory.
*/
static const std::string storageClientConfig =
"etc/storageClient.xml";
/**
* The name of the configuration file for the authentication client factory.
*/
static const std::string authenticationClientConfig =
"etc/authenticationClient.xml";
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Configure a Configurable with an XML file.
*----------------------------------------------------------------------------*/
void
RpcAddAudioClipToPlaylistTest :: configure(
Ptr<Configurable>::Ref configurable,
const std::string fileName)
throw (std::invalid_argument,
xmlpp::exception)
{
Ptr<xmlpp::DomParser>::Ref parser(new xmlpp::DomParser(fileName, true));
const xmlpp::Document * document = parser->get_document();
const xmlpp::Element * root = document->get_root_node();
configurable->configure(*root);
}
/*------------------------------------------------------------------------------
* Set up the test environment
*----------------------------------------------------------------------------*/
void
RpcAddAudioClipToPlaylistTest :: setUp(void) throw ()
{
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
if (!daemon->isConfigured()) {
try {
configure(daemon, schedulerDaemonConfig);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("semantic error in scheduler configuration file");
} catch (xmlpp::exception &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("error parsing scheduler configuration file");
}
}
daemon->install();
// daemon->start();
// sleep(2);
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
try {
Ptr<StorageClientFactory>::Ref scf
= StorageClientFactory::getInstance();
configure(scf, storageClientConfig);
Ptr<StorageClientInterface>::Ref storage = scf->getStorageClient();
storage->reset();
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL("semantic error in storage configuration file");
} catch (xmlpp::exception &e) {
CPPUNIT_FAIL("error parsing storage configuration file");
} catch (std::exception &e) {
CPPUNIT_FAIL(e.what());
}
Ptr<AuthenticationClientFactory>::Ref acf;
try {
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfig);
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL("semantic error in authentication configuration file");
} catch (xmlpp::exception &e) {
CPPUNIT_FAIL("error parsing authentication configuration file");
} catch (std::exception &e) {
CPPUNIT_FAIL(e.what());
}
authentication = acf->getAuthenticationClient();
try {
sessionId = authentication->login("root", "q");
} catch (XmlRpcException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
parameters["login"] = "root";
parameters["password"] = "q";
CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("sessionId"));
xmlRpcClient.close();
sessionId.reset(new SessionId(std::string(result["sessionId"])));
}
@ -172,14 +86,16 @@ RpcAddAudioClipToPlaylistTest :: setUp(void) throw ()
void
RpcAddAudioClipToPlaylistTest :: tearDown(void) throw ()
{
authentication->logout(sessionId);
sessionId.reset();
authentication.reset();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
// daemon->stop();
// sleep(2);
daemon->uninstall();
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
parameters["sessionId"] = sessionId->getId();
CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
xmlRpcClient.close();
}

View 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/RpcAddAudioClipToPlaylistTest.h,v $
------------------------------------------------------------------------------*/
@ -42,15 +42,14 @@
#include <cppunit/extensions/HelperMacros.h>
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/SessionId.h"
namespace LiveSupport {
namespace Scheduler {
using namespace LiveSupport;
using namespace LiveSupport::Core;
using namespace LiveSupport::Authentication;
/* ================================================================ constants */
@ -64,7 +63,7 @@ using namespace LiveSupport::Authentication;
* Unit test for the AddAudioClipToPlaylistMethod class.
*
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @version $Revision: 1.3 $
* @see AddAudioClipToPlaylistMethod
*/
class RpcAddAudioClipToPlaylistTest : public CPPUNIT_NS::TestFixture
@ -75,30 +74,11 @@ class RpcAddAudioClipToPlaylistTest : public CPPUNIT_NS::TestFixture
private:
/**
* 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.
*
* @param configurable configure this
* @param fileName the name of the XML file to configure with.
* @exception std::invalid_argument on configuration errors.
* @exception xmlpp::exception on XML parsing errors.
*/
void
configure(Ptr<Configurable>::Ref configurable,
std::string fileName)
throw (std::invalid_argument,
xmlpp::exception);
protected:
/**
@ -109,7 +89,6 @@ class RpcAddAudioClipToPlaylistTest : public CPPUNIT_NS::TestFixture
void
firstTest(void) throw (CPPUNIT_NS::Exception);
public:
/**

View File

@ -22,45 +22,24 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcCreatePlaylistTest.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#else
#error "Need unistd.h"
#endif
#include <string>
#include <iostream>
#include <XmlRpcValue.h>
#include <XmlRpcClient.h>
#include <XmlRpcValue.h>
#include "SchedulerDaemon.h"
#include "LiveSupport/Db/ConnectionManagerFactory.h"
#include "LiveSupport/Storage/StorageClientFactory.h"
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
#include "CreatePlaylistMethod.h"
#include "OpenPlaylistForEditingMethod.h"
#include "RpcCreatePlaylistTest.h"
using namespace XmlRpc;
using namespace LiveSupport::Db;
using namespace LiveSupport::Storage;
using namespace LiveSupport::Core;
using namespace LiveSupport::Scheduler;
using namespace LiveSupport::Authentication;
/* =================================================== local data structures */
@ -69,53 +48,11 @@ using namespace LiveSupport::Authentication;
CPPUNIT_TEST_SUITE_REGISTRATION(RpcCreatePlaylistTest);
/**
* The name of the configuration file for the scheduler daemon.
*/
static const std::string schedulerDaemonConfig =
"etc/scheduler.xml";
/**
* The name of the configuration file for the storage client factory.
*/
static const std::string storageClientConfig =
"etc/storageClient.xml";
/**
* The name of the configuration file for the connection manager factory.
*/
static const std::string connectionManagerConfig =
"etc/connectionManagerFactory.xml";
/**
* The name of the configuration file for the authentication client factory.
*/
static const std::string authenticationClientConfig =
"etc/authenticationClient.xml";
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Configure a Configurable with an XML file.
*----------------------------------------------------------------------------*/
void
RpcCreatePlaylistTest :: 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
@ -123,47 +60,23 @@ RpcCreatePlaylistTest :: configure(
void
RpcCreatePlaylistTest :: setUp(void) throw ()
{
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
if (!daemon->isConfigured()) {
try {
configure(daemon, schedulerDaemonConfig);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("semantic error in scheduler configuration file");
} catch (xmlpp::exception &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("error parsing scheduler configuration file");
}
}
daemon->install();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
Ptr<AuthenticationClientFactory>::Ref acf;
try {
Ptr<StorageClientFactory>::Ref scf
= StorageClientFactory::getInstance();
configure(scf, storageClientConfig);
Ptr<StorageClientInterface>::Ref storage = scf->getStorageClient();
storage->reset();
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
Ptr<ConnectionManagerFactory>::Ref cmf
= ConnectionManagerFactory::getInstance();
configure(cmf, connectionManagerConfig);
CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfig);
parameters["login"] = "root";
parameters["password"] = "q";
CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("sessionId"));
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL("semantic error in configuration file");
} catch (xmlpp::exception &e) {
CPPUNIT_FAIL("error parsing configuration file");
} catch (std::exception &e) {
CPPUNIT_FAIL(e.what());
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
}
xmlRpcClient.close();
sessionId.reset(new SessionId(std::string(result["sessionId"])));
}
@ -173,12 +86,16 @@ RpcCreatePlaylistTest :: setUp(void) throw ()
void
RpcCreatePlaylistTest :: tearDown(void) throw ()
{
authentication->logout(sessionId);
sessionId.reset();
authentication.reset();
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
daemon->uninstall();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
parameters["sessionId"] = sessionId->getId();
CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
xmlRpcClient.close();
}
@ -189,18 +106,20 @@ void
RpcCreatePlaylistTest :: firstTest(void)
throw (CPPUNIT_NS::Exception)
{
XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
parameters["sessionId"] = sessionId->getId();
result.clear();
xmlRpcClient.execute("createPlaylist", parameters, result);
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("id"));
CPPUNIT_ASSERT(result["id"].getType == XmlRpcValue::TypeString);
CPPUNIT_ASSERT(result["id"].getType() == XmlRpc::XmlRpcValue::TypeString);
CPPUNIT_ASSERT(result.hasMember("playlength"));
CPPUNIT_ASSERT(result["playlength"].getType == XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(result["playlength"].getType()
== XmlRpc::XmlRpcValue::TypeInt);
CPPUNIT_ASSERT(int(result["playlength"]) == 0);
parameters.clear();
@ -211,7 +130,7 @@ RpcCreatePlaylistTest :: firstTest(void)
xmlRpcClient.execute("openPlaylistForEditing", parameters, result);
CPPUNIT_ASSERT(xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("faultCode"));
CPPUNIT_ASSERT(int(result["faultCode"]) == 105);
CPPUNIT_ASSERT(int(result["faultCode"]) == 104);
xmlRpcClient.close();
}

View 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/RpcCreatePlaylistTest.h,v $
------------------------------------------------------------------------------*/
@ -42,15 +42,14 @@
#include <cppunit/extensions/HelperMacros.h>
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/SessionId.h"
namespace LiveSupport {
namespace Scheduler {
using namespace LiveSupport;
using namespace LiveSupport::Core;
using namespace LiveSupport::Authentication;
/* ================================================================ constants */
@ -64,7 +63,7 @@ using namespace LiveSupport::Authentication;
* Unit test for the CreatePlaylistMethod class.
*
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @version $Revision: 1.3 $
* @see CreatePlaylistMethod
*/
class RpcCreatePlaylistTest : public CPPUNIT_NS::TestFixture
@ -75,30 +74,11 @@ class RpcCreatePlaylistTest : public CPPUNIT_NS::TestFixture
private:
/**
* 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.
*
* @param configurable configure this
* @param fileName the name of the XML file to configure with.
* @exception std::invalid_argument on configuration errors.
* @exception xmlpp::exception on XML parsing errors.
*/
void
configure(Ptr<Configurable>::Ref configurable,
std::string fileName)
throw (std::invalid_argument,
xmlpp::exception);
protected:
/**

View File

@ -22,46 +22,24 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/RpcDeletePlaylistTest.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#else
#error "Need unistd.h"
#endif
#include <string>
#include <iostream>
#include <XmlRpcValue.h>
#include <XmlRpcClient.h>
#include <XmlRpcValue.h>
#include "SchedulerDaemon.h"
#include "LiveSupport/Db/ConnectionManagerFactory.h"
#include "LiveSupport/Storage/StorageClientFactory.h"
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
#include "OpenPlaylistForEditingMethod.h"
#include "SavePlaylistMethod.h"
#include "DeletePlaylistMethod.h"
#include "RpcDeletePlaylistTest.h"
using namespace LiveSupport::Db;
using namespace LiveSupport::Storage;
using namespace LiveSupport::Core;
using namespace LiveSupport::Scheduler;
using namespace LiveSupport::Authentication;
/* =================================================== local data structures */
@ -70,53 +48,11 @@ using namespace LiveSupport::Authentication;
CPPUNIT_TEST_SUITE_REGISTRATION(RpcDeletePlaylistTest);
/**
* The name of the configuration file for the scheduler daemon.
*/
static const std::string schedulerDaemonConfig =
"etc/scheduler.xml";
/**
* The name of the configuration file for the storage client factory.
*/
static const std::string storageClientConfig =
"etc/storageClient.xml";
/**
* The name of the configuration file for the connection manager factory.
*/
static const std::string connectionManagerConfig =
"etc/connectionManagerFactory.xml";
/**
* The name of the configuration file for the authentication client factory.
*/
static const std::string authenticationClientConfig =
"etc/authenticationClient.xml";
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Configure a Configurable with an XML file.
*----------------------------------------------------------------------------*/
void
RpcDeletePlaylistTest :: 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
@ -124,47 +60,23 @@ RpcDeletePlaylistTest :: configure(
void
RpcDeletePlaylistTest :: setUp(void) throw ()
{
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
if (!daemon->isConfigured()) {
try {
configure(daemon, schedulerDaemonConfig);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("semantic error in scheduler configuration file");
} catch (xmlpp::exception &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("error parsing scheduler configuration file");
}
}
daemon->install();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
Ptr<AuthenticationClientFactory>::Ref acf;
try {
Ptr<StorageClientFactory>::Ref scf
= StorageClientFactory::getInstance();
configure(scf, storageClientConfig);
Ptr<StorageClientInterface>::Ref storage = scf->getStorageClient();
storage->reset();
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
Ptr<ConnectionManagerFactory>::Ref cmf
= ConnectionManagerFactory::getInstance();
configure(cmf, connectionManagerConfig);
CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfig);
parameters["login"] = "root";
parameters["password"] = "q";
CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("sessionId"));
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL("semantic error in configuration file");
} catch (xmlpp::exception &e) {
CPPUNIT_FAIL("error parsing configuration file");
} catch (std::exception &e) {
CPPUNIT_FAIL(e.what());
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
}
xmlRpcClient.close();
sessionId.reset(new SessionId(std::string(result["sessionId"])));
}
@ -174,12 +86,16 @@ RpcDeletePlaylistTest :: setUp(void) throw ()
void
RpcDeletePlaylistTest :: tearDown(void) throw ()
{
authentication->logout(sessionId);
sessionId.reset();
authentication.reset();
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
daemon->uninstall();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
parameters["sessionId"] = sessionId->getId();
CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
xmlRpcClient.close();
}

View 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/RpcDeletePlaylistTest.h,v $
------------------------------------------------------------------------------*/
@ -42,15 +42,14 @@
#include <cppunit/extensions/HelperMacros.h>
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/SessionId.h"
namespace LiveSupport {
namespace Scheduler {
using namespace LiveSupport;
using namespace LiveSupport::Core;
using namespace LiveSupport::Authentication;
/* ================================================================ constants */
@ -65,7 +64,7 @@ using namespace LiveSupport::Authentication;
*
* @author $Author: maroy, fgerlits
$
* @version $Revision: 1.2 $
* @version $Revision: 1.3 $
* @see DeletePlaylistMethod
*/
class RpcDeletePlaylistTest : public CPPUNIT_NS::TestFixture
@ -77,31 +76,11 @@ class RpcDeletePlaylistTest : public CPPUNIT_NS::TestFixture
private:
/**
* 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.
*
* @param configurable configure this
* @param fileName the name of the XML file to configure with.
* @exception std::invalid_argument on configuration errors.
* @exception xmlpp::exception on XML parsing errors.
*/
void
configure(Ptr<Configurable>::Ref configurable,
std::string fileName)
throw (std::invalid_argument,
xmlpp::exception);
protected:
/**

View File

@ -22,66 +22,31 @@
Author : $Author: fgerlits $
Version : $Revision: 1.7 $
Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcDisplayAudioClipTest.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#else
#error "Need unistd.h"
#endif
#include <string>
#include <iostream>
#include <XmlRpcClient.h>
#include <XmlRpcValue.h>
#include "LiveSupport/Db/ConnectionManagerFactory.h"
#include "LiveSupport/Storage/StorageClientFactory.h"
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
#include "SchedulerDaemon.h"
#include "DisplayAudioClipMethod.h"
#include "DisplayAudioClipMethodTest.h"
#include "RpcDisplayAudioClipTest.h"
using namespace LiveSupport::Db;
using namespace LiveSupport::Storage;
using namespace LiveSupport::Core;
using namespace LiveSupport::Scheduler;
using namespace LiveSupport::Authentication;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
CPPUNIT_TEST_SUITE_REGISTRATION(DisplayAudioClipMethodTest);
/**
* The name of the configuration file for the storage client factory.
*/
const std::string DisplayAudioClipMethodTest::storageClientConfig =
"etc/storageClient.xml";
/**
* The name of the configuration file for the connection manager factory.
*/
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";
CPPUNIT_TEST_SUITE_REGISTRATION(RpcDisplayAudioClipTest);
/* =============================================== local function prototypes */
@ -89,61 +54,29 @@ const std::string DisplayAudioClipMethodTest::authenticationClientConfig =
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Configure a Configurable with an XML file.
*----------------------------------------------------------------------------*/
void
DisplayAudioClipMethodTest :: configure(
Ptr<Configurable>::Ref configurable,
const std::string fileName)
throw (std::invalid_argument,
xmlpp::exception)
{
Ptr<xmlpp::DomParser>::Ref parser(new xmlpp::DomParser(fileName, true));
const xmlpp::Document * document = parser->get_document();
const xmlpp::Element * root = document->get_root_node();
configurable->configure(*root);
}
/*------------------------------------------------------------------------------
* Set up the test environment
*----------------------------------------------------------------------------*/
void
DisplayAudioClipMethodTest :: setUp(void) throw ()
RpcDisplayAudioClipTest :: setUp(void) throw ()
{
Ptr<AuthenticationClientFactory>::Ref acf;
try {
Ptr<StorageClientFactory>::Ref scf
= StorageClientFactory::getInstance();
configure(scf, storageClientConfig);
Ptr<StorageClientInterface>::Ref storage = scf->getStorageClient();
storage->reset();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
Ptr<ConnectionManagerFactory>::Ref cmf
= ConnectionManagerFactory::getInstance();
configure(cmf, connectionManagerConfig);
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfig);
CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL("semantic error in configuration file");
} catch (xmlpp::exception &e) {
CPPUNIT_FAIL("error parsing configuration file");
} catch (std::exception &e) {
CPPUNIT_FAIL(e.what());
}
authentication = acf->getAuthenticationClient();
try {
sessionId = authentication->login("root", "q");
} catch (XmlRpcException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
parameters["login"] = "root";
parameters["password"] = "q";
CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("sessionId"));
xmlRpcClient.close();
sessionId.reset(new SessionId(std::string(result["sessionId"])));
}
@ -151,11 +84,18 @@ DisplayAudioClipMethodTest :: setUp(void) throw ()
* Clean up the test environment
*----------------------------------------------------------------------------*/
void
DisplayAudioClipMethodTest :: tearDown(void) throw ()
RpcDisplayAudioClipTest :: tearDown(void) throw ()
{
authentication->logout(sessionId);
sessionId.reset();
authentication.reset();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
parameters["sessionId"] = sessionId->getId();
CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
xmlRpcClient.close();
}
@ -163,7 +103,7 @@ DisplayAudioClipMethodTest :: tearDown(void) throw ()
* Just a very simple smoke test
*----------------------------------------------------------------------------*/
void
DisplayAudioClipMethodTest :: firstTest(void)
RpcDisplayAudioClipTest :: firstTest(void)
throw (CPPUNIT_NS::Exception)
{
XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
@ -193,7 +133,7 @@ DisplayAudioClipMethodTest :: firstTest(void)
* A very simple negative test
*----------------------------------------------------------------------------*/
void
DisplayAudioClipMethodTest :: negativeTest(void)
RpcDisplayAudioClipTest :: negativeTest(void)
throw (CPPUNIT_NS::Exception)
{
XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);

View File

@ -22,12 +22,12 @@
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcDisplayAudioClipTest.h,v $
------------------------------------------------------------------------------*/
#ifndef DisplayAudioClipMethodTest_h
#define DisplayAudioClipMethodTest_h
#ifndef RpcDisplayAudioClipTest_h
#define RpcDisplayAudioClipTest_h
#ifndef __cplusplus
#error This is a C++ include file
@ -42,15 +42,14 @@
#include <cppunit/extensions/HelperMacros.h>
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/SessionId.h"
namespace LiveSupport {
namespace Scheduler {
using namespace LiveSupport;
using namespace LiveSupport::Core;
using namespace LiveSupport::Authentication;
/* ================================================================ constants */
@ -64,60 +63,23 @@ using namespace LiveSupport::Authentication;
* Unit test for the DisplayAudioClipMethod class.
*
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @version $Revision: 1.3 $
* @see DisplayAudioClipMethod
*/
class DisplayAudioClipMethodTest : public CPPUNIT_NS::TestFixture
class RpcDisplayAudioClipTest : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE(DisplayAudioClipMethodTest);
CPPUNIT_TEST_SUITE(RpcDisplayAudioClipTest);
CPPUNIT_TEST(firstTest);
CPPUNIT_TEST(negativeTest);
CPPUNIT_TEST_SUITE_END();
private:
/**
* The name of the configuration file for the storage client factory.
*/
static const std::string storageClientConfig;
/**
* The name of the configuration file for the connection manager
* factory.
*/
static const std::string connectionManagerConfig;
/**
* 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.
*
* @param configurable configure this
* @param fileName the name of the XML file to configure with.
* @exception std::invalid_argument on configuration errors.
* @exception xmlpp::exception on XML parsing errors.
*/
void
configure(Ptr<Configurable>::Ref configurable,
std::string fileName)
throw (std::invalid_argument,
xmlpp::exception);
protected:
/**
@ -161,5 +123,5 @@ class DisplayAudioClipMethodTest : public CPPUNIT_NS::TestFixture
} // namespace Scheduler
} // namespace LiveSupport
#endif // DisplayAudioClipMethodTest_h
#endif // RpcDisplayAudioClipTest_h

View File

@ -22,125 +22,61 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcDisplayAudioClipsTest.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#else
#error "Need unistd.h"
#endif
#include <string>
#include <iostream>
#include <vector>
#include <XmlRpcClient.h>
#include <XmlRpcValue.h>
#include "LiveSupport/Db/ConnectionManagerFactory.h"
#include "LiveSupport/Storage/StorageClientFactory.h"
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
#include "SchedulerDaemon.h"
#include "DisplayAudioClipsMethod.h"
#include "DisplayAudioClipsMethodTest.h"
#include "RpcDisplayAudioClipsTest.h"
using namespace LiveSupport::Db;
using namespace LiveSupport::Storage;
using namespace LiveSupport::Core;
using namespace LiveSupport::Scheduler;
using namespace LiveSupport::Authentication;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
CPPUNIT_TEST_SUITE_REGISTRATION(DisplayAudioClipsMethodTest);
/**
* The name of the configuration file for the storage client factory.
*/
const std::string DisplayAudioClipsMethodTest::storageClientConfig =
"etc/storageClient.xml";
/**
* The name of the configuration file for the connection manager factory.
*/
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";
CPPUNIT_TEST_SUITE_REGISTRATION(RpcDisplayAudioClipsTest);
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Configure a Configurable with an XML file.
*----------------------------------------------------------------------------*/
void
DisplayAudioClipsMethodTest :: configure(
Ptr<Configurable>::Ref configurable,
const std::string fileName)
throw (std::invalid_argument,
xmlpp::exception)
{
Ptr<xmlpp::DomParser>::Ref parser(new xmlpp::DomParser(fileName, true));
const xmlpp::Document * document = parser->get_document();
const xmlpp::Element * root = document->get_root_node();
configurable->configure(*root);
}
/*------------------------------------------------------------------------------
* Set up the test environment
*----------------------------------------------------------------------------*/
void
DisplayAudioClipsMethodTest :: setUp(void) throw ()
RpcDisplayAudioClipsTest :: setUp(void) throw ()
{
Ptr<AuthenticationClientFactory>::Ref acf;
try {
Ptr<StorageClientFactory>::Ref scf
= StorageClientFactory::getInstance();
configure(scf, storageClientConfig);
Ptr<StorageClientInterface>::Ref storage = scf->getStorageClient();
storage->reset();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
Ptr<ConnectionManagerFactory>::Ref cmf
= ConnectionManagerFactory::getInstance();
configure(cmf, connectionManagerConfig);
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfig);
CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL("semantic error in configuration file");
} catch (xmlpp::exception &e) {
CPPUNIT_FAIL("error parsing configuration file");
} catch (std::exception &e) {
CPPUNIT_FAIL(e.what());
}
authentication = acf->getAuthenticationClient();
if (!(sessionId = authentication->login("root", "q"))) {
CPPUNIT_FAIL("could not log in to authentication server");
}
parameters["login"] = "root";
parameters["password"] = "q";
CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("sessionId"));
xmlRpcClient.close();
sessionId.reset(new SessionId(std::string(result["sessionId"])));
}
@ -148,11 +84,18 @@ DisplayAudioClipsMethodTest :: setUp(void) throw ()
* Clean up the test environment
*----------------------------------------------------------------------------*/
void
DisplayAudioClipsMethodTest :: tearDown(void) throw ()
RpcDisplayAudioClipsTest :: tearDown(void) throw ()
{
authentication->logout(sessionId);
sessionId.reset();
authentication.reset();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
parameters["sessionId"] = sessionId->getId();
CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
xmlRpcClient.close();
}
@ -160,7 +103,7 @@ DisplayAudioClipsMethodTest :: tearDown(void) throw ()
* Just a very simple smoke test
*----------------------------------------------------------------------------*/
void
DisplayAudioClipsMethodTest :: firstTest(void)
RpcDisplayAudioClipsTest :: firstTest(void)
throw (CPPUNIT_NS::Exception)
{
XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
@ -171,7 +114,7 @@ DisplayAudioClipsMethodTest :: firstTest(void)
parameters["sessionId"] = sessionId->getId();
xmlRpcClient.execute("displayAudioClips", parameters, result);
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.size() == 2);
CPPUNIT_ASSERT(result.size() >= 2);
XmlRpc::XmlRpcValue audioClip = result[0];
CPPUNIT_ASSERT(audioClip.hasMember("id"));

View File

@ -22,12 +22,12 @@
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcDisplayAudioClipsTest.h,v $
------------------------------------------------------------------------------*/
#ifndef DisplayAudioClipsMethodTest_h
#define DisplayAudioClipsMethodTest_h
#ifndef RpcDisplayAudioClipsTest_h
#define RpcDisplayAudioClipsTest_h
#ifndef __cplusplus
#error This is a C++ include file
@ -42,15 +42,14 @@
#include <cppunit/extensions/HelperMacros.h>
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/SessionId.h"
namespace LiveSupport {
namespace Scheduler {
using namespace LiveSupport;
using namespace LiveSupport::Core;
using namespace LiveSupport::Authentication;
/* ================================================================ constants */
@ -64,59 +63,22 @@ using namespace LiveSupport::Authentication;
* Unit test for the DisplayAudioClipsMethod class.
*
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @see DisplayAudioClipsMethod
* @version $Revision: 1.3 $
* @see RpcDisplayAudioClips
*/
class DisplayAudioClipsMethodTest : public CPPUNIT_NS::TestFixture
class RpcDisplayAudioClipsTest : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE(DisplayAudioClipsMethodTest);
CPPUNIT_TEST_SUITE(RpcDisplayAudioClipsTest);
CPPUNIT_TEST(firstTest);
CPPUNIT_TEST_SUITE_END();
private:
/**
* The name of the configuration file for the storage client factory.
*/
static const std::string storageClientConfig;
/**
* The name of the configuration file for the connection manager
* factory.
*/
static const std::string connectionManagerConfig;
/**
* 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.
*
* @param configurable configure this
* @param fileName the name of the XML file to configure with.
* @exception std::invalid_argument on configuration errors.
* @exception xmlpp::exception on XML parsing errors.
*/
void
configure(Ptr<Configurable>::Ref configurable,
std::string fileName)
throw (std::invalid_argument,
xmlpp::exception);
protected:
/**
@ -153,5 +115,5 @@ class DisplayAudioClipsMethodTest : public CPPUNIT_NS::TestFixture
} // namespace Scheduler
} // namespace LiveSupport
#endif // DisplayAudioClipsMethodTest_h
#endif // RpcDisplayAudioClipsTest_h

View File

@ -22,39 +22,24 @@
Author : $Author: fgerlits $
Version : $Revision: 1.9 $
Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcDisplayPlaylistTest.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#else
#error "Need unistd.h"
#endif
#include <string>
#include <XmlRpcClient.h>
#include <XmlRpcValue.h>
#include "SchedulerDaemon.h"
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
#include "LiveSupport/Storage/StorageClientFactory.h"
#include "RpcDisplayPlaylistTest.h"
using namespace std;
using namespace XmlRpc;
using namespace LiveSupport::Core;
using namespace LiveSupport::Storage;
using namespace LiveSupport::Scheduler;
using namespace LiveSupport::Authentication;
using namespace LiveSupport::Core;
using namespace LiveSupport::Scheduler;
/* =================================================== local data structures */
@ -68,93 +53,35 @@ CPPUNIT_TEST_SUITE_REGISTRATION(RpcDisplayPlaylistTest);
*/
static const std::string configFileName = "etc/scheduler.xml";
/**
* The name of the configuration file for the storage client factory.
*/
static const std::string storageClientConfig =
"etc/storageClient.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
RpcDisplayPlaylistTest :: configure(
Ptr<Configurable>::Ref configurable,
const std::string & fileName)
throw (std::invalid_argument,
xmlpp::exception)
{
Ptr<xmlpp::DomParser>::Ref parser(new xmlpp::DomParser(fileName, true));
const xmlpp::Document * document = parser->get_document();
const xmlpp::Element * root = document->get_root_node();
configurable->configure(*root);
}
/*------------------------------------------------------------------------------
* Set up the test environment
*----------------------------------------------------------------------------*/
void
RpcDisplayPlaylistTest :: setUp(void) throw ()
{
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
if (!daemon->isConfigured()) {
try {
configure(daemon, configFileName);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("semantic error in scheduler configuration file");
} catch (xmlpp::exception &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("error parsing scheduler configuration file");
}
}
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
daemon->install();
// daemon->start();
// sleep(5);
CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
Ptr<AuthenticationClientFactory>::Ref acf;
try {
Ptr<StorageClientFactory>::Ref scf
= StorageClientFactory::getInstance();
configure(scf, storageClientConfig);
Ptr<StorageClientInterface>::Ref storage = scf->getStorageClient();
storage->reset();
parameters["login"] = "root";
parameters["password"] = "q";
CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("sessionId"));
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfigFileName);
xmlRpcClient.close();
} 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");
}
authentication = acf->getAuthenticationClient();
try {
sessionId = authentication->login("root", "q");
} catch (XmlRpcException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
sessionId.reset(new SessionId(std::string(result["sessionId"])));
}
@ -164,14 +91,16 @@ RpcDisplayPlaylistTest :: setUp(void) throw ()
void
RpcDisplayPlaylistTest :: tearDown(void) throw ()
{
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
// daemon->stop();
daemon->uninstall();
authentication->logout(sessionId);
sessionId.reset();
authentication.reset();
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
parameters["sessionId"] = sessionId->getId();
CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
xmlRpcClient.close();
}

View 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/RpcDisplayPlaylistTest.h,v $
------------------------------------------------------------------------------*/
@ -42,15 +42,14 @@
#include <cppunit/extensions/HelperMacros.h>
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/SessionId.h"
namespace LiveSupport {
namespace Scheduler {
using namespace LiveSupport;
using namespace LiveSupport::Core;
using namespace LiveSupport::Authentication;
/* ================================================================ constants */
@ -64,7 +63,7 @@ using namespace LiveSupport::Authentication;
* Unit test to test the displayPlaylist XML-RPC call.
*
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @version $Revision: 1.3 $
* @see SchedulerDaemon
*/
class RpcDisplayPlaylistTest : public CPPUNIT_NS::TestFixture
@ -75,30 +74,12 @@ class RpcDisplayPlaylistTest : public CPPUNIT_NS::TestFixture
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:
/**

View File

@ -22,67 +22,31 @@
Author : $Author: fgerlits $
Version : $Revision: 1.7 $
Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcDisplayPlaylistsTest.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#else
#error "Need unistd.h"
#endif
#include <string>
#include <iostream>
#include <vector>
#include <XmlRpcClient.h>
#include <XmlRpcValue.h>
#include "LiveSupport/Db/ConnectionManagerFactory.h"
#include "LiveSupport/Storage/StorageClientFactory.h"
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
#include "SchedulerDaemon.h"
#include "DisplayPlaylistsMethod.h"
#include "DisplayPlaylistsMethodTest.h"
#include "RpcDisplayPlaylistsTest.h"
using namespace LiveSupport::Db;
using namespace LiveSupport::Storage;
using namespace LiveSupport::Core;
using namespace LiveSupport::Scheduler;
using namespace LiveSupport::Authentication;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
CPPUNIT_TEST_SUITE_REGISTRATION(DisplayPlaylistsMethodTest);
/**
* The name of the configuration file for the storage client factory.
*/
const std::string DisplayPlaylistsMethodTest::storageClientConfig =
"etc/storageClient.xml";
/**
* The name of the configuration file for the connection manager factory.
*/
const std::string DisplayPlaylistsMethodTest::connectionManagerConfig =
"etc/connectionManagerFactory.xml";
/**
* The name of the configuration file for the authentication client factory.
*/
const std::string DisplayPlaylistsMethodTest::authenticationClientConfig =
"etc/authenticationClient.xml";
CPPUNIT_TEST_SUITE_REGISTRATION(RpcDisplayPlaylistsTest);
/* =============================================== local function prototypes */
@ -90,61 +54,29 @@ const std::string DisplayPlaylistsMethodTest::authenticationClientConfig =
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Configure a Configurable with an XML file.
*----------------------------------------------------------------------------*/
void
DisplayPlaylistsMethodTest :: configure(
Ptr<Configurable>::Ref configurable,
const std::string fileName)
throw (std::invalid_argument,
xmlpp::exception)
{
Ptr<xmlpp::DomParser>::Ref parser(new xmlpp::DomParser(fileName, true));
const xmlpp::Document * document = parser->get_document();
const xmlpp::Element * root = document->get_root_node();
configurable->configure(*root);
}
/*------------------------------------------------------------------------------
* Set up the test environment
*----------------------------------------------------------------------------*/
void
DisplayPlaylistsMethodTest :: setUp(void) throw ()
RpcDisplayPlaylistsTest :: setUp(void) throw ()
{
Ptr<AuthenticationClientFactory>::Ref acf;
try {
Ptr<StorageClientFactory>::Ref scf
= StorageClientFactory::getInstance();
configure(scf, storageClientConfig);
Ptr<StorageClientInterface>::Ref storage = scf->getStorageClient();
storage->reset();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
Ptr<ConnectionManagerFactory>::Ref cmf
= ConnectionManagerFactory::getInstance();
configure(cmf, connectionManagerConfig);
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfig);
CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL("semantic error in configuration file");
} catch (xmlpp::exception &e) {
CPPUNIT_FAIL("error parsing configuration file");
} catch (std::exception &e) {
CPPUNIT_FAIL(e.what());
}
authentication = acf->getAuthenticationClient();
try {
sessionId = authentication->login("root", "q");
} catch (XmlRpcException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
parameters["login"] = "root";
parameters["password"] = "q";
CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("sessionId"));
xmlRpcClient.close();
sessionId.reset(new SessionId(std::string(result["sessionId"])));
}
@ -152,11 +84,18 @@ DisplayPlaylistsMethodTest :: setUp(void) throw ()
* Clean up the test environment
*----------------------------------------------------------------------------*/
void
DisplayPlaylistsMethodTest :: tearDown(void) throw ()
RpcDisplayPlaylistsTest :: tearDown(void) throw ()
{
authentication->logout(sessionId);
sessionId.reset();
authentication.reset();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
parameters["sessionId"] = sessionId->getId();
CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
xmlRpcClient.close();
}
@ -164,7 +103,7 @@ DisplayPlaylistsMethodTest :: tearDown(void) throw ()
* Just a very simple smoke test
*----------------------------------------------------------------------------*/
void
DisplayPlaylistsMethodTest :: firstTest(void)
RpcDisplayPlaylistsTest :: firstTest(void)
throw (CPPUNIT_NS::Exception)
{
XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);

View File

@ -22,12 +22,12 @@
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcDisplayPlaylistsTest.h,v $
------------------------------------------------------------------------------*/
#ifndef DisplayPlaylistsMethodTest_h
#define DisplayPlaylistsMethodTest_h
#ifndef RpcDisplayPlaylistsTest_h
#define RpcDisplayPlaylistsTest_h
#ifndef __cplusplus
#error This is a C++ include file
@ -42,15 +42,14 @@
#include <cppunit/extensions/HelperMacros.h>
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/SessionId.h"
namespace LiveSupport {
namespace Scheduler {
using namespace LiveSupport;
using namespace LiveSupport::Core;
using namespace LiveSupport::Authentication;
/* ================================================================ constants */
@ -64,59 +63,22 @@ using namespace LiveSupport::Authentication;
* Unit test for the DisplayPlaylistsMethod class.
*
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @version $Revision: 1.3 $
* @see DisplayPlaylistsMethod
*/
class DisplayPlaylistsMethodTest : public CPPUNIT_NS::TestFixture
class RpcDisplayPlaylistsTest : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE(DisplayPlaylistsMethodTest);
CPPUNIT_TEST_SUITE(RpcDisplayPlaylistsTest);
CPPUNIT_TEST(firstTest);
CPPUNIT_TEST_SUITE_END();
private:
/**
* The name of the configuration file for the storage client factory.
*/
static const std::string storageClientConfig;
/**
* The name of the configuration file for the connection manager
* factory.
*/
static const std::string connectionManagerConfig;
/**
* 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.
*
* @param configurable configure this
* @param fileName the name of the XML file to configure with.
* @exception std::invalid_argument on configuration errors.
* @exception xmlpp::exception on XML parsing errors.
*/
void
configure(Ptr<Configurable>::Ref configurable,
std::string fileName)
throw (std::invalid_argument,
xmlpp::exception);
protected:
/**
@ -127,7 +89,6 @@ class DisplayPlaylistsMethodTest : public CPPUNIT_NS::TestFixture
void
firstTest(void) throw (CPPUNIT_NS::Exception);
public:
/**
@ -153,5 +114,5 @@ class DisplayPlaylistsMethodTest : public CPPUNIT_NS::TestFixture
} // namespace Scheduler
} // namespace LiveSupport
#endif // DisplayPlaylistsMethodTest_h
#endif // RpcDisplayPlaylistsTest_h

View File

@ -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/RpcDisplayScheduleTest.cxx,v $
------------------------------------------------------------------------------*/
@ -33,27 +33,17 @@
#include "configure.h"
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#else
#error "Need unistd.h"
#endif
#include <string>
#include <XmlRpcClient.h>
#include <XmlRpcValue.h>
#include "SchedulerDaemon.h"
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
#include "RpcDisplayScheduleTest.h"
using namespace std;
using namespace XmlRpc;
using namespace LiveSupport::Core;
using namespace LiveSupport::Scheduler;
using namespace LiveSupport::Authentication;
/* =================================================== local data structures */
@ -67,36 +57,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION(RpcDisplayScheduleTest);
*/
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
RpcDisplayScheduleTest :: 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
*----------------------------------------------------------------------------*/
@ -107,7 +73,11 @@ RpcDisplayScheduleTest :: setUp(void) throw ()
if (!daemon->isConfigured()) {
try {
configure(daemon, configFileName);
Ptr<xmlpp::DomParser>::Ref parser(new xmlpp::DomParser(
configFileName, true));
const xmlpp::Document * document = parser->get_document();
const xmlpp::Element * root = document->get_root_node();
daemon->configure(*root);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("semantic error in configuration file");
@ -118,30 +88,24 @@ RpcDisplayScheduleTest :: setUp(void) throw ()
}
daemon->install();
// daemon->start();
// sleep(5);
Ptr<AuthenticationClientFactory>::Ref acf;
try {
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfigFileName);
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
} 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");
}
authentication = acf->getAuthenticationClient();
try {
sessionId = authentication->login("root", "q");
} catch (XmlRpcException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
parameters["login"] = "root";
parameters["password"] = "q";
CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("sessionId"));
xmlRpcClient.close();
sessionId.reset(new SessionId(std::string(result["sessionId"])));
}
@ -151,14 +115,19 @@ RpcDisplayScheduleTest :: setUp(void) throw ()
void
RpcDisplayScheduleTest :: tearDown(void) throw ()
{
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
// daemon->stop();
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
parameters["sessionId"] = sessionId->getId();
CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
xmlRpcClient.close();
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
daemon->uninstall();
authentication->logout(sessionId);
sessionId.reset();
authentication.reset();
}

View 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/RpcDisplayScheduleTest.h,v $
------------------------------------------------------------------------------*/
@ -42,15 +42,14 @@
#include <cppunit/extensions/HelperMacros.h>
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/SessionId.h"
namespace LiveSupport {
namespace Scheduler {
using namespace LiveSupport;
using namespace LiveSupport::Core;
using namespace LiveSupport::Authentication;
/* ================================================================ constants */
@ -64,7 +63,7 @@ using namespace LiveSupport::Authentication;
* Unit test to test the displaySchedule XML-RPC call.
*
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @version $Revision: 1.3 $
* @see SchedulerDaemon
*/
class RpcDisplayScheduleTest : public CPPUNIT_NS::TestFixture
@ -74,30 +73,12 @@ class RpcDisplayScheduleTest : public CPPUNIT_NS::TestFixture
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:
/**

View File

@ -22,37 +22,25 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcGetSchedulerTimeTest.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#else
#error "Need unistd.h"
#endif
#include <string>
#include <XmlRpcClient.h>
#include <XmlRpcValue.h>
#include "SchedulerDaemon.h"
#include "RpcGetSchedulerTimeTest.h"
using namespace std;
using namespace XmlRpc;
using namespace LiveSupport::Core;
using namespace LiveSupport::Scheduler;
/* =================================================== local data structures */
@ -71,24 +59,6 @@ static const std::string configFileName = "etc/scheduler.xml";
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Configure a Configurable with an XML file.
*----------------------------------------------------------------------------*/
void
RpcGetSchedulerTimeTest :: 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
*----------------------------------------------------------------------------*/
@ -99,7 +69,11 @@ RpcGetSchedulerTimeTest :: setUp(void) throw ()
if (!daemon->isConfigured()) {
try {
configure(daemon, configFileName);
Ptr<xmlpp::DomParser>::Ref parser(new xmlpp::DomParser(
configFileName, true));
const xmlpp::Document * document = parser->get_document();
const xmlpp::Element * root = document->get_root_node();
daemon->configure(*root);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("semantic error in configuration file");
@ -110,8 +84,6 @@ RpcGetSchedulerTimeTest :: setUp(void) throw ()
}
daemon->install();
// daemon->start();
// sleep(5);
}
@ -122,8 +94,6 @@ void
RpcGetSchedulerTimeTest :: tearDown(void) throw ()
{
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
// daemon->stop();
daemon->uninstall();
}

View 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/RpcGetSchedulerTimeTest.h,v $
------------------------------------------------------------------------------*/
@ -42,10 +42,10 @@
#include <cppunit/extensions/HelperMacros.h>
namespace LiveSupport {
namespace Scheduler {
using namespace LiveSupport;
using namespace LiveSupport::Core;
/* ================================================================ constants */
@ -60,7 +60,7 @@ using namespace LiveSupport::Core;
* Unit test to test the getSchedulerTime XML-RPC call.
*
* @author $Author: fgerlits $
* @version $Revision: 1.3 $
* @version $Revision: 1.4 $
* @see SchedulerDaemon
*/
class RpcGetSchedulerTimeTest : public CPPUNIT_NS::TestFixture
@ -69,22 +69,6 @@ class RpcGetSchedulerTimeTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST(simpleTest);
CPPUNIT_TEST_SUITE_END();
private:
/**
* 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:
/**

View File

@ -22,37 +22,25 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcGetVersionTest.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#else
#error "Need unistd.h"
#endif
#include <string>
#include <XmlRpcClient.h>
#include <XmlRpcValue.h>
#include "SchedulerDaemon.h"
#include "RpcGetVersionTest.h"
using namespace std;
using namespace XmlRpc;
using namespace LiveSupport::Core;
using namespace LiveSupport::Scheduler;
/* =================================================== local data structures */
@ -60,11 +48,6 @@ using namespace LiveSupport::Scheduler;
CPPUNIT_TEST_SUITE_REGISTRATION(RpcGetVersionTest);
/**
* The name of the configuration file for the scheduler daemon.
*/
static const std::string configFileName = "etc/scheduler.xml";
/**
* The prefix of the persumed version string.
*/
@ -76,24 +59,6 @@ static const std::string versionPrefix = "LiveSupport Scheduler Daemon";
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Configure a Configurable with an XML file.
*----------------------------------------------------------------------------*/
void
RpcGetVersionTest :: 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
*----------------------------------------------------------------------------*/
@ -101,22 +66,7 @@ void
RpcGetVersionTest :: setUp(void) throw ()
{
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
if (!daemon->isConfigured()) {
try {
configure(daemon, configFileName);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("semantic error in configuration file");
} catch (xmlpp::exception &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("error parsing configuration file");
}
}
daemon->install();
// daemon->start();
// sleep(5);
}
@ -127,8 +77,6 @@ void
RpcGetVersionTest :: tearDown(void) throw ()
{
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
// daemon->stop();
daemon->uninstall();
}

View File

@ -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/RpcGetVersionTest.h,v $
------------------------------------------------------------------------------*/
@ -42,13 +42,10 @@
#include <cppunit/extensions/HelperMacros.h>
namespace LiveSupport {
namespace Scheduler {
using namespace LiveSupport;
using namespace LiveSupport::Core;
/* ================================================================ constants */
@ -60,8 +57,8 @@ using namespace LiveSupport::Core;
/**
* Unit test to test the getVersion XML-RPC call.
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @see SchedulerDaemon
*/
class RpcGetVersionTest : public CPPUNIT_NS::TestFixture
@ -70,21 +67,6 @@ class RpcGetVersionTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST(simpleTest);
CPPUNIT_TEST_SUITE_END();
private:
/**
* 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:
/**

View File

@ -22,37 +22,24 @@
Author : $Author: fgerlits $
Version : $Revision: 1.6 $
Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcRemoveFromScheduleTest.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#else
#error "Need unistd.h"
#endif
#include <string>
#include <XmlRpcClient.h>
#include <XmlRpcValue.h>
#include "SchedulerDaemon.h"
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
#include "RpcRemoveFromScheduleTest.h"
using namespace std;
using namespace XmlRpc;
using namespace LiveSupport::Core;
using namespace LiveSupport::Scheduler;
using namespace LiveSupport::Authentication;
/* =================================================== local data structures */
@ -62,41 +49,12 @@ using namespace LiveSupport::Authentication;
CPPUNIT_TEST_SUITE_REGISTRATION(RpcRemoveFromScheduleTest);
/**
* The name of the configuration file for the scheduler daemon.
*/
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
RpcRemoveFromScheduleTest :: 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
*----------------------------------------------------------------------------*/
@ -104,44 +62,25 @@ void
RpcRemoveFromScheduleTest :: setUp(void) throw ()
{
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
if (!daemon->isConfigured()) {
try {
configure(daemon, configFileName);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("semantic error in configuration file");
} catch (xmlpp::exception &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("error parsing configuration file");
}
}
daemon->install();
// daemon->start();
// sleep(5);
Ptr<AuthenticationClientFactory>::Ref acf;
try {
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfigFileName);
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
} 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");
}
authentication = acf->getAuthenticationClient();
try {
sessionId = authentication->login("root", "q");
} catch (XmlRpcException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
parameters["login"] = "root";
parameters["password"] = "q";
CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("sessionId"));
xmlRpcClient.close();
sessionId.reset(new SessionId(std::string(result["sessionId"])));
}
@ -151,14 +90,20 @@ RpcRemoveFromScheduleTest :: setUp(void) throw ()
void
RpcRemoveFromScheduleTest :: tearDown(void) throw ()
{
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
// daemon->stop();
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
parameters["sessionId"] = sessionId->getId();
CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
xmlRpcClient.close();
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
daemon->uninstall();
authentication->logout(sessionId);
sessionId.reset();
authentication.reset();
}

View 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/RpcRemoveFromScheduleTest.h,v $
------------------------------------------------------------------------------*/
@ -42,15 +42,14 @@
#include <cppunit/extensions/HelperMacros.h>
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/SessionId.h"
namespace LiveSupport {
namespace Scheduler {
using namespace LiveSupport;
using namespace LiveSupport::Core;
using namespace LiveSupport::Authentication;
/* ================================================================ constants */
@ -64,7 +63,7 @@ using namespace LiveSupport::Authentication;
* Unit test to test the removeFromSchedule XML-RPC call.
*
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @version $Revision: 1.3 $
* @see SchedulerDaemon
*/
class RpcRemoveFromScheduleTest : public CPPUNIT_NS::TestFixture
@ -75,30 +74,12 @@ class RpcRemoveFromScheduleTest : public CPPUNIT_NS::TestFixture
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:
/**

View File

@ -22,37 +22,24 @@
Author : $Author: fgerlits $
Version : $Revision: 1.6 $
Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcRescheduleTest.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#else
#error "Need unistd.h"
#endif
#include <string>
#include <XmlRpcClient.h>
#include <XmlRpcValue.h>
#include "SchedulerDaemon.h"
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
#include "RpcRescheduleTest.h"
using namespace XmlRpc;
using namespace LiveSupport::Core;
using namespace LiveSupport::Scheduler;
using namespace LiveSupport::Authentication;
/* =================================================== local data structures */
@ -66,36 +53,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION(RpcRescheduleTest);
*/
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
RpcRescheduleTest :: 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
*----------------------------------------------------------------------------*/
@ -106,7 +69,11 @@ RpcRescheduleTest :: setUp(void) throw ()
if (!daemon->isConfigured()) {
try {
configure(daemon, configFileName);
Ptr<xmlpp::DomParser>::Ref parser(new xmlpp::DomParser(
configFileName, true));
const xmlpp::Document * document = parser->get_document();
const xmlpp::Element * root = document->get_root_node();
daemon->configure(*root);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("semantic error in configuration file");
@ -117,30 +84,24 @@ RpcRescheduleTest :: setUp(void) throw ()
}
daemon->install();
// daemon->start();
// sleep(5);
Ptr<AuthenticationClientFactory>::Ref acf;
try {
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfigFileName);
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
} 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");
}
authentication = acf->getAuthenticationClient();
try {
sessionId = authentication->login("root", "q");
} catch (XmlRpcException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
parameters["login"] = "root";
parameters["password"] = "q";
CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("sessionId"));
xmlRpcClient.close();
sessionId.reset(new SessionId(std::string(result["sessionId"])));
}
@ -150,14 +111,19 @@ RpcRescheduleTest :: setUp(void) throw ()
void
RpcRescheduleTest :: tearDown(void) throw ()
{
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
// daemon->stop();
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
parameters["sessionId"] = sessionId->getId();
CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
xmlRpcClient.close();
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
daemon->uninstall();
authentication->logout(sessionId);
sessionId.reset();
authentication.reset();
}
@ -168,11 +134,11 @@ void
RpcRescheduleTest :: simpleTest(void)
throw (CPPUNIT_NS::Exception)
{
XmlRpcValue parameters;
XmlRpcValue result;
struct tm time;
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
struct tm time;
XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
// first schedule a playlist, so that there is something to reschedule
parameters["sessionId"] = sessionId->getId();
@ -235,10 +201,10 @@ void
RpcRescheduleTest :: negativeTest(void)
throw (CPPUNIT_NS::Exception)
{
XmlRpcValue parameters;
XmlRpcValue result;
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
parameters["sessionId"] = sessionId->getId();
parameters["scheduleEntryId"] = "0000000000009999";

View 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/RpcRescheduleTest.h,v $
------------------------------------------------------------------------------*/
@ -42,15 +42,14 @@
#include <cppunit/extensions/HelperMacros.h>
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/SessionId.h"
namespace LiveSupport {
namespace Scheduler {
using namespace LiveSupport;
using namespace LiveSupport::Core;
using namespace LiveSupport::Authentication;
/* ================================================================ constants */
@ -64,7 +63,7 @@ using namespace LiveSupport::Authentication;
* Unit test to test the removeFromSchedule XML-RPC call.
*
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @version $Revision: 1.3 $
* @see SchedulerDaemon
*/
class RpcRescheduleTest : public CPPUNIT_NS::TestFixture
@ -75,30 +74,12 @@ class RpcRescheduleTest : public CPPUNIT_NS::TestFixture
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:
/**

View File

@ -22,42 +22,24 @@
Author : $Author: fgerlits $
Version : $Revision: 1.8 $
Version : $Revision: 1.9 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcUploadPlaylistTest.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#else
#error "Need unistd.h"
#endif
#include <string>
#include <XmlRpcClient.h>
#include <XmlRpcValue.h>
#include "LiveSupport/Core/XmlRpcTools.h"
#include "LiveSupport/Core/UniqueId.h"
#include "SchedulerDaemon.h"
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
#include "LiveSupport/Storage/StorageClientFactory.h"
#include "RpcUploadPlaylistTest.h"
using namespace std;
using namespace XmlRpc;
using namespace LiveSupport::Core;
using namespace LiveSupport::Scheduler;
using namespace LiveSupport::Authentication;
using namespace LiveSupport::Storage;
/* =================================================== local data structures */
@ -71,41 +53,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION(RpcUploadPlaylistTest);
*/
static const std::string configFileName = "etc/scheduler.xml";
/**
* The name of the configuration file for the storage client factory.
*/
static const std::string storageClientConfig =
"etc/storageClient.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
RpcUploadPlaylistTest :: 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
*----------------------------------------------------------------------------*/
@ -116,7 +69,11 @@ RpcUploadPlaylistTest :: setUp(void) throw ()
if (!daemon->isConfigured()) {
try {
configure(daemon, configFileName);
Ptr<xmlpp::DomParser>::Ref parser(new xmlpp::DomParser(
configFileName, true));
const xmlpp::Document * document = parser->get_document();
const xmlpp::Element * root = document->get_root_node();
daemon->configure(*root);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
CPPUNIT_FAIL("semantic error in configuration file");
@ -127,36 +84,24 @@ RpcUploadPlaylistTest :: setUp(void) throw ()
}
daemon->install();
// daemon->start();
// sleep(5);
Ptr<AuthenticationClientFactory>::Ref acf;
try {
Ptr<StorageClientFactory>::Ref scf
= StorageClientFactory::getInstance();
configure(scf, storageClientConfig);
Ptr<StorageClientInterface>::Ref storage = scf->getStorageClient();
storage->reset();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
acf = AuthenticationClientFactory::getInstance();
configure(acf, authenticationClientConfigFileName);
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
} 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");
}
authentication = acf->getAuthenticationClient();
try {
sessionId = authentication->login("root", "q");
} catch (XmlRpcException &e) {
std::string eMsg = "could not log in:\n";
eMsg += e.what();
CPPUNIT_FAIL(eMsg);
}
CPPUNIT_ASSERT(xmlRpcClient.execute("resetStorage", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
parameters["login"] = "root";
parameters["password"] = "q";
CPPUNIT_ASSERT(xmlRpcClient.execute("login", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
CPPUNIT_ASSERT(result.hasMember("sessionId"));
xmlRpcClient.close();
sessionId.reset(new SessionId(std::string(result["sessionId"])));
}
@ -166,14 +111,19 @@ RpcUploadPlaylistTest :: setUp(void) throw ()
void
RpcUploadPlaylistTest :: tearDown(void) throw ()
{
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
// daemon->stop();
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
parameters["sessionId"] = sessionId->getId();
CPPUNIT_ASSERT(xmlRpcClient.execute("logout", parameters, result));
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
xmlRpcClient.close();
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
daemon->uninstall();
authentication->logout(sessionId);
sessionId.reset();
authentication.reset();
}
@ -184,13 +134,14 @@ void
RpcUploadPlaylistTest :: simpleTest(void)
throw (CPPUNIT_NS::Exception)
{
XmlRpcValue parameters;
XmlRpcValue result;
struct tm time;
XmlRpc::XmlRpcValue parameters;
XmlRpc::XmlRpcValue result;
struct tm time;
XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
XmlRpc::XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
// try to schedule playlist #1 for the time below
parameters.clear();
parameters["sessionId"] = sessionId->getId();
parameters["playlistId"] = "0000000000000001";
time.tm_year = 2001;

View 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/RpcUploadPlaylistTest.h,v $
------------------------------------------------------------------------------*/
@ -42,15 +42,14 @@
#include <cppunit/extensions/HelperMacros.h>
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/SessionId.h"
namespace LiveSupport {
namespace Scheduler {
using namespace LiveSupport;
using namespace LiveSupport::Core;
using namespace LiveSupport::Authentication;
/* ================================================================ constants */
@ -64,7 +63,7 @@ using namespace LiveSupport::Authentication;
* Unit test to test the uploadPlaylist XML-RPC call.
*
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @version $Revision: 1.3 $
* @see SchedulerDaemon
*/
class RpcUploadPlaylistTest : public CPPUNIT_NS::TestFixture
@ -74,30 +73,12 @@ class RpcUploadPlaylistTest : public CPPUNIT_NS::TestFixture
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:
/**

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.20 $
Version : $Revision: 1.21 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.cxx,v $
------------------------------------------------------------------------------*/
@ -139,6 +139,9 @@ SchedulerDaemon :: SchedulerDaemon (void) throw ()
updateFadeInFadeOutMethod.reset(new UpdateFadeInFadeOutMethod());
uploadPlaylistMethod.reset(new UploadPlaylistMethod());
validatePlaylistMethod.reset(new ValidatePlaylistMethod());
loginMethod.reset(new LoginMethod());
logoutMethod.reset(new LogoutMethod());
resetStorageMethod.reset(new ResetStorageMethod());
}
@ -323,6 +326,9 @@ SchedulerDaemon :: registerXmlRpcFunctions(
xmlRpcServer->addMethod(updateFadeInFadeOutMethod.get());
xmlRpcServer->addMethod(uploadPlaylistMethod.get());
xmlRpcServer->addMethod(validatePlaylistMethod.get());
xmlRpcServer->addMethod(loginMethod.get());
xmlRpcServer->addMethod(logoutMethod.get());
xmlRpcServer->addMethod(resetStorageMethod.get());
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.15 $
Version : $Revision: 1.16 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.h,v $
------------------------------------------------------------------------------*/
@ -85,6 +85,9 @@
#include "UploadPlaylistMethod.h"
#include "ValidatePlaylistMethod.h"
#include "XmlRpcDaemon.h"
#include "LoginMethod.h"
#include "LogoutMethod.h"
#include "ResetStorageMethod.h"
namespace LiveSupport {
@ -158,7 +161,7 @@ using namespace LiveSupport::PlaylistExecutor;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.15 $
* @version $Revision: 1.16 $
* @see ConnectionManagerFactory
* @see AuthenticationClientFactory
* @see StorageClientFactory
@ -298,6 +301,21 @@ class SchedulerDaemon : public Installable,
*/
Ptr<ValidatePlaylistMethod>::Ref validatePlaylistMethod;
/**
* The loginMethod the daemon is providing.
*/
Ptr<LoginMethod>::Ref loginMethod;
/**
* The logoutMethod the daemon is providing.
*/
Ptr<LogoutMethod>::Ref logoutMethod;
/**
* The resetStorageMethod the daemon is providing.
*/
Ptr<ResetStorageMethod>::Ref resetStorageMethod;
/**
* Default constructor.
*/