diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2012-08-10 17:05:24 +0200 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2012-08-10 17:05:24 +0200 |
commit | 540a8d30ffeac5d6214b2c7bc6354e01d3f403d7 (patch) | |
tree | 199e2a1154e5b2ea2e6354db7324eb7d93070a87 /tests/url | |
parent | 3763777e7811b7efdae57d747f02f51fe4706fc4 (diff) | |
download | crawler-540a8d30ffeac5d6214b2c7bc6354e01d3f403d7.tar.gz crawler-540a8d30ffeac5d6214b2c7bc6354e01d3f403d7.tar.bz2 |
module loader works on Windows, simple URL normalizer test works
Diffstat (limited to 'tests/url')
-rwxr-xr-x | tests/url/Makefile.W32 | 16 | ||||
-rwxr-xr-x[-rw-r--r--] | tests/url/test1.cpp | 113 |
2 files changed, 68 insertions, 61 deletions
diff --git a/tests/url/Makefile.W32 b/tests/url/Makefile.W32 index c2d74e7..573f636 100755 --- a/tests/url/Makefile.W32 +++ b/tests/url/Makefile.W32 @@ -5,26 +5,28 @@ SUBDIRS = !INCLUDE $(TOPDIR)\makefiles\nmake\platform.mk INCLUDE_CXXFLAGS = \ - /D_WIN32_WINNT=0x504 + /D_WIN32_WINNT=0x504 \ + /DUSE_MODULELOADER INCLUDE_DIRS = \ /I. \ - /I$(TOPDIR)\src + /I$(TOPDIR)\src \ + /I$(TOPDIR)\src\modules\urlnormalizer\simpleurl INCLUDE_LDFLAGS = \ INCLUDE_LIBS = \ + $(TOPDIR)\src\crawlingwolf.lib \ + $(TOPDIR)\src\modules\urlnormalizer\simpleurl\simpleurlnormalizer.lib TEST_CPP_BINS = \ - test1.exe \ - test2.exe + test1.exe OBJS = !INCLUDE $(TOPDIR)\makefiles\nmake\sub.mk test1.exe: test1.obj -test2.exe: test2.obj local_all: @@ -34,5 +36,5 @@ local_clean: local_distclean: local_test: - @-exec_test test1 "TypeList and TypeTraits" - @-exec_test test2 "TypeInfo C++ demangle" +# @-exec_test test1 "TypeList and TypeTraits" +# @-exec_test test2 "TypeInfo C++ demangle" diff --git a/tests/url/test1.cpp b/tests/url/test1.cpp index b2ee90e..095de24 100644..100755 --- a/tests/url/test1.cpp +++ b/tests/url/test1.cpp @@ -4,7 +4,7 @@ #include "ModuleLoader.hpp" #else #include "SimpleURLNormalizer.hpp" -#include "GoogleURLNormalizer.hpp" +//#include "GoogleURLNormalizer.hpp" #endif #include <vector> @@ -16,71 +16,76 @@ using namespace std; int main( int argc, char *argv[] ) { - if( argc < 3 ) { - cerr << "usage: test1 <method> <action> <baseUrl> [<relativeUrl>]\n" << endl; - return 1; - } - - char *method = argv[1]; - char *action = argv[2]; - char *baseUrlString = argv[3]; - char *partialUrlString = argv[4]; + try { + if( argc < 3 ) { + cerr << "usage: test1 <method> <action> <baseUrl> [<relativeUrl>]\n" << endl; + return 1; + } + + char *method = argv[1]; + char *action = argv[2]; + char *baseUrlString = argv[3]; + char *partialUrlString = argv[4]; #ifdef USE_MODULELOADER - vector<string> modules; - modules.push_back( "../../src/modules/urlnormalizer/simpleurl/mod_urlnormalizer_simple.so" ); - modules.push_back( "../../src/modules/urlnormalizer/googleurl/mod_urlnormalizer_googleurl.so" ); - ModuleLoader<URLNormalizer> urlNormalizers( modules ); + vector<string> modules; + // modules.push_back( "../../src/modules/urlnormalizer/simpleurl/mod_urlnormalizer_simple" MODULE_EXT ); + modules.push_back( "..\\..\\src\\modules\\urlnormalizer\\simpleurl\\mod_urlnormalizer_simple" MODULE_EXT ); + // modules.push_back( "../../src/modules/urlnormalizer/googleurl/mod_urlnormalizer_googleurl" MODULE_EXT ); + ModuleLoader<URLNormalizer> urlNormalizers( modules ); - URLNormalizer *normalizer = urlNormalizers.create( method ); + URLNormalizer *normalizer = urlNormalizers.create( method ); #else - URLNormalizer *normalizer; - if( strcmp( method, "simple" ) == 0 ) { - normalizer = new SimpleURLNormalizer( ); - } else if( strcmp( method, "google" ) == 0 ) { - normalizer = new GoogleURLNormalizer( ); - } else { - cerr << "Unknown normalization method '" << method << "'" << endl; - return 1; - } + URLNormalizer *normalizer; + if( strcmp( method, "simple" ) == 0 ) { + normalizer = new SimpleURLNormalizer( ); + // } else if( strcmp( method, "google" ) == 0 ) { + // normalizer = new GoogleURLNormalizer( ); + } else { + cerr << "Unknown normalization method '" << method << "'" << endl; + return 1; + } #endif - - - URL url; - - if( strcmp( action, "parse" ) == 0 ) { - url = normalizer->parseUrl( baseUrlString ); - } else if( strcmp( action, "normalize" ) == 0 ) { - URL baseUrl = normalizer->parseUrl( baseUrlString ); - if( baseUrl == URL::Null ) { - cerr << "Illegal base URL!" << endl; + + URL url; + + if( strcmp( action, "parse" ) == 0 ) { + url = normalizer->parseUrl( baseUrlString ); + } else if( strcmp( action, "normalize" ) == 0 ) { + URL baseUrl = normalizer->parseUrl( baseUrlString ); + if( baseUrl == URL::Null ) { + cerr << "Illegal base URL!" << endl; + return 1; + } + url = normalizer->normalize( baseUrl, partialUrlString ); + } else { + cerr << "Unknown action '" << action << "'" << endl; return 1; } - url = normalizer->normalize( baseUrl, partialUrlString ); - } else { - cerr << "Unknown action '" << action << "'" << endl; - return 1; - } - if( url == URL::Null ) { - cerr << "Illegal URL!" << endl; - return 1; - } - - cout << "protocol: " << url.protocol( ) << endl - << "host: " << url.host( ) << endl - << "port: " << url.port( ) << endl - << "path: " << url.path( ) << endl - << "query: " << url.query( ) << endl - << "fragment: " << url.fragment( ) << endl; + if( url == URL::Null ) { + cerr << "Illegal URL!" << endl; + return 1; + } + + cout << "protocol: " << url.protocol( ) << endl + << "host: " << url.host( ) << endl + << "port: " << url.port( ) << endl + << "path: " << url.path( ) << endl + << "query: " << url.query( ) << endl + << "fragment: " << url.fragment( ) << endl; - cout << "URL: " << url << endl; + cout << "URL: " << url << endl; #ifdef USE_MODULELOADER - urlNormalizers.destroy( normalizer ); + urlNormalizers.destroy( normalizer ); #else - delete normalizer; + delete normalizer; #endif - return 0; + return 0; + } catch( exception &e ) { + cerr << e.what( ) << endl; + return 1; + } } |