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

http://dive4elements.wald.intevation.org