view artifacts/src/test/java/org/dive4elements/river/utils/MapUtilsTest.java @ 9671:9cfc495a9f40 3.2.x

Add minimal test coverage for MapServer connection generation
author Tom Gottfried <tom@intevation.de>
date Fri, 22 May 2020 19:45:08 +0200
parents
children b70b1bc0eece
line wrap: on
line source
/* Copyright (C) 2020 by Bundesanstalt für Gewässerkunde
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU AGPL (>=v3)
 * and comes with ABSOLUTELY NO WARRANTY! Check out the
 * documentation coming with Dive4Elements River for details.
 */

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import org.dive4elements.river.utils.MapUtils;

public class MapUtilsTest {

    private static final String DRV_PG  = "jdbc:postgresql:";
    private static final String DRV_ORA = "jdbc:oracle:thin:";

    private static final String USER = "d4euser";
    private static final String PSWD = "d4epswd";
    private static final String DB   = "d4edb";
    private static final String HOST = "d4ehost";
    private static final String PORT = "2345";

    private static final String PG_CON_SUFFIX = " sslmode=disable";

    @Test
    public void hostPortNamedPG() {
        MapUtils mu = new MapUtils();
        String con = MapUtils.getConnection(
            USER, PSWD, DRV_PG + "//" + HOST + ":" + PORT + "/" + DB);
        assertEquals(
            "dbname=" + DB
            + " host='" + HOST + "' user=" + USER + " port=" + PORT
            + " password='" + PSWD + "'" + PG_CON_SUFFIX,
            con);
    }

    @Test
    public void serviceNameORA() {
        MapUtils mu = new MapUtils();
        String con = MapUtils.getConnection(
            USER, PSWD, DRV_ORA + "@//" + HOST + ":" + PORT + "/" + DB);
        assertEquals(
            USER + "/" + PSWD + "@" + HOST + ":" + PORT + "/" + DB,
            con);
    }
}

http://dive4elements.wald.intevation.org