3 import static org.junit.Assert.*;
5 import org.junit.BeforeClass;
9 import java.io.FileInputStream;
10 import java.io.InputStream;
12 import java.sql.SQLException;
13 import java.util.Properties;
17 static final String
user = PROPERTIES.getProperty(
"default_super_user");
18 static final String
password = PROPERTIES.getProperty(
"default_user_password");
23 String fileName = System.getProperty(
"propertiesFileName");
25 if (fileName == null || fileName.equals(
"")) {
28 File initialFile =
new File(fileName);
29 InputStream inputStream =
new FileInputStream(initialFile);
30 base_properties.load(inputStream);
36 String url = PROPERTIES.getProperty(
"binary_connection_url") +
":"
39 assertNotEquals(null, conn);
41 boolean closed = conn.isClosed();
42 assertEquals(
true, closed);
43 }
catch (SQLException sq) {
44 String err =
"Connection test failed " + sq.toString();
53 url = PROPERTIES.getProperty(
"query_connection_url1");
55 assertNotEquals(null, conn);
57 boolean closed = conn.isClosed();
58 assertEquals(
true, closed);
60 }
catch (SQLException sq) {
61 String err =
"Connection test failed for url " + url +
":" + sq.toString();
68 url = PROPERTIES.getProperty(
"query_connection_url2");
71 }
catch (SQLException re) {
72 assertEquals(re.getMessage(),
"Invalid value supplied for max rows XXX");
79 url = PROPERTIES.getProperty(
"query_connection_url3");
81 assertNotEquals(null, conn);
83 boolean closed = conn.isClosed();
84 assertEquals(
true, closed);
86 }
catch (SQLException sq) {
87 String err =
"Connection test failed for url " + url +
":" + sq.toString();
96 url = PROPERTIES.getProperty(
"query_connection_url4");
98 assertNotEquals(null, conn);
100 boolean closed = conn.isClosed();
101 assertEquals(
true, closed);
103 }
catch (SQLException sq) {
104 String err =
"Connection test failed for url " + url +
":" + sq.toString();
113 url = PROPERTIES.getProperty(
"query_connection_url5");
114 Connection
conn = DriverManager.getConnection(url);
115 assertNotEquals(null, conn);
117 boolean closed = conn.isClosed();
118 assertEquals(
true, closed);
120 }
catch (SQLException sq) {
121 String err =
"Connection test failed for url " + url +
":" + sq.toString();
128 String url =
"jdbc:omnisci:l3:6666:l5:l6:l7:l8:l9:l10:l11:l12:50000:l14:l15";
130 }
catch (SQLException sq) {
131 assertEquals(sq.getMessage(),
132 "Invalid number of arguments provided in url [15]. Maximum allowed [13]");
138 String url = PROPERTIES.getProperty(
"http_connection_url") +
":"
139 +
PROPERTIES.getProperty(
"default_db") +
":http";
141 assertNotEquals(null, conn);
143 boolean closed = conn.isClosed();
144 assertEquals(
true, closed);
145 }
catch (SQLException sq) {
146 String err =
"Connection test failed " + sq.toString();
153 String url = PROPERTIES.getProperty(
"failed_connection_url") +
":"
155 Properties pt =
new Properties();
156 pt.setProperty(
"user",
user);
157 pt.setProperty(
"password",
password);
158 Connection
conn = DriverManager.getConnection(url, pt);
159 }
catch (SQLException sq) {
162 sq.getMessage().contains(
"No suitable driver found for jdbc:NOT_heavyai"));
165 String err =
"Connection should have thrown";
172 String url = PROPERTIES.getProperty(
"default_db_connection_url") +
":"
174 Properties pt =
new Properties();
175 pt.setProperty(
"user",
user);
176 pt.setProperty(
"password",
password);
177 pt.setProperty(
"db_name",
"SomeOtherDB");
179 Connection
conn = DriverManager.getConnection(url, pt);
180 }
catch (SQLException sq) {
181 fail(sq.getMessage());
188 String url =
"jdbc:omnisci:" + base_properties.getProperty(
"host_name");
190 assertNotEquals(null, conn);
192 boolean closed = conn.isClosed();
193 assertEquals(
true, closed);
194 }
catch (SQLException sq) {
195 String err =
"Connection test failed " + sq.toString();
203 String url = PROPERTIES.getProperty(
"binary_connection_url") +
":"
204 +
PROPERTIES.getProperty(
"default_db") +
":binary_tls";
206 Properties pt =
new Properties();
207 pt.setProperty(
"user",
user);
208 pt.setProperty(
"password",
password);
209 Connection
conn = DriverManager.getConnection(url, pt);
210 assertNotEquals(null, conn);
212 boolean closed = conn.isClosed();
213 assertEquals(
true, closed);
214 }
catch (SQLException sq) {
215 String err =
"Connection test failed " + sq.toString();
223 Properties pt =
new Properties();
224 String url = PROPERTIES.getProperty(
"binary_connection_url") +
":"
225 +
PROPERTIES.getProperty(
"default_db") +
":binary_tls";
227 ClassLoader cl = getClass().getClassLoader();
228 String trust_store = PROPERTIES.getProperty(
"server_trust_store");
229 trust_store = cl.getResource(trust_store).getPath();
230 pt.setProperty(
"server_trust_store", trust_store);
232 String sslcert_cl1 = PROPERTIES.getProperty(
"sslcert_cl1_pkcs12");
233 sslcert_cl1 = cl.getResource(sslcert_cl1).getPath();
234 pt.setProperty(
"sslcert", sslcert_cl1);
236 pt.setProperty(
"sslkey_password", PROPERTIES.getProperty(
"sslkey_password_cl1"));
238 pt.setProperty(
"user",
"pki");
239 pt.setProperty(
"password",
"");
240 pt.setProperty(
"server_trust_store_pwd",
241 PROPERTIES.getProperty(
"server_trust_store_password"));
242 pt.setProperty(
"pkiauth", PROPERTIES.getProperty(
"pkiauth"));
244 Connection
conn = DriverManager.getConnection(url, pt);
245 assertNotEquals(null, conn);
247 Statement statement = conn.createStatement();
248 statement.executeUpdate(
"drop table if exists test_jdbc_tm_tble");
251 boolean closed = conn.isClosed();
252 assertEquals(
true, closed);
253 }
catch (SQLException sq) {
254 String err =
"Connection test failed " + sq.toString();
262 Properties pt =
new Properties();
263 String url = PROPERTIES.getProperty(
"binary_connection_url") +
":"
264 +
PROPERTIES.getProperty(
"default_db") +
":binary_tls";
266 ClassLoader cl = getClass().getClassLoader();
267 String trust_store = PROPERTIES.getProperty(
"server_trust_store");
268 trust_store = cl.getResource(trust_store).getPath();
269 pt.setProperty(
"server_trust_store", trust_store);
272 String sslcert_cl2 = PROPERTIES.getProperty(
"sslcert_cl2");
273 sslcert_cl2 = cl.getResource(sslcert_cl2).getPath();
274 pt.setProperty(
"sslcert", sslcert_cl2);
276 String sslkey_cl2 = PROPERTIES.getProperty(
"sslkey_cl2");
277 sslkey_cl2 = cl.getResource(sslkey_cl2).getPath();
278 pt.setProperty(
"sslkey", sslkey_cl2);
280 pt.setProperty(
"user",
"pki");
281 pt.setProperty(
"password",
"");
282 pt.setProperty(
"server_trust_store_pwd",
283 PROPERTIES.getProperty(
"server_trust_store_password"));
284 pt.setProperty(
"pkiauth", PROPERTIES.getProperty(
"pkiauth"));
286 Connection
conn = DriverManager.getConnection(url, pt);
287 assertNotEquals(null, conn);
289 boolean closed = conn.isClosed();
290 fail(
"Credential should not have been accepted");
291 }
catch (SQLException sq) {
292 String err =
"Connection test failed " + sq.toString();
293 assertTrue(err.contains(
"Invalid credentials"));
300 Properties pt =
new Properties();
301 pt.setProperty(
"user",
user);
302 pt.setProperty(
"password",
password);
303 pt.setProperty(
"protocol",
"https_insecure");
304 String url = PROPERTIES.getProperty(
"https_connection_url") +
":"
306 Connection
conn = DriverManager.getConnection(url, pt);
307 assertNotEquals(null, conn);
309 boolean closed = conn.isClosed();
310 assertEquals(
true, closed);
311 }
catch (SQLException sq) {
312 String err =
"Connection test failed " + sq.toString();
320 ClassLoader cl = getClass().getClassLoader();
321 String trust_store = PROPERTIES.getProperty(
"server_trust_store");
322 trust_store = cl.getResource(trust_store).getPath();
324 Properties pt =
new Properties();
325 pt.setProperty(
"server_trust_store", trust_store);
326 pt.setProperty(
"server_trust_store_pwd",
327 PROPERTIES.getProperty(
"server_trust_store_password"));
329 pt.setProperty(
"user",
user);
330 pt.setProperty(
"password",
password);
331 pt.setProperty(
"protocol",
"https_insecure");
333 String url = PROPERTIES.getProperty(
"https_connection_url") +
":"
335 Connection
conn = DriverManager.getConnection(url, pt);
336 assertNotEquals(null, conn);
338 boolean closed = conn.isClosed();
339 assertEquals(
true, closed);
340 }
catch (SQLException sq) {
341 String err =
"Connection test failed " + sq.toString();
349 Properties pt =
new Properties();
350 pt.setProperty(
"user",
user);
351 pt.setProperty(
"password",
password);
352 pt.setProperty(
"protocol",
"https");
353 String url = PROPERTIES.getProperty(
"https_connection_url") +
":"
355 Connection
conn = DriverManager.getConnection(url, pt);
356 assertNotEquals(null, conn);
358 boolean closed = conn.isClosed();
359 assertEquals(
true, closed);
360 }
catch (SQLException sq) {
361 String err =
"Connection test failed " + sq.toString();
369 ClassLoader cl = getClass().getClassLoader();
370 String trust_store = PROPERTIES.getProperty(
"ca_primary_trust_store");
371 trust_store = cl.getResource(trust_store).getPath();
372 Properties pt =
new Properties();
373 pt.setProperty(
"server_trust_store", trust_store);
374 pt.setProperty(
"server_trust_store_pwd",
375 PROPERTIES.getProperty(
"server_trust_store_password"));
377 pt.setProperty(
"user",
user);
378 pt.setProperty(
"password",
password);
379 pt.setProperty(
"protocol",
"https");
381 String url = PROPERTIES.getProperty(
"https_connection_url") +
":"
384 Connection
conn = DriverManager.getConnection(url, pt);
386 assertNotEquals(null, conn);
387 boolean closed = conn.isClosed();
388 assertEquals(
true, closed);
390 assertNotEquals(null, conn);
391 }
catch (SQLException sq) {
392 String err =
"Connection test failed " + sq.toString();
399 Properties pt =
new Properties();
400 String url = PROPERTIES.getProperty(
"https_connection_url") +
":"
401 +
PROPERTIES.getProperty(
"default_db") +
":https_insecure";
403 ClassLoader cl = getClass().getClassLoader();
404 String trust_store = PROPERTIES.getProperty(
"server_trust_store");
405 trust_store = cl.getResource(trust_store).getPath();
406 pt.setProperty(
"server_trust_store", trust_store);
408 String sslcert_cl1 = PROPERTIES.getProperty(
"sslcert_cl1_pkcs12");
409 sslcert_cl1 = cl.getResource(sslcert_cl1).getPath();
410 pt.setProperty(
"sslcert", sslcert_cl1);
412 pt.setProperty(
"sslkey_password", PROPERTIES.getProperty(
"sslkey_password_cl1"));
414 pt.setProperty(
"user",
"pki");
415 pt.setProperty(
"password",
"");
416 pt.setProperty(
"server_trust_store_pwd",
417 PROPERTIES.getProperty(
"server_trust_store_password"));
418 pt.setProperty(
"pkiauth", PROPERTIES.getProperty(
"pkiauth"));
420 Connection
conn = DriverManager.getConnection(url, pt);
421 Statement statement = conn.createStatement();
422 statement.executeUpdate(
"drop table if exists test_jdbc_tm_tble");
423 assertNotEquals(null, conn);
425 boolean closed = conn.isClosed();
426 assertEquals(
true, closed);
427 }
catch (SQLException sq) {
428 String err =
"Connection test failed " + sq.toString();
void tst4_connect_url_override()
void tst1_binary_unencrypted_query_url4()
void tst2_http_unencrypted()
void tst1_binary_unencrypted_query_url1()
void tst3b_https_encrypted_without_server_validation_supplied_truststore()
void tst3d_https_encrypted_with_server_validation_supplied_truststore()
static Properties base_properties
void tst1_binary_unencrypted()
void tst1_binary_unencrypted_query_url2()
void tst5_properties_connection()
void tst1e_binary_encrypted_supplied_truststore_pkiauth_invalid()
void tst1_binary_unencrypted_query_url5()
static Properties PROPERTIES
void tst3c_https_encrypted_server_validation_default_truststore()
void tst3a_https_encrypted_without_server_validation_default_truststore()
void tst1b_binary_encrypted_default()
void tst3e_https_insecure_encrypted_supplied_truststore_pkiauth_valid()
void tst1_binary_unencrypted_query_url3()
static final String password
void tst1c_binary_encrypted_supplied_truststore_pkiauth_valid()
static void setUpBeforeClass()