2009-05-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Added xml-rpc functionality. Currently only addURI commad is
	supported. To enable xml-rpc, run aria2 with
	--enable-http-server. This option name is temporal and will be
	changed. The feature that reports download progress in html format
	is temporarily disabled.
	* src/HttpServer.cc
	* src/HttpServer.h
	* src/HttpServerBodyCommand.cc
	* src/HttpServerBodyCommand.h
	* src/HttpServerCommand.cc
	* src/HttpServerResponseCommand.cc
	* src/Makefile.am
	* src/OptionParser.cc
	* src/OptionParser.h
	* src/RequestGroupMan.cc
	* src/RequestGroupMan.h
	* src/XmlRpcMethod.cc
	* src/XmlRpcMethod.h
	* src/XmlRpcMethodFactory.cc
	* src/XmlRpcMethodFactory.h
	* src/XmlRpcMethodImpl.cc
	* src/XmlRpcMethodImpl.h
	* src/download_helper.cc
	* src/download_helper.h
	* test/Makefile.am
	* test/XmlRpcMethodTest.cc
This commit is contained in:
Tatsuhiro Tsujikawa 2009-05-08 07:58:50 +00:00
parent 3a81b3c3d7
commit b57b75f98d
24 changed files with 1091 additions and 107 deletions

65
test/XmlRpcMethodTest.cc Normal file
View file

@ -0,0 +1,65 @@
#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"
namespace aria2 {
namespace xmlrpc {
class XmlRpcMethodTest:public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(XmlRpcMethodTest);
CPPUNIT_TEST(testAddURI);
CPPUNIT_TEST_SUITE_END();
private:
SharedHandle<DownloadEngine> _e;
SharedHandle<Option> _option;
public:
void setUp()
{
_option.reset(new Option());
_e.reset(new DownloadEngine(SharedHandle<EventPoll>(new SelectEventPoll())));
_e->option = _option.get();
_e->_requestGroupMan.reset
(new RequestGroupMan(std::deque<SharedHandle<RequestGroup> >(),
1, _option.get()));
}
void tearDown() {}
void testAddURI();
};
CPPUNIT_TEST_SUITE_REGISTRATION(XmlRpcMethodTest);
void XmlRpcMethodTest::testAddURI()
{
AddURIXmlRpcMethod m;
XmlRpcRequest req("aria2.addURI", BDE::list());
req._params << BDE::list();
req._params[0] << BDE("http://localhost/");
std::string res = m.execute(req, _e.get());
const std::deque<SharedHandle<RequestGroup> > rgs =
_e->_requestGroupMan->getReservedGroups();
CPPUNIT_ASSERT_EQUAL((size_t)1, rgs.size());
CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/"),
rgs.front()->getRemainingUris().front());
CPPUNIT_ASSERT(res.find("OK") != std::string::npos);
}
} // namespace xmlrpc
} // namespace aria2