mirror of https://github.com/aria2/aria2
2009-12-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Defined method name in XmlRpcMethod subclasses. * src/XmlRpcMethodFactory.cc * src/XmlRpcMethodImpl.cc * src/XmlRpcMethodImpl.h * test/XmlRpcMethodTest.ccpull/1/head
parent
af20aea88c
commit
1c331e901a
|
@ -1,3 +1,11 @@
|
|||
2009-12-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Defined method name in XmlRpcMethod subclasses.
|
||||
* src/XmlRpcMethodFactory.cc
|
||||
* src/XmlRpcMethodImpl.cc
|
||||
* src/XmlRpcMethodImpl.h
|
||||
* test/XmlRpcMethodTest.cc
|
||||
|
||||
2009-12-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Added system.multicall XML-RPC method.
|
||||
|
|
|
@ -44,52 +44,52 @@ namespace xmlrpc {
|
|||
SharedHandle<XmlRpcMethod>
|
||||
XmlRpcMethodFactory::create(const std::string& methodName)
|
||||
{
|
||||
if(methodName == "aria2.addUri") {
|
||||
if(methodName == AddUriXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new AddUriXmlRpcMethod());
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
} else if(methodName == "aria2.addTorrent") {
|
||||
} else if(methodName == AddTorrentXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new AddTorrentXmlRpcMethod());
|
||||
#endif // ENABLE_BITTORRENT
|
||||
#ifdef ENABLE_METALINK
|
||||
}
|
||||
else if(methodName == "aria2.addMetalink") {
|
||||
else if(methodName == AddMetalinkXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new AddMetalinkXmlRpcMethod());
|
||||
#endif // ENABLE_METALINK
|
||||
}
|
||||
else if(methodName == "aria2.remove") {
|
||||
else if(methodName == RemoveXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new RemoveXmlRpcMethod());
|
||||
} else if(methodName == "aria2.changePosition") {
|
||||
} else if(methodName == ChangePositionXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new ChangePositionXmlRpcMethod());
|
||||
} else if(methodName == "aria2.tellStatus") {
|
||||
} else if(methodName == TellStatusXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new TellStatusXmlRpcMethod());
|
||||
} else if(methodName == "aria2.getUris") {
|
||||
} else if(methodName == GetUrisXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new GetUrisXmlRpcMethod());
|
||||
} else if(methodName == "aria2.getFiles") {
|
||||
} else if(methodName == GetFilesXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new GetFilesXmlRpcMethod());
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
}
|
||||
else if(methodName == "aria2.getPeers") {
|
||||
else if(methodName == GetPeersXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new GetPeersXmlRpcMethod());
|
||||
#endif // ENABLE_BITTORRENT
|
||||
} else if(methodName == "aria2.tellActive") {
|
||||
} else if(methodName == TellActiveXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new TellActiveXmlRpcMethod());
|
||||
} else if(methodName == "aria2.tellWaiting") {
|
||||
} else if(methodName == TellWaitingXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new TellWaitingXmlRpcMethod());
|
||||
} else if(methodName == "aria2.tellStopped") {
|
||||
} else if(methodName == TellStoppedXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new TellStoppedXmlRpcMethod());
|
||||
} else if(methodName == "aria2.getOption") {
|
||||
} else if(methodName == GetOptionXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new GetOptionXmlRpcMethod());
|
||||
} else if(methodName == "aria2.changeOption") {
|
||||
} else if(methodName == ChangeOptionXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new ChangeOptionXmlRpcMethod());
|
||||
} else if(methodName == "aria2.getGlobalOption") {
|
||||
} else if(methodName == GetGlobalOptionXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new GetGlobalOptionXmlRpcMethod());
|
||||
} else if(methodName == "aria2.changeGlobalOption") {
|
||||
} else if(methodName == ChangeGlobalOptionXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new ChangeGlobalOptionXmlRpcMethod());
|
||||
} else if(methodName == "aria2.purgeDownloadResult") {
|
||||
} else if(methodName == PurgeDownloadResultXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new PurgeDownloadResultXmlRpcMethod());
|
||||
} else if(methodName == "aria2.getVersion") {
|
||||
} else if(methodName == GetVersionXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new GetVersionXmlRpcMethod());
|
||||
} else if(methodName == "system.multicall") {
|
||||
} else if(methodName == SystemMulticallXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new SystemMulticallXmlRpcMethod());
|
||||
} else {
|
||||
return SharedHandle<XmlRpcMethod>(new NoSuchMethodXmlRpcMethod());
|
||||
|
|
|
@ -844,7 +844,7 @@ BDE SystemMulticallXmlRpcMethod::process
|
|||
continue;
|
||||
}
|
||||
const std::string& methodName = (*i)[KEY_METHOD_NAME].s();
|
||||
if(methodName == "system.multicall") {
|
||||
if(methodName == getMethodName()) {
|
||||
list << createErrorResponse
|
||||
(DL_ABORT_EX("Recursive system.multicall forbidden."));
|
||||
continue;
|
||||
|
|
|
@ -47,17 +47,35 @@ namespace xmlrpc {
|
|||
class AddUriXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.addUri";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
|
||||
class RemoveXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.remove";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
class AddTorrentXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.addTorrent";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
#endif // ENABLE_BITTORRENT
|
||||
|
||||
|
@ -65,84 +83,180 @@ protected:
|
|||
class AddMetalinkXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.addMetalink";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
#endif // ENABLE_METALINK
|
||||
|
||||
class PurgeDownloadResultXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.purgeDownloadResult";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
|
||||
class GetUrisXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.getUris";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
|
||||
class GetFilesXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.getFiles";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
class GetPeersXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.getPeers";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
#endif // ENABLE_BITTORRENT
|
||||
|
||||
class TellStatusXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.tellStatus";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
|
||||
class TellActiveXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.tellActive";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
|
||||
class TellWaitingXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.tellWaiting";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
|
||||
class TellStoppedXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.tellStopped";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
|
||||
class ChangeOptionXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.changeOption";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
|
||||
class ChangeGlobalOptionXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.changeGlobalOption";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
|
||||
class GetVersionXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.getVersion";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
|
||||
class GetOptionXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.getOption";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
|
||||
class GetGlobalOptionXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.getGlobalOption";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
|
||||
class ChangePositionXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.changePosition";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
|
||||
class SystemMulticallXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "system.multicall";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
|
||||
class NoSuchMethodXmlRpcMethod:public XmlRpcMethod {
|
||||
|
|
|
@ -135,7 +135,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(XmlRpcMethodTest);
|
|||
void XmlRpcMethodTest::testAddUri()
|
||||
{
|
||||
AddUriXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.addUri", BDE::list());
|
||||
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req._params << BDE::list();
|
||||
req._params[0] << BDE("http://localhost/");
|
||||
{
|
||||
|
@ -163,7 +163,7 @@ void XmlRpcMethodTest::testAddUri()
|
|||
void XmlRpcMethodTest::testAddUri_withoutUri()
|
||||
{
|
||||
AddUriXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.addUri", BDE::list());
|
||||
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
||||
XmlRpcResponse res = m.execute(req, _e.get());
|
||||
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ void XmlRpcMethodTest::testAddUri_withoutUri()
|
|||
void XmlRpcMethodTest::testAddUri_notUri()
|
||||
{
|
||||
AddUriXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.addUri", BDE::list());
|
||||
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req._params << BDE::list();
|
||||
req._params[0] << BDE("not uri");
|
||||
XmlRpcResponse res = m.execute(req, _e.get());
|
||||
|
@ -181,7 +181,7 @@ void XmlRpcMethodTest::testAddUri_notUri()
|
|||
void XmlRpcMethodTest::testAddUri_withBadOption()
|
||||
{
|
||||
AddUriXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.addUri", BDE::list());
|
||||
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req._params << BDE::list();
|
||||
req._params[0] << BDE("http://localhost");
|
||||
BDE opt = BDE::dict();
|
||||
|
@ -194,13 +194,13 @@ void XmlRpcMethodTest::testAddUri_withBadOption()
|
|||
void XmlRpcMethodTest::testAddUri_withPosition()
|
||||
{
|
||||
AddUriXmlRpcMethod m;
|
||||
XmlRpcRequest req1("aria2.addUri", BDE::list());
|
||||
XmlRpcRequest req1(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req1._params << BDE::list();
|
||||
req1._params[0] << BDE("http://uri1");
|
||||
XmlRpcResponse res1 = m.execute(req1, _e.get());
|
||||
CPPUNIT_ASSERT_EQUAL(0, res1._code);
|
||||
|
||||
XmlRpcRequest req2("aria2.addUri", BDE::list());
|
||||
XmlRpcRequest req2(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req2._params << BDE::list();
|
||||
req2._params[0] << BDE("http://uri2");
|
||||
req2._params << BDE::dict();
|
||||
|
@ -216,7 +216,7 @@ void XmlRpcMethodTest::testAddUri_withPosition()
|
|||
void XmlRpcMethodTest::testAddUri_withBadPosition()
|
||||
{
|
||||
AddUriXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.addUri", BDE::list());
|
||||
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req._params << BDE::list();
|
||||
req._params[0] << BDE("http://localhost/");
|
||||
req._params << BDE::dict();
|
||||
|
@ -229,7 +229,7 @@ void XmlRpcMethodTest::testAddUri_withBadPosition()
|
|||
void XmlRpcMethodTest::testAddTorrent()
|
||||
{
|
||||
AddTorrentXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.addTorrent", BDE::list());
|
||||
XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req._params << BDE(readFile("single.torrent"));
|
||||
BDE uris = BDE::list();
|
||||
uris << BDE("http://localhost/aria2-0.8.2.tar.bz2");
|
||||
|
@ -262,7 +262,7 @@ void XmlRpcMethodTest::testAddTorrent()
|
|||
void XmlRpcMethodTest::testAddTorrent_withoutTorrent()
|
||||
{
|
||||
AddTorrentXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.addTorrent", BDE::list());
|
||||
XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), BDE::list());
|
||||
XmlRpcResponse res = m.execute(req, _e.get());
|
||||
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ void XmlRpcMethodTest::testAddTorrent_withoutTorrent()
|
|||
void XmlRpcMethodTest::testAddTorrent_notBase64Torrent()
|
||||
{
|
||||
AddTorrentXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.addTorrent", BDE::list());
|
||||
XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req._params << BDE("not torrent");
|
||||
XmlRpcResponse res = m.execute(req, _e.get());
|
||||
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
||||
|
@ -279,14 +279,14 @@ void XmlRpcMethodTest::testAddTorrent_notBase64Torrent()
|
|||
void XmlRpcMethodTest::testAddTorrent_withPosition()
|
||||
{
|
||||
AddTorrentXmlRpcMethod m;
|
||||
XmlRpcRequest req1("aria2.addTorrent", BDE::list());
|
||||
XmlRpcRequest req1(AddTorrentXmlRpcMethod::getMethodName(), BDE::list());
|
||||
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);
|
||||
|
||||
XmlRpcRequest req2("aria2.addTorrent", BDE::list());
|
||||
XmlRpcRequest req2(AddTorrentXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req2._params << BDE(readFile("single.torrent"));
|
||||
req2._params << BDE::list();
|
||||
req2._params << BDE::dict();
|
||||
|
@ -304,7 +304,7 @@ void XmlRpcMethodTest::testAddTorrent_withPosition()
|
|||
void XmlRpcMethodTest::testAddMetalink()
|
||||
{
|
||||
AddMetalinkXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.addMetalink", BDE::list());
|
||||
XmlRpcRequest req(AddMetalinkXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req._params << BDE(readFile("2files.metalink"));
|
||||
{
|
||||
XmlRpcResponse res = m.execute(req, _e.get());
|
||||
|
@ -337,7 +337,7 @@ void XmlRpcMethodTest::testAddMetalink()
|
|||
void XmlRpcMethodTest::testAddMetalink_withoutMetalink()
|
||||
{
|
||||
AddMetalinkXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.addMetalink", BDE::list());
|
||||
XmlRpcRequest req(AddMetalinkXmlRpcMethod::getMethodName(), BDE::list());
|
||||
XmlRpcResponse res = m.execute(req, _e.get());
|
||||
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ void XmlRpcMethodTest::testAddMetalink_withoutMetalink()
|
|||
void XmlRpcMethodTest::testAddMetalink_notBase64Metalink()
|
||||
{
|
||||
AddMetalinkXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.addMetalink", BDE::list());
|
||||
XmlRpcRequest req(AddMetalinkXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req._params << BDE("not metalink");
|
||||
XmlRpcResponse res = m.execute(req, _e.get());
|
||||
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
||||
|
@ -354,7 +354,7 @@ void XmlRpcMethodTest::testAddMetalink_notBase64Metalink()
|
|||
void XmlRpcMethodTest::testAddMetalink_withPosition()
|
||||
{
|
||||
AddUriXmlRpcMethod m1;
|
||||
XmlRpcRequest req1("aria2.addUri", BDE::list());
|
||||
XmlRpcRequest req1(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req1._params << BDE::list();
|
||||
req1._params[0] << BDE("http://uri");
|
||||
XmlRpcResponse res1 = m1.execute(req1, _e.get());
|
||||
|
@ -381,7 +381,7 @@ void XmlRpcMethodTest::testChangeOption()
|
|||
_e->_requestGroupMan->addReservedGroup(group);
|
||||
|
||||
ChangeOptionXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.changeOption", BDE::list());
|
||||
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req._params << BDE("1");
|
||||
BDE opt = BDE::dict();
|
||||
opt[PREF_MAX_DOWNLOAD_LIMIT] = BDE("100K");
|
||||
|
@ -424,7 +424,7 @@ void XmlRpcMethodTest::testChangeOption_withBadOption()
|
|||
_e->_requestGroupMan->addReservedGroup(group);
|
||||
|
||||
ChangeOptionXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.changeOption", BDE::list());
|
||||
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req._params << BDE("1");
|
||||
BDE opt = BDE::dict();
|
||||
opt[PREF_MAX_DOWNLOAD_LIMIT] = BDE("badvalue");
|
||||
|
@ -439,7 +439,7 @@ void XmlRpcMethodTest::testChangeOption_withNotAllowedOption()
|
|||
_e->_requestGroupMan->addReservedGroup(group);
|
||||
|
||||
ChangeOptionXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.changeOption", BDE::list());
|
||||
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req._params << BDE("1");
|
||||
BDE opt = BDE::dict();
|
||||
opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("100K");
|
||||
|
@ -451,7 +451,7 @@ void XmlRpcMethodTest::testChangeOption_withNotAllowedOption()
|
|||
void XmlRpcMethodTest::testChangeOption_withoutGid()
|
||||
{
|
||||
ChangeOptionXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.changeOption", BDE::list());
|
||||
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
|
||||
XmlRpcResponse res = m.execute(req, _e.get());
|
||||
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
||||
}
|
||||
|
@ -459,7 +459,7 @@ void XmlRpcMethodTest::testChangeOption_withoutGid()
|
|||
void XmlRpcMethodTest::testChangeGlobalOption()
|
||||
{
|
||||
ChangeGlobalOptionXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.changeGlobalOption", BDE::list());
|
||||
XmlRpcRequest req(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
|
||||
BDE opt = BDE::dict();
|
||||
opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("100K");
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
|
@ -484,7 +484,7 @@ void XmlRpcMethodTest::testChangeGlobalOption()
|
|||
void XmlRpcMethodTest::testChangeGlobalOption_withBadOption()
|
||||
{
|
||||
ChangeGlobalOptionXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.changeGlobalOption", BDE::list());
|
||||
XmlRpcRequest req(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
|
||||
BDE opt = BDE::dict();
|
||||
opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("badvalue");
|
||||
req._params << opt;
|
||||
|
@ -495,7 +495,7 @@ void XmlRpcMethodTest::testChangeGlobalOption_withBadOption()
|
|||
void XmlRpcMethodTest::testChangeGlobalOption_withNotAllowedOption()
|
||||
{
|
||||
ChangeGlobalOptionXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.changeGlobalOption", BDE::list());
|
||||
XmlRpcRequest req(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
|
||||
BDE opt = BDE::dict();
|
||||
opt[PREF_MAX_DOWNLOAD_LIMIT] = BDE("100K");
|
||||
req._params << opt;
|
||||
|
@ -536,7 +536,7 @@ void XmlRpcMethodTest::testNoSuchMethod()
|
|||
void XmlRpcMethodTest::testTellStatus_withoutGid()
|
||||
{
|
||||
TellStatusXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.tellStatus", BDE::list());
|
||||
XmlRpcRequest req(TellStatusXmlRpcMethod::getMethodName(), BDE::list());
|
||||
XmlRpcResponse res = m.execute(req, _e.get());
|
||||
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
||||
}
|
||||
|
@ -545,7 +545,7 @@ static void addUri(const std::string& uri,
|
|||
const SharedHandle<DownloadEngine>& e)
|
||||
{
|
||||
AddUriXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.addUri", BDE::list());
|
||||
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req._params << BDE::list();
|
||||
req._params[0] << BDE(uri);
|
||||
CPPUNIT_ASSERT_EQUAL(0, m.execute(req, e.get())._code);
|
||||
|
@ -557,7 +557,7 @@ static void addTorrent
|
|||
(const std::string& torrentFile, const SharedHandle<DownloadEngine>& e)
|
||||
{
|
||||
AddTorrentXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.addTorrent", BDE::list());
|
||||
XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req._params << BDE(readFile(torrentFile));
|
||||
XmlRpcResponse res = m.execute(req, e.get());
|
||||
}
|
||||
|
@ -574,7 +574,7 @@ void XmlRpcMethodTest::testTellWaiting()
|
|||
#endif // ENABLE_BITTORRENT
|
||||
|
||||
TellWaitingXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.tellWaiting", BDE::list());
|
||||
XmlRpcRequest req(TellWaitingXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req._params << BDE((int64_t)1);
|
||||
req._params << BDE((int64_t)2);
|
||||
XmlRpcResponse res = m.execute(req, _e.get());
|
||||
|
@ -583,7 +583,7 @@ void XmlRpcMethodTest::testTellWaiting()
|
|||
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
|
||||
req = XmlRpcRequest("aria2.tellWaiting", BDE::list());
|
||||
req = XmlRpcRequest(TellWaitingXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req._params << BDE((int64_t)1);
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
req._params << BDE((int64_t)3);
|
||||
|
@ -598,7 +598,7 @@ void XmlRpcMethodTest::testTellWaiting()
|
|||
CPPUNIT_ASSERT_EQUAL((size_t)2, res._param.size());
|
||||
#endif // !ENABLE_BITTORRENT
|
||||
// waiting.size() < offset+num
|
||||
req = XmlRpcRequest("aria2.tellWaiting", BDE::list());
|
||||
req = XmlRpcRequest(TellWaitingXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req._params << BDE((int64_t)1);
|
||||
req._params << BDE((int64_t)4);
|
||||
res = m.execute(req, _e.get());
|
||||
|
@ -613,7 +613,7 @@ void XmlRpcMethodTest::testTellWaiting()
|
|||
void XmlRpcMethodTest::testTellWaiting_fail()
|
||||
{
|
||||
TellWaitingXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.tellWaiting", BDE::list());
|
||||
XmlRpcRequest req(TellWaitingXmlRpcMethod::getMethodName(), BDE::list());
|
||||
XmlRpcResponse res = m.execute(req, _e.get());
|
||||
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
||||
}
|
||||
|
@ -621,7 +621,7 @@ void XmlRpcMethodTest::testTellWaiting_fail()
|
|||
void XmlRpcMethodTest::testGetVersion()
|
||||
{
|
||||
GetVersionXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.getVersion", BDE::none);
|
||||
XmlRpcRequest req(GetVersionXmlRpcMethod::getMethodName(), BDE::none);
|
||||
XmlRpcResponse res = m.execute(req, _e.get());
|
||||
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(PACKAGE_VERSION), res._param["version"].s());
|
||||
|
@ -692,7 +692,7 @@ void XmlRpcMethodTest::testChangePosition()
|
|||
(SharedHandle<RequestGroup>(new RequestGroup(_option)));
|
||||
|
||||
ChangePositionXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.changePosition", BDE::list());
|
||||
XmlRpcRequest req(ChangePositionXmlRpcMethod::getMethodName(), BDE::list());
|
||||
req._params << std::string("1");
|
||||
req._params << BDE((int64_t)1);
|
||||
req._params << std::string("POS_SET");
|
||||
|
@ -706,7 +706,7 @@ void XmlRpcMethodTest::testChangePosition()
|
|||
void XmlRpcMethodTest::testChangePosition_fail()
|
||||
{
|
||||
ChangePositionXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.changePosition", BDE::list());
|
||||
XmlRpcRequest req(ChangePositionXmlRpcMethod::getMethodName(), BDE::list());
|
||||
XmlRpcResponse res = m.execute(req, _e.get());
|
||||
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
||||
|
||||
|
@ -724,7 +724,7 @@ void XmlRpcMethodTest::testSystemMulticall()
|
|||
req._params << reqparams;
|
||||
for(int i = 0; i < 2; ++i) {
|
||||
BDE dict = BDE::dict();
|
||||
dict["methodName"] = std::string("aria2.addUri");
|
||||
dict["methodName"] = std::string(AddUriXmlRpcMethod::getMethodName());
|
||||
BDE params = BDE::list();
|
||||
params << BDE::list();
|
||||
params[0] << BDE("http://localhost/"+util::itos(i));
|
||||
|
@ -749,12 +749,12 @@ void XmlRpcMethodTest::testSystemMulticall()
|
|||
{
|
||||
// missing params
|
||||
BDE dict = BDE::dict();
|
||||
dict["methodName"] = std::string("aria2.getVersion");
|
||||
dict["methodName"] = std::string(GetVersionXmlRpcMethod::getMethodName());
|
||||
reqparams << dict;
|
||||
}
|
||||
{
|
||||
BDE dict = BDE::dict();
|
||||
dict["methodName"] = std::string("aria2.getVersion");
|
||||
dict["methodName"] = std::string(GetVersionXmlRpcMethod::getMethodName());
|
||||
dict["params"] = BDE::list();
|
||||
reqparams << dict;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue