2015-08-23 21:25:35 +02:00
|
|
|
#define CATCH_CONFIG_MAIN
|
|
|
|
#include "catch.hpp"
|
|
|
|
|
2022-02-02 17:20:29 +01:00
|
|
|
#include <mapnik/mapnik.hpp>
|
2015-08-23 21:25:35 +02:00
|
|
|
#include <mapnik/datasource_cache.hpp>
|
|
|
|
#include <mapnik/debug.hpp>
|
2015-10-07 23:41:07 +02:00
|
|
|
#include <mapnik/util/fs.hpp>
|
2015-08-23 21:25:35 +02:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <vector>
|
|
|
|
#include <algorithm>
|
|
|
|
|
2022-01-26 23:25:53 +01:00
|
|
|
TEST_CASE("datasource_cache")
|
|
|
|
{
|
2022-02-02 17:20:29 +01:00
|
|
|
mapnik::setup();
|
2022-01-26 23:25:53 +01:00
|
|
|
SECTION("registration")
|
2015-08-23 21:25:35 +02:00
|
|
|
{
|
2022-01-26 23:25:53 +01:00
|
|
|
try
|
2015-10-07 23:41:07 +02:00
|
|
|
{
|
2022-01-26 23:25:53 +01:00
|
|
|
mapnik::logger logger;
|
|
|
|
mapnik::logger::severity_type original_severity = logger.get_severity();
|
|
|
|
bool success = false;
|
|
|
|
auto& cache = mapnik::datasource_cache::instance();
|
2015-10-07 23:41:07 +02:00
|
|
|
|
2022-01-26 23:25:53 +01:00
|
|
|
// registering a directory without any plugins should return false
|
|
|
|
success = cache.register_datasources("test/data/vrt");
|
2015-10-07 23:41:07 +02:00
|
|
|
CHECK(success == false);
|
|
|
|
|
2022-01-26 23:25:53 +01:00
|
|
|
// use existence of shape.input as proxy for whether any datasource plugins are available
|
|
|
|
std::string shape_plugin("./plugins/input/shape.input");
|
|
|
|
if (mapnik::util::exists(shape_plugin))
|
|
|
|
{
|
|
|
|
// registering a directory for the first time should return true
|
|
|
|
success = cache.register_datasources("plugins/input");
|
|
|
|
REQUIRE(success == true);
|
|
|
|
|
|
|
|
// registering the same directory again should now return false
|
|
|
|
success = cache.register_datasources("plugins/input");
|
|
|
|
CHECK(success == false);
|
|
|
|
|
|
|
|
// registering the same directory again, but recursively should
|
|
|
|
// still return false - even though there are subdirectories, they
|
|
|
|
// do not contain any more plugins.
|
|
|
|
success = cache.register_datasources("plugins/input", true);
|
|
|
|
CHECK(success == false);
|
|
|
|
}
|
2022-11-10 16:57:38 +01:00
|
|
|
}
|
|
|
|
catch (std::exception const& ex)
|
2022-01-26 23:25:53 +01:00
|
|
|
{
|
|
|
|
std::clog << ex.what() << "\n";
|
|
|
|
REQUIRE(false);
|
2015-10-07 23:41:07 +02:00
|
|
|
}
|
2015-08-23 21:25:35 +02:00
|
|
|
}
|
|
|
|
}
|