moved AuthenticationClientInterface.h from Core to Authentication

moved StorageClientInterface.h from Core to Storage
added tests for AuthenticationClientFactory and StorageClientFactory
This commit is contained in:
fgerlits 2004-12-15 20:36:26 +00:00
parent 1796f4b4a3
commit 8d8eaa93be
15 changed files with 549 additions and 47 deletions

View file

@ -20,8 +20,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# Author : $Author: maroy $
# Version : $Revision: 1.8 $
# Author : $Author: fgerlits $
# Version : $Revision: 1.9 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/etc/Makefile.in,v $
#
# @configure_input@
@ -106,9 +106,10 @@ STORAGE_LIB_OBJS = ${TMP_DIR}/StorageClientFactory.o \
${TMP_DIR}/TestStorageClient.o \
${TMP_DIR}/WebStorageClient.o
TEST_RUNNER_OBJS = ${TMP_DIR}/TestStorageClientTest.o \
${TMP_DIR}/WebStorageClientTest.o \
${TMP_DIR}/TestRunner.o
TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \
${TMP_DIR}/StorageClientFactoryTest.o \
${TMP_DIR}/TestStorageClientTest.o \
${TMP_DIR}/WebStorageClientTest.o
TEST_RUNNER_LIBS = -l${STORAGE_LIB} -l${CORE_LIB} -l${AUTHENTICATION_LIB} \
-lxml++-1.0 -lcppunit -ldl -lxmlrpc++ -lssl

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.5 $
Author : $Author: fgerlits $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientFactory.h,v $
------------------------------------------------------------------------------*/
@ -43,7 +43,7 @@
#include <stdexcept>
#include "LiveSupport/Core/Configurable.h"
#include "LiveSupport/Core/StorageClientInterface.h"
#include "LiveSupport/Storage/StorageClientInterface.h"
namespace LiveSupport {
@ -98,8 +98,8 @@ using namespace LiveSupport::Core;
* <!ELEMENT storageClientFactory (testStorage|webStorage) >
* </code></pre>
*
* @author $Author: maroy $
* @version $Revision: 1.5 $
* @author $Author: fgerlits $
* @version $Revision: 1.6 $
* @see TestStorageClient
* @see WebStorageClient
*/

View file

@ -0,0 +1,308 @@
/*------------------------------------------------------------------------------
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/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h,v $
------------------------------------------------------------------------------*/
#ifndef LiveSupport_Storage_StorageClientInterface_h
#define LiveSupport_Storage_StorageClientInterface_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <stdexcept>
#include "LiveSupport/Core/UniqueId.h"
#include "LiveSupport/Core/Playlist.h"
#include "LiveSupport/Core/SessionId.h"
namespace LiveSupport {
namespace Storage {
using namespace Core;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* An interface for storage clients.
*
* @author $Author: fgerlits $
* @version $Revision: 1.1 $
*/
class StorageClientInterface
{
public:
/**
* Tell if a playlist with a given id exists.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to check for.
* @return true if a playlist with the specified id exists,
* false otherwise.
*/
virtual const bool
existsPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
= 0;
/**
* Return a playlist with the specified id, to be displayed.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to return.
* @return the requested playlist.
* @exception std::logic_error if no playlist with the specified
* id exists.
*/
virtual Ptr<Playlist>::Ref
getPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
= 0;
/**
* Return a playlist with the specified id, to be edited.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to return.
* @return the requested playlist.
* @exception std::logic_error if no playlist with the specified
* id exists.
*/
virtual Ptr<Playlist>::Ref
editPlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
= 0;
/**
* Save the playlist after editing.
*
* @param sessionId the session ID from the authentication client
* @param playlist the playlist to save.
* @exception std::logic_error if the playlist has not been previously
* opened by getPlaylist()
*/
virtual void
savePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error)
= 0;
/**
* Acquire the resources for the playlist.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to acquire.
* @return a new Playlist instance containing a uri field which
* points to an executable (playable) SMIL representation of
* the playlist (in the local storage).
* @exception std::logic_error if no playlist with the specified
* specified id exists.
*/
virtual Ptr<Playlist>::Ref
acquirePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
= 0;
/**
* Release the resources (audio clips, other playlists) used
* in a playlist.
*
* @param sessionId the session ID from the authentication client
* @param playlist the playlist to release.
* @exception std::logic_error if the playlist has no uri field,
* or the file does not exist, etc.
*/
virtual void
releasePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref playlist) const
throw (std::logic_error)
= 0;
/**
* Delete a playlist with the specified id.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the playlist to be deleted.
* @exception std::logic_error if no playlist with the specified
* id exists.
*/
virtual void
deletePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::logic_error)
= 0;
/**
* Return a list of all playlists in the playlist store.
*
* @param sessionId the session ID from the authentication client
* @return a vector containing the playlists.
*/
virtual Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
getAllPlaylists(Ptr<SessionId>::Ref sessionId) const
throw (std::logic_error)
= 0;
/**
* Create a new playlist.
*
* @param sessionId the session ID from the authentication client
* @return the newly created playlist.
*/
virtual Ptr<Playlist>::Ref
createPlaylist(Ptr<SessionId>::Ref sessionId)
throw (std::logic_error)
= 0;
/**
* Tell if an audio clip with a given id exists.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the audio clip to check for.
* @return true if an audio clip with the specified id exists,
* false otherwise.
*/
virtual const bool
existsAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
= 0;
/**
* Return an audio clip with the specified id.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the audio clip to return.
* @return the requested audio clip.
* @exception std::logic_error if no audio clip with the
* specified id exists.
*/
virtual Ptr<AudioClip>::Ref
getAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
= 0;
/**
* Store an audio clip.
*
* @param sessionId the session ID from the authentication client
* @param audioClip the audio clip to store.
* @return true if the operation was successful.
*
* @exception std::logic_error if we have not logged in yet.
*/
virtual bool
storeAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip)
throw (std::logic_error)
= 0;
/**
* Acquire the resources for the audio clip with the specified id.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the audio clip to acquire.
* @return a new AudioClip instance, containing a uri field which
* points to (a way of getting) the sound file.
* @exception std::logic_error if no audio clip with the
* specified id exists.
*/
virtual Ptr<AudioClip>::Ref
acquireAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id) const
throw (std::logic_error)
= 0;
/**
* Release the resource (sound file) used by an audio clip.
*
* @param sessionId the session ID from the authentication client
* @param audioClip the id of the audio clip to release.
* @exception std::logic_error if the audio clip has no uri field,
* or the file does not exist, etc.
*/
virtual void
releaseAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<AudioClip>::Ref audioClip) const
throw (std::logic_error)
= 0;
/**
* Delete an audio clip with the specified id.
*
* @param sessionId the session ID from the authentication client
* @param id the id of the audio clip to be deleted.
* @exception std::logic_error if no audio clip with the
* specified id exists.
*/
virtual void
deleteAudioClip(Ptr<SessionId>::Ref sessionId,
Ptr<UniqueId>::Ref id)
throw (std::logic_error)
= 0;
/**
* Return a list of all audio clips in the playlist store.
*
* @param sessionId the session ID from the authentication client
* @return a vector containing the playlists.
*/
virtual Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref
getAllAudioClips(Ptr<SessionId>::Ref sessionId) const
throw (std::logic_error)
= 0;
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace Storage
} // namespace LiveSupport
#endif // LiveSupport_Storage_StorageClientInterface_h

