2007-03-26 12:16:57 +00:00
|
|
|
#include "OptionHandlerImpl.h"
|
|
|
|
#include "prefs.h"
|
|
|
|
#include "Exception.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include <iostream>
|
2007-03-26 12:16:57 +00:00
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
namespace aria2 {
|
|
|
|
|
2007-03-26 12:16:57 +00:00
|
|
|
class OptionHandlerTest:public CppUnit::TestFixture {
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE(OptionHandlerTest);
|
|
|
|
CPPUNIT_TEST(testNullOptionHandler);
|
|
|
|
CPPUNIT_TEST(testBooleanOptionHandler);
|
|
|
|
CPPUNIT_TEST(testNumberOptionHandler);
|
|
|
|
CPPUNIT_TEST(testNumberOptionHandler_min);
|
|
|
|
CPPUNIT_TEST(testNumberOptionHandler_max);
|
|
|
|
CPPUNIT_TEST(testNumberOptionHandler_min_max);
|
|
|
|
CPPUNIT_TEST(testUnitNumberOptionHandler);
|
|
|
|
CPPUNIT_TEST(testParameterOptionHandler_1argInit);
|
|
|
|
CPPUNIT_TEST(testParameterOptionHandler_2argsInit);
|
|
|
|
CPPUNIT_TEST(testParameterOptionHandler_listInit);
|
|
|
|
CPPUNIT_TEST(testDefaultOptionHandler);
|
|
|
|
CPPUNIT_TEST(testFloatNumberOptionHandler);
|
|
|
|
CPPUNIT_TEST(testFloatNumberOptionHandler_min);
|
|
|
|
CPPUNIT_TEST(testFloatNumberOptionHandler_max);
|
|
|
|
CPPUNIT_TEST(testFloatNumberOptionHandler_min_max);
|
|
|
|
CPPUNIT_TEST(testLogOptionHandler);
|
|
|
|
CPPUNIT_TEST(testHttpProxyOptionHandler);
|
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
|
|
|
|
public:
|
|
|
|
void testNullOptionHandler();
|
|
|
|
void testBooleanOptionHandler();
|
|
|
|
void testNumberOptionHandler();
|
|
|
|
void testNumberOptionHandler_min();
|
|
|
|
void testNumberOptionHandler_max();
|
|
|
|
void testNumberOptionHandler_min_max();
|
|
|
|
void testUnitNumberOptionHandler();
|
|
|
|
void testParameterOptionHandler_1argInit();
|
|
|
|
void testParameterOptionHandler_2argsInit();
|
|
|
|
void testParameterOptionHandler_listInit();
|
|
|
|
void testDefaultOptionHandler();
|
|
|
|
void testFloatNumberOptionHandler();
|
|
|
|
void testFloatNumberOptionHandler_min();
|
|
|
|
void testFloatNumberOptionHandler_max();
|
|
|
|
void testFloatNumberOptionHandler_min_max();
|
|
|
|
void testLogOptionHandler();
|
|
|
|
void testHttpProxyOptionHandler();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( OptionHandlerTest );
|
|
|
|
|
|
|
|
void OptionHandlerTest::testNullOptionHandler()
|
|
|
|
{
|
|
|
|
NullOptionHandler handler;
|
|
|
|
CPPUNIT_ASSERT(handler.canHandle("foo"));
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(0, "bar");
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OptionHandlerTest::testBooleanOptionHandler()
|
|
|
|
{
|
|
|
|
BooleanOptionHandler handler("foo");
|
|
|
|
CPPUNIT_ASSERT(handler.canHandle("foo"));
|
|
|
|
CPPUNIT_ASSERT(!handler.canHandle("foobar"));
|
|
|
|
Option option;
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, V_TRUE);
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(V_TRUE), option.get("foo"));
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, V_FALSE);
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(V_FALSE), option.get("foo"));
|
2007-03-26 12:16:57 +00:00
|
|
|
try {
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "hello");
|
2007-08-09 14:54:36 +00:00
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionHandlerTest::testNumberOptionHandler()
|
|
|
|
{
|
|
|
|
NumberOptionHandler handler("foo");
|
|
|
|
CPPUNIT_ASSERT(handler.canHandle("foo"));
|
|
|
|
CPPUNIT_ASSERT(!handler.canHandle("foobar"));
|
|
|
|
Option option;
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "0");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("0"), option.get("foo"));
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OptionHandlerTest::testNumberOptionHandler_min()
|
|
|
|
{
|
|
|
|
NumberOptionHandler handler("foo", 1);
|
|
|
|
Option option;
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "1");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("1"), option.get("foo"));
|
2007-03-26 12:16:57 +00:00
|
|
|
try {
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "0");
|
2007-08-09 14:54:36 +00:00
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionHandlerTest::testNumberOptionHandler_max()
|
|
|
|
{
|
|
|
|
NumberOptionHandler handler("foo", -1, 100);
|
|
|
|
Option option;
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "100");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("100"), option.get("foo"));
|
2007-03-26 12:16:57 +00:00
|
|
|
try {
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "101");
|
2007-08-09 14:54:36 +00:00
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionHandlerTest::testNumberOptionHandler_min_max()
|
|
|
|
{
|
|
|
|
NumberOptionHandler handler("foo", 1, 100);
|
|
|
|
Option option;
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "1");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("1"), option.get("foo"));
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "100");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("100"), option.get("foo"));
|
2007-03-26 12:16:57 +00:00
|
|
|
try {
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "0");
|
2007-08-09 14:54:36 +00:00
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
try {
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "101");
|
2007-08-09 14:54:36 +00:00
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionHandlerTest::testUnitNumberOptionHandler()
|
|
|
|
{
|
|
|
|
UnitNumberOptionHandler handler("foo");
|
|
|
|
CPPUNIT_ASSERT(handler.canHandle("foo"));
|
|
|
|
CPPUNIT_ASSERT(!handler.canHandle("foobar"));
|
|
|
|
Option option;
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "4294967296");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("4294967296"), option.get("foo"));
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "4096M");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("4294967296"), option.get("foo"));
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "4096K");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("4194304"), option.get("foo"));
|
2007-11-22 11:17:35 +00:00
|
|
|
try {
|
|
|
|
handler.parse(&option, "K");
|
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace();
|
2007-11-22 11:17:35 +00:00
|
|
|
}
|
|
|
|
try {
|
|
|
|
handler.parse(&option, "M");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace();
|
2007-11-22 11:17:35 +00:00
|
|
|
}
|
|
|
|
try {
|
|
|
|
handler.parse(&option, "");
|
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace();
|
2007-11-22 11:17:35 +00:00
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OptionHandlerTest::testParameterOptionHandler_1argInit()
|
|
|
|
{
|
|
|
|
ParameterOptionHandler handler("foo", "value1");
|
|
|
|
CPPUNIT_ASSERT(handler.canHandle("foo"));
|
|
|
|
CPPUNIT_ASSERT(!handler.canHandle("foobar"));
|
|
|
|
Option option;
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "value1");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("value1"), option.get("foo"));
|
2007-03-26 12:16:57 +00:00
|
|
|
try {
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "value3");
|
2007-08-09 14:54:36 +00:00
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionHandlerTest::testParameterOptionHandler_2argsInit()
|
|
|
|
{
|
|
|
|
ParameterOptionHandler handler("foo", "value1", "value2");
|
|
|
|
CPPUNIT_ASSERT(handler.canHandle("foo"));
|
|
|
|
CPPUNIT_ASSERT(!handler.canHandle("foobar"));
|
|
|
|
Option option;
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "value1");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("value1"), option.get("foo"));
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "value2");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("value2"), option.get("foo"));
|
2007-03-26 12:16:57 +00:00
|
|
|
try {
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "value3");
|
2007-08-09 14:54:36 +00:00
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionHandlerTest::testParameterOptionHandler_listInit()
|
|
|
|
{
|
2008-02-08 15:53:45 +00:00
|
|
|
std::deque<std::string> validValues;
|
2007-03-26 12:16:57 +00:00
|
|
|
validValues.push_back("value1");
|
|
|
|
validValues.push_back("value2");
|
|
|
|
|
|
|
|
ParameterOptionHandler handler("foo", validValues);
|
|
|
|
CPPUNIT_ASSERT(handler.canHandle("foo"));
|
|
|
|
CPPUNIT_ASSERT(!handler.canHandle("foobar"));
|
|
|
|
Option option;
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "value1");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("value1"), option.get("foo"));
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "value2");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("value2"), option.get("foo"));
|
2007-03-26 12:16:57 +00:00
|
|
|
try {
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "value3");
|
2007-08-09 14:54:36 +00:00
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionHandlerTest::testDefaultOptionHandler()
|
|
|
|
{
|
|
|
|
DefaultOptionHandler handler("foo");
|
|
|
|
CPPUNIT_ASSERT(handler.canHandle("foo"));
|
|
|
|
CPPUNIT_ASSERT(!handler.canHandle("foobar"));
|
|
|
|
Option option;
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "bar");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("bar"), option.get("foo"));
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), option.get("foo"));
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OptionHandlerTest::testFloatNumberOptionHandler()
|
|
|
|
{
|
|
|
|
FloatNumberOptionHandler handler("foo");
|
|
|
|
CPPUNIT_ASSERT(handler.canHandle("foo"));
|
|
|
|
CPPUNIT_ASSERT(!handler.canHandle("foobar"));
|
|
|
|
Option option;
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "1.0");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("1.0"), option.get("foo"));
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OptionHandlerTest::testFloatNumberOptionHandler_min()
|
|
|
|
{
|
|
|
|
FloatNumberOptionHandler handler("foo", 0.0);
|
|
|
|
Option option;
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "0.0");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("0.0"), option.get("foo"));
|
2007-03-26 12:16:57 +00:00
|
|
|
try {
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "-0.1");
|
2007-08-09 14:54:36 +00:00
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionHandlerTest::testFloatNumberOptionHandler_max()
|
|
|
|
{
|
|
|
|
FloatNumberOptionHandler handler("foo", -1, 10.0);
|
|
|
|
Option option;
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "10.0");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("10.0"), option.get("foo"));
|
2007-03-26 12:16:57 +00:00
|
|
|
try {
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "10.1");
|
2007-08-09 14:54:36 +00:00
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionHandlerTest::testFloatNumberOptionHandler_min_max()
|
|
|
|
{
|
|
|
|
FloatNumberOptionHandler handler("foo", 0.0, 10.0);
|
|
|
|
Option option;
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "0.0");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("0.0"), option.get("foo"));
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "10.0");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("10.0"), option.get("foo"));
|
2007-03-26 12:16:57 +00:00
|
|
|
try {
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "-0.1");
|
2007-08-09 14:54:36 +00:00
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
try {
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "10.1");
|
2007-08-09 14:54:36 +00:00
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionHandlerTest::testLogOptionHandler()
|
|
|
|
{
|
|
|
|
LogOptionHandler handler("foo");
|
|
|
|
CPPUNIT_ASSERT(handler.canHandle("foo"));
|
|
|
|
CPPUNIT_ASSERT(!handler.canHandle("foobar"));
|
|
|
|
Option option;
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "/tmp/log.txt");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/log.txt"), option.get(PREF_LOG));
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), option.get(PREF_STDOUT_LOG));
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
option.clear();
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "-");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), option.get(PREF_LOG));
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(V_TRUE), option.get(PREF_STDOUT_LOG));
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OptionHandlerTest::testHttpProxyOptionHandler()
|
|
|
|
{
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
HttpProxyOptionHandler handler(PREF_HTTP_PROXY,
|
|
|
|
PREF_HTTP_PROXY_HOST,
|
|
|
|
PREF_HTTP_PROXY_PORT);
|
|
|
|
CPPUNIT_ASSERT(handler.canHandle(PREF_HTTP_PROXY));
|
2007-03-26 12:16:57 +00:00
|
|
|
CPPUNIT_ASSERT(!handler.canHandle("foobar"));
|
|
|
|
Option option;
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "bar:80");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("bar:80"), option.get(PREF_HTTP_PROXY));
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("bar"), option.get(PREF_HTTP_PROXY_HOST));
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("80"), option.get(PREF_HTTP_PROXY_PORT));
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(V_TRUE), option.get(PREF_HTTP_PROXY_ENABLED));
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
try {
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "bar");
|
2007-08-09 14:54:36 +00:00
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
try {
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "bar:");
|
2007-08-09 14:54:36 +00:00
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
try {
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, ":");
|
2007-08-09 14:54:36 +00:00
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
try {
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, ":80");
|
2007-08-09 14:54:36 +00:00
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
try {
|
2007-11-21 16:14:40 +00:00
|
|
|
handler.parse(&option, "foo:bar");
|
2007-08-09 14:54:36 +00:00
|
|
|
CPPUNIT_FAIL("exception must be thrown.");
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
} // namespace aria2
|