2009-05-08 07:58:50 +00:00
|
|
|
#include "XmlRpcMethod.h"
|
|
|
|
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
|
|
|
|
#include "DownloadEngine.h"
|
|
|
|
#include "SelectEventPoll.h"
|
|
|
|
#include "Option.h"
|
|
|
|
#include "RequestGroupMan.h"
|
|
|
|
#include "ServerStatMan.h"
|
|
|
|
#include "RequestGroup.h"
|
|
|
|
#include "XmlRpcMethodImpl.h"
|
|
|
|
#include "BDE.h"
|
|
|
|
#include "OptionParser.h"
|
|
|
|
#include "OptionHandler.h"
|
|
|
|
#include "XmlRpcRequest.h"
|
2009-05-14 12:59:52 +00:00
|
|
|
#include "XmlRpcResponse.h"
|
2009-05-14 15:23:50 +00:00
|
|
|
#include "prefs.h"
|
2009-05-15 05:20:11 +00:00
|
|
|
#include "TestUtil.h"
|
2009-05-22 12:28:32 +00:00
|
|
|
#include "DownloadContext.h"
|
2009-07-10 15:55:42 +00:00
|
|
|
#include "FeatureConfig.h"
|
2009-12-20 09:49:43 +00:00
|
|
|
#include "util.h"
|
2010-01-17 13:54:42 +00:00
|
|
|
#include "array_fun.h"
|
2009-11-27 13:07:08 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
|
|
|
# include "BtRegistry.h"
|
|
|
|
# include "BtRuntime.h"
|
|
|
|
# include "PieceStorage.h"
|
|
|
|
# include "PeerStorage.h"
|
|
|
|
# include "BtProgressInfoFile.h"
|
|
|
|
# include "BtAnnounce.h"
|
2010-01-31 08:05:21 +00:00
|
|
|
# include "bittorrent_helper.h"
|
2009-11-27 13:07:08 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
2009-05-08 07:58:50 +00:00
|
|
|
|
|
|
|
namespace aria2 {
|
|
|
|
|
|
|
|
namespace xmlrpc {
|
|
|
|
|
|
|
|
class XmlRpcMethodTest:public CppUnit::TestFixture {
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE(XmlRpcMethodTest);
|
2009-05-10 14:51:20 +00:00
|
|
|
CPPUNIT_TEST(testAddUri);
|
2009-05-22 12:28:32 +00:00
|
|
|
CPPUNIT_TEST(testAddUri_withoutUri);
|
|
|
|
CPPUNIT_TEST(testAddUri_notUri);
|
|
|
|
CPPUNIT_TEST(testAddUri_withBadOption);
|
2009-05-30 13:55:14 +00:00
|
|
|
CPPUNIT_TEST(testAddUri_withPosition);
|
2009-06-14 11:29:46 +00:00
|
|
|
CPPUNIT_TEST(testAddUri_withBadPosition);
|
2009-05-27 17:27:05 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2009-05-15 05:20:11 +00:00
|
|
|
CPPUNIT_TEST(testAddTorrent);
|
2009-05-22 12:28:32 +00:00
|
|
|
CPPUNIT_TEST(testAddTorrent_withoutTorrent);
|
|
|
|
CPPUNIT_TEST(testAddTorrent_notBase64Torrent);
|
2009-05-30 13:55:14 +00:00
|
|
|
CPPUNIT_TEST(testAddTorrent_withPosition);
|
2009-05-27 17:27:05 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
#ifdef ENABLE_METALINK
|
2009-05-15 05:20:11 +00:00
|
|
|
CPPUNIT_TEST(testAddMetalink);
|
2009-05-22 12:28:32 +00:00
|
|
|
CPPUNIT_TEST(testAddMetalink_withoutMetalink);
|
|
|
|
CPPUNIT_TEST(testAddMetalink_notBase64Metalink);
|
2009-05-30 13:55:14 +00:00
|
|
|
CPPUNIT_TEST(testAddMetalink_withPosition);
|
2009-05-27 17:27:05 +00:00
|
|
|
#endif // ENABLE_METALINK
|
2009-05-14 15:23:50 +00:00
|
|
|
CPPUNIT_TEST(testChangeOption);
|
2009-05-22 12:28:32 +00:00
|
|
|
CPPUNIT_TEST(testChangeOption_withBadOption);
|
2009-10-04 09:01:11 +00:00
|
|
|
CPPUNIT_TEST(testChangeOption_withNotAllowedOption);
|
2009-05-22 12:28:32 +00:00
|
|
|
CPPUNIT_TEST(testChangeOption_withoutGid);
|
2009-05-14 15:44:59 +00:00
|
|
|
CPPUNIT_TEST(testChangeGlobalOption);
|
2009-05-22 12:28:32 +00:00
|
|
|
CPPUNIT_TEST(testChangeGlobalOption_withBadOption);
|
2009-10-04 09:01:11 +00:00
|
|
|
CPPUNIT_TEST(testChangeGlobalOption_withNotAllowedOption);
|
2009-05-22 12:28:32 +00:00
|
|
|
CPPUNIT_TEST(testTellStatus_withoutGid);
|
2009-06-23 15:14:24 +00:00
|
|
|
CPPUNIT_TEST(testTellWaiting);
|
|
|
|
CPPUNIT_TEST(testTellWaiting_fail);
|
2009-07-10 15:55:42 +00:00
|
|
|
CPPUNIT_TEST(testGetVersion);
|
2009-05-09 04:55:53 +00:00
|
|
|
CPPUNIT_TEST(testNoSuchMethod);
|
2009-12-20 09:49:43 +00:00
|
|
|
CPPUNIT_TEST(testGatherStoppedDownload);
|
|
|
|
CPPUNIT_TEST(testGatherProgressCommon);
|
2010-01-31 08:05:21 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
|
|
|
CPPUNIT_TEST(testGatherBitTorrentMetadata);
|
|
|
|
#endif // ENABLE_BITTORRENT
|
2009-12-21 15:17:34 +00:00
|
|
|
CPPUNIT_TEST(testChangePosition);
|
|
|
|
CPPUNIT_TEST(testChangePosition_fail);
|
2010-01-17 11:55:22 +00:00
|
|
|
CPPUNIT_TEST(testGetSessionInfo);
|
2010-03-06 14:21:43 +00:00
|
|
|
CPPUNIT_TEST(testChangeUri);
|
|
|
|
CPPUNIT_TEST(testChangeUri_fail);
|
2009-12-26 10:16:56 +00:00
|
|
|
CPPUNIT_TEST(testSystemMulticall);
|
|
|
|
CPPUNIT_TEST(testSystemMulticall_fail);
|
2009-05-08 07:58:50 +00:00
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
private:
|
|
|
|
SharedHandle<DownloadEngine> _e;
|
|
|
|
SharedHandle<Option> _option;
|
|
|
|
public:
|
|
|
|
void setUp()
|
|
|
|
{
|
2009-05-14 15:23:50 +00:00
|
|
|
RequestGroup::resetGIDCounter();
|
2009-05-08 07:58:50 +00:00
|
|
|
_option.reset(new Option());
|
2009-05-15 05:20:11 +00:00
|
|
|
_option->put(PREF_DIR, "/tmp");
|
2009-06-23 15:14:24 +00:00
|
|
|
_option->put(PREF_SEGMENT_SIZE, "1048576");
|
2009-05-08 07:58:50 +00:00
|
|
|
_e.reset(new DownloadEngine(SharedHandle<EventPoll>(new SelectEventPoll())));
|
|
|
|
_e->option = _option.get();
|
|
|
|
_e->_requestGroupMan.reset
|
2010-02-28 12:30:11 +00:00
|
|
|
(new RequestGroupMan(std::vector<SharedHandle<RequestGroup> >(),
|
2010-01-05 16:01:46 +00:00
|
|
|
1, _option.get()));
|
2009-05-08 07:58:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void tearDown() {}
|
|
|
|
|
2009-05-10 14:51:20 +00:00
|
|
|
void testAddUri();
|
2009-05-22 12:28:32 +00:00
|
|
|
void testAddUri_withoutUri();
|
|
|
|
void testAddUri_notUri();
|
|
|
|
void testAddUri_withBadOption();
|
2009-05-30 13:55:14 +00:00
|
|
|
void testAddUri_withPosition();
|
2009-06-14 11:29:46 +00:00
|
|
|
void testAddUri_withBadPosition();
|
2009-05-27 17:27:05 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2009-05-15 05:20:11 +00:00
|
|
|
void testAddTorrent();
|
2009-05-22 12:28:32 +00:00
|
|
|
void testAddTorrent_withoutTorrent();
|
|
|
|
void testAddTorrent_notBase64Torrent();
|
2009-05-30 13:55:14 +00:00
|
|
|
void testAddTorrent_withPosition();
|
2009-05-27 17:27:05 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
#ifdef ENABLE_METALINK
|
2009-05-15 05:20:11 +00:00
|
|
|
void testAddMetalink();
|
2009-05-22 12:28:32 +00:00
|
|
|
void testAddMetalink_withoutMetalink();
|
|
|
|
void testAddMetalink_notBase64Metalink();
|
2009-05-30 13:55:14 +00:00
|
|
|
void testAddMetalink_withPosition();
|
2009-05-27 17:27:05 +00:00
|
|
|
#endif // ENABLE_METALINK
|
2009-05-14 15:23:50 +00:00
|
|
|
void testChangeOption();
|
2009-05-22 12:28:32 +00:00
|
|
|
void testChangeOption_withBadOption();
|
2009-10-04 09:01:11 +00:00
|
|
|
void testChangeOption_withNotAllowedOption();
|
2009-05-22 12:28:32 +00:00
|
|
|
void testChangeOption_withoutGid();
|
2009-05-14 15:44:59 +00:00
|
|
|
void testChangeGlobalOption();
|
2009-05-22 12:28:32 +00:00
|
|
|
void testChangeGlobalOption_withBadOption();
|
2009-10-04 09:01:11 +00:00
|
|
|
void testChangeGlobalOption_withNotAllowedOption();
|
2009-05-22 12:28:32 +00:00
|
|
|
void testTellStatus_withoutGid();
|
2009-06-23 15:14:24 +00:00
|
|
|
void testTellWaiting();
|
|
|
|
void testTellWaiting_fail();
|
2009-07-10 15:55:42 +00:00
|
|
|
void testGetVersion();
|
2009-05-09 04:55:53 +00:00
|
|
|
void testNoSuchMethod();
|
2009-12-20 09:49:43 +00:00
|
|
|
void testGatherStoppedDownload();
|
|
|
|
void testGatherProgressCommon();
|
2010-01-31 08:05:21 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
|
|
|
void testGatherBitTorrentMetadata();
|
|
|
|
#endif // ENABLE_BITTORRENT
|
2009-12-21 15:17:34 +00:00
|
|
|
void testChangePosition();
|
|
|
|
void testChangePosition_fail();
|
2010-01-17 11:55:22 +00:00
|
|
|
void testGetSessionInfo();
|
2010-03-06 14:21:43 +00:00
|
|
|
void testChangeUri();
|
|
|
|
void testChangeUri_fail();
|
2009-12-26 10:16:56 +00:00
|
|
|
void testSystemMulticall();
|
|
|
|
void testSystemMulticall_fail();
|
2009-05-08 07:58:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION(XmlRpcMethodTest);
|
|
|
|
|
2009-05-10 14:51:20 +00:00
|
|
|
void XmlRpcMethodTest::testAddUri()
|
2009-05-08 07:58:50 +00:00
|
|
|
{
|
2009-05-10 14:51:20 +00:00
|
|
|
AddUriXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-08 07:58:50 +00:00
|
|
|
req._params << BDE::list();
|
|
|
|
req._params[0] << BDE("http://localhost/");
|
2009-05-22 12:28:32 +00:00
|
|
|
{
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
const std::deque<SharedHandle<RequestGroup> > rgs =
|
|
|
|
_e->_requestGroupMan->getReservedGroups();
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)1, rgs.size());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/"),
|
2010-01-05 16:01:46 +00:00
|
|
|
rgs.front()->getDownloadContext()->getFirstFileEntry()->getRemainingUris().front());
|
2009-05-22 12:28:32 +00:00
|
|
|
}
|
|
|
|
// with options
|
|
|
|
BDE opt = BDE::dict();
|
|
|
|
opt[PREF_DIR] = BDE("/sink");
|
|
|
|
req._params << opt;
|
|
|
|
{
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/sink"),
|
2010-01-05 16:01:46 +00:00
|
|
|
_e->_requestGroupMan->findReservedGroup(2)->
|
|
|
|
getDownloadContext()->getDir());
|
2009-05-22 12:28:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void XmlRpcMethodTest::testAddUri_withoutUri()
|
|
|
|
{
|
|
|
|
AddUriXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-14 12:59:52 +00:00
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
2009-05-22 12:28:32 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
}
|
|
|
|
|
|
|
|
void XmlRpcMethodTest::testAddUri_notUri()
|
|
|
|
{
|
|
|
|
AddUriXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-22 12:28:32 +00:00
|
|
|
req._params << BDE::list();
|
|
|
|
req._params[0] << BDE("not uri");
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
}
|
|
|
|
|
|
|
|
void XmlRpcMethodTest::testAddUri_withBadOption()
|
|
|
|
{
|
|
|
|
AddUriXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-22 12:28:32 +00:00
|
|
|
req._params << BDE::list();
|
|
|
|
req._params[0] << BDE("http://localhost");
|
|
|
|
BDE opt = BDE::dict();
|
|
|
|
opt[PREF_FILE_ALLOCATION] = BDE("badvalue");
|
|
|
|
req._params << opt;
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
2009-05-09 04:55:53 +00:00
|
|
|
}
|
|
|
|
|
2009-05-30 13:55:14 +00:00
|
|
|
void XmlRpcMethodTest::testAddUri_withPosition()
|
|
|
|
{
|
|
|
|
AddUriXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req1(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-30 13:55:14 +00:00
|
|
|
req1._params << BDE::list();
|
|
|
|
req1._params[0] << BDE("http://uri1");
|
|
|
|
XmlRpcResponse res1 = m.execute(req1, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res1._code);
|
|
|
|
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req2(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-30 13:55:14 +00:00
|
|
|
req2._params << BDE::list();
|
|
|
|
req2._params[0] << BDE("http://uri2");
|
|
|
|
req2._params << BDE::dict();
|
|
|
|
req2._params << BDE((int64_t)0);
|
|
|
|
m.execute(req2, _e.get());
|
|
|
|
|
|
|
|
std::string uri =
|
2009-06-29 08:42:58 +00:00
|
|
|
_e->_requestGroupMan->getReservedGroups()[0]->getDownloadContext()->getFirstFileEntry()->getRemainingUris()[0];
|
2009-05-30 13:55:14 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://uri2"), uri);
|
|
|
|
}
|
|
|
|
|
2009-06-14 11:29:46 +00:00
|
|
|
void XmlRpcMethodTest::testAddUri_withBadPosition()
|
|
|
|
{
|
|
|
|
AddUriXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
2009-06-14 11:29:46 +00:00
|
|
|
req._params << BDE::list();
|
|
|
|
req._params[0] << BDE("http://localhost/");
|
|
|
|
req._params << BDE::dict();
|
|
|
|
req._params << BDE((int64_t)-1);
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
}
|
|
|
|
|
2009-05-27 17:27:05 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2009-05-15 05:20:11 +00:00
|
|
|
void XmlRpcMethodTest::testAddTorrent()
|
|
|
|
{
|
|
|
|
AddTorrentXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-15 05:20:11 +00:00
|
|
|
req._params << BDE(readFile("single.torrent"));
|
|
|
|
BDE uris = BDE::list();
|
|
|
|
uris << BDE("http://localhost/aria2-0.8.2.tar.bz2");
|
|
|
|
req._params << uris;
|
|
|
|
{
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("1"), res._param.s());
|
|
|
|
|
|
|
|
SharedHandle<RequestGroup> group = _e->_requestGroupMan->findReservedGroup(1);
|
|
|
|
CPPUNIT_ASSERT(!group.isNull());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-0.8.2.tar.bz2"),
|
2010-01-05 16:01:46 +00:00
|
|
|
group->getFirstFilePath());
|
2009-06-29 08:42:58 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)1, group->getDownloadContext()->getFirstFileEntry()->getRemainingUris().size());
|
2009-05-15 05:20:11 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/aria2-0.8.2.tar.bz2"),
|
2010-01-05 16:01:46 +00:00
|
|
|
group->getDownloadContext()->getFirstFileEntry()->getRemainingUris()[0]);
|
2009-05-15 05:20:11 +00:00
|
|
|
}
|
|
|
|
// with options
|
|
|
|
BDE opt = BDE::dict();
|
|
|
|
opt[PREF_DIR] = BDE("/sink");
|
|
|
|
req._params << opt;
|
|
|
|
{
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/sink/aria2-0.8.2.tar.bz2"),
|
2010-01-05 16:01:46 +00:00
|
|
|
_e->_requestGroupMan->findReservedGroup(2)->getFirstFilePath());
|
2009-05-15 05:20:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-22 12:28:32 +00:00
|
|
|
void XmlRpcMethodTest::testAddTorrent_withoutTorrent()
|
|
|
|
{
|
|
|
|
AddTorrentXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-22 12:28:32 +00:00
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
}
|
|
|
|
|
|
|
|
void XmlRpcMethodTest::testAddTorrent_notBase64Torrent()
|
|
|
|
{
|
|
|
|
AddTorrentXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-22 12:28:32 +00:00
|
|
|
req._params << BDE("not torrent");
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
}
|
2009-05-30 13:55:14 +00:00
|
|
|
|
|
|
|
void XmlRpcMethodTest::testAddTorrent_withPosition()
|
|
|
|
{
|
|
|
|
AddTorrentXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req1(AddTorrentXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-30 13:55:14 +00:00
|
|
|
req1._params << BDE(readFile("test.torrent"));
|
|
|
|
req1._params << BDE::list();
|
|
|
|
req1._params << BDE::dict();
|
|
|
|
XmlRpcResponse res1 = m.execute(req1, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res1._code);
|
|
|
|
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req2(AddTorrentXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-30 13:55:14 +00:00
|
|
|
req2._params << BDE(readFile("single.torrent"));
|
|
|
|
req2._params << BDE::list();
|
|
|
|
req2._params << BDE::dict();
|
|
|
|
req2._params << BDE((int64_t)0);
|
|
|
|
m.execute(req2, _e.get());
|
|
|
|
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)1,
|
2010-01-05 16:01:46 +00:00
|
|
|
_e->_requestGroupMan->getReservedGroups()[0]->
|
|
|
|
getDownloadContext()->getFileEntries().size());
|
2009-05-30 13:55:14 +00:00
|
|
|
}
|
|
|
|
|
2009-05-27 17:27:05 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
2009-05-22 12:28:32 +00:00
|
|
|
|
2009-05-27 17:27:05 +00:00
|
|
|
#ifdef ENABLE_METALINK
|
2009-05-15 05:20:11 +00:00
|
|
|
void XmlRpcMethodTest::testAddMetalink()
|
|
|
|
{
|
|
|
|
AddMetalinkXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(AddMetalinkXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-15 05:20:11 +00:00
|
|
|
req._params << BDE(readFile("2files.metalink"));
|
|
|
|
{
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)2, res._param.size());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("1"), res._param[0].s());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("2"), res._param[1].s());
|
|
|
|
|
|
|
|
SharedHandle<RequestGroup> tar = _e->_requestGroupMan->findReservedGroup(1);
|
|
|
|
CPPUNIT_ASSERT(!tar.isNull());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-5.0.0.tar.bz2"),
|
2010-01-05 16:01:46 +00:00
|
|
|
tar->getFirstFilePath());
|
2009-05-15 05:20:11 +00:00
|
|
|
SharedHandle<RequestGroup> deb = _e->_requestGroupMan->findReservedGroup(2);
|
|
|
|
CPPUNIT_ASSERT(!deb.isNull());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-5.0.0.deb"),
|
2010-01-05 16:01:46 +00:00
|
|
|
deb->getFirstFilePath());
|
2009-05-15 05:20:11 +00:00
|
|
|
}
|
|
|
|
// with options
|
|
|
|
BDE opt = BDE::dict();
|
|
|
|
opt[PREF_DIR] = BDE("/sink");
|
|
|
|
req._params << opt;
|
|
|
|
{
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/sink/aria2-5.0.0.tar.bz2"),
|
2010-01-05 16:01:46 +00:00
|
|
|
_e->_requestGroupMan->findReservedGroup(3)->getFirstFilePath());
|
2009-05-15 05:20:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-22 12:28:32 +00:00
|
|
|
void XmlRpcMethodTest::testAddMetalink_withoutMetalink()
|
|
|
|
{
|
|
|
|
AddMetalinkXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(AddMetalinkXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-22 12:28:32 +00:00
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
}
|
|
|
|
|
|
|
|
void XmlRpcMethodTest::testAddMetalink_notBase64Metalink()
|
|
|
|
{
|
|
|
|
AddMetalinkXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(AddMetalinkXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-22 12:28:32 +00:00
|
|
|
req._params << BDE("not metalink");
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
}
|
2009-05-30 13:55:14 +00:00
|
|
|
|
|
|
|
void XmlRpcMethodTest::testAddMetalink_withPosition()
|
|
|
|
{
|
|
|
|
AddUriXmlRpcMethod m1;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req1(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-30 13:55:14 +00:00
|
|
|
req1._params << BDE::list();
|
|
|
|
req1._params[0] << BDE("http://uri");
|
|
|
|
XmlRpcResponse res1 = m1.execute(req1, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res1._code);
|
|
|
|
|
|
|
|
AddMetalinkXmlRpcMethod m2;
|
|
|
|
XmlRpcRequest req2("ari2.addMetalink", BDE::list());
|
|
|
|
req2._params << BDE(readFile("2files.metalink"));
|
|
|
|
req2._params << BDE::dict();
|
|
|
|
req2._params << BDE((int64_t)0);
|
|
|
|
XmlRpcResponse res2 = m2.execute(req2, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res2._code);
|
|
|
|
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-5.0.0.tar.bz2"),
|
2010-01-05 16:01:46 +00:00
|
|
|
_e->_requestGroupMan->getReservedGroups()[0]->
|
|
|
|
getFirstFilePath());
|
2009-05-30 13:55:14 +00:00
|
|
|
}
|
|
|
|
|
2009-05-27 17:27:05 +00:00
|
|
|
#endif // ENABLE_METALINK
|
2009-05-22 12:28:32 +00:00
|
|
|
|
2009-05-14 15:23:50 +00:00
|
|
|
void XmlRpcMethodTest::testChangeOption()
|
|
|
|
{
|
2009-06-29 08:42:58 +00:00
|
|
|
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
2009-05-14 15:23:50 +00:00
|
|
|
_e->_requestGroupMan->addReservedGroup(group);
|
|
|
|
|
|
|
|
ChangeOptionXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-14 15:23:50 +00:00
|
|
|
req._params << BDE("1");
|
|
|
|
BDE opt = BDE::dict();
|
|
|
|
opt[PREF_MAX_DOWNLOAD_LIMIT] = BDE("100K");
|
2009-05-27 17:27:05 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2009-11-27 13:07:08 +00:00
|
|
|
opt[PREF_BT_MAX_PEERS] = BDE("100");
|
2009-11-27 12:47:57 +00:00
|
|
|
opt[PREF_BT_REQUEST_PEER_SPEED_LIMIT] = BDE("300K");
|
2009-05-14 15:23:50 +00:00
|
|
|
opt[PREF_MAX_UPLOAD_LIMIT] = BDE("50K");
|
2009-11-27 13:07:08 +00:00
|
|
|
|
|
|
|
BtObject btObject;
|
|
|
|
btObject._btRuntime = SharedHandle<BtRuntime>(new BtRuntime());
|
|
|
|
_e->getBtRegistry()->put(group->getGID(), btObject);
|
2009-05-27 17:27:05 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
2009-05-14 15:23:50 +00:00
|
|
|
req._params << opt;
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
|
2009-11-27 13:07:08 +00:00
|
|
|
SharedHandle<Option> option = group->getOption();
|
|
|
|
|
2009-05-14 15:23:50 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((unsigned int)100*1024,
|
2010-01-05 16:01:46 +00:00
|
|
|
group->getMaxDownloadSpeedLimit());
|
2009-10-04 09:01:11 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("102400"),
|
2010-01-05 16:01:46 +00:00
|
|
|
option->get(PREF_MAX_DOWNLOAD_LIMIT));
|
2009-05-27 17:27:05 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2009-11-27 13:07:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("307200"),
|
2010-01-05 16:01:46 +00:00
|
|
|
option->get(PREF_BT_REQUEST_PEER_SPEED_LIMIT));
|
2009-11-27 13:07:08 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("100"), option->get(PREF_BT_MAX_PEERS));
|
|
|
|
CPPUNIT_ASSERT_EQUAL((unsigned int)100, btObject._btRuntime->getMaxPeers());
|
|
|
|
|
|
|
|
CPPUNIT_ASSERT_EQUAL((unsigned int)50*1024,
|
2010-01-05 16:01:46 +00:00
|
|
|
group->getMaxUploadSpeedLimit());
|
2009-11-27 13:07:08 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("51200"),
|
2010-01-05 16:01:46 +00:00
|
|
|
option->get(PREF_MAX_UPLOAD_LIMIT));
|
2009-05-27 17:27:05 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
2009-05-14 15:23:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 12:28:32 +00:00
|
|
|
void XmlRpcMethodTest::testChangeOption_withBadOption()
|
|
|
|
{
|
2009-06-29 08:42:58 +00:00
|
|
|
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
2009-05-22 12:28:32 +00:00
|
|
|
_e->_requestGroupMan->addReservedGroup(group);
|
|
|
|
|
|
|
|
ChangeOptionXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-22 12:28:32 +00:00
|
|
|
req._params << BDE("1");
|
|
|
|
BDE opt = BDE::dict();
|
|
|
|
opt[PREF_MAX_DOWNLOAD_LIMIT] = BDE("badvalue");
|
|
|
|
req._params << opt;
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
}
|
|
|
|
|
2009-10-04 09:01:11 +00:00
|
|
|
void XmlRpcMethodTest::testChangeOption_withNotAllowedOption()
|
|
|
|
{
|
|
|
|
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
|
|
|
_e->_requestGroupMan->addReservedGroup(group);
|
|
|
|
|
|
|
|
ChangeOptionXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
|
2009-10-04 09:01:11 +00:00
|
|
|
req._params << BDE("1");
|
|
|
|
BDE opt = BDE::dict();
|
|
|
|
opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("100K");
|
|
|
|
req._params << opt;
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
}
|
|
|
|
|
2009-05-22 12:28:32 +00:00
|
|
|
void XmlRpcMethodTest::testChangeOption_withoutGid()
|
|
|
|
{
|
|
|
|
ChangeOptionXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-22 12:28:32 +00:00
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
}
|
|
|
|
|
2009-05-14 15:44:59 +00:00
|
|
|
void XmlRpcMethodTest::testChangeGlobalOption()
|
|
|
|
{
|
|
|
|
ChangeGlobalOptionXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-14 15:44:59 +00:00
|
|
|
BDE opt = BDE::dict();
|
|
|
|
opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("100K");
|
2009-05-27 17:27:05 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2009-05-14 15:44:59 +00:00
|
|
|
opt[PREF_MAX_OVERALL_UPLOAD_LIMIT] = BDE("50K");
|
2009-05-27 17:27:05 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
2009-05-14 15:44:59 +00:00
|
|
|
req._params << opt;
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((unsigned int)100*1024,
|
2010-01-05 16:01:46 +00:00
|
|
|
_e->_requestGroupMan->getMaxOverallDownloadSpeedLimit());
|
2009-10-04 09:01:11 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("102400"),
|
2010-01-05 16:01:46 +00:00
|
|
|
_e->option->get(PREF_MAX_OVERALL_DOWNLOAD_LIMIT));
|
2009-05-27 17:27:05 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2009-05-14 15:44:59 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((unsigned int)50*1024,
|
2010-01-05 16:01:46 +00:00
|
|
|
_e->_requestGroupMan->getMaxOverallUploadSpeedLimit());
|
2009-10-04 09:01:11 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("51200"),
|
2010-01-05 16:01:46 +00:00
|
|
|
_e->option->get(PREF_MAX_OVERALL_UPLOAD_LIMIT));
|
2009-05-27 17:27:05 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
2009-05-14 15:44:59 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 12:28:32 +00:00
|
|
|
void XmlRpcMethodTest::testChangeGlobalOption_withBadOption()
|
|
|
|
{
|
|
|
|
ChangeGlobalOptionXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-22 12:28:32 +00:00
|
|
|
BDE opt = BDE::dict();
|
|
|
|
opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("badvalue");
|
|
|
|
req._params << opt;
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
}
|
|
|
|
|
2009-10-04 09:01:11 +00:00
|
|
|
void XmlRpcMethodTest::testChangeGlobalOption_withNotAllowedOption()
|
|
|
|
{
|
|
|
|
ChangeGlobalOptionXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
|
2009-10-04 09:01:11 +00:00
|
|
|
BDE opt = BDE::dict();
|
|
|
|
opt[PREF_MAX_DOWNLOAD_LIMIT] = BDE("100K");
|
|
|
|
req._params << opt;
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
}
|
|
|
|
|
2009-05-09 04:55:53 +00:00
|
|
|
void XmlRpcMethodTest::testNoSuchMethod()
|
|
|
|
{
|
|
|
|
NoSuchMethodXmlRpcMethod m;
|
|
|
|
XmlRpcRequest req("make.hamburger", BDE::none);
|
2009-05-14 12:59:52 +00:00
|
|
|
XmlRpcResponse res = m.execute(req, 0);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("No such method: make.hamburger"),
|
2010-01-05 16:01:46 +00:00
|
|
|
res._param["faultString"].s());
|
2009-05-09 04:55:53 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL
|
|
|
|
(std::string("<?xml version=\"1.0\"?>"
|
2010-01-05 16:01:46 +00:00
|
|
|
"<methodResponse>"
|
|
|
|
"<fault>"
|
|
|
|
"<value>"
|
|
|
|
"<struct>"
|
|
|
|
"<member>"
|
|
|
|
"<name>faultCode</name><value><int>1</int></value>"
|
|
|
|
"</member>"
|
|
|
|
"<member>"
|
|
|
|
"<name>faultString</name>"
|
|
|
|
"<value>"
|
|
|
|
"<string>No such method: make.hamburger</string>"
|
|
|
|
"</value>"
|
|
|
|
"</member>"
|
|
|
|
"</struct>"
|
|
|
|
"</value>"
|
|
|
|
"</fault>"
|
|
|
|
"</methodResponse>"),
|
2009-05-14 12:59:52 +00:00
|
|
|
res.toXml());
|
2009-05-08 07:58:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 12:28:32 +00:00
|
|
|
void XmlRpcMethodTest::testTellStatus_withoutGid()
|
|
|
|
{
|
|
|
|
TellStatusXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(TellStatusXmlRpcMethod::getMethodName(), BDE::list());
|
2009-05-22 12:28:32 +00:00
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
}
|
|
|
|
|
2009-06-23 15:14:24 +00:00
|
|
|
static void addUri(const std::string& uri,
|
2010-01-05 16:01:46 +00:00
|
|
|
const SharedHandle<DownloadEngine>& e)
|
2009-06-23 15:14:24 +00:00
|
|
|
{
|
|
|
|
AddUriXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
2009-06-23 15:14:24 +00:00
|
|
|
req._params << BDE::list();
|
|
|
|
req._params[0] << BDE(uri);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, m.execute(req, e.get())._code);
|
|
|
|
}
|
|
|
|
|
2009-12-05 11:35:18 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
|
|
|
|
2009-11-25 15:49:20 +00:00
|
|
|
static void addTorrent
|
|
|
|
(const std::string& torrentFile, const SharedHandle<DownloadEngine>& e)
|
|
|
|
{
|
|
|
|
AddTorrentXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), BDE::list());
|
2009-11-25 15:49:20 +00:00
|
|
|
req._params << BDE(readFile(torrentFile));
|
|
|
|
XmlRpcResponse res = m.execute(req, e.get());
|
|
|
|
}
|
|
|
|
|
2009-12-05 11:35:18 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
|
2009-06-23 15:14:24 +00:00
|
|
|
void XmlRpcMethodTest::testTellWaiting()
|
|
|
|
{
|
|
|
|
addUri("http://1/", _e);
|
|
|
|
addUri("http://2/", _e);
|
|
|
|
addUri("http://3/", _e);
|
2009-12-05 11:35:18 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2009-11-25 15:49:20 +00:00
|
|
|
addTorrent("single.torrent", _e);
|
2010-01-23 10:11:26 +00:00
|
|
|
#else // !ENABLE_BITTORRENT
|
|
|
|
addUri("http://4/", _e);
|
|
|
|
#endif // !ENABLE_BITTORRENT
|
2009-06-23 15:14:24 +00:00
|
|
|
|
|
|
|
TellWaitingXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(TellWaitingXmlRpcMethod::getMethodName(), BDE::list());
|
2009-06-23 15:14:24 +00:00
|
|
|
req._params << BDE((int64_t)1);
|
|
|
|
req._params << BDE((int64_t)2);
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)2, res._param.size());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("2"), res._param[0]["gid"].s());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("3"), res._param[1]["gid"].s());
|
|
|
|
// waiting.size() == offset+num
|
2009-12-26 13:07:27 +00:00
|
|
|
req = XmlRpcRequest(TellWaitingXmlRpcMethod::getMethodName(), BDE::list());
|
2009-06-23 15:14:24 +00:00
|
|
|
req._params << BDE((int64_t)1);
|
|
|
|
req._params << BDE((int64_t)3);
|
|
|
|
res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)3, res._param.size());
|
|
|
|
// waiting.size() < offset+num
|
2009-12-26 13:07:27 +00:00
|
|
|
req = XmlRpcRequest(TellWaitingXmlRpcMethod::getMethodName(), BDE::list());
|
2009-06-23 15:14:24 +00:00
|
|
|
req._params << BDE((int64_t)1);
|
|
|
|
req._params << BDE((int64_t)4);
|
|
|
|
res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)3, res._param.size());
|
2010-01-17 09:50:38 +00:00
|
|
|
// negative offset
|
|
|
|
req = XmlRpcRequest(TellWaitingXmlRpcMethod::getMethodName(), BDE::list());
|
|
|
|
req._params << BDE((int64_t)-1);
|
|
|
|
req._params << BDE((int64_t)2);
|
|
|
|
res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)2, res._param.size());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("4"), res._param[0]["gid"].s());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("3"), res._param[1]["gid"].s());
|
|
|
|
// negative offset and size < num
|
|
|
|
req._params[1] = BDE((int64_t)100);
|
|
|
|
res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)4, res._param.size());
|
|
|
|
// nagative offset and normalized offset < 0
|
|
|
|
req._params[0] = BDE((int64_t)-5);
|
|
|
|
res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)0, res._param.size());
|
|
|
|
// nagative offset and normalized offset == 0
|
|
|
|
req._params[0] = BDE((int64_t)-4);
|
|
|
|
res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)1, res._param.size());
|
2009-06-23 15:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void XmlRpcMethodTest::testTellWaiting_fail()
|
|
|
|
{
|
|
|
|
TellWaitingXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(TellWaitingXmlRpcMethod::getMethodName(), BDE::list());
|
2009-06-23 15:14:24 +00:00
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
}
|
|
|
|
|
2009-07-10 15:55:42 +00:00
|
|
|
void XmlRpcMethodTest::testGetVersion()
|
|
|
|
{
|
|
|
|
GetVersionXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(GetVersionXmlRpcMethod::getMethodName(), BDE::none);
|
2009-07-10 15:55:42 +00:00
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(PACKAGE_VERSION), res._param["version"].s());
|
|
|
|
const BDE& featureList = res._param["enabledFeatures"];
|
|
|
|
std::string features;
|
|
|
|
for(BDE::List::const_iterator i = featureList.listBegin();
|
|
|
|
i != featureList.listEnd(); ++i) {
|
|
|
|
features += (*i).s();
|
|
|
|
features += ", ";
|
|
|
|
}
|
|
|
|
|
|
|
|
CPPUNIT_ASSERT_EQUAL(FeatureConfig::getInstance()->featureSummary()+", ",
|
2010-01-05 16:01:46 +00:00
|
|
|
features);
|
2009-07-10 15:55:42 +00:00
|
|
|
}
|
|
|
|
|
2009-12-20 09:49:43 +00:00
|
|
|
void XmlRpcMethodTest::testGatherStoppedDownload()
|
|
|
|
{
|
|
|
|
std::vector<SharedHandle<FileEntry> > fileEntries;
|
2010-03-21 14:04:05 +00:00
|
|
|
std::vector<gid_t> followedBy;
|
2009-12-20 09:49:43 +00:00
|
|
|
followedBy.push_back(3);
|
|
|
|
followedBy.push_back(4);
|
|
|
|
SharedHandle<DownloadResult> d
|
|
|
|
(new DownloadResult(1,
|
2010-01-05 16:01:46 +00:00
|
|
|
fileEntries,
|
|
|
|
false,
|
|
|
|
UINT64_MAX,
|
|
|
|
1000,
|
|
|
|
downloadresultcode::FINISHED,
|
|
|
|
followedBy,
|
|
|
|
2));
|
2009-12-20 09:49:43 +00:00
|
|
|
BDE entry = BDE::dict();
|
|
|
|
gatherStoppedDownload(entry, d);
|
|
|
|
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("3"), entry["followedBy"][0].s());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("4"), entry["followedBy"][1].s());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("2"), entry["belongsTo"].s());
|
|
|
|
}
|
|
|
|
|
|
|
|
void XmlRpcMethodTest::testGatherProgressCommon()
|
|
|
|
{
|
2010-01-17 13:54:42 +00:00
|
|
|
SharedHandle<DownloadContext> dctx(new DownloadContext(0, 0,"aria2.tar.bz2"));
|
|
|
|
std::string uris[] = { "http://localhost/aria2.tar.bz2" };
|
2010-03-25 13:51:10 +00:00
|
|
|
dctx->getFirstFileEntry()->addUris(vbegin(uris), vend(uris));
|
2009-12-20 09:49:43 +00:00
|
|
|
|
|
|
|
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
|
|
|
group->setDownloadContext(dctx);
|
|
|
|
std::vector<SharedHandle<RequestGroup> > followedBy;
|
|
|
|
for(int i = 0; i < 2; ++i) {
|
|
|
|
followedBy.push_back(SharedHandle<RequestGroup>(new RequestGroup(_option)));
|
|
|
|
}
|
|
|
|
|
|
|
|
group->followedBy(followedBy.begin(), followedBy.end());
|
|
|
|
group->belongsTo(2);
|
|
|
|
|
|
|
|
BDE entry = BDE::dict();
|
|
|
|
gatherProgressCommon(entry, group);
|
|
|
|
|
|
|
|
CPPUNIT_ASSERT_EQUAL(util::itos(followedBy[0]->getGID()),
|
2010-01-05 16:01:46 +00:00
|
|
|
entry["followedBy"][0].s());
|
2009-12-20 09:49:43 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(util::itos(followedBy[1]->getGID()),
|
2010-01-05 16:01:46 +00:00
|
|
|
entry["followedBy"][1].s());
|
2009-12-20 09:49:43 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("2"), entry["belongsTo"].s());
|
2010-01-17 13:54:42 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)1, entry["files"].size());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"),
|
|
|
|
entry["files"][0]["path"].s());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(uris[0], entry["files"][0]["uris"][0]["uri"].s());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), entry["dir"].s());
|
2009-12-20 09:49:43 +00:00
|
|
|
}
|
|
|
|
|
2010-01-31 08:05:21 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
|
|
|
void XmlRpcMethodTest::testGatherBitTorrentMetadata()
|
|
|
|
{
|
|
|
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
|
|
|
bittorrent::load("test.torrent", dctx);
|
|
|
|
BDE btDict = BDE::dict();
|
|
|
|
gatherBitTorrentMetadata(btDict, dctx->getAttribute(bittorrent::BITTORRENT));
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("REDNOAH.COM RULES"), btDict["comment"].s());
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)1123456789, btDict["creationDate"].i());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("multi"), btDict["mode"].s());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2-test"), btDict["info"]["name"].s());
|
|
|
|
const BDE& announceList = btDict["announceList"];
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)3, announceList.size());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://tracker1"), announceList[0][0].s());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://tracker2"), announceList[1][0].s());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://tracker3"), announceList[2][0].s());
|
|
|
|
// Remove some keys
|
|
|
|
BDE modBtAttrs = dctx->getAttribute(bittorrent::BITTORRENT);
|
|
|
|
modBtAttrs.removeKey(bittorrent::COMMENT);
|
|
|
|
modBtAttrs.removeKey(bittorrent::CREATION_DATE);
|
|
|
|
modBtAttrs.removeKey(bittorrent::MODE);
|
|
|
|
modBtAttrs.removeKey(bittorrent::METADATA);
|
|
|
|
btDict = BDE::dict();
|
|
|
|
gatherBitTorrentMetadata(btDict, modBtAttrs);
|
|
|
|
CPPUNIT_ASSERT(!btDict.containsKey("comment"));
|
|
|
|
CPPUNIT_ASSERT(!btDict.containsKey("creationDate"));
|
|
|
|
CPPUNIT_ASSERT(!btDict.containsKey("mode"));
|
|
|
|
CPPUNIT_ASSERT(!btDict.containsKey("info"));
|
|
|
|
CPPUNIT_ASSERT(btDict.containsKey("announceList"));
|
|
|
|
}
|
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
|
2009-12-21 15:17:34 +00:00
|
|
|
void XmlRpcMethodTest::testChangePosition()
|
|
|
|
{
|
|
|
|
_e->_requestGroupMan->addReservedGroup
|
|
|
|
(SharedHandle<RequestGroup>(new RequestGroup(_option)));
|
|
|
|
_e->_requestGroupMan->addReservedGroup
|
|
|
|
(SharedHandle<RequestGroup>(new RequestGroup(_option)));
|
|
|
|
|
|
|
|
ChangePositionXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(ChangePositionXmlRpcMethod::getMethodName(), BDE::list());
|
2009-12-21 15:17:34 +00:00
|
|
|
req._params << std::string("1");
|
|
|
|
req._params << BDE((int64_t)1);
|
|
|
|
req._params << std::string("POS_SET");
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)1, res._param.i());
|
|
|
|
CPPUNIT_ASSERT_EQUAL
|
2010-03-21 14:04:05 +00:00
|
|
|
((gid_t)1, _e->_requestGroupMan->getReservedGroups()[1]->getGID());
|
2009-12-21 15:17:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void XmlRpcMethodTest::testChangePosition_fail()
|
|
|
|
{
|
|
|
|
ChangePositionXmlRpcMethod m;
|
2009-12-26 13:07:27 +00:00
|
|
|
XmlRpcRequest req(ChangePositionXmlRpcMethod::getMethodName(), BDE::list());
|
2009-12-21 15:17:34 +00:00
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
|
|
|
|
req._params << std::string("1");
|
|
|
|
req._params << BDE((int64_t)2);
|
|
|
|
req._params << std::string("bad keyword");
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
}
|
|
|
|
|
2010-03-06 14:21:43 +00:00
|
|
|
void XmlRpcMethodTest::testChangeUri()
|
|
|
|
{
|
|
|
|
SharedHandle<FileEntry> files[3];
|
|
|
|
for(int i = 0; i < 3; ++i) {
|
|
|
|
files[i].reset(new FileEntry());
|
|
|
|
}
|
|
|
|
files[1]->addUri("http://example.org/aria2.tar.bz2");
|
|
|
|
files[1]->addUri("http://example.org/mustremove1");
|
|
|
|
files[1]->addUri("http://example.org/mustremove2");
|
|
|
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
|
|
|
dctx->setFileEntries(&files[0], &files[3]);
|
|
|
|
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
|
|
|
group->setDownloadContext(dctx);
|
|
|
|
_e->_requestGroupMan->addReservedGroup(group);
|
|
|
|
|
|
|
|
ChangeUriXmlRpcMethod m;
|
|
|
|
XmlRpcRequest req(ChangeUriXmlRpcMethod::getMethodName(), BDE::list());
|
|
|
|
req._params << std::string("1"); // GID
|
2010-03-07 07:24:19 +00:00
|
|
|
req._params << 2; // index of FileEntry
|
2010-03-06 14:21:43 +00:00
|
|
|
BDE removeuris = BDE::list();
|
|
|
|
removeuris << std::string("http://example.org/mustremove1");
|
|
|
|
removeuris << std::string("http://example.org/mustremove2");
|
|
|
|
removeuris << std::string("http://example.org/notexist");
|
|
|
|
req._params << removeuris;
|
|
|
|
BDE adduris = BDE::list();
|
|
|
|
adduris << std::string("http://example.org/added1");
|
|
|
|
adduris << std::string("http://example.org/added2");
|
|
|
|
adduris << std::string("baduri");
|
|
|
|
adduris << std::string("http://example.org/added3");
|
|
|
|
req._params << adduris;
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)2, res._param[0].i());
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)3, res._param[1].i());
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)0, files[0]->getRemainingUris().size());
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)0, files[2]->getRemainingUris().size());
|
|
|
|
std::deque<std::string> uris = files[1]->getRemainingUris();
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)4, uris.size());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://example.org/aria2.tar.bz2"),uris[0]);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://example.org/added1"), uris[1]);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://example.org/added2"), uris[2]);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://example.org/added3"), uris[3]);
|
|
|
|
|
|
|
|
// Change adduris
|
|
|
|
adduris = BDE::list();
|
|
|
|
adduris << std::string("http://example.org/added1-1");
|
|
|
|
adduris << std::string("http://example.org/added1-2");
|
|
|
|
req._params[3] = adduris;
|
|
|
|
// Set position parameter
|
|
|
|
req._params << 2;
|
|
|
|
res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, res._param[0].i());
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)2, res._param[1].i());
|
|
|
|
uris = files[1]->getRemainingUris();
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)6, uris.size());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://example.org/added1-1"), uris[2]);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://example.org/added1-2"), uris[3]);
|
|
|
|
|
|
|
|
// Change index of FileEntry
|
2010-03-07 07:24:19 +00:00
|
|
|
req._params[1] = 1;
|
2010-03-06 14:21:43 +00:00
|
|
|
// Set position far beyond the size of uris in FileEntry.
|
|
|
|
req._params[4] = 1000;
|
|
|
|
res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, res._param[0].i());
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)2, res._param[1].i());
|
|
|
|
uris = files[0]->getRemainingUris();
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)2, uris.size());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://example.org/added1-1"), uris[0]);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http://example.org/added1-2"), uris[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void XmlRpcMethodTest::testChangeUri_fail()
|
|
|
|
{
|
|
|
|
SharedHandle<FileEntry> files[3];
|
|
|
|
for(int i = 0; i < 3; ++i) {
|
|
|
|
files[i].reset(new FileEntry());
|
|
|
|
}
|
|
|
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
|
|
|
dctx->setFileEntries(&files[0], &files[3]);
|
|
|
|
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
|
|
|
group->setDownloadContext(dctx);
|
|
|
|
_e->_requestGroupMan->addReservedGroup(group);
|
|
|
|
|
|
|
|
ChangeUriXmlRpcMethod m;
|
|
|
|
XmlRpcRequest req(ChangeUriXmlRpcMethod::getMethodName(), BDE::list());
|
|
|
|
req._params << std::string("1"); // GID
|
2010-03-07 07:24:19 +00:00
|
|
|
req._params << 1; // index of FileEntry
|
2010-03-06 14:21:43 +00:00
|
|
|
BDE removeuris = BDE::list();
|
|
|
|
req._params << removeuris;
|
|
|
|
BDE adduris = BDE::list();
|
|
|
|
req._params << adduris;
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
|
|
|
|
req._params[0] = std::string("2");
|
|
|
|
res = m.execute(req, _e.get());
|
|
|
|
// RPC request fails because GID#2 does not exist.
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
|
|
|
|
req._params[0] = std::string("1");
|
2010-03-07 07:24:19 +00:00
|
|
|
req._params[1] = 4;
|
2010-03-06 14:21:43 +00:00
|
|
|
res = m.execute(req, _e.get());
|
|
|
|
// RPC request fails because FileEntry#3 does not exist.
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
|
|
|
|
req._params[1] = std::string("0");
|
|
|
|
res = m.execute(req, _e.get());
|
|
|
|
// RPC request fails because index of FileEntry is string.
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
|
2010-03-07 07:24:19 +00:00
|
|
|
req._params[1] = 1;
|
2010-03-06 14:21:43 +00:00
|
|
|
req._params[2] = std::string("http://url");
|
|
|
|
res = m.execute(req, _e.get());
|
|
|
|
// RPC request fails because 3rd param is not list.
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
|
|
|
|
req._params[2] = BDE::list();
|
|
|
|
req._params[3] = std::string("http://url");
|
|
|
|
res = m.execute(req, _e.get());
|
|
|
|
// RPC request fails because 4th param is not list.
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
}
|
|
|
|
|
2010-01-17 11:55:22 +00:00
|
|
|
void XmlRpcMethodTest::testGetSessionInfo()
|
|
|
|
{
|
|
|
|
GetSessionInfoXmlRpcMethod m;
|
|
|
|
XmlRpcRequest req(GetSessionInfoXmlRpcMethod::getMethodName(), BDE::list());
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(util::toHex(_e->getSessionId()),
|
|
|
|
res._param["sessionId"].s());
|
|
|
|
}
|
|
|
|
|
2009-12-26 10:16:56 +00:00
|
|
|
void XmlRpcMethodTest::testSystemMulticall()
|
|
|
|
{
|
|
|
|
SystemMulticallXmlRpcMethod m;
|
|
|
|
XmlRpcRequest req("system.multicall", BDE::list());
|
|
|
|
BDE reqparams = BDE::list();
|
|
|
|
req._params << reqparams;
|
|
|
|
for(int i = 0; i < 2; ++i) {
|
|
|
|
BDE dict = BDE::dict();
|
2009-12-26 13:07:27 +00:00
|
|
|
dict["methodName"] = std::string(AddUriXmlRpcMethod::getMethodName());
|
2009-12-26 10:16:56 +00:00
|
|
|
BDE params = BDE::list();
|
|
|
|
params << BDE::list();
|
|
|
|
params[0] << BDE("http://localhost/"+util::itos(i));
|
|
|
|
dict["params"] = params;
|
|
|
|
reqparams << dict;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
BDE dict = BDE::dict();
|
|
|
|
dict["methodName"] = std::string("not exists");
|
|
|
|
dict["params"] = BDE::list();
|
|
|
|
reqparams << dict;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
reqparams << std::string("not struct");
|
|
|
|
}
|
|
|
|
{
|
|
|
|
BDE dict = BDE::dict();
|
|
|
|
dict["methodName"] = std::string("system.multicall");
|
|
|
|
dict["params"] = BDE::list();
|
|
|
|
reqparams << dict;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// missing params
|
|
|
|
BDE dict = BDE::dict();
|
2009-12-26 13:07:27 +00:00
|
|
|
dict["methodName"] = std::string(GetVersionXmlRpcMethod::getMethodName());
|
2009-12-26 10:16:56 +00:00
|
|
|
reqparams << dict;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
BDE dict = BDE::dict();
|
2009-12-26 13:07:27 +00:00
|
|
|
dict["methodName"] = std::string(GetVersionXmlRpcMethod::getMethodName());
|
2009-12-26 10:16:56 +00:00
|
|
|
dict["params"] = BDE::list();
|
|
|
|
reqparams << dict;
|
|
|
|
}
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)7, res._param.size());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("1"), res._param[0][0].s());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("2"), res._param[1][0].s());
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)1, res._param[2]["faultCode"].i());
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)1, res._param[3]["faultCode"].i());
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)1, res._param[4]["faultCode"].i());
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)1, res._param[5]["faultCode"].i());
|
|
|
|
CPPUNIT_ASSERT(res._param[6].isList());
|
|
|
|
}
|
|
|
|
|
|
|
|
void XmlRpcMethodTest::testSystemMulticall_fail()
|
|
|
|
{
|
|
|
|
SystemMulticallXmlRpcMethod m;
|
|
|
|
XmlRpcRequest req("system.multicall", BDE::list());
|
|
|
|
XmlRpcResponse res = m.execute(req, _e.get());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
|
|
|
}
|
|
|
|
|
2009-05-08 07:58:50 +00:00
|
|
|
} // namespace xmlrpc
|
|
|
|
|
|
|
|
} // namespace aria2
|