View file

@ -0,0 +1,158 @@
/*------------------------------------------------------------------------------
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/modules/storage/src/StorageClientFactoryTest.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 <fstream>
#include <iostream>
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
#include "LiveSupport/Storage/StorageClientFactory.h"
#include "LiveSupport/Storage/StorageClientInterface.h"
#include "StorageClientFactoryTest.h"
using namespace std;
using namespace LiveSupport::Core;
using namespace LiveSupport::Authentication;
using namespace LiveSupport::Storage;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
CPPUNIT_TEST_SUITE_REGISTRATION(StorageClientFactoryTest);
/**
* The name of the configuration file for the storage client factory.
*/
static const std::string storageConfig = "etc/storageClient.xml";
/**
* The name of the configuration file for the authentication client factory.
*/
static const std::string authenticationConfig = "etc/authenticationClient.xml";
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Set up the test environment
*----------------------------------------------------------------------------*/
void
StorageClientFactoryTest :: setUp(void) throw ()
{
Ptr<AuthenticationClientFactory>::Ref
acf = AuthenticationClientFactory::getInstance();
try {
Ptr<xmlpp::DomParser>::Ref parser(
new xmlpp::DomParser(authenticationConfig, true));
const xmlpp::Document * document = parser->get_document();
const xmlpp::Element * root = document->get_root_node();
acf->configure(*root);
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL("semantic error in authentication configuration file");
} catch (xmlpp::exception &e) {
CPPUNIT_FAIL("error parsing authentication configuration file");
}
Ptr<StorageClientFactory>::Ref
scf = StorageClientFactory::getInstance();
try {
Ptr<xmlpp::DomParser>::Ref parser(
new xmlpp::DomParser(storageConfig, true));
const xmlpp::Document * document = parser->get_document();
const xmlpp::Element * root = document->get_root_node();
scf->configure(*root);
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL("semantic error in storage configuration file");
} catch (xmlpp::exception &e) {
CPPUNIT_FAIL("error parsing storage configuration file");
}
}
/*------------------------------------------------------------------------------
* Clean up the test environment
*----------------------------------------------------------------------------*/
void
StorageClientFactoryTest :: tearDown(void) throw ()
{
}
/*------------------------------------------------------------------------------
* Test to see if we can do some simple operations
*----------------------------------------------------------------------------*/
void
StorageClientFactoryTest :: firstTest(void)
throw (CPPUNIT_NS::Exception)
{
Ptr<StorageClientFactory>::Ref
scf = StorageClientFactory::getInstance();
Ptr<StorageClientInterface>::Ref
storage = scf->getStorageClient();
Ptr<AuthenticationClientFactory>::Ref
acf = AuthenticationClientFactory::getInstance();
Ptr<AuthenticationClientInterface>::Ref
authentication = acf->getAuthenticationClient();
Ptr<SessionId>::Ref
sessionId = authentication->login("root", "q");
CPPUNIT_ASSERT(sessionId);
Ptr<UniqueId>::Ref id01(new UniqueId(1));
Ptr<UniqueId>::Ref id77(new UniqueId(77));
CPPUNIT_ASSERT( storage->existsPlaylist(sessionId, id01));
CPPUNIT_ASSERT(!storage->existsPlaylist(sessionId, id77));
Ptr<Playlist>::Ref playlist = storage->getPlaylist(sessionId, id01);
CPPUNIT_ASSERT(playlist->getId()->getId() == id01->getId());
}

