diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-05-07 18:41:18 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-05-07 18:41:18 +0900 |
| commit | ad5af56c172701ce18d86769f8c02657013eb790 (patch) | |
| tree | 0e969f80e300663040c271bf831e19ab192a5157 /test/MetalinkParserControllerTest.cc | |
| parent | e7d7233d54b1c91ae15c778350708d75cfae74ae (diff) | |
Support relative URI in Metalink file.
If relative URI is found in Metalink file, aria2 resolves its full URI
contatenating the URI from which Metalink file is retrieved and
relative URI in Metalink file. This feature is not available if
Metalink file in local disk is specified in command line.
Diffstat (limited to 'test/MetalinkParserControllerTest.cc')
| -rw-r--r-- | test/MetalinkParserControllerTest.cc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/MetalinkParserControllerTest.cc b/test/MetalinkParserControllerTest.cc index d35b45ac..476eb110 100644 --- a/test/MetalinkParserControllerTest.cc +++ b/test/MetalinkParserControllerTest.cc @@ -20,6 +20,7 @@ class MetalinkParserControllerTest:public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(MetalinkParserControllerTest); CPPUNIT_TEST(testEntryTransaction); CPPUNIT_TEST(testResourceTransaction); + CPPUNIT_TEST(testResourceTransaction_withBaseUri); CPPUNIT_TEST(testMetaurlTransaction); #ifdef ENABLE_MESSAGE_DIGEST CPPUNIT_TEST(testChecksumTransaction); @@ -38,6 +39,7 @@ public: void testEntryTransaction(); void testResourceTransaction(); + void testResourceTransaction_withBaseUri(); void testMetaurlTransaction(); #ifdef ENABLE_MESSAGE_DIGEST void testChecksumTransaction(); @@ -110,6 +112,46 @@ void MetalinkParserControllerTest::testResourceTransaction() } } +void MetalinkParserControllerTest::testResourceTransaction_withBaseUri() +{ + MetalinkParserController ctrl; + ctrl.setBaseUri("http://base/dir/file"); + ctrl.newEntryTransaction(); + ctrl.newResourceTransaction(); + ctrl.setURLOfResource("aria2.tar.bz2"); + ctrl.commitResourceTransaction(); +#ifdef ENABLE_BITTORRENT + ctrl.newMetaurlTransaction(); + ctrl.setURLOfMetaurl("/meta/aria2.tar.bz2.torrent"); + ctrl.setMediatypeOfMetaurl("torrent"); + ctrl.commitMetaurlTransaction(); + ctrl.newMetaurlTransaction(); + ctrl.setURLOfMetaurl("magnet:?xt=urn:btih:248d0a1cd08284299de78d5c1ed359bb46717d8c"); + ctrl.setMediatypeOfMetaurl("torrent"); + ctrl.commitMetaurlTransaction(); +#endif // ENABLE_BITTORRENT + ctrl.commitEntryTransaction(); + { + SharedHandle<Metalinker> m = ctrl.getResult(); + CPPUNIT_ASSERT_EQUAL((size_t)1, m->getEntries()[0]->resources.size()); + SharedHandle<MetalinkResource> res = m->getEntries()[0]->resources[0]; + CPPUNIT_ASSERT_EQUAL(std::string("http://base/dir/aria2.tar.bz2"), + res->url); + CPPUNIT_ASSERT_EQUAL(MetalinkResource::TYPE_HTTP, res->type); + +#ifdef ENABLE_BITTORRENT + CPPUNIT_ASSERT_EQUAL((size_t)2, m->getEntries()[0]->metaurls.size()); + SharedHandle<MetalinkMetaurl> metaurl = m->getEntries()[0]->metaurls[0]; + CPPUNIT_ASSERT_EQUAL(std::string("http://base/meta/aria2.tar.bz2.torrent"), + metaurl->url); + + metaurl = m->getEntries()[0]->metaurls[1]; + CPPUNIT_ASSERT_EQUAL(std::string("magnet:?xt=urn:btih:248d0a1cd08284299de78d5c1ed359bb46717d8c"), + metaurl->url); +#endif // ENABLE_BITTORRENT + } +} + void MetalinkParserControllerTest::testMetaurlTransaction() { MetalinkParserController ctrl; |
