diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-10-04 09:01:11 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-10-04 09:01:11 +0000 |
| commit | c0595d17ff8df87af95cbd3f4a430eecaf85cbf1 (patch) | |
| tree | 6baf88d746aedff380a0680b99d740bad1d76ccf /test/XmlRpcMethodTest.cc | |
| parent | ce3de835b4ca854b73b1f9dcb54131ba704e5115 (diff) | |
2009-10-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that the option values changed by XML-RPC
method(changeOption and changeGlobalOption) are overwritten to the
previous value by the next these request which doesn't contain
that option value. Supporse max-download-limit is initially 0. You
changed this value to 100K by changeOption. Then you issue
changeOption request to change max-upload-limit to 50K. This
second request doesn't contain xml-download-limit, so it is back
to initial value, 0. Another improvement is that exception is
thrown when changeOption and changeGlobalOption request contains
option name which doesn't allowed in each request.
* src/DownloadEngine.h
* src/XmlRpcMethod.cc
* src/XmlRpcMethod.h
* src/XmlRpcMethodImpl.cc
* src/download_helper.cc
* src/download_helper.h
* test/XmlRpcMethodTest.cc
Diffstat (limited to 'test/XmlRpcMethodTest.cc')
| -rw-r--r-- | test/XmlRpcMethodTest.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/XmlRpcMethodTest.cc b/test/XmlRpcMethodTest.cc index 87bd8e5a..39461a2e 100644 --- a/test/XmlRpcMethodTest.cc +++ b/test/XmlRpcMethodTest.cc @@ -46,9 +46,11 @@ class XmlRpcMethodTest:public CppUnit::TestFixture { #endif // ENABLE_METALINK CPPUNIT_TEST(testChangeOption); CPPUNIT_TEST(testChangeOption_withBadOption); + CPPUNIT_TEST(testChangeOption_withNotAllowedOption); CPPUNIT_TEST(testChangeOption_withoutGid); CPPUNIT_TEST(testChangeGlobalOption); CPPUNIT_TEST(testChangeGlobalOption_withBadOption); + CPPUNIT_TEST(testChangeGlobalOption_withNotAllowedOption); CPPUNIT_TEST(testTellStatus_withoutGid); CPPUNIT_TEST(testTellWaiting); CPPUNIT_TEST(testTellWaiting_fail); @@ -94,9 +96,11 @@ public: #endif // ENABLE_METALINK void testChangeOption(); void testChangeOption_withBadOption(); + void testChangeOption_withNotAllowedOption(); void testChangeOption_withoutGid(); void testChangeGlobalOption(); void testChangeGlobalOption_withBadOption(); + void testChangeGlobalOption_withNotAllowedOption(); void testTellStatus_withoutGid(); void testTellWaiting(); void testTellWaiting_fail(); @@ -369,8 +373,12 @@ void XmlRpcMethodTest::testChangeOption() CPPUNIT_ASSERT_EQUAL(0, res._code); CPPUNIT_ASSERT_EQUAL((unsigned int)100*1024, group->getMaxDownloadSpeedLimit()); + CPPUNIT_ASSERT_EQUAL(std::string("102400"), + group->getOption()->get(PREF_MAX_DOWNLOAD_LIMIT)); #ifdef ENABLE_BITTORRENT CPPUNIT_ASSERT_EQUAL((unsigned int)50*1024, group->getMaxUploadSpeedLimit()); + CPPUNIT_ASSERT_EQUAL(std::string("51200"), + group->getOption()->get(PREF_MAX_UPLOAD_LIMIT)); #endif // ENABLE_BITTORRENT } @@ -389,6 +397,21 @@ void XmlRpcMethodTest::testChangeOption_withBadOption() CPPUNIT_ASSERT_EQUAL(1, res._code); } +void XmlRpcMethodTest::testChangeOption_withNotAllowedOption() +{ + SharedHandle<RequestGroup> group(new RequestGroup(_option)); + _e->_requestGroupMan->addReservedGroup(group); + + ChangeOptionXmlRpcMethod m; + XmlRpcRequest req("aria2.changeOption", BDE::list()); + 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); +} + void XmlRpcMethodTest::testChangeOption_withoutGid() { ChangeOptionXmlRpcMethod m; @@ -412,9 +435,13 @@ void XmlRpcMethodTest::testChangeGlobalOption() CPPUNIT_ASSERT_EQUAL(0, res._code); CPPUNIT_ASSERT_EQUAL((unsigned int)100*1024, _e->_requestGroupMan->getMaxOverallDownloadSpeedLimit()); + CPPUNIT_ASSERT_EQUAL(std::string("102400"), + _e->option->get(PREF_MAX_OVERALL_DOWNLOAD_LIMIT)); #ifdef ENABLE_BITTORRENT CPPUNIT_ASSERT_EQUAL((unsigned int)50*1024, _e->_requestGroupMan->getMaxOverallUploadSpeedLimit()); + CPPUNIT_ASSERT_EQUAL(std::string("51200"), + _e->option->get(PREF_MAX_OVERALL_UPLOAD_LIMIT)); #endif // ENABLE_BITTORRENT } @@ -429,6 +456,17 @@ void XmlRpcMethodTest::testChangeGlobalOption_withBadOption() CPPUNIT_ASSERT_EQUAL(1, res._code); } +void XmlRpcMethodTest::testChangeGlobalOption_withNotAllowedOption() +{ + ChangeGlobalOptionXmlRpcMethod m; + XmlRpcRequest req("aria2.changeGlobalOption", BDE::list()); + 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); +} + void XmlRpcMethodTest::testNoSuchMethod() { NoSuchMethodXmlRpcMethod m; |