View file

@ -0,0 +1,107 @@
/*------------------------------------------------------------------------------
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/modules/storage/src/StorageClientFactoryTest.h,v $
------------------------------------------------------------------------------*/
#ifndef StorageClientFactoryTest_h
#define StorageClientFactoryTest_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 Storage {
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* Unit test for the StorageClientFactory class.
*
* @author $Author: fgerlits $
* @version $Revision: 1.1 $
* @see StorageClientFactory
*/
class StorageClientFactoryTest : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE(StorageClientFactoryTest);
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 Storage
} // namespace LiveSupport
#endif // StorageClientFactoryTest_h

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.18 $
Version : $Revision: 1.19 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.h,v $
------------------------------------------------------------------------------*/
@ -46,8 +46,8 @@
#include "LiveSupport/Core/UniqueId.h"
#include "LiveSupport/Core/Playlist.h"
#include "LiveSupport/Core/Configurable.h"
#include "LiveSupport/Core/StorageClientInterface.h"
#include "LiveSupport/Core/SessionId.h"
#include "LiveSupport/Storage/StorageClientInterface.h"
namespace LiveSupport {
@ -90,7 +90,7 @@ using namespace LiveSupport::Core;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.18 $
* @version $Revision: 1.19 $
*/
class TestStorageClient :
virtual public Configurable,

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.7 $
Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.h,v $
------------------------------------------------------------------------------*/
@ -46,8 +46,8 @@
#include "LiveSupport/Core/UniqueId.h"
#include "LiveSupport/Core/Playlist.h"
#include "LiveSupport/Core/Configurable.h"
#include "LiveSupport/Core/StorageClientInterface.h"
#include "LiveSupport/Core/SessionId.h"
#include "LiveSupport/Storage/StorageClientInterface.h"
namespace LiveSupport {
@ -99,7 +99,7 @@ using namespace LiveSupport::Core;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.7 $
* @version $Revision: 1.8 $
*/
class WebStorageClient :
virtual public Configurable,

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/modules/storage/src/WebStorageClientTest.h,v $
------------------------------------------------------------------------------*/
@ -42,13 +42,14 @@
#include <cppunit/extensions/HelperMacros.h>
#include "LiveSupport/Core/AuthenticationClientInterface.h"
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
namespace LiveSupport {
namespace Storage {
using namespace LiveSupport::Core;
using namespace LiveSupport::Authentication;
/* ================================================================ constants */
@ -62,7 +63,7 @@ using namespace LiveSupport::Core;
* Unit test for the UploadPlaylistMetohd class.
*
* @author $Author: fgerlits $
* @version $Revision: 1.3 $
* @version $Revision: 1.4 $
* @see WebStorageClient
*/
class WebStorageClientTest : public CPPUNIT_NS::TestFixture