added embedded playlist test case

workaround for WebStorageClient::acquirePlaylist
see http://bugs.campware.org/view.php?id=1440
This commit is contained in:
maroy 2005-09-04 12:39:25 +00:00
parent 8dbcf2182c
commit f961cee180
3 changed files with 84 additions and 12 deletions

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.47 $
Author : $Author: maroy $
Version : $Revision: 1.48 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $
------------------------------------------------------------------------------*/
@ -394,6 +394,11 @@ static const std::string getPlaylistSessionIdParamName = "sessid";
*----------------------------------------------------------------------------*/
static const std::string getPlaylistPlaylistIdParamName = "plid";
/*------------------------------------------------------------------------------
* The name of the recursive parameter in the input structure
*----------------------------------------------------------------------------*/
static const std::string getPlaylistRecursiveParamName = "recursive";
/*------------------------------------------------------------------------------
* The name of the result URL parameter returned by the method
*----------------------------------------------------------------------------*/
@ -931,7 +936,9 @@ WebStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
= sessionId->getId();
parameters[getPlaylistPlaylistIdParamName]
= std::string(*id);
parameters[getPlaylistRecursiveParamName]
= false;
result.clear();
if (!xmlRpcClient.execute(getPlaylistOpenMethodName.c_str(),
parameters, result)) {
@ -950,7 +957,7 @@ WebStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
<< result;
throw Core::XmlRpcMethodFaultException(eMsg.str());
}
if (! result.hasMember(getPlaylistUrlParamName)
|| result[getPlaylistUrlParamName].getType()
!= XmlRpcValue::TypeString
@ -1000,7 +1007,7 @@ WebStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
throw XmlRpcCommunicationException(eMsg);
}
xmlRpcClient.close();
if (xmlRpcClient.isFault()) {
std::stringstream eMsg;
eMsg << "XML-RPC method '"
@ -1267,8 +1274,12 @@ WebStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<Playlist>::Ref oldPlaylist = getPlaylist(sessionId, id);
Ptr<time_duration>::Ref playlength = oldPlaylist->getPlaylength();
Ptr<Playlist>::Ref newPlaylist(new Playlist(UniqueId::generateId(),
Ptr<Playlist>::Ref newPlaylist(new Playlist(oldPlaylist->getId(),
playlength));
newPlaylist->setTitle(oldPlaylist->getTitle());
newPlaylist->setToken(oldPlaylist->getToken());
// TODO: copy over all metadata as well
Ptr<xmlpp::Document>::Ref
smilDocument(new xmlpp::Document(xmlVersion));
xmlpp::Element * smilRootNode
@ -1399,6 +1410,7 @@ WebStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<std::string>::Ref playlistUri(new std::string(fileName.str()));
newPlaylist->setUri(playlistUri);
return newPlaylist;
}

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.44 $
Author : $Author: maroy $
Version : $Revision: 1.45 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClientTest.cxx,v $
------------------------------------------------------------------------------*/
@ -358,6 +358,57 @@ WebStorageClientTest :: playlistTest(void)
}
/*------------------------------------------------------------------------------
* Test on an embedded playlist
*----------------------------------------------------------------------------*/
void
WebStorageClientTest :: embeddedPlaylistTest(void)
throw (CPPUNIT_NS::Exception)
{
try {
wsc->reset();
} catch (XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(wsc->getPlaylistIds()->size() >= 3);
Ptr<UniqueId>::Ref playlistId = wsc->getPlaylistIds()->at(2);
Ptr<SessionId>::Ref sessionId;
try {
sessionId = authentication->login("root", "q");
} catch (XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(sessionId);
// test acquirePlaylist()
Ptr<Playlist>::Ref playlist;
try {
playlist = wsc->acquirePlaylist(sessionId, playlistId);
} catch (XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(playlist);
CPPUNIT_ASSERT(playlist->getUri());
std::ifstream ifs(playlist->getUri()->substr(7).c_str());
if (!ifs) { // cut off "file://"
ifs.close();
CPPUNIT_FAIL("playlist temp file not found");
}
ifs.close();
// test releasePlaylist()
try {
wsc->releasePlaylist(playlist);
} catch (XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(!playlist->getUri());
}
/*------------------------------------------------------------------------------
* Testing the audio clip operations
*----------------------------------------------------------------------------*/

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.11 $
Author : $Author: maroy $
Version : $Revision: 1.12 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClientTest.h,v $
------------------------------------------------------------------------------*/
@ -63,8 +63,8 @@ using namespace LiveSupport::Authentication;
/**
* Unit test for the UploadPlaylistMetohd class.
*
* @author $Author: fgerlits $
* @version $Revision: 1.11 $
* @author $Author: maroy $
* @version $Revision: 1.12 $
* @see WebStorageClient
*/
class WebStorageClientTest : public BaseTestMethod
@ -74,6 +74,7 @@ class WebStorageClientTest : public BaseTestMethod
CPPUNIT_TEST(getVersionTest);
CPPUNIT_TEST(simplePlaylistTest);
CPPUNIT_TEST(playlistTest);
CPPUNIT_TEST(embeddedPlaylistTest);
CPPUNIT_TEST(audioClipTest);
CPPUNIT_TEST(searchTest);
CPPUNIT_TEST(getAllTest);
@ -133,6 +134,14 @@ class WebStorageClientTest : public BaseTestMethod
void
playlistTest(void) throw (CPPUNIT_NS::Exception);
/**
* Testing an embedded playlist
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
embeddedPlaylistTest(void) throw (CPPUNIT_NS::Exception);
/**
* Testing the search operations.
*