diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-02-16 00:44:23 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-02-16 00:44:23 +0900 |
| commit | 1698b2c7b1b6b474425842e57f89a33a68442e04 (patch) | |
| tree | b405d73d5c49bca70216bda84284984e3aa28c4a /test | |
| parent | a21fb350a0ad354bd2a63f609295d16394e383eb (diff) | |
Save downloads added by aria2.addTorrent or aria2.addMetalink in
--save-session file.
Uploaded data are saved as file named hex string of sha1 hash of
uploaded data plus extension(".torrent" for torrent and ".metalink"
for metalink). For example,
0a3893293e27ac0490424c06de4d09242215f0a6.torrent. The directory where
these files are saved is specified by --dir option. These file paths
are written in --save-session file.
Diffstat (limited to 'test')
| -rw-r--r-- | test/XmlRpcMethodTest.cc | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/test/XmlRpcMethodTest.cc b/test/XmlRpcMethodTest.cc index f33b42cc..c15f689f 100644 --- a/test/XmlRpcMethodTest.cc +++ b/test/XmlRpcMethodTest.cc @@ -85,8 +85,9 @@ public: { RequestGroup::resetGIDCounter(); option_.reset(new Option()); - option_->put(PREF_DIR, "/tmp"); + option_->put(PREF_DIR, A2_TEST_OUT_DIR"/aria2_XmlRpcMethodTest"); option_->put(PREF_SEGMENT_SIZE, "1048576"); + File(option_->get(PREF_DIR)).mkdirs(); e_.reset (new DownloadEngine(SharedHandle<EventPoll>(new SelectEventPoll()))); e_->setOption(option_.get()); @@ -255,6 +256,8 @@ void XmlRpcMethodTest::testAddUri_withBadPosition() #ifdef ENABLE_BITTORRENT void XmlRpcMethodTest::testAddTorrent() { + File(e_->getOption()->get(PREF_DIR)+ + "/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").remove(); AddTorrentXmlRpcMethod m; XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), List::g()); req.params->append(readFile(A2_TEST_DIR"/single.torrent")); @@ -263,13 +266,16 @@ void XmlRpcMethodTest::testAddTorrent() req.params->append(uris); { XmlRpcResponse res = m.execute(req, e_.get()); + CPPUNIT_ASSERT + (File(e_->getOption()->get(PREF_DIR)+ + "/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").exists()); CPPUNIT_ASSERT_EQUAL(0, res.code); CPPUNIT_ASSERT_EQUAL(std::string("1"), asString(res.param)->s()); SharedHandle<RequestGroup> group = e_->getRequestGroupMan()->findReservedGroup(1); CPPUNIT_ASSERT(group); - CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-0.8.2.tar.bz2"), + CPPUNIT_ASSERT_EQUAL(e_->getOption()->get(PREF_DIR)+"/aria2-0.8.2.tar.bz2", group->getFirstFilePath()); CPPUNIT_ASSERT_EQUAL((size_t)1, group->getDownloadContext()->getFirstFileEntry()-> @@ -279,15 +285,20 @@ void XmlRpcMethodTest::testAddTorrent() getRemainingUris()[0]); } // with options + std::string dir = A2_TEST_OUT_DIR"/aria2_XmlRpcMethodTest_testAddTorrent"; + File(dir).mkdirs(); SharedHandle<Dict> opt = Dict::g(); - opt->put(PREF_DIR, "/sink"); + opt->put(PREF_DIR, dir); + File(dir+"/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").remove(); req.params->append(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"), - e_->getRequestGroupMan()->findReservedGroup(2)-> - getFirstFilePath()); + CPPUNIT_ASSERT_EQUAL + (dir+"/aria2-0.8.2.tar.bz2", + e_->getRequestGroupMan()->findReservedGroup(2)->getFirstFilePath()); + CPPUNIT_ASSERT + (File(dir+"/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").exists()); } } @@ -335,6 +346,8 @@ void XmlRpcMethodTest::testAddTorrent_withPosition() #ifdef ENABLE_METALINK void XmlRpcMethodTest::testAddMetalink() { + File(e_->getOption()->get(PREF_DIR)+ + "/c908634fbc257fd56f0114912c2772aeeb4064f4.metalink").remove(); AddMetalinkXmlRpcMethod m; XmlRpcRequest req(AddMetalinkXmlRpcMethod::getMethodName(), List::g()); req.params->append(readFile(A2_TEST_DIR"/2files.metalink")); @@ -345,28 +358,36 @@ void XmlRpcMethodTest::testAddMetalink() CPPUNIT_ASSERT_EQUAL((size_t)2, resParams->size()); CPPUNIT_ASSERT_EQUAL(std::string("1"), asString(resParams->get(0))->s()); CPPUNIT_ASSERT_EQUAL(std::string("2"), asString(resParams->get(1))->s()); + CPPUNIT_ASSERT + (File(e_->getOption()->get(PREF_DIR)+ + "/c908634fbc257fd56f0114912c2772aeeb4064f4.metalink").exists()); SharedHandle<RequestGroup> tar = e_->getRequestGroupMan()->findReservedGroup(1); CPPUNIT_ASSERT(tar); - CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-5.0.0.tar.bz2"), + CPPUNIT_ASSERT_EQUAL(e_->getOption()->get(PREF_DIR)+"/aria2-5.0.0.tar.bz2", tar->getFirstFilePath()); SharedHandle<RequestGroup> deb = e_->getRequestGroupMan()->findReservedGroup(2); CPPUNIT_ASSERT(deb); - CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-5.0.0.deb"), + CPPUNIT_ASSERT_EQUAL(e_->getOption()->get(PREF_DIR)+"/aria2-5.0.0.deb", deb->getFirstFilePath()); } // with options + std::string dir = A2_TEST_OUT_DIR"/aria2_XmlRpcMethodTest_testAddMetalink"; + File(dir).mkdirs(); SharedHandle<Dict> opt = Dict::g(); - opt->put(PREF_DIR, "/sink"); + opt->put(PREF_DIR, dir); + File(dir+"/c908634fbc257fd56f0114912c2772aeeb4064f4.metalink").remove(); req.params->append(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"), + CPPUNIT_ASSERT_EQUAL(dir+"/aria2-5.0.0.tar.bz2", e_->getRequestGroupMan()->findReservedGroup(3)-> getFirstFilePath()); + CPPUNIT_ASSERT + (File(dir+"/c908634fbc257fd56f0114912c2772aeeb4064f4.metalink").exists()); } } @@ -405,7 +426,7 @@ void XmlRpcMethodTest::testAddMetalink_withPosition() 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"), + CPPUNIT_ASSERT_EQUAL(e_->getOption()->get(PREF_DIR)+"/aria2-5.0.0.tar.bz2", e_->getRequestGroupMan()->getReservedGroups()[0]-> getFirstFilePath()); } @@ -779,7 +800,8 @@ void XmlRpcMethodTest::testGatherProgressCommon() (asList(file->get("uris"))->get(0)) ->get("uri")) ->s()); - CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), asString(entry->get("dir"))->s()); + CPPUNIT_ASSERT_EQUAL(e_->getOption()->get(PREF_DIR), + asString(entry->get("dir"))->s()); keys.push_back("gid"); entry = Dict::g(); |
