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
This commit is contained in:
Tatsuhiro Tsujikawa 2009-12-26 13:07:27 +00:00
parent af20aea88c
commit 1c331e901a
5 changed files with 178 additions and 56 deletions

View file

@ -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> 2009-12-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added system.multicall XML-RPC method. Added system.multicall XML-RPC method.

View file

@ -44,52 +44,52 @@ namespace xmlrpc {
SharedHandle<XmlRpcMethod> SharedHandle<XmlRpcMethod>
XmlRpcMethodFactory::create(const std::string& methodName) XmlRpcMethodFactory::create(const std::string& methodName)
{ {
if(methodName == "aria2.addUri") { if(methodName == AddUriXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new AddUriXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new AddUriXmlRpcMethod());
#ifdef ENABLE_BITTORRENT #ifdef ENABLE_BITTORRENT
} else if(methodName == "aria2.addTorrent") { } else if(methodName == AddTorrentXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new AddTorrentXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new AddTorrentXmlRpcMethod());
#endif // ENABLE_BITTORRENT #endif // ENABLE_BITTORRENT
#ifdef ENABLE_METALINK #ifdef ENABLE_METALINK
} }
else if(methodName == "aria2.addMetalink") { else if(methodName == AddMetalinkXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new AddMetalinkXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new AddMetalinkXmlRpcMethod());
#endif // ENABLE_METALINK #endif // ENABLE_METALINK
} }
else if(methodName == "aria2.remove") { else if(methodName == RemoveXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new RemoveXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new RemoveXmlRpcMethod());
} else if(methodName == "aria2.changePosition") { } else if(methodName == ChangePositionXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new ChangePositionXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new ChangePositionXmlRpcMethod());
} else if(methodName == "aria2.tellStatus") { } else if(methodName == TellStatusXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new TellStatusXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new TellStatusXmlRpcMethod());
} else if(methodName == "aria2.getUris") { } else if(methodName == GetUrisXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new GetUrisXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new GetUrisXmlRpcMethod());
} else if(methodName == "aria2.getFiles") { } else if(methodName == GetFilesXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new GetFilesXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new GetFilesXmlRpcMethod());
#ifdef ENABLE_BITTORRENT #ifdef ENABLE_BITTORRENT
} }
else if(methodName == "aria2.getPeers") { else if(methodName == GetPeersXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new GetPeersXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new GetPeersXmlRpcMethod());
#endif // ENABLE_BITTORRENT #endif // ENABLE_BITTORRENT
} else if(methodName == "aria2.tellActive") { } else if(methodName == TellActiveXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new TellActiveXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new TellActiveXmlRpcMethod());
} else if(methodName == "aria2.tellWaiting") { } else if(methodName == TellWaitingXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new TellWaitingXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new TellWaitingXmlRpcMethod());
} else if(methodName == "aria2.tellStopped") { } else if(methodName == TellStoppedXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new TellStoppedXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new TellStoppedXmlRpcMethod());
} else if(methodName == "aria2.getOption") { } else if(methodName == GetOptionXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new GetOptionXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new GetOptionXmlRpcMethod());
} else if(methodName == "aria2.changeOption") { } else if(methodName == ChangeOptionXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new ChangeOptionXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new ChangeOptionXmlRpcMethod());
} else if(methodName == "aria2.getGlobalOption") { } else if(methodName == GetGlobalOptionXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new GetGlobalOptionXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new GetGlobalOptionXmlRpcMethod());
} else if(methodName == "aria2.changeGlobalOption") { } else if(methodName == ChangeGlobalOptionXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new ChangeGlobalOptionXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new ChangeGlobalOptionXmlRpcMethod());
} else if(methodName == "aria2.purgeDownloadResult") { } else if(methodName == PurgeDownloadResultXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new PurgeDownloadResultXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new PurgeDownloadResultXmlRpcMethod());
} else if(methodName == "aria2.getVersion") { } else if(methodName == GetVersionXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new GetVersionXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new GetVersionXmlRpcMethod());
} else if(methodName == "system.multicall") { } else if(methodName == SystemMulticallXmlRpcMethod::getMethodName()) {
return SharedHandle<XmlRpcMethod>(new SystemMulticallXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new SystemMulticallXmlRpcMethod());
} else { } else {
return SharedHandle<XmlRpcMethod>(new NoSuchMethodXmlRpcMethod()); return SharedHandle<XmlRpcMethod>(new NoSuchMethodXmlRpcMethod());

View file

@ -844,7 +844,7 @@ BDE SystemMulticallXmlRpcMethod::process
continue; continue;
} }
const std::string& methodName = (*i)[KEY_METHOD_NAME].s(); const std::string& methodName = (*i)[KEY_METHOD_NAME].s();
if(methodName == "system.multicall") { if(methodName == getMethodName()) {
list << createErrorResponse list << createErrorResponse
(DL_ABORT_EX("Recursive system.multicall forbidden.")); (DL_ABORT_EX("Recursive system.multicall forbidden."));
continue; continue;

View file

@ -47,17 +47,35 @@ namespace xmlrpc {
class AddUriXmlRpcMethod:public XmlRpcMethod { class AddUriXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 { class RemoveXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 #ifdef ENABLE_BITTORRENT
class AddTorrentXmlRpcMethod:public XmlRpcMethod { class AddTorrentXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 #endif // ENABLE_BITTORRENT
@ -65,84 +83,180 @@ protected:
class AddMetalinkXmlRpcMethod:public XmlRpcMethod { class AddMetalinkXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 #endif // ENABLE_METALINK
class PurgeDownloadResultXmlRpcMethod:public XmlRpcMethod { class PurgeDownloadResultXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 { class GetUrisXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 { class GetFilesXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 #ifdef ENABLE_BITTORRENT
class GetPeersXmlRpcMethod:public XmlRpcMethod { class GetPeersXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 #endif // ENABLE_BITTORRENT
class TellStatusXmlRpcMethod:public XmlRpcMethod { class TellStatusXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 { class TellActiveXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 { class TellWaitingXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 { class TellStoppedXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 { class ChangeOptionXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 { class ChangeGlobalOptionXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 { class GetVersionXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 { class GetOptionXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 { class GetGlobalOptionXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 { class ChangePositionXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 { class SystemMulticallXmlRpcMethod:public XmlRpcMethod {
protected: protected:
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); 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 { class NoSuchMethodXmlRpcMethod:public XmlRpcMethod {

View file

@ -135,7 +135,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(XmlRpcMethodTest);
void XmlRpcMethodTest::testAddUri() void XmlRpcMethodTest::testAddUri()
{ {
AddUriXmlRpcMethod m; AddUriXmlRpcMethod m;
XmlRpcRequest req("aria2.addUri", BDE::list()); XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
req._params << BDE::list(); req._params << BDE::list();
req._params[0] << BDE("http://localhost/"); req._params[0] << BDE("http://localhost/");
{ {
@ -163,7 +163,7 @@ void XmlRpcMethodTest::testAddUri()
void XmlRpcMethodTest::testAddUri_withoutUri() void XmlRpcMethodTest::testAddUri_withoutUri()
{ {
AddUriXmlRpcMethod m; AddUriXmlRpcMethod m;
XmlRpcRequest req("aria2.addUri", BDE::list()); XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
XmlRpcResponse res = m.execute(req, _e.get()); XmlRpcResponse res = m.execute(req, _e.get());
CPPUNIT_ASSERT_EQUAL(1, res._code); CPPUNIT_ASSERT_EQUAL(1, res._code);
} }
@ -171,7 +171,7 @@ void XmlRpcMethodTest::testAddUri_withoutUri()
void XmlRpcMethodTest::testAddUri_notUri() void XmlRpcMethodTest::testAddUri_notUri()
{ {
AddUriXmlRpcMethod m; AddUriXmlRpcMethod m;
XmlRpcRequest req("aria2.addUri", BDE::list()); XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
req._params << BDE::list(); req._params << BDE::list();
req._params[0] << BDE("not uri"); req._params[0] << BDE("not uri");
XmlRpcResponse res = m.execute(req, _e.get()); XmlRpcResponse res = m.execute(req, _e.get());
@ -181,7 +181,7 @@ void XmlRpcMethodTest::testAddUri_notUri()
void XmlRpcMethodTest::testAddUri_withBadOption() void XmlRpcMethodTest::testAddUri_withBadOption()
{ {
AddUriXmlRpcMethod m; AddUriXmlRpcMethod m;
XmlRpcRequest req("aria2.addUri", BDE::list()); XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
req._params << BDE::list(); req._params << BDE::list();
req._params[0] << BDE("http://localhost"); req._params[0] << BDE("http://localhost");
BDE opt = BDE::dict(); BDE opt = BDE::dict();
@ -194,13 +194,13 @@ void XmlRpcMethodTest::testAddUri_withBadOption()
void XmlRpcMethodTest::testAddUri_withPosition() void XmlRpcMethodTest::testAddUri_withPosition()
{ {
AddUriXmlRpcMethod m; AddUriXmlRpcMethod m;
XmlRpcRequest req1("aria2.addUri", BDE::list()); XmlRpcRequest req1(AddUriXmlRpcMethod::getMethodName(), BDE::list());
req1._params << BDE::list(); req1._params << BDE::list();
req1._params[0] << BDE("http://uri1"); req1._params[0] << BDE("http://uri1");
XmlRpcResponse res1 = m.execute(req1, _e.get()); XmlRpcResponse res1 = m.execute(req1, _e.get());
CPPUNIT_ASSERT_EQUAL(0, res1._code); CPPUNIT_ASSERT_EQUAL(0, res1._code);
XmlRpcRequest req2("aria2.addUri", BDE::list()); XmlRpcRequest req2(AddUriXmlRpcMethod::getMethodName(), BDE::list());
req2._params << BDE::list(); req2._params << BDE::list();
req2._params[0] << BDE("http://uri2"); req2._params[0] << BDE("http://uri2");
req2._params << BDE::dict(); req2._params << BDE::dict();
@ -216,7 +216,7 @@ void XmlRpcMethodTest::testAddUri_withPosition()
void XmlRpcMethodTest::testAddUri_withBadPosition() void XmlRpcMethodTest::testAddUri_withBadPosition()
{ {
AddUriXmlRpcMethod m; AddUriXmlRpcMethod m;
XmlRpcRequest req("aria2.addUri", BDE::list()); XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
req._params << BDE::list(); req._params << BDE::list();
req._params[0] << BDE("http://localhost/"); req._params[0] << BDE("http://localhost/");
req._params << BDE::dict(); req._params << BDE::dict();
@ -229,7 +229,7 @@ void XmlRpcMethodTest::testAddUri_withBadPosition()
void XmlRpcMethodTest::testAddTorrent() void XmlRpcMethodTest::testAddTorrent()
{ {
AddTorrentXmlRpcMethod m; AddTorrentXmlRpcMethod m;
XmlRpcRequest req("aria2.addTorrent", BDE::list()); XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), BDE::list());
req._params << BDE(readFile("single.torrent")); req._params << BDE(readFile("single.torrent"));
BDE uris = BDE::list(); BDE uris = BDE::list();
uris << BDE("http://localhost/aria2-0.8.2.tar.bz2"); uris << BDE("http://localhost/aria2-0.8.2.tar.bz2");
@ -262,7 +262,7 @@ void XmlRpcMethodTest::testAddTorrent()
void XmlRpcMethodTest::testAddTorrent_withoutTorrent() void XmlRpcMethodTest::testAddTorrent_withoutTorrent()
{ {
AddTorrentXmlRpcMethod m; AddTorrentXmlRpcMethod m;
XmlRpcRequest req("aria2.addTorrent", BDE::list()); XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), BDE::list());
XmlRpcResponse res = m.execute(req, _e.get()); XmlRpcResponse res = m.execute(req, _e.get());
CPPUNIT_ASSERT_EQUAL(1, res._code); CPPUNIT_ASSERT_EQUAL(1, res._code);
} }
@ -270,7 +270,7 @@ void XmlRpcMethodTest::testAddTorrent_withoutTorrent()
void XmlRpcMethodTest::testAddTorrent_notBase64Torrent() void XmlRpcMethodTest::testAddTorrent_notBase64Torrent()
{ {
AddTorrentXmlRpcMethod m; AddTorrentXmlRpcMethod m;
XmlRpcRequest req("aria2.addTorrent", BDE::list()); XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), BDE::list());
req._params << BDE("not torrent"); req._params << BDE("not torrent");
XmlRpcResponse res = m.execute(req, _e.get()); XmlRpcResponse res = m.execute(req, _e.get());
CPPUNIT_ASSERT_EQUAL(1, res._code); CPPUNIT_ASSERT_EQUAL(1, res._code);
@ -279,14 +279,14 @@ void XmlRpcMethodTest::testAddTorrent_notBase64Torrent()
void XmlRpcMethodTest::testAddTorrent_withPosition() void XmlRpcMethodTest::testAddTorrent_withPosition()
{ {
AddTorrentXmlRpcMethod m; AddTorrentXmlRpcMethod m;
XmlRpcRequest req1("aria2.addTorrent", BDE::list()); XmlRpcRequest req1(AddTorrentXmlRpcMethod::getMethodName(), BDE::list());
req1._params << BDE(readFile("test.torrent")); req1._params << BDE(readFile("test.torrent"));
req1._params << BDE::list(); req1._params << BDE::list();
req1._params << BDE::dict(); req1._params << BDE::dict();
XmlRpcResponse res1 = m.execute(req1, _e.get()); XmlRpcResponse res1 = m.execute(req1, _e.get());
CPPUNIT_ASSERT_EQUAL(0, res1._code); 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(readFile("single.torrent"));
req2._params << BDE::list(); req2._params << BDE::list();
req2._params << BDE::dict(); req2._params << BDE::dict();
@ -304,7 +304,7 @@ void XmlRpcMethodTest::testAddTorrent_withPosition()
void XmlRpcMethodTest::testAddMetalink() void XmlRpcMethodTest::testAddMetalink()
{ {
AddMetalinkXmlRpcMethod m; AddMetalinkXmlRpcMethod m;
XmlRpcRequest req("aria2.addMetalink", BDE::list()); XmlRpcRequest req(AddMetalinkXmlRpcMethod::getMethodName(), BDE::list());
req._params << BDE(readFile("2files.metalink")); req._params << BDE(readFile("2files.metalink"));
{ {
XmlRpcResponse res = m.execute(req, _e.get()); XmlRpcResponse res = m.execute(req, _e.get());
@ -337,7 +337,7 @@ void XmlRpcMethodTest::testAddMetalink()
void XmlRpcMethodTest::testAddMetalink_withoutMetalink() void XmlRpcMethodTest::testAddMetalink_withoutMetalink()
{ {
AddMetalinkXmlRpcMethod m; AddMetalinkXmlRpcMethod m;
XmlRpcRequest req("aria2.addMetalink", BDE::list()); XmlRpcRequest req(AddMetalinkXmlRpcMethod::getMethodName(), BDE::list());
XmlRpcResponse res = m.execute(req, _e.get()); XmlRpcResponse res = m.execute(req, _e.get());
CPPUNIT_ASSERT_EQUAL(1, res._code); CPPUNIT_ASSERT_EQUAL(1, res._code);
} }
@ -345,7 +345,7 @@ void XmlRpcMethodTest::testAddMetalink_withoutMetalink()
void XmlRpcMethodTest::testAddMetalink_notBase64Metalink() void XmlRpcMethodTest::testAddMetalink_notBase64Metalink()
{ {
AddMetalinkXmlRpcMethod m; AddMetalinkXmlRpcMethod m;
XmlRpcRequest req("aria2.addMetalink", BDE::list()); XmlRpcRequest req(AddMetalinkXmlRpcMethod::getMethodName(), BDE::list());
req._params << BDE("not metalink"); req._params << BDE("not metalink");
XmlRpcResponse res = m.execute(req, _e.get()); XmlRpcResponse res = m.execute(req, _e.get());
CPPUNIT_ASSERT_EQUAL(1, res._code); CPPUNIT_ASSERT_EQUAL(1, res._code);
@ -354,7 +354,7 @@ void XmlRpcMethodTest::testAddMetalink_notBase64Metalink()
void XmlRpcMethodTest::testAddMetalink_withPosition() void XmlRpcMethodTest::testAddMetalink_withPosition()
{ {
AddUriXmlRpcMethod m1; AddUriXmlRpcMethod m1;
XmlRpcRequest req1("aria2.addUri", BDE::list()); XmlRpcRequest req1(AddUriXmlRpcMethod::getMethodName(), BDE::list());
req1._params << BDE::list(); req1._params << BDE::list();
req1._params[0] << BDE("http://uri"); req1._params[0] << BDE("http://uri");
XmlRpcResponse res1 = m1.execute(req1, _e.get()); XmlRpcResponse res1 = m1.execute(req1, _e.get());
@ -381,7 +381,7 @@ void XmlRpcMethodTest::testChangeOption()
_e->_requestGroupMan->addReservedGroup(group); _e->_requestGroupMan->addReservedGroup(group);
ChangeOptionXmlRpcMethod m; ChangeOptionXmlRpcMethod m;
XmlRpcRequest req("aria2.changeOption", BDE::list()); XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
req._params << BDE("1"); req._params << BDE("1");
BDE opt = BDE::dict(); BDE opt = BDE::dict();
opt[PREF_MAX_DOWNLOAD_LIMIT] = BDE("100K"); opt[PREF_MAX_DOWNLOAD_LIMIT] = BDE("100K");
@ -424,7 +424,7 @@ void XmlRpcMethodTest::testChangeOption_withBadOption()
_e->_requestGroupMan->addReservedGroup(group); _e->_requestGroupMan->addReservedGroup(group);
ChangeOptionXmlRpcMethod m; ChangeOptionXmlRpcMethod m;
XmlRpcRequest req("aria2.changeOption", BDE::list()); XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
req._params << BDE("1"); req._params << BDE("1");
BDE opt = BDE::dict(); BDE opt = BDE::dict();
opt[PREF_MAX_DOWNLOAD_LIMIT] = BDE("badvalue"); opt[PREF_MAX_DOWNLOAD_LIMIT] = BDE("badvalue");
@ -439,7 +439,7 @@ void XmlRpcMethodTest::testChangeOption_withNotAllowedOption()
_e->_requestGroupMan->addReservedGroup(group); _e->_requestGroupMan->addReservedGroup(group);
ChangeOptionXmlRpcMethod m; ChangeOptionXmlRpcMethod m;
XmlRpcRequest req("aria2.changeOption", BDE::list()); XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
req._params << BDE("1"); req._params << BDE("1");
BDE opt = BDE::dict(); BDE opt = BDE::dict();
opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("100K"); opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("100K");
@ -451,7 +451,7 @@ void XmlRpcMethodTest::testChangeOption_withNotAllowedOption()
void XmlRpcMethodTest::testChangeOption_withoutGid() void XmlRpcMethodTest::testChangeOption_withoutGid()
{ {
ChangeOptionXmlRpcMethod m; ChangeOptionXmlRpcMethod m;
XmlRpcRequest req("aria2.changeOption", BDE::list()); XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
XmlRpcResponse res = m.execute(req, _e.get()); XmlRpcResponse res = m.execute(req, _e.get());
CPPUNIT_ASSERT_EQUAL(1, res._code); CPPUNIT_ASSERT_EQUAL(1, res._code);
} }
@ -459,7 +459,7 @@ void XmlRpcMethodTest::testChangeOption_withoutGid()
void XmlRpcMethodTest::testChangeGlobalOption() void XmlRpcMethodTest::testChangeGlobalOption()
{ {
ChangeGlobalOptionXmlRpcMethod m; ChangeGlobalOptionXmlRpcMethod m;
XmlRpcRequest req("aria2.changeGlobalOption", BDE::list()); XmlRpcRequest req(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
BDE opt = BDE::dict(); BDE opt = BDE::dict();
opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("100K"); opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("100K");
#ifdef ENABLE_BITTORRENT #ifdef ENABLE_BITTORRENT
@ -484,7 +484,7 @@ void XmlRpcMethodTest::testChangeGlobalOption()
void XmlRpcMethodTest::testChangeGlobalOption_withBadOption() void XmlRpcMethodTest::testChangeGlobalOption_withBadOption()
{ {
ChangeGlobalOptionXmlRpcMethod m; ChangeGlobalOptionXmlRpcMethod m;
XmlRpcRequest req("aria2.changeGlobalOption", BDE::list()); XmlRpcRequest req(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
BDE opt = BDE::dict(); BDE opt = BDE::dict();
opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("badvalue"); opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("badvalue");
req._params << opt; req._params << opt;
@ -495,7 +495,7 @@ void XmlRpcMethodTest::testChangeGlobalOption_withBadOption()
void XmlRpcMethodTest::testChangeGlobalOption_withNotAllowedOption() void XmlRpcMethodTest::testChangeGlobalOption_withNotAllowedOption()
{ {
ChangeGlobalOptionXmlRpcMethod m; ChangeGlobalOptionXmlRpcMethod m;
XmlRpcRequest req("aria2.changeGlobalOption", BDE::list()); XmlRpcRequest req(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
BDE opt = BDE::dict(); BDE opt = BDE::dict();
opt[PREF_MAX_DOWNLOAD_LIMIT] = BDE("100K"); opt[PREF_MAX_DOWNLOAD_LIMIT] = BDE("100K");
req._params << opt; req._params << opt;
@ -536,7 +536,7 @@ void XmlRpcMethodTest::testNoSuchMethod()
void XmlRpcMethodTest::testTellStatus_withoutGid() void XmlRpcMethodTest::testTellStatus_withoutGid()
{ {
TellStatusXmlRpcMethod m; TellStatusXmlRpcMethod m;
XmlRpcRequest req("aria2.tellStatus", BDE::list()); XmlRpcRequest req(TellStatusXmlRpcMethod::getMethodName(), BDE::list());
XmlRpcResponse res = m.execute(req, _e.get()); XmlRpcResponse res = m.execute(req, _e.get());
CPPUNIT_ASSERT_EQUAL(1, res._code); CPPUNIT_ASSERT_EQUAL(1, res._code);
} }
@ -545,7 +545,7 @@ static void addUri(const std::string& uri,
const SharedHandle<DownloadEngine>& e) const SharedHandle<DownloadEngine>& e)
{ {
AddUriXmlRpcMethod m; AddUriXmlRpcMethod m;
XmlRpcRequest req("aria2.addUri", BDE::list()); XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list());
req._params << BDE::list(); req._params << BDE::list();
req._params[0] << BDE(uri); req._params[0] << BDE(uri);
CPPUNIT_ASSERT_EQUAL(0, m.execute(req, e.get())._code); 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) (const std::string& torrentFile, const SharedHandle<DownloadEngine>& e)
{ {
AddTorrentXmlRpcMethod m; AddTorrentXmlRpcMethod m;
XmlRpcRequest req("aria2.addTorrent", BDE::list()); XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), BDE::list());
req._params << BDE(readFile(torrentFile)); req._params << BDE(readFile(torrentFile));
XmlRpcResponse res = m.execute(req, e.get()); XmlRpcResponse res = m.execute(req, e.get());
} }
@ -574,7 +574,7 @@ void XmlRpcMethodTest::testTellWaiting()
#endif // ENABLE_BITTORRENT #endif // ENABLE_BITTORRENT
TellWaitingXmlRpcMethod m; 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)1);
req._params << BDE((int64_t)2); req._params << BDE((int64_t)2);
XmlRpcResponse res = m.execute(req, _e.get()); 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("2"), res._param[0]["gid"].s());
CPPUNIT_ASSERT_EQUAL(std::string("3"), res._param[1]["gid"].s()); CPPUNIT_ASSERT_EQUAL(std::string("3"), res._param[1]["gid"].s());
// waiting.size() == offset+num // 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)1);
#ifdef ENABLE_BITTORRENT #ifdef ENABLE_BITTORRENT
req._params << BDE((int64_t)3); req._params << BDE((int64_t)3);
@ -598,7 +598,7 @@ void XmlRpcMethodTest::testTellWaiting()
CPPUNIT_ASSERT_EQUAL((size_t)2, res._param.size()); CPPUNIT_ASSERT_EQUAL((size_t)2, res._param.size());
#endif // !ENABLE_BITTORRENT #endif // !ENABLE_BITTORRENT
// waiting.size() < offset+num // 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)1);
req._params << BDE((int64_t)4); req._params << BDE((int64_t)4);
res = m.execute(req, _e.get()); res = m.execute(req, _e.get());
@ -613,7 +613,7 @@ void XmlRpcMethodTest::testTellWaiting()
void XmlRpcMethodTest::testTellWaiting_fail() void XmlRpcMethodTest::testTellWaiting_fail()
{ {
TellWaitingXmlRpcMethod m; TellWaitingXmlRpcMethod m;
XmlRpcRequest req("aria2.tellWaiting", BDE::list()); XmlRpcRequest req(TellWaitingXmlRpcMethod::getMethodName(), BDE::list());
XmlRpcResponse res = m.execute(req, _e.get()); XmlRpcResponse res = m.execute(req, _e.get());
CPPUNIT_ASSERT_EQUAL(1, res._code); CPPUNIT_ASSERT_EQUAL(1, res._code);
} }
@ -621,7 +621,7 @@ void XmlRpcMethodTest::testTellWaiting_fail()
void XmlRpcMethodTest::testGetVersion() void XmlRpcMethodTest::testGetVersion()
{ {
GetVersionXmlRpcMethod m; GetVersionXmlRpcMethod m;
XmlRpcRequest req("aria2.getVersion", BDE::none); XmlRpcRequest req(GetVersionXmlRpcMethod::getMethodName(), BDE::none);
XmlRpcResponse res = m.execute(req, _e.get()); XmlRpcResponse res = m.execute(req, _e.get());
CPPUNIT_ASSERT_EQUAL(0, res._code); CPPUNIT_ASSERT_EQUAL(0, res._code);
CPPUNIT_ASSERT_EQUAL(std::string(PACKAGE_VERSION), res._param["version"].s()); CPPUNIT_ASSERT_EQUAL(std::string(PACKAGE_VERSION), res._param["version"].s());
@ -692,7 +692,7 @@ void XmlRpcMethodTest::testChangePosition()
(SharedHandle<RequestGroup>(new RequestGroup(_option))); (SharedHandle<RequestGroup>(new RequestGroup(_option)));
ChangePositionXmlRpcMethod m; ChangePositionXmlRpcMethod m;
XmlRpcRequest req("aria2.changePosition", BDE::list()); XmlRpcRequest req(ChangePositionXmlRpcMethod::getMethodName(), BDE::list());
req._params << std::string("1"); req._params << std::string("1");
req._params << BDE((int64_t)1); req._params << BDE((int64_t)1);
req._params << std::string("POS_SET"); req._params << std::string("POS_SET");
@ -706,7 +706,7 @@ void XmlRpcMethodTest::testChangePosition()
void XmlRpcMethodTest::testChangePosition_fail() void XmlRpcMethodTest::testChangePosition_fail()
{ {
ChangePositionXmlRpcMethod m; ChangePositionXmlRpcMethod m;
XmlRpcRequest req("aria2.changePosition", BDE::list()); XmlRpcRequest req(ChangePositionXmlRpcMethod::getMethodName(), BDE::list());
XmlRpcResponse res = m.execute(req, _e.get()); XmlRpcResponse res = m.execute(req, _e.get());
CPPUNIT_ASSERT_EQUAL(1, res._code); CPPUNIT_ASSERT_EQUAL(1, res._code);
@ -724,7 +724,7 @@ void XmlRpcMethodTest::testSystemMulticall()
req._params << reqparams; req._params << reqparams;
for(int i = 0; i < 2; ++i) { for(int i = 0; i < 2; ++i) {
BDE dict = BDE::dict(); BDE dict = BDE::dict();
dict["methodName"] = std::string("aria2.addUri"); dict["methodName"] = std::string(AddUriXmlRpcMethod::getMethodName());
BDE params = BDE::list(); BDE params = BDE::list();
params << BDE::list(); params << BDE::list();
params[0] << BDE("http://localhost/"+util::itos(i)); params[0] << BDE("http://localhost/"+util::itos(i));
@ -749,12 +749,12 @@ void XmlRpcMethodTest::testSystemMulticall()
{ {
// missing params // missing params
BDE dict = BDE::dict(); BDE dict = BDE::dict();
dict["methodName"] = std::string("aria2.getVersion"); dict["methodName"] = std::string(GetVersionXmlRpcMethod::getMethodName());
reqparams << dict; reqparams << dict;
} }
{ {
BDE dict = BDE::dict(); BDE dict = BDE::dict();
dict["methodName"] = std::string("aria2.getVersion"); dict["methodName"] = std::string(GetVersionXmlRpcMethod::getMethodName());
dict["params"] = BDE::list(); dict["params"] = BDE::list();
reqparams << dict; reqparams << dict;
} }