2007-06-03 14:24:37 +00:00
|
|
|
#include "RequestGroupMan.h"
|
2007-07-09 13:30:45 +00:00
|
|
|
#include "CUIDCounter.h"
|
|
|
|
#include "prefs.h"
|
2007-08-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
MessageDigestHelper is introduced in order to simplify the use
of message digest. Removed repeated code.
The message digest algorithm is now specified by string, like
"sha1",
"md5".
* src/messageDigest.{h, cc}
* src/MessageDigestHelper.{h, cc}: New class.
* src/DefaultPieceStorage.cc
* src/DefaultBtContext.{h, cc}
(computeFastSet): New function.
(setInfoHash): Added for unit testing.
(setNumPieces): Added for unit testing.
* src/DefaultBtInteractive.cc
* src/BtPieceMessage.cc
* src/Peer.cc
* src/Checksum.h
* src/message.h
* src/IteratableChecksumValidator.h
* src/ChunkChecksumValidator.{h, cc}: Use
IteratableChecksumValidator
inside it.
* src/SegmentMan.{h, cc}
(checkIntegrity): Removed.
* src/IteratableChunkChecksumValidator.{h, cc}
* src/Util.h
(sha1Sum): Removed.
(simpleMessageDigest): Removed.
(fileChecksum): Removed.
(computeFastSet): Removed.
* src/ShaVisitor.cc
* src/ChunkChecksum.h
* src/DownloadCommand.cc
Removed messageDigest virtual functions.
* src/MultiDiskAdaptor.{h, cc}
* src/DiskAdaptor.h
* src/ByteArrayDiskWriter.h
* src/DiskWriter.h
* src/DiskAdaptorWriter.h
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Fixed comilation error when message digest is disabled.
* src/MetalinkEntry.{h, cc}
* src/MetalinkRequestInfo.cc
Removed srandom and random.
* src/SimpleRandomizer.h
Added size() virtual function to DiskAdaptor
* src/MultiDiskAdaptor.h
Fixed the bug that causes that files are not opened correctly in
multi-file torrent.
* src/TorrentRequestInfo.cc
* src/MultiDiskAdaptor.cc
Added SHA256 support
* src/messageDigest.cc
* src/Xml2MetalinkProcessor.cc
Show supported message digest algorithms
* src/main.cc
Updated contact info.
* src/main.cc
2007-08-08 14:40:11 +00:00
|
|
|
#include "RequestFactory.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "SingleFileDownloadContext.h"
|
|
|
|
#include "RequestGroup.h"
|
2007-06-03 14:24:37 +00:00
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
class RequestGroupManTest : public CppUnit::TestFixture {
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE(RequestGroupManTest);
|
|
|
|
CPPUNIT_TEST(testIsSameFileBeingDownloaded);
|
2007-07-09 13:30:45 +00:00
|
|
|
CPPUNIT_TEST(testGetInitialCommands);
|
2007-06-03 14:24:37 +00:00
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
private:
|
|
|
|
|
|
|
|
public:
|
2007-07-09 13:30:45 +00:00
|
|
|
void setUp()
|
|
|
|
{
|
|
|
|
CUIDCounterHandle counter = new CUIDCounter();
|
|
|
|
CUIDCounterSingletonHolder::instance(counter);
|
|
|
|
}
|
2007-06-03 14:24:37 +00:00
|
|
|
|
|
|
|
void testIsSameFileBeingDownloaded();
|
2007-07-09 13:30:45 +00:00
|
|
|
void testGetInitialCommands();
|
2007-06-03 14:24:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( RequestGroupManTest );
|
|
|
|
|
|
|
|
void RequestGroupManTest::testIsSameFileBeingDownloaded()
|
|
|
|
{
|
|
|
|
Option option;
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
Strings uris;
|
|
|
|
uris.push_back("http://localhost/aria2.tar.bz2");
|
|
|
|
RequestGroupHandle rg1 = new RequestGroup(&option, uris);
|
|
|
|
RequestGroupHandle rg2 = new RequestGroup(&option, uris);
|
2007-06-03 14:24:37 +00:00
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
SingleFileDownloadContextHandle dctx1 =
|
|
|
|
new SingleFileDownloadContext(0, 0, "aria2.tar.bz2");
|
|
|
|
SingleFileDownloadContextHandle dctx2 =
|
|
|
|
new SingleFileDownloadContext(0, 0, "aria2.tar.bz2");
|
2007-06-03 14:24:37 +00:00
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
rg1->setDownloadContext(dctx1);
|
|
|
|
rg2->setDownloadContext(dctx2);
|
2007-06-03 14:24:37 +00:00
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
RequestGroups rgs;
|
|
|
|
rgs.push_back(rg1);
|
|
|
|
rgs.push_back(rg2);
|
2007-06-03 14:24:37 +00:00
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
RequestGroupMan gm(rgs, 1);
|
|
|
|
|
2007-06-03 14:24:37 +00:00
|
|
|
CPPUNIT_ASSERT(gm.isSameFileBeingDownloaded(rg1.get()));
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
dctx2->setFilename("aria2.tar.gz");
|
2007-06-03 14:24:37 +00:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT(!gm.isSameFileBeingDownloaded(rg1.get()));
|
|
|
|
|
|
|
|
}
|
2007-07-09 13:30:45 +00:00
|
|
|
|
|
|
|
void RequestGroupManTest::testGetInitialCommands()
|
|
|
|
{
|
2007-10-11 16:58:24 +00:00
|
|
|
// TODO implement later
|
|
|
|
/*
|
2007-07-09 13:30:45 +00:00
|
|
|
Option option;
|
|
|
|
option.put(PREF_SPLIT, "1");
|
|
|
|
option.put(PREF_TIMEOUT, "10");
|
2007-08-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
MessageDigestHelper is introduced in order to simplify the use
of message digest. Removed repeated code.
The message digest algorithm is now specified by string, like
"sha1",
"md5".
* src/messageDigest.{h, cc}
* src/MessageDigestHelper.{h, cc}: New class.
* src/DefaultPieceStorage.cc
* src/DefaultBtContext.{h, cc}
(computeFastSet): New function.
(setInfoHash): Added for unit testing.
(setNumPieces): Added for unit testing.
* src/DefaultBtInteractive.cc
* src/BtPieceMessage.cc
* src/Peer.cc
* src/Checksum.h
* src/message.h
* src/IteratableChecksumValidator.h
* src/ChunkChecksumValidator.{h, cc}: Use
IteratableChecksumValidator
inside it.
* src/SegmentMan.{h, cc}
(checkIntegrity): Removed.
* src/IteratableChunkChecksumValidator.{h, cc}
* src/Util.h
(sha1Sum): Removed.
(simpleMessageDigest): Removed.
(fileChecksum): Removed.
(computeFastSet): Removed.
* src/ShaVisitor.cc
* src/ChunkChecksum.h
* src/DownloadCommand.cc
Removed messageDigest virtual functions.
* src/MultiDiskAdaptor.{h, cc}
* src/DiskAdaptor.h
* src/ByteArrayDiskWriter.h
* src/DiskWriter.h
* src/DiskAdaptorWriter.h
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Fixed comilation error when message digest is disabled.
* src/MetalinkEntry.{h, cc}
* src/MetalinkRequestInfo.cc
Removed srandom and random.
* src/SimpleRandomizer.h
Added size() virtual function to DiskAdaptor
* src/MultiDiskAdaptor.h
Fixed the bug that causes that files are not opened correctly in
multi-file torrent.
* src/TorrentRequestInfo.cc
* src/MultiDiskAdaptor.cc
Added SHA256 support
* src/messageDigest.cc
* src/Xml2MetalinkProcessor.cc
Show supported message digest algorithms
* src/main.cc
Updated contact info.
* src/main.cc
2007-08-08 14:40:11 +00:00
|
|
|
|
|
|
|
RequestFactoryHandle requestFactory = new RequestFactory();
|
|
|
|
requestFactory->setOption(&option);
|
|
|
|
RequestFactorySingletonHolder::instance(requestFactory);
|
|
|
|
|
2007-07-09 13:30:45 +00:00
|
|
|
RequestGroupMan gm;
|
|
|
|
|
|
|
|
RequestGroupHandle rg1 = new RequestGroup("aria2.tar.bz2.metalink",
|
|
|
|
&option);
|
|
|
|
RequestGroupHandle rg2 = new RequestGroup("http://localhost/aria2.tar.bz2",
|
|
|
|
&option);
|
|
|
|
|
|
|
|
gm.addRequestGroup(rg1);
|
|
|
|
gm.addRequestGroup(rg2);
|
|
|
|
|
|
|
|
ConsoleDownloadEngine e;
|
|
|
|
e.option = &option;
|
|
|
|
Commands commands = gm.getInitialCommands(&e);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)1, commands.size());
|
2007-10-11 16:58:24 +00:00
|
|
|
*/
|
2007-07-09 13:30:45 +00:00
|
|
|
}
|