Mercurial > dive4elements > river
comparison artifacts/src/test/java/org/dive4elements/river/utils/MapUtilsTest.java @ 9683:f4fdf7798bab
Fixed missing package name
author | Gernot Belger <g.belger@bjoernsen.de> |
---|---|
date | Wed, 15 Jul 2020 14:25:53 +0200 |
parents | b70b1bc0eece |
children |
comparison
equal
deleted
inserted
replaced
9682:9ec4686badae | 9683:f4fdf7798bab |
---|---|
4 * This file is Free Software under the GNU AGPL (>=v3) | 4 * This file is Free Software under the GNU AGPL (>=v3) |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | 5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
6 * documentation coming with Dive4Elements River for details. | 6 * documentation coming with Dive4Elements River for details. |
7 */ | 7 */ |
8 | 8 |
9 package org.dive4elements.river.utils; | |
10 | |
9 import static org.junit.Assert.assertEquals; | 11 import static org.junit.Assert.assertEquals; |
10 import static org.junit.Assert.assertNull; | 12 import static org.junit.Assert.assertNull; |
11 | 13 |
12 import org.junit.Test; | 14 import org.junit.Test; |
13 | |
14 import org.dive4elements.river.utils.MapUtils; | |
15 | 15 |
16 public class MapUtilsTest { | 16 public class MapUtilsTest { |
17 | 17 |
18 private static final String DRV_PG = "jdbc:postgresql:"; | 18 private static final String DRV_PG = "jdbc:postgresql:"; |
19 private static final String DRV_ORA = "jdbc:oracle:thin:"; | 19 private static final String DRV_ORA = "jdbc:oracle:thin:"; |
26 | 26 |
27 private static final String PG_CON_SUFFIX = " sslmode=disable"; | 27 private static final String PG_CON_SUFFIX = " sslmode=disable"; |
28 | 28 |
29 @Test | 29 @Test |
30 public void noJDBCURL() { | 30 public void noJDBCURL() { |
31 String con = MapUtils.getConnection(USER, PSWD, "xx"); | 31 final String con = MapUtils.getConnection(USER, PSWD, "xx"); |
32 assertNull(con); | 32 assertNull(con); |
33 } | 33 } |
34 | 34 |
35 @Test | 35 @Test |
36 public void invalidHostPG() { | 36 public void invalidHostPG() { |
37 String con = MapUtils.getConnection( | 37 final String con = MapUtils.getConnection( |
38 USER, PSWD, DRV_PG + "//invalid_host_name/"); | 38 USER, PSWD, DRV_PG + "//invalid_host_name/"); |
39 assertNull(con); | 39 assertNull(con); |
40 } | 40 } |
41 | 41 |
42 @Test | 42 @Test |
43 public void localNamedPG() { | 43 public void localNamedPG() { |
44 String con = MapUtils.getConnection( | 44 final String con = MapUtils.getConnection( |
45 USER, PSWD, DRV_PG + DB); | 45 USER, PSWD, DRV_PG + DB); |
46 assertEquals( | 46 assertEquals( |
47 "dbname=" + DB | 47 "dbname=" + DB |
48 + " user=" + USER | 48 + " user=" + USER |
49 + " password='" + PSWD + "'" + PG_CON_SUFFIX, | 49 + " password='" + PSWD + "'" + PG_CON_SUFFIX, |
50 con); | 50 con); |
51 } | 51 } |
52 | 52 |
53 @Test | 53 @Test |
54 public void localUserPG() { | 54 public void localUserPG() { |
55 String con = MapUtils.getConnection( | 55 final String con = MapUtils.getConnection( |
56 USER, PSWD, DRV_PG + "/"); | 56 USER, PSWD, DRV_PG + "/"); |
57 assertEquals( | 57 assertEquals( |
58 "dbname=" + USER | 58 "dbname=" + USER |
59 + " user=" + USER | 59 + " user=" + USER |
60 + " password='" + PSWD + "'" + PG_CON_SUFFIX, | 60 + " password='" + PSWD + "'" + PG_CON_SUFFIX, |
61 con); | 61 con); |
62 } | 62 } |
63 | 63 |
64 @Test | 64 @Test |
65 public void hostNamedPG() { | 65 public void hostNamedPG() { |
66 String con = MapUtils.getConnection( | 66 final String con = MapUtils.getConnection( |
67 USER, PSWD, DRV_PG + "//" + HOST + "/" + DB); | 67 USER, PSWD, DRV_PG + "//" + HOST + "/" + DB); |
68 assertEquals( | 68 assertEquals( |
69 "dbname=" + DB | 69 "dbname=" + DB |
70 + " user=" + USER | 70 + " user=" + USER |
71 + " host='" + HOST + "'" | 71 + " host='" + HOST + "'" |
72 + " password='" + PSWD + "'" + PG_CON_SUFFIX, | 72 + " password='" + PSWD + "'" + PG_CON_SUFFIX, |
73 con); | 73 con); |
74 } | 74 } |
75 | 75 |
76 @Test | 76 @Test |
77 public void hostUserPG() { | 77 public void hostUserPG() { |
78 String con = MapUtils.getConnection( | 78 final String con = MapUtils.getConnection( |
79 USER, PSWD, DRV_PG + "//" + HOST + "/"); | 79 USER, PSWD, DRV_PG + "//" + HOST + "/"); |
80 assertEquals( | 80 assertEquals( |
81 "dbname=" + USER | 81 "dbname=" + USER |
82 + " user=" + USER | 82 + " user=" + USER |
83 + " host='" + HOST + "'" | 83 + " host='" + HOST + "'" |
84 + " password='" + PSWD + "'" + PG_CON_SUFFIX, | 84 + " password='" + PSWD + "'" + PG_CON_SUFFIX, |
85 con); | 85 con); |
86 } | 86 } |
87 | 87 |
88 @Test | 88 @Test |
89 public void hostPortUserPG() { | 89 public void hostPortUserPG() { |
90 String con = MapUtils.getConnection( | 90 final String con = MapUtils.getConnection( |
91 USER, PSWD, DRV_PG + "//" + HOST + ":" + PORT + "/"); | 91 USER, PSWD, DRV_PG + "//" + HOST + ":" + PORT + "/"); |
92 assertEquals( | 92 assertEquals( |
93 "dbname=" + USER | 93 "dbname=" + USER |
94 + " user=" + USER | 94 + " user=" + USER |
95 + " host='" + HOST + "' port=" + PORT | 95 + " host='" + HOST + "' port=" + PORT |
96 + " password='" + PSWD + "'" + PG_CON_SUFFIX, | 96 + " password='" + PSWD + "'" + PG_CON_SUFFIX, |
97 con); | 97 con); |
98 } | 98 } |
99 | 99 |
100 @Test | 100 @Test |
101 public void hostPortNamedPG() { | 101 public void hostPortNamedPG() { |
102 String con = MapUtils.getConnection( | 102 final String con = MapUtils.getConnection( |
103 USER, PSWD, DRV_PG + "//" + HOST + ":" + PORT + "/" + DB); | 103 USER, PSWD, DRV_PG + "//" + HOST + ":" + PORT + "/" + DB); |
104 assertEquals( | 104 assertEquals( |
105 "dbname=" + DB | 105 "dbname=" + DB |
106 + " user=" + USER | 106 + " user=" + USER |
107 + " host='" + HOST + "' port=" + PORT | 107 + " host='" + HOST + "' port=" + PORT |
108 + " password='" + PSWD + "'" + PG_CON_SUFFIX, | 108 + " password='" + PSWD + "'" + PG_CON_SUFFIX, |
109 con); | 109 con); |
110 } | 110 } |
111 | 111 |
112 @Test | 112 @Test |
113 public void serviceNameORA() { | 113 public void serviceNameORA() { |
114 String con = MapUtils.getConnection( | 114 final String con = MapUtils.getConnection( |
115 USER, PSWD, DRV_ORA + "@//" + HOST + ":" + PORT + "/" + DB); | 115 USER, PSWD, DRV_ORA + "@//" + HOST + ":" + PORT + "/" + DB); |
116 assertEquals( | 116 assertEquals( |
117 USER + "/" + PSWD + "@" + HOST + ":" + PORT + "/" + DB, | 117 USER + "/" + PSWD + "@" + HOST + ":" + PORT + "/" + DB, |
118 con); | 118 con); |
119 } | 119 } |
120 | 120 |
121 @Test | 121 @Test |
122 public void connectDescriptorORA() { | 122 public void connectDescriptorORA() { |
123 String con = MapUtils.getConnection( | 123 final String con = MapUtils.getConnection( |
124 USER, PSWD, DRV_ORA | 124 USER, PSWD, DRV_ORA |
125 + "@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" | 125 + "@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" |
126 + HOST + ")(PORT=" + PORT + "))(CONNECT_DATA=(SERVICE_NAME=" | 126 + HOST + ")(PORT=" + PORT + "))(CONNECT_DATA=(SERVICE_NAME=" |
127 + DB + ")))"); | 127 + DB + ")))"); |
128 assertEquals( | 128 assertEquals( |
129 USER + "/" + PSWD | 129 USER + "/" + PSWD |
130 + "@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" | 130 + "@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" |
131 + HOST + ")(PORT=" + PORT + "))(CONNECT_DATA=(SERVICE_NAME=" | 131 + HOST + ")(PORT=" + PORT + "))(CONNECT_DATA=(SERVICE_NAME=" |
132 + DB + ")))", | 132 + DB + ")))", |
133 con); | 133 con); |
134 } | 134 } |
135 } | 135 } |