forked from hpcc-systems/HPCC-Platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-enabling the unit test infrastructure, adding new tests for URI and linking existing tests into it. Some other tests are not yet linked (aren't cppunit or aren't in a shared lib) and will be done in the furure. There is a good documentation on how to extend, and about each part of the infrastructure. The remote tests are also a good example on how to create more API/TDD unit tests in the future.
- Loading branch information
Showing
8 changed files
with
267 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
################################################################################ | ||
# Copyright (C) 2012 HPCC Systems. | ||
# | ||
# This program is free software: you can redistribute it and/or All rights | ||
# reserved. This program is NOT PRESENTLY free software: you can NOT | ||
# redistribute | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
################################################################################ | ||
HPCC_ADD_SUBDIRECTORY (unittests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
################################################################################ | ||
# Copyright (C) 2012 HPCC Systems. | ||
# | ||
# All rights reserved. This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
################################################################################ | ||
|
||
|
||
# Component: unittests | ||
##################################################### | ||
# Description: | ||
# ------------ | ||
# Cmake Input File for unittests | ||
##################################################### | ||
|
||
project( unitests ) | ||
|
||
set ( SRCS | ||
unittests.cpp | ||
remotetests.cpp | ||
) | ||
|
||
include_directories ( | ||
. | ||
./../../system/include | ||
./../../system/jlib | ||
./../../common/remote | ||
) | ||
|
||
ADD_DEFINITIONS( -D_CONSOLE ) | ||
|
||
HPCC_ADD_EXECUTABLE ( unittests ${SRCS} ) | ||
|
||
install ( TARGETS unittests DESTINATION ${OSSDIR}/bin ) | ||
target_link_libraries ( unittests | ||
jlib | ||
remote | ||
cppunit | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/*############################################################################## | ||
Copyright (C) 2012 HPCC Systems. | ||
All rights reserved. This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as | ||
published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
############################################################################## */ | ||
|
||
#ifdef _USE_CPPUNIT | ||
#include "jlib.hpp" | ||
#include "jlog.hpp" | ||
#include "uri.hpp" | ||
|
||
#include <cppunit/extensions/TestFactoryRegistry.h> | ||
#include <cppunit/ui/text/TestRunner.h> | ||
#include <cppunit/extensions/HelperMacros.h> | ||
// CPPUNIT_ASSERT is too slow, even when not matching failure | ||
#define ASSERT(a) { if (!(a)) CPPUNIT_ASSERT(a); } | ||
|
||
// =============================================================== jURI - URI parser | ||
class URITests : public CppUnit::TestFixture | ||
{ | ||
CPPUNIT_TEST_SUITE( URITests ); | ||
CPPUNIT_TEST(testURIError); | ||
CPPUNIT_TEST(testURIUnknwon); | ||
CPPUNIT_TEST(testURILocal); | ||
CPPUNIT_TEST(testURIDali); | ||
CPPUNIT_TEST_SUITE_END(); | ||
const IContextLogger &logctx; | ||
|
||
void test_uri(const char * str, bool shouldBeURI, URISchemeType scheme=URIScheme_error, const char * server=NULL, const char * path=NULL) | ||
{ | ||
bool isURI = URI::isURI(str); | ||
ASSERT(isURI == shouldBeURI); | ||
if (!isURI) | ||
return; | ||
|
||
// Now, validate URI | ||
try | ||
{ | ||
URI res(str); | ||
ASSERT(res.getScheme() == scheme); | ||
// No need to validate the rest | ||
if (scheme == URIScheme_error) | ||
return; | ||
StringBuffer response; | ||
res.appendServerStr(response); | ||
ASSERT(strcmp(response.str(), server) == 0); | ||
response.clear(); | ||
res.appendPathStr(response); | ||
ASSERT(strcmp(response.str(), path) == 0); | ||
} | ||
catch (IException *e) | ||
{ | ||
StringBuffer buf; | ||
logctx.CTXLOG("Exception: %s", e->errorMessage(buf).str()); | ||
e->Release(); | ||
ASSERT(false); // Check exception log | ||
} | ||
} | ||
|
||
public: | ||
URITests() : logctx(queryDummyContextLogger()) {} | ||
|
||
void testURIError() { | ||
test_uri("You, shall not, pass!", false); | ||
test_uri("http://almost there...", false); | ||
} | ||
|
||
void testURIUnknwon() { | ||
test_uri("ftp://www.hpccsystems.com/", true); | ||
test_uri("gopher://www.hpccsystems.com/", true); | ||
test_uri("https://www.hpccsystems.com:443/", true); | ||
test_uri("http://user:[email protected]:8080/my/path?is=full#of-stuff", true); | ||
} | ||
|
||
void testURILocal() { | ||
test_uri("file:///opt/HPCCSystems/examples/IMDB/ActorsInMovies.ecl", true, URIScheme_file, "", "/opt/HPCCSystems/examples/IMDB/ActorsInMovies.ecl"); | ||
} | ||
|
||
void testURIDali() { | ||
// Dali file types | ||
test_uri("hpcc://mydali/path/to/file", true, URIScheme_hpcc, "mydali", "path/to/file"); | ||
test_uri("hpcc://mydali/path/to/superfile?super", true, URIScheme_hpcc, "mydali", "path/to/superfile?super"); | ||
test_uri("hpcc://mydali/path/to/superfile?super#subname", true, URIScheme_hpcc, "mydali", "path/to/superfile?super#subname"); | ||
test_uri("hpcc://mydali/path/to/streamfile?stream", true, URIScheme_hpcc, "mydali", "path/to/streamfile?stream"); | ||
test_uri("hpcc://mydali/path/to/streamfile?stream#047", true, URIScheme_hpcc, "mydali", "path/to/streamfile?stream#47"); | ||
|
||
// Variations in Dali location | ||
test_uri("hpcc://mydali:7070/path/to/file", true, URIScheme_hpcc, "mydali:7070", "path/to/file"); | ||
test_uri("hpcc://user@mydali:7070/path/to/file", true, URIScheme_hpcc, "user@mydali:7070", "path/to/file"); | ||
test_uri("hpcc://user@mydali/path/to/file", true, URIScheme_hpcc, "user@mydali", "path/to/file"); | ||
test_uri("hpcc://user:passwd@mydali:7070/path/to/file", true, URIScheme_hpcc, "user:passwd@mydali:7070", "path/to/file"); | ||
test_uri("hpcc://user:passwd@mydali/path/to/file", true, URIScheme_hpcc, "user:passwd@mydali", "path/to/file"); | ||
} | ||
}; | ||
|
||
CPPUNIT_TEST_SUITE_REGISTRATION( URITests ); | ||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( URITests, "URITests" ); | ||
|
||
#endif // _USE_CPPUNIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters