diff --git a/include/mapnik/config_error.hpp b/include/mapnik/config_error.hpp index fcb5e7c52..275f795ae 100644 --- a/include/mapnik/config_error.hpp +++ b/include/mapnik/config_error.hpp @@ -1,3 +1,25 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2006 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + #ifndef MAPNIK_CONFIG_ERROR_INCLUDED #define MAPNIK_CONFIG_ERROR_INCLUDED diff --git a/include/mapnik/enumeration.hpp b/include/mapnik/enumeration.hpp index c61c9b96d..602699b58 100644 --- a/include/mapnik/enumeration.hpp +++ b/include/mapnik/enumeration.hpp @@ -1,3 +1,25 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2006 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + #ifndef MAPNIK_ENUMERATION_INCLUDED #define MAPNIK_ENUMERATION_INCLUDED diff --git a/include/mapnik/libxml2_loader.hpp b/include/mapnik/libxml2_loader.hpp index f2a7f1533..63ddcfe4e 100644 --- a/include/mapnik/libxml2_loader.hpp +++ b/include/mapnik/libxml2_loader.hpp @@ -1,3 +1,25 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2006 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + #ifndef LOAD_MAP_XML2_INCLUDED #define LOAD_MAP_XML2_INCLUDED diff --git a/include/mapnik/ptree_helpers.hpp b/include/mapnik/ptree_helpers.hpp index f75496a5a..598520457 100644 --- a/include/mapnik/ptree_helpers.hpp +++ b/include/mapnik/ptree_helpers.hpp @@ -1,3 +1,25 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2006 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + #ifndef MAPNIK_CONFIG_HELPERS_INCLUDED #define MAPNIK_CONFIG_HELPERS_INCLUDED diff --git a/tests/data/broken_maps/amenity.xml b/tests/data/broken_maps/amenity.xml new file mode 100644 index 000000000..5e800355c --- /dev/null +++ b/tests/data/broken_maps/amenity.xml @@ -0,0 +1,86 @@ + + diff --git a/tests/data/broken_maps/bgcolor_broken.xml b/tests/data/broken_maps/bgcolor_broken.xml new file mode 100644 index 000000000..5604b3051 --- /dev/null +++ b/tests/data/broken_maps/bgcolor_broken.xml @@ -0,0 +1,3 @@ + + + diff --git a/tests/data/broken_maps/bool_value_broken.xml b/tests/data/broken_maps/bool_value_broken.xml new file mode 100644 index 000000000..d3a1c1d6c --- /dev/null +++ b/tests/data/broken_maps/bool_value_broken.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/tests/data/broken_maps/color_value_broken.xml b/tests/data/broken_maps/color_value_broken.xml new file mode 100644 index 000000000..72292b109 --- /dev/null +++ b/tests/data/broken_maps/color_value_broken.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/tests/data/broken_maps/css_value_broken.xml b/tests/data/broken_maps/css_value_broken.xml new file mode 100644 index 000000000..56086d497 --- /dev/null +++ b/tests/data/broken_maps/css_value_broken.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/tests/data/broken_maps/datasource_type_broken.xml b/tests/data/broken_maps/datasource_type_broken.xml new file mode 100644 index 000000000..4a060d9b4 --- /dev/null +++ b/tests/data/broken_maps/datasource_type_broken.xml @@ -0,0 +1,13 @@ + + + + + + foobar_db + some_one + SECRET + gis + + + + diff --git a/tests/data/broken_maps/datasource_type_missing.xml b/tests/data/broken_maps/datasource_type_missing.xml new file mode 100644 index 000000000..bac8281f0 --- /dev/null +++ b/tests/data/broken_maps/datasource_type_missing.xml @@ -0,0 +1,12 @@ + + + + + + some_one + SECRET + gis + + + + diff --git a/tests/data/broken_maps/db_host_broken.xml b/tests/data/broken_maps/db_host_broken.xml new file mode 100644 index 000000000..0480113c9 --- /dev/null +++ b/tests/data/broken_maps/db_host_broken.xml @@ -0,0 +1,16 @@ + + + +]> + + + + postgis + &db_host; + SECRET + &db_name; + + + + diff --git a/tests/data/broken_maps/db_user_broken.xml b/tests/data/broken_maps/db_user_broken.xml new file mode 100644 index 000000000..a6d13ed28 --- /dev/null +++ b/tests/data/broken_maps/db_user_broken.xml @@ -0,0 +1,16 @@ + + + +]> + + + + postgis + &db_user; + SECRET + &db_name; + + + + diff --git a/tests/data/broken_maps/expression_broken.xml b/tests/data/broken_maps/expression_broken.xml new file mode 100644 index 000000000..a0420e45f --- /dev/null +++ b/tests/data/broken_maps/expression_broken.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/tests/data/broken_maps/font_name_broken.xml b/tests/data/broken_maps/font_name_broken.xml new file mode 100644 index 000000000..95a306c79 --- /dev/null +++ b/tests/data/broken_maps/font_name_broken.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/tests/data/broken_maps/line_cap_style_broken.xml b/tests/data/broken_maps/line_cap_style_broken.xml new file mode 100644 index 000000000..92298999d --- /dev/null +++ b/tests/data/broken_maps/line_cap_style_broken.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/tests/data/broken_maps/line_join_style_broken.xml b/tests/data/broken_maps/line_join_style_broken.xml new file mode 100644 index 000000000..736e0a7dd --- /dev/null +++ b/tests/data/broken_maps/line_join_style_broken.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/tests/data/broken_maps/line_pattern_symbolizer_broken.xml b/tests/data/broken_maps/line_pattern_symbolizer_broken.xml new file mode 100644 index 000000000..7101aec51 --- /dev/null +++ b/tests/data/broken_maps/line_pattern_symbolizer_broken.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/tests/data/broken_maps/max_scale_denom_broken.xml b/tests/data/broken_maps/max_scale_denom_broken.xml new file mode 100644 index 000000000..60ada9ca4 --- /dev/null +++ b/tests/data/broken_maps/max_scale_denom_broken.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/tests/data/broken_maps/min_scale_denom_broken.xml b/tests/data/broken_maps/min_scale_denom_broken.xml new file mode 100644 index 000000000..3c68435a9 --- /dev/null +++ b/tests/data/broken_maps/min_scale_denom_broken.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/tests/data/broken_maps/missing_icon.xml b/tests/data/broken_maps/missing_icon.xml new file mode 100644 index 000000000..cd3687c56 --- /dev/null +++ b/tests/data/broken_maps/missing_icon.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/tests/data/broken_maps/point_symbolizer_broken.xml b/tests/data/broken_maps/point_symbolizer_broken.xml new file mode 100644 index 000000000..b89849777 --- /dev/null +++ b/tests/data/broken_maps/point_symbolizer_broken.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/tests/data/broken_maps/polygon_pattern_symbolizer_broken.xml b/tests/data/broken_maps/polygon_pattern_symbolizer_broken.xml new file mode 100644 index 000000000..455f24929 --- /dev/null +++ b/tests/data/broken_maps/polygon_pattern_symbolizer_broken.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/tests/data/broken_maps/shield_symbolizer_broken.xml b/tests/data/broken_maps/shield_symbolizer_broken.xml new file mode 100644 index 000000000..9d58f4e47 --- /dev/null +++ b/tests/data/broken_maps/shield_symbolizer_broken.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/tests/data/broken_maps/stroke_dasharray_broken.xml b/tests/data/broken_maps/stroke_dasharray_broken.xml new file mode 100644 index 000000000..ad3de7def --- /dev/null +++ b/tests/data/broken_maps/stroke_dasharray_broken.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/tests/data/broken_maps/style_name_missing.xml b/tests/data/broken_maps/style_name_missing.xml new file mode 100644 index 000000000..5d95cb15a --- /dev/null +++ b/tests/data/broken_maps/style_name_missing.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/data/broken_maps/xml_tag_mismatch.xml b/tests/data/broken_maps/xml_tag_mismatch.xml new file mode 100644 index 000000000..480bd1b92 --- /dev/null +++ b/tests/data/broken_maps/xml_tag_mismatch.xml @@ -0,0 +1,10 @@ + + + + + + + + + + + + diff --git a/tests/data/good_maps/osm-styles.xml b/tests/data/good_maps/osm-styles.xml new file mode 100644 index 000000000..0d5c79eae --- /dev/null +++ b/tests/data/good_maps/osm-styles.xml @@ -0,0 +1,1262 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/good_maps/point_symbolizers.xml b/tests/data/good_maps/point_symbolizers.xml new file mode 100644 index 000000000..a016a7544 --- /dev/null +++ b/tests/data/good_maps/point_symbolizers.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/tests/data/good_maps/whitespace_at_end_of_filter_expression.xml b/tests/data/good_maps/whitespace_at_end_of_filter_expression.xml new file mode 100644 index 000000000..d6454d77a --- /dev/null +++ b/tests/data/good_maps/whitespace_at_end_of_filter_expression.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/tests/data/images/dummy.png b/tests/data/images/dummy.png new file mode 100644 index 000000000..8b8c5fd22 Binary files /dev/null and b/tests/data/images/dummy.png differ diff --git a/tests/python/test_load_map.py b/tests/python/test_load_map.py new file mode 100755 index 000000000..84b7cc755 --- /dev/null +++ b/tests/python/test_load_map.py @@ -0,0 +1,91 @@ +#!/usr/bin/python + +from mapnik import * +import sys +import glob + +def testGood( file ) : + print "Testing good file '" + file + "' ... ", + + m = Map(512, 512) + try: + load_map(m, file, True) + except RuntimeError, what: + print "FAILED" + print what + return False + except: + print "FAILED" + return False + else: + print "OK" + return True + + +def testBroken( file ) : + print "Testing broken file '" + file + "' ... ", + + m = Map(512, 512) + try: + strict = True + load_map(m, file, strict) + except UserWarning, what: + print "OK" + print "=== Error Message =============" + print what + print + return True + except RuntimeError, what: + print "FAILED (not a UserWarning)" + print "=== Error Message =============" + print what + print + else: + print "FAILED" + + return False + + +def test(): + success = 0 + failed = 0 + failed_tests = [] + + broken_files = glob.glob("../data/broken_maps/*.xml") + # eh, can't glob this ... :-) + broken_files.append( "../data/broken/does_not_exist.xml" ) + for file in broken_files: + if testBroken( file ): + success += 1 + else: + failed += 1 + failed_tests.append( file ) + + good_files = glob.glob("../data/good_maps/*.xml") + for file in good_files: + if testGood( file ): + success += 1 + else: + failed += 1 + failed_tests.append( file ) + + print "=======================================================" + print "Status:", + if failed: + print "FAILED" + print "Errors in: ", failed_tests + else: + print "SUCCESS" + print "Success:", success, "Failed:", failed, "Total:", success + failed + print "=======================================================" + if failed: + return False + else: + return True + + +if __name__ == "__main__": + if test(): + sys.exit( 0 ) + else: + sys.exit( 1 ) diff --git a/tests/python/test_save_map.py b/tests/python/test_save_map.py new file mode 100755 index 000000000..359fe9d61 --- /dev/null +++ b/tests/python/test_save_map.py @@ -0,0 +1,76 @@ +#!/usr/bin/python + +from mapnik import * +import os +import sys +import glob + + +def test(): +# success = 0 +# failed = 0 +# failed_tests = [] + +# TODO: write a better test +# 1. construct map in memory +# 2. save map as XML +# 3. load map to a second object +# 4. Compare both map objects + + map = Map(256, 256) + in_map = "../data/good_maps/osm-styles.xml" + print "Loading map '" + in_map + "' ... ", + load_map( map, in_map ) + print "OK" + + test_map = "test_map.xml" + failed = False; + try: + print "Saving map '" + test_map + "' ... ", + save_map( map, test_map) + print "OK" + except: + print "FAILED" + failed = True; + + + if not failed: + new_map = Map(256, 256) + try: + print "Reloading map '" + test_map + "' ... ", + load_map( new_map, test_map) + print "OK" + except UserWarning, what: + print "FAILED" + print "Error: ", what + failed = True; + except RuntimeError, what: + print "FAILED" + print "Error: ", what + failed = True; + except: + print "FAILED" + failed = True; + + if not failed and os.path.exists( test_map ): + print "Removing '" + test_map + "'" + os.remove( test_map ) + + print "=======================================================" + print "Status:", + if failed: + print "FAILED" + else: + print "SUCCESS" + print "=======================================================" + return not failed + + + + + +if __name__ == "__main__": + if test(): + sys.exit( 0 ) + else: + sys.exit( 1 )