mirror of
https://github.com/aria2/aria2.git
synced 2025-04-07 06:27:37 +03:00
2008-08-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Implemented ServerStatMan::removeStaleServerStat() and its test case. * src/ServerStatMan.cc * src/ServerStatMan.h * test/ServerStatManTest.cc
This commit is contained in:
parent
d85014b937
commit
6aba376430
4 changed files with 57 additions and 1 deletions
|
@ -14,6 +14,7 @@ class ServerStatManTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testAddAndFind);
|
||||
CPPUNIT_TEST(testSave);
|
||||
CPPUNIT_TEST(testLoad);
|
||||
CPPUNIT_TEST(testRemoveStaleServerStat);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
public:
|
||||
void setUp() {}
|
||||
|
@ -23,6 +24,7 @@ public:
|
|||
void testAddAndFind();
|
||||
void testSave();
|
||||
void testLoad();
|
||||
void testRemoveStaleServerStat();
|
||||
};
|
||||
|
||||
|
||||
|
@ -62,7 +64,7 @@ void ServerStatManTest::testSave()
|
|||
localhost_ftp->setLastUpdated(Time(1210000001));
|
||||
SharedHandle<ServerStat> mirror(new ServerStat("mirror", "http"));
|
||||
mirror->setDownloadSpeed(0);
|
||||
mirror->setError();
|
||||
mirror->setStatus(ServerStat::ERROR);
|
||||
mirror->setLastUpdated(Time(1210000002));
|
||||
|
||||
ServerStatMan ssm;
|
||||
|
@ -108,4 +110,30 @@ void ServerStatManTest::testLoad()
|
|||
CPPUNIT_ASSERT_EQUAL(ServerStat::ERROR, mirror->getStatus());
|
||||
}
|
||||
|
||||
void ServerStatManTest::testRemoveStaleServerStat()
|
||||
{
|
||||
Time now;
|
||||
SharedHandle<ServerStat> localhost_http(new ServerStat("localhost", "http"));
|
||||
localhost_http->setDownloadSpeed(25000);
|
||||
localhost_http->setLastUpdated(now);
|
||||
SharedHandle<ServerStat> localhost_ftp(new ServerStat("localhost", "ftp"));
|
||||
localhost_ftp->setDownloadSpeed(30000);
|
||||
localhost_ftp->setLastUpdated(Time(1210000001));
|
||||
SharedHandle<ServerStat> mirror(new ServerStat("mirror", "http"));
|
||||
mirror->setDownloadSpeed(0);
|
||||
mirror->setStatus(ServerStat::ERROR);
|
||||
mirror->setLastUpdated(Time(1210000002));
|
||||
|
||||
ServerStatMan ssm;
|
||||
CPPUNIT_ASSERT(ssm.add(localhost_http));
|
||||
CPPUNIT_ASSERT(ssm.add(localhost_ftp));
|
||||
CPPUNIT_ASSERT(ssm.add(mirror));
|
||||
|
||||
ssm.removeStaleServerStat(24*60*60);
|
||||
|
||||
CPPUNIT_ASSERT(!ssm.find("localhost", "http").isNull());
|
||||
CPPUNIT_ASSERT(ssm.find("localhost", "ftp").isNull());
|
||||
CPPUNIT_ASSERT(ssm.find("mirror", "http").isNull());
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue