File: datasource_registration_test.cpp

package info (click to toggle)
mapnik 3.0.12%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 17,084 kB
  • ctags: 18,454
  • sloc: cpp: 142,516; python: 1,416; sh: 769; makefile: 170; xml: 140; lisp: 13
file content (52 lines) | stat: -rw-r--r-- 1,687 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#define CATCH_CONFIG_MAIN
#include "catch.hpp"

#include <mapnik/datasource_cache.hpp>
#include <mapnik/debug.hpp>
#include <mapnik/util/fs.hpp>

#include <iostream>
#include <vector>
#include <algorithm>

TEST_CASE("datasource_cache") {

SECTION("registration") {
    try
    {
        mapnik::logger logger;
        mapnik::logger::severity_type original_severity = logger.get_severity();
        bool success = false;
        auto &cache = mapnik::datasource_cache::instance();

        // registering a directory without any plugins should return false
        success = cache.register_datasources("test/data/vrt");
        CHECK(success == false);

        // 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);
        }
    }
    catch (std::exception const & ex)
    {
        std::clog << ex.what() << "\n";
        REQUIRE(false);
    }

}
}