mirror of https://github.com/aria2/aria2
				
				
				
			2007-11-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Re-implemented a file listing for Metalink, which was dropped 
while
	http/ftp/torrent integration was being implemented.
	* src/MetalinkHelper.{h, cc}: New class.
	* test/MetalinkHelperTest.cc
	* src/main.cc
	* src/Metalink2RequestGroup.cc
			
			
				pull/1/head
			
			
		
							parent
							
								
									f9f388af87
								
							
						
					
					
						commit
						166f7aa8c2
					
				| 
						 | 
				
			
			@ -1,3 +1,12 @@
 | 
			
		|||
2007-11-03  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 | 
			
		||||
 | 
			
		||||
	Re-implemented a file listing for Metalink, which was dropped while
 | 
			
		||||
	http/ftp/torrent integration was being implemented.
 | 
			
		||||
	* src/MetalinkHelper.{h, cc}: New class.
 | 
			
		||||
	* test/MetalinkHelperTest.cc
 | 
			
		||||
	* src/main.cc
 | 
			
		||||
	* src/Metalink2RequestGroup.cc
 | 
			
		||||
 | 
			
		||||
2007-11-03  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 | 
			
		||||
 | 
			
		||||
	Added the ability to display the detailed torrent file information.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -250,7 +250,8 @@ SRCS += Metalinker.cc Metalinker.h\
 | 
			
		|||
	MetalinkProcessor.h\
 | 
			
		||||
	Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h\
 | 
			
		||||
	Metalink2RequestGroup.cc Metalink2RequestGroup.h\
 | 
			
		||||
	MetalinkPostDownloadHandler.cc MetalinkPostDownloadHandler.h
 | 
			
		||||
	MetalinkPostDownloadHandler.cc MetalinkPostDownloadHandler.h\
 | 
			
		||||
	MetalinkHelper.cc MetalinkHelper.h
 | 
			
		||||
endif # ENABLE_METALINK
 | 
			
		||||
 | 
			
		||||
if !HAVE_BASENAME
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -157,7 +157,8 @@ bin_PROGRAMS = aria2c$(EXEEXT)
 | 
			
		|||
@ENABLE_METALINK_TRUE@	MetalinkProcessor.h\
 | 
			
		||||
@ENABLE_METALINK_TRUE@	Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h\
 | 
			
		||||
@ENABLE_METALINK_TRUE@	Metalink2RequestGroup.cc Metalink2RequestGroup.h\
 | 
			
		||||
@ENABLE_METALINK_TRUE@	MetalinkPostDownloadHandler.cc MetalinkPostDownloadHandler.h
 | 
			
		||||
@ENABLE_METALINK_TRUE@	MetalinkPostDownloadHandler.cc MetalinkPostDownloadHandler.h\
 | 
			
		||||
@ENABLE_METALINK_TRUE@	MetalinkHelper.cc MetalinkHelper.h
 | 
			
		||||
 | 
			
		||||
@HAVE_BASENAME_FALSE@am__append_4 = libgen.c libgen.h
 | 
			
		||||
@HAVE_GETADDRINFO_FALSE@am__append_5 = getaddrinfo.c getaddrinfo.h
 | 
			
		||||
| 
						 | 
				
			
			@ -344,10 +345,11 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
 | 
			
		|||
	Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h \
 | 
			
		||||
	Metalink2RequestGroup.cc Metalink2RequestGroup.h \
 | 
			
		||||
	MetalinkPostDownloadHandler.cc MetalinkPostDownloadHandler.h \
 | 
			
		||||
	libgen.c libgen.h getaddrinfo.c getaddrinfo.h gai_strerror.c \
 | 
			
		||||
	gai_strerror.h gettimeofday.c gettimeofday.h inet_aton.c \
 | 
			
		||||
	inet_aton.h localtime_r.c localtime_r.h strptime.c strptime.h \
 | 
			
		||||
	timegm.c timegm.h
 | 
			
		||||
	MetalinkHelper.cc MetalinkHelper.h libgen.c libgen.h \
 | 
			
		||||
	getaddrinfo.c getaddrinfo.h gai_strerror.c gai_strerror.h \
 | 
			
		||||
	gettimeofday.c gettimeofday.h inet_aton.c inet_aton.h \
 | 
			
		||||
	localtime_r.c localtime_r.h strptime.c strptime.h timegm.c \
 | 
			
		||||
	timegm.h
 | 
			
		||||
