added & checked the first new Rpc...Test (the others should now be easy)
This commit is contained in:
parent
089744e465
commit
fe6a11cab1
|
@ -20,8 +20,8 @@
|
|||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#
|
||||
# Author : $Author: maroy $
|
||||
# Version : $Revision: 1.31 $
|
||||
# Author : $Author: fgerlits $
|
||||
# Version : $Revision: 1.32 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
|
||||
#
|
||||
# @configure_input@
|
||||
|
@ -193,6 +193,7 @@ TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \
|
|||
${TMP_DIR}/RpcDisplayPlaylistTest.o \
|
||||
${TMP_DIR}/RpcRemoveFromScheduleTest.o \
|
||||
${TMP_DIR}/RpcRescheduleTest.o \
|
||||
${TMP_DIR}/RpcAddAudioClipToPlaylistTest.o \
|
||||
${TMP_DIR}/XmlRpcToolsTest.o \
|
||||
${TMP_DIR}/GetVersionMethodTest.o \
|
||||
${TMP_DIR}/RpcGetVersionTest.o \
|
||||
|
|
|
@ -13,13 +13,27 @@
|
|||
|
||||
<!ELEMENT storageClientFactory (testStorage) >
|
||||
|
||||
<!ELEMENT testStorage (playlist*) >
|
||||
<!ELEMENT testStorage (playlist*, audioClip*) >
|
||||
<!ATTLIST testStorage tempFiles CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT playlist EMPTY >
|
||||
<!ELEMENT playlist (playlistElement*) >
|
||||
<!ATTLIST playlist id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlist playlength NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT playlistElement ((audioClip|playlist), fadeInfo?) >
|
||||
<!ATTLIST playlistElement id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlistElement relativeOffset NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT audioClip EMPTY >
|
||||
<!ATTLIST audioClip id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST audioClip playlength NMTOKEN #REQUIRED >
|
||||
<!ATTLIST audioClip uri CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT fadeInfo EMPTY >
|
||||
<!ATTLIST fadeInfo id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST fadeInfo fadeIn NMTOKEN #REQUIRED >
|
||||
<!ATTLIST fadeInfo fadeOut NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT scheduleFactory (postgresqlSchedule) >
|
||||
<!ELEMENT postgresqlSchedule EMPTY >
|
||||
|
||||
|
@ -48,7 +62,20 @@
|
|||
|
||||
<storageClientFactory>
|
||||
<testStorage tempFiles="file:///tmp/tempPlaylist">
|
||||
<playlist id="1" playlength="01:00:00.00"/>
|
||||
<playlist id="1" playlength="01:30:00.000">
|
||||
<playlistElement id="101" relativeOffset="0" >
|
||||
<audioClip id="10001" playlength="01:00:00.000"
|
||||
uri="file:var/test1.mp3" />
|
||||
</playlistElement>
|
||||
<playlistElement id="102" relativeOffset="01:00:00.000" >
|
||||
<audioClip id="10002" playlength="00:30:00.000"
|
||||
uri="file:var/test2.mp3" />
|
||||
</playlistElement>
|
||||
</playlist>
|
||||
<audioClip id="10001" playlength="01:00:00.000"
|
||||
uri="file:var/test1.mp3" />
|
||||
<audioClip id="10002" playlength="00:30:00.000"
|
||||
uri="file:var/test2.mp3" />
|
||||
</testStorage>
|
||||
</storageClientFactory>
|
||||
|
||||
|
|
|
@ -0,0 +1,220 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/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 "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::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
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);
|
||||
|
||||
try {
|
||||
Ptr<StorageClientFactory>::Ref scf
|
||||
= StorageClientFactory::getInstance();
|
||||
configure(scf, storageClientConfig);
|
||||
} 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();
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RpcAddAudioClipToPlaylistTest :: tearDown(void) throw ()
|
||||
{
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
|
||||
Ptr<SchedulerDaemon>::Ref daemon = SchedulerDaemon::getInstance();
|
||||
// daemon->stop();
|
||||
// sleep(2);
|
||||
daemon->uninstall();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Just a very simple smoke test
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
RpcAddAudioClipToPlaylistTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<OpenPlaylistForEditingMethod>::Ref
|
||||
openPlaylistMethod(new OpenPlaylistForEditingMethod());
|
||||
Ptr<AddAudioClipToPlaylistMethod>::Ref
|
||||
addAudioClipMethod(new AddAudioClipToPlaylistMethod());
|
||||
|
||||
XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false);
|
||||
XmlRpc::XmlRpcValue parameters;
|
||||
XmlRpc::XmlRpcValue result;
|
||||
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
parameters["audioClipId"] = 10001;
|
||||
parameters["relativeOffset"] = 0;
|
||||
|
||||
result.clear();
|
||||
xmlRpcClient.execute("openPlaylistForEditing", parameters, result);
|
||||
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
|
||||
CPPUNIT_ASSERT(result.hasMember("id"));
|
||||
CPPUNIT_ASSERT(int(result["id"]) == 1);
|
||||
|
||||
result.clear();
|
||||
xmlRpcClient.execute("addAudioClipToPlaylist", parameters, result);
|
||||
CPPUNIT_ASSERT(xmlRpcClient.isFault());
|
||||
|
||||
parameters.clear();
|
||||
parameters["sessionId"] = sessionId->getId();
|
||||
parameters["playlistId"] = 1;
|
||||
parameters["audioClipId"] = 10001;
|
||||
parameters["relativeOffset"] = 90*60;
|
||||
|
||||
result.clear();
|
||||
xmlRpcClient.execute("addAudioClipToPlaylist", parameters, result);
|
||||
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/RpcAddAudioClipToPlaylistTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef RpcAddAudioClipToPlaylistTest_h
|
||||
#define RpcAddAudioClipToPlaylistTest_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>
|
||||
|
||||
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the AddAudioClipToPlaylistMethod class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see AddAudioClipToPlaylistMethod
|
||||
*/
|
||||
class RpcAddAudioClipToPlaylistTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(RpcAddAudioClipToPlaylistTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
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:
|
||||
|
||||
/**
|
||||
* 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 // RpcAddAudioClipToPlaylistTest_h
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcDisplayPlaylistTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -176,7 +176,7 @@ RpcDisplayPlaylistTest :: simpleTest(void)
|
|||
xmlRpcClient.execute("displayPlaylist", parameters, result);
|
||||
CPPUNIT_ASSERT(!xmlRpcClient.isFault());
|
||||
CPPUNIT_ASSERT(((int) result["id"]) == 1);
|
||||
CPPUNIT_ASSERT(((int) result["playlength"]) == (60 * 60));
|
||||
CPPUNIT_ASSERT(((int) result["playlength"]) == (90 * 60));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.12 $
|
||||
Version : $Revision: 1.13 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -108,8 +108,8 @@ SchedulerDaemon :: SchedulerDaemon (void) throw ()
|
|||
displayPlaylistMethod.reset(new DisplayPlaylistMethod());
|
||||
removeFromScheduleMethod.reset(new RemoveFromScheduleMethod());
|
||||
rescheduleMethod.reset(new RescheduleMethod());
|
||||
openPlaylistForEditingMethod.reset(new OpenPlaylistForEditingMethod());
|
||||
addAudioClipToPlaylistMethod.reset(new AddAudioClipToPlaylistMethod());
|
||||
openPlaylistForEditingMethod.reset(new OpenPlaylistForEditingMethod());
|
||||
}
|
||||
|
||||
|
||||
|
@ -237,8 +237,12 @@ SchedulerDaemon :: install(void) throw (std::exception)
|
|||
{
|
||||
// TODO: check if we have already been configured
|
||||
Ptr<ScheduleFactory>::Ref sf = ScheduleFactory::getInstance();
|
||||
sf->install();
|
||||
|
||||
try {
|
||||
sf->install();
|
||||
}
|
||||
catch (std::exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
Ptr<PlayLogFactory>::Ref plf = PlayLogFactory::getInstance();
|
||||
plf->install();
|
||||
}
|
||||
|
@ -251,8 +255,8 @@ void
|
|||
SchedulerDaemon :: uninstall(void) throw (std::exception)
|
||||
{
|
||||
// TODO: check if we have already been configured
|
||||
Ptr<PlayLogFactory>::Ref plf = PlayLogFactory::getInstance();
|
||||
try {
|
||||
Ptr<PlayLogFactory>::Ref plf = PlayLogFactory::getInstance();
|
||||
plf->uninstall();
|
||||
}
|
||||
catch (std::exception &e) {
|
||||
|
|
Loading…
Reference in New Issue