comparison 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
comparison
equal deleted inserted replaced
9670:07d854c325d8 9671:9cfc495a9f40
1 /* Copyright (C) 2020 by Bundesanstalt für Gewässerkunde
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU AGPL (>=v3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
6 * documentation coming with Dive4Elements River for details.
7 */
8
9 import static org.junit.Assert.assertEquals;
10
11 import org.junit.Test;
12
13 import org.dive4elements.river.utils.MapUtils;
14
15 public class MapUtilsTest {
16
17 private static final String DRV_PG = "jdbc:postgresql:";
18 private static final String DRV_ORA = "jdbc:oracle:thin:";
19
20 private static final String USER = "d4euser";
21 private static final String PSWD = "d4epswd";
22 private static final String DB = "d4edb";
23 private static final String HOST = "d4ehost";
24 private static final String PORT = "2345";
25
26 private static final String PG_CON_SUFFIX = " sslmode=disable";
27
28 @Test
29 public void hostPortNamedPG() {
30 MapUtils mu = new MapUtils();
31 String con = MapUtils.getConnection(
32 USER, PSWD, DRV_PG + "//" + HOST + ":" + PORT + "/" + DB);
33 assertEquals(
34 "dbname=" + DB
35 + " host='" + HOST + "' user=" + USER + " port=" + PORT
36 + " password='" + PSWD + "'" + PG_CON_SUFFIX,
37 con);
38 }
39
40 @Test
41 public void serviceNameORA() {
42 MapUtils mu = new MapUtils();
43 String con = MapUtils.getConnection(
44 USER, PSWD, DRV_ORA + "@//" + HOST + ":" + PORT + "/" + DB);
45 assertEquals(
46 USER + "/" + PSWD + "@" + HOST + ":" + PORT + "/" + DB,
47 con);
48 }
49 }

http://dive4elements.wald.intevation.org