@ENABLE_MESSAGE_DIGEST_TRUE@am__objects_1 = IteratableChunkChecksumValidator.$(OBJEXT) \
 | 
			
		||||
@ENABLE_MESSAGE_DIGEST_TRUE@	IteratableChecksumValidator.$(OBJEXT) \
 | 
			
		||||
@ENABLE_MESSAGE_DIGEST_TRUE@	ChecksumCommand.$(OBJEXT) \
 | 
			
		||||
| 
						 | 
				
			
			@ -425,7 +427,8 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
 | 
			
		|||
@ENABLE_METALINK_TRUE@	MetalinkResource.$(OBJEXT) \
 | 
			
		||||
@ENABLE_METALINK_TRUE@	Xml2MetalinkProcessor.$(OBJEXT) \
 | 
			
		||||
@ENABLE_METALINK_TRUE@	Metalink2RequestGroup.$(OBJEXT) \
 | 
			
		||||
@ENABLE_METALINK_TRUE@	MetalinkPostDownloadHandler.$(OBJEXT)
 | 
			
		||||
@ENABLE_METALINK_TRUE@	MetalinkPostDownloadHandler.$(OBJEXT) \
 | 
			
		||||
@ENABLE_METALINK_TRUE@	MetalinkHelper.$(OBJEXT)
 | 
			
		||||
@HAVE_BASENAME_FALSE@am__objects_4 = libgen.$(OBJEXT)
 | 
			
		||||
@HAVE_GETADDRINFO_FALSE@am__objects_5 = getaddrinfo.$(OBJEXT)
 | 
			
		||||
@HAVE_GAI_STRERROR_FALSE@am__objects_6 = gai_strerror.$(OBJEXT)
 | 
			
		||||
| 
						 | 
				
			
			@ -959,6 +962,7 @@ distclean-compile:
 | 
			
		|||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetaFileUtil.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Metalink2RequestGroup.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkEntry.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkHelper.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkPostDownloadHandler.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkResource.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Metalinker.Po@am__quote@
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,6 +42,7 @@
 | 
			
		|||
#include "message.h"
 | 
			
		||||
#include "BtDependency.h"
 | 
			
		||||
#include "SingleFileDownloadContext.h"
 | 
			
		||||
#include "MetalinkHelper.h"
 | 
			
		||||
 | 
			
		||||
Metalink2RequestGroup::Metalink2RequestGroup(const Option* option):_option(option), _logger(LogFactory::getInstance()) {}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -92,16 +93,8 @@ public:
 | 
			
		|||
 | 
			
		||||
RequestGroups Metalink2RequestGroup::generate(const string& metalinkFile)
 | 
			
		||||
{
 | 
			
		||||
  Xml2MetalinkProcessor proc;
 | 
			
		||||
 | 
			
		||||
  MetalinkerHandle metalinker = proc.parseFile(metalinkFile);
 | 
			
		||||
  if(metalinker->entries.empty()) {
 | 
			
		||||
    throw new DlAbortEx("No file entry found. Probably, the metalink file is not configured properly or broken.");
 | 
			
		||||
  }
 | 
			
		||||
  MetalinkEntries entries =
 | 
			
		||||
    metalinker->queryEntry(_option->get(PREF_METALINK_VERSION),
 | 
			
		||||
			   _option->get(PREF_METALINK_LANGUAGE),
 | 
			
		||||
			   _option->get(PREF_METALINK_OS));
 | 
			
		||||
  MetalinkEntries entries = MetalinkHelper::parseAndQuery(metalinkFile,
 | 
			
		||||
							  _option);
 | 
			
		||||
  if(entries.size() == 0) {
 | 
			
		||||
    _logger->notice(EX_NO_RESULT_WITH_YOUR_PREFS);
 | 
			
		||||
    return RequestGroups();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,59 @@
 | 
			
		|||
/* <!-- copyright */
 | 
			
		||||
/*
 | 
			
		||||
 * aria2 - The high speed download utility
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2006 Tatsuhiro Tsujikawa
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
 * the Free Software Foundation; either version 2 of the License, or
 | 
			
		||||
 * (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
			
		||||
 *
 | 
			
		||||
 * In addition, as a special exception, the copyright holders give
 | 
			
		||||
 * permission to link the code of portions of this program with the
 | 
			
		||||
 * OpenSSL library under certain conditions as described in each
 | 
			
		||||
 * individual source file, and distribute linked combinations
 | 
			
		||||
 * including the two.
 | 
			
		||||
 * You must obey the GNU General Public License in all respects
 | 
			
		||||
 * for all of the code used other than OpenSSL.  If you modify
 | 
			
		||||
 * file(s) with this exception, you may extend this exception to your
 | 
			
		||||
 * version of the file(s), but you are not obligated to do so.  If you
 | 
			
		||||
 * do not wish to do so, delete this exception statement from your
 | 
			
		||||
 * version.  If you delete this exception statement from all source
 | 
			
		||||
 * files in the program, then also delete it here.
 | 
			
		||||
 */
 | 
			
		||||
/* copyright --> */
 | 
			
		||||
#include "MetalinkHelper.h"
 | 
			
		||||
#include "Option.h"
 | 
			
		||||
#include "MetalinkEntry.h"
 | 
			
		||||
#include "Xml2MetalinkProcessor.h"
 | 
			
		||||
#include "Metalinker.h"
 | 
			
		||||
#include "prefs.h"
 | 
			
		||||
 | 
			
		||||
MetalinkHelper::MetalinkHelper() {}
 | 
			
		||||
 | 
			
		||||
MetalinkHelper::~MetalinkHelper() {}
 | 
			
		||||
 | 
			
		||||
MetalinkEntries MetalinkHelper::parseAndQuery(const string& filename, const Option* option)
 | 
			
		||||
{
 | 
			
		||||
  Xml2MetalinkProcessor proc;
 | 
			
		||||
 | 
			
		||||
  MetalinkerHandle metalinker = proc.parseFile(filename);
 | 
			
		||||
  if(metalinker->entries.empty()) {
 | 
			
		||||
    throw new DlAbortEx("No file entry found. Probably, the metalink file is not configured properly or broken.");
 | 
			
		||||
  }
 | 
			
		||||
  MetalinkEntries entries =
 | 
			
		||||
    metalinker->queryEntry(option->get(PREF_METALINK_VERSION),
 | 
			
		||||
			   option->get(PREF_METALINK_LANGUAGE),
 | 
			
		||||
			   option->get(PREF_METALINK_OS));
 | 
			
		||||
  return entries;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,54 @@
 | 
			
		|||
/* <!-- copyright */
 | 
			
		||||
/*
 | 
			
		||||
 * aria2 - The high speed download utility
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2006 Tatsuhiro Tsujikawa
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
 * the Free Software Foundation; either version 2 of the License, or
 | 
			
		||||
 * (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
			
		||||
 *
 | 
			
		||||
 * In addition, as a special exception, the copyright holders give
 | 
			
		||||
 * permission to link the code of portions of this program with the
 | 
			
		||||
 * OpenSSL library under certain conditions as described in each
 | 
			
		||||
 * individual source file, and distribute linked combinations
 | 
			
		||||
 * including the two.
 | 
			
		||||
 * You must obey the GNU General Public License in all respects
 | 
			
		||||
 * for all of the code used other than OpenSSL.  If you modify
 | 
			
		||||
 * file(s) with this exception, you may extend this exception to your
 | 
			
		||||
 * version of the file(s), but you are not obligated to do so.  If you
 | 
			
		||||
 * do not wish to do so, delete this exception statement from your
 | 
			
		||||
 * version.  If you delete this exception statement from all source
 | 
			
		||||
 * files in the program, then also delete it here.
 | 
			
		||||
 */
 | 
			
		||||
/* copyright --> */
 | 
			
		||||
#ifndef _D_METALINK_HELPER_H_
 | 
			
		||||
#define _D_METALINK_HELPER_H_
 | 
			
		||||
 | 
			
		||||
#include "common.h"
 | 
			
		||||
 | 
			
		||||
class Option;
 | 
			
		||||
class MetalinkEntry;
 | 
			
		||||
extern typedef SharedHandle<MetalinkEntry> MetalinkEntryHandle;
 | 
			
		||||
extern typedef deque<MetalinkEntryHandle> MetalinkEntries;
 | 
			
		||||
 | 
			
		||||
class MetalinkHelper {
 | 
			
		||||
private:
 | 
			
		||||
  MetalinkHelper();
 | 
			
		||||
 | 
			
		||||
  ~MetalinkHelper();
 | 
			
		||||
public:
 | 
			
		||||
  static MetalinkEntries parseAndQuery(const string& filename, const Option* option);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // _D_METALINK_HELPER_H_
 | 
			
		||||
| 
						 | 
				
			
			@ -59,6 +59,7 @@
 | 
			
		|||
#include "DefaultBtContext.h"
 | 
			
		||||
#include "RequestGroup.h"
 | 
			
		||||
#include "Option.h"
 | 
			
		||||
#include "MetalinkHelper.h"
 | 
			
		||||
#include <deque>
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -300,8 +301,12 @@ int main(int argc, char* argv[]) {
 | 
			
		|||
#endif // ENABLE_BITTORRENT
 | 
			
		||||
#ifdef ENABLE_METALINK
 | 
			
		||||
      if(op->defined(PREF_METALINK_FILE)) {
 | 
			
		||||
	if(op->get(PREF_SHOW_FILES) == V_TRUE) {
 | 
			
		||||
	  Util::toStream(cout, MetalinkEntry::toFileEntry(MetalinkHelper::parseAndQuery(op->get(PREF_METALINK_FILE), op)));
 | 
			
		||||
	} else {
 | 
			
		||||
	  downloadMetalink(op);
 | 
			
		||||
	}
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
#endif // ENABLE_METALINK
 | 
			
		||||
	if(op->defined(PREF_INPUT_FILE)) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -98,7 +98,8 @@ aria2c_SOURCES += MetalinkerTest.cc\
 | 
			
		|||
	MetalinkEntryTest.cc\
 | 
			
		||||
	Xml2MetalinkProcessorTest.cc\
 | 
			
		||||
	Metalink2RequestGroupTest.cc\
 | 
			
		||||
	MetalinkPostDownloadHandlerTest.cc
 | 
			
		||||
	MetalinkPostDownloadHandlerTest.cc\
 | 
			
		||||
	MetalinkHelperTest.cc
 | 
			
		||||
endif # ENABLE_METALINK
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -88,7 +88,8 @@ check_PROGRAMS = $(am__EXEEXT_1)
 | 
			
		|||
@ENABLE_METALINK_TRUE@	MetalinkEntryTest.cc\
 | 
			
		||||
@ENABLE_METALINK_TRUE@	Xml2MetalinkProcessorTest.cc\
 | 
			
		||||
@ENABLE_METALINK_TRUE@	Metalink2RequestGroupTest.cc\
 | 
			
		||||
@ENABLE_METALINK_TRUE@	MetalinkPostDownloadHandlerTest.cc
 | 
			
		||||
@ENABLE_METALINK_TRUE@	MetalinkPostDownloadHandlerTest.cc\
 | 
			
		||||
@ENABLE_METALINK_TRUE@	MetalinkHelperTest.cc
 | 
			
		||||
 | 
			
		||||
subdir = test
 | 
			
		||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 | 
			
		||||
| 
						 | 
				
			
			@ -152,7 +153,7 @@ am__aria2c_SOURCES_DIST = AllTest.cc PieceTest.cc \
 | 
			
		|||
	BtPostDownloadHandlerTest.cc TimeSeedCriteriaTest.cc \
 | 
			
		||||
	MetalinkerTest.cc MetalinkEntryTest.cc \
 | 
			
		||||
	Xml2MetalinkProcessorTest.cc Metalink2RequestGroupTest.cc \
 | 
			
		||||
	MetalinkPostDownloadHandlerTest.cc
 | 
			
		||||
	MetalinkPostDownloadHandlerTest.cc MetalinkHelperTest.cc
 | 
			
		||||
@ENABLE_MESSAGE_DIGEST_TRUE@am__objects_1 =  \
 | 
			
		||||
@ENABLE_MESSAGE_DIGEST_TRUE@	MessageDigestHelperTest.$(OBJEXT) \
 | 
			
		||||
@ENABLE_MESSAGE_DIGEST_TRUE@	IteratableChunkChecksumValidatorTest.$(OBJEXT)
 | 
			
		||||
| 
						 | 
				
			
			@ -200,7 +201,8 @@ am__aria2c_SOURCES_DIST = AllTest.cc PieceTest.cc \
 | 
			
		|||
@ENABLE_METALINK_TRUE@	MetalinkEntryTest.$(OBJEXT) \
 | 
			
		||||
@ENABLE_METALINK_TRUE@	Xml2MetalinkProcessorTest.$(OBJEXT) \
 | 
			
		||||
@ENABLE_METALINK_TRUE@	Metalink2RequestGroupTest.$(OBJEXT) \
 | 
			
		||||
@ENABLE_METALINK_TRUE@	MetalinkPostDownloadHandlerTest.$(OBJEXT)
 | 
			
		||||
@ENABLE_METALINK_TRUE@	MetalinkPostDownloadHandlerTest.$(OBJEXT) \
 | 
			
		||||
@ENABLE_METALINK_TRUE@	MetalinkHelperTest.$(OBJEXT)
 | 
			
		||||
am_aria2c_OBJECTS = AllTest.$(OBJEXT) PieceTest.$(OBJEXT) \
 | 
			
		||||
	DefaultPieceStorageTest.$(OBJEXT) SegmentTest.$(OBJEXT) \
 | 
			
		||||
	GrowSegmentTest.$(OBJEXT) \
 | 
			
		||||
| 
						 | 
				
			
			@ -551,6 +553,7 @@ distclean-compile:
 | 
			
		|||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetaFileUtilTest.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Metalink2RequestGroupTest.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkEntryTest.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkHelperTest.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkPostDownloadHandlerTest.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkerTest.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MultiDiskAdaptorTest.Po@am__quote@
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,44 @@
 | 
			
		|||
#include "MetalinkHelper.h"
 | 
			
		||||
#include "MetalinkEntry.h"
 | 
			
		||||
#include "Option.h"
 | 
			
		||||
#include "prefs.h"
 | 
			
		||||
#include <cppunit/extensions/HelperMacros.h>
 | 
			
		||||
 | 
			
		||||
using namespace std;
 | 
			
		||||
 | 
			
		||||
class MetalinkHelperTest:public CppUnit::TestFixture {
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_TEST_SUITE(MetalinkHelperTest);
 | 
			
		||||
  CPPUNIT_TEST(testParseAndQuery);
 | 
			
		||||
  CPPUNIT_TEST(testParseAndQuery_version);
 | 
			
		||||
  CPPUNIT_TEST_SUITE_END();
 | 
			
		||||
private:
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  void setUp() {}
 | 
			
		||||
 | 
			
		||||
  void tearDown() {}
 | 
			
		||||
 | 
			
		||||
  void testParseAndQuery();
 | 
			
		||||
  void testParseAndQuery_version();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
CPPUNIT_TEST_SUITE_REGISTRATION( MetalinkHelperTest );
 | 
			
		||||
 | 
			
		||||
void MetalinkHelperTest::testParseAndQuery()
 | 
			
		||||
{
 | 
			
		||||
  Option option;
 | 
			
		||||
  MetalinkEntries entries = MetalinkHelper::parseAndQuery("test.xml", &option);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)5, entries.size());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MetalinkHelperTest::testParseAndQuery_version()
 | 
			
		||||
{
 | 
			
		||||
  Option option;
 | 
			
		||||
  option.put(PREF_METALINK_VERSION, "0.5.1");
 | 
			
		||||
  MetalinkEntries entries = MetalinkHelper::parseAndQuery("test.xml", &option);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)1, entries.size());
 | 
			
		||||
  MetalinkEntryHandle entry = entries.front();
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(string("aria2-0.5.1.tar.bz2"), entry->getPath());
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue