OmniSciDB  4201147b46
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ai.heavy.jdbc.HeavyAIConnectionTest Class Reference
+ Collaboration diagram for ai.heavy.jdbc.HeavyAIConnectionTest:

Public Member Functions

void tst1_binary_unencrypted ()
 
void tst1_binary_unencrypted_query_url1 ()
 
void tst1_binary_unencrypted_query_url2 ()
 
void tst1_binary_unencrypted_query_url3 ()
 
void tst1_binary_unencrypted_query_url4 ()
 
void tst1_binary_unencrypted_query_url5 ()
 
void tst1_url_too_long ()
 
void tst2_http_unencrypted ()
 
void tst3_connect_fail ()
 
void tst4_connect_url_override ()
 
void tst5_properties_connection ()
 
void tst1b_binary_encrypted_default ()
 
void tst1c_binary_encrypted_supplied_truststore_pkiauth_valid ()
 
void tst1e_binary_encrypted_supplied_truststore_pkiauth_invalid ()
 
void tst3a_https_encrypted_without_server_validation_default_truststore ()
 
void tst3b_https_encrypted_without_server_validation_supplied_truststore ()
 
void tst3c_https_encrypted_server_validation_default_truststore ()
 
void tst3d_https_encrypted_with_server_validation_supplied_truststore ()
 
void tst3e_https_insecure_encrypted_supplied_truststore_pkiauth_valid ()
 

Static Public Member Functions

static void setUpBeforeClass () throws Exception
 

Static Package Attributes

static Properties PROPERTIES = new Property_loader("connection_test.properties")
 
static final String user = PROPERTIES.getProperty("default_super_user")
 
static final String password = PROPERTIES.getProperty("default_user_password")
 
static Properties base_properties
 

Detailed Description

Definition at line 15 of file HeavyAIConnectionTest.java.

Member Function Documentation

static void ai.heavy.jdbc.HeavyAIConnectionTest.setUpBeforeClass ( ) throws Exception
inlinestatic

Definition at line 22 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.base_properties.

22  {
23  String fileName = System.getProperty("propertiesFileName");
24  base_properties = new Properties();
25  if (fileName == null || fileName.equals("")) {
26  return;
27  }
28  File initialFile = new File(fileName);
29  InputStream inputStream = new FileInputStream(initialFile);
30  base_properties.load(inputStream);
31  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst1_binary_unencrypted ( )
inline

Definition at line 34 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.password, ai.heavy.jdbc.HeavyAIConnectionTest.PROPERTIES, and ai.heavy.jdbc.HeavyAIConnectionTest.user.

34  {
35  try {
36  String url = PROPERTIES.getProperty("binary_connection_url") + ":"
37  + PROPERTIES.getProperty("default_db");
38  Connection conn = DriverManager.getConnection(url, user, password);
39  assertNotEquals(null, conn);
40  conn.close();
41  boolean closed = conn.isClosed();
42  assertEquals(true, closed);
43  } catch (SQLException sq) {
44  String err = "Connection test failed " + sq.toString();
45  fail(err);
46  }
47  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst1_binary_unencrypted_query_url1 ( )
inline

Definition at line 50 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.password, and ai.heavy.jdbc.HeavyAIConnectionTest.user.

50  {
51  String url = null;
52  try {
53  url = PROPERTIES.getProperty("query_connection_url1");
54  Connection conn = DriverManager.getConnection(url, user, password);
55  assertNotEquals(null, conn);
56  conn.close();
57  boolean closed = conn.isClosed();
58  assertEquals(true, closed);
59 
60  } catch (SQLException sq) {
61  String err = "Connection test failed for url " + url + ":" + sq.toString();
62  fail(err);
63  }
64  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst1_binary_unencrypted_query_url2 ( )
inline

Definition at line 66 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.password, and ai.heavy.jdbc.HeavyAIConnectionTest.user.

66  {
67  String url = null;
68  url = PROPERTIES.getProperty("query_connection_url2");
69  try {
70  Connection conn = DriverManager.getConnection(url, user, password);
71  } catch (SQLException re) {
72  assertEquals(re.getMessage(), "Invalid value supplied for max rows XXX");
73  }
74  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst1_binary_unencrypted_query_url3 ( )
inline

Definition at line 76 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.password, and ai.heavy.jdbc.HeavyAIConnectionTest.user.

76  {
77  String url = null;
78  try {
79  url = PROPERTIES.getProperty("query_connection_url3");
80  Connection conn = DriverManager.getConnection(url, user, password);
81  assertNotEquals(null, conn);
82  conn.close();
83  boolean closed = conn.isClosed();
84  assertEquals(true, closed);
85 
86  } catch (SQLException sq) {
87  String err = "Connection test failed for url " + url + ":" + sq.toString();
88  fail(err);
89  }
90  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst1_binary_unencrypted_query_url4 ( )
inline

Definition at line 93 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.password, and ai.heavy.jdbc.HeavyAIConnectionTest.user.

93  {
94  String url = null;
95  try {
96  url = PROPERTIES.getProperty("query_connection_url4");
97  Connection conn = DriverManager.getConnection(url, user, password);
98  assertNotEquals(null, conn);
99  conn.close();
100  boolean closed = conn.isClosed();
101  assertEquals(true, closed);
102 
103  } catch (SQLException sq) {
104  String err = "Connection test failed for url " + url + ":" + sq.toString();
105  fail(err);
106  }
107  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst1_binary_unencrypted_query_url5 ( )
inline

Definition at line 110 of file HeavyAIConnectionTest.java.

110  {
111  String url = null;
112  try {
113  url = PROPERTIES.getProperty("query_connection_url5");
114  Connection conn = DriverManager.getConnection(url);
115  assertNotEquals(null, conn);
116  conn.close();
117  boolean closed = conn.isClosed();
118  assertEquals(true, closed);
119 
120  } catch (SQLException sq) {
121  String err = "Connection test failed for url " + url + ":" + sq.toString();
122  fail(err);
123  }
124  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst1_url_too_long ( )
inline

Definition at line 126 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.password, and ai.heavy.jdbc.HeavyAIConnectionTest.user.

126  {
127  try {
128  String url = "jdbc:omnisci:l3:6666:l5:l6:l7:l8:l9:l10:l11:l12:50000:l14:l15";
129  Connection conn = DriverManager.getConnection(url, user, password);
130  } catch (SQLException sq) {
131  assertEquals(sq.getMessage(),
132  "Invalid number of arguments provided in url [15]. Maximum allowed [13]");
133  }
134  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst1b_binary_encrypted_default ( )
inline

Definition at line 201 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.password, ai.heavy.jdbc.HeavyAIConnectionTest.PROPERTIES, and ai.heavy.jdbc.HeavyAIConnectionTest.user.

201  {
202  try {
203  String url = PROPERTIES.getProperty("binary_connection_url") + ":"
204  + PROPERTIES.getProperty("default_db") + ":binary_tls";
205 
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);
211  conn.close();
212  boolean closed = conn.isClosed();
213  assertEquals(true, closed);
214  } catch (SQLException sq) {
215  String err = "Connection test failed " + sq.toString();
216  fail(err);
217  }
218  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst1c_binary_encrypted_supplied_truststore_pkiauth_valid ( )
inline

Definition at line 221 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.PROPERTIES.

221  {
222  try {
223  Properties pt = new Properties();
224  String url = PROPERTIES.getProperty("binary_connection_url") + ":"
225  + PROPERTIES.getProperty("default_db") + ":binary_tls";
226 
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);
231 
232  String sslcert_cl1 = PROPERTIES.getProperty("sslcert_cl1_pkcs12");
233  sslcert_cl1 = cl.getResource(sslcert_cl1).getPath();
234  pt.setProperty("sslcert", sslcert_cl1);
235 
236  pt.setProperty("sslkey_password", PROPERTIES.getProperty("sslkey_password_cl1"));
237 
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"));
243 
244  Connection conn = DriverManager.getConnection(url, pt);
245  assertNotEquals(null, conn);
246 
247  Statement statement = conn.createStatement();
248  statement.executeUpdate("drop table if exists test_jdbc_tm_tble");
249 
250  conn.close();
251  boolean closed = conn.isClosed();
252  assertEquals(true, closed);
253  } catch (SQLException sq) {
254  String err = "Connection test failed " + sq.toString();
255  fail(err);
256  }
257  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst1e_binary_encrypted_supplied_truststore_pkiauth_invalid ( )
inline

Definition at line 260 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.PROPERTIES.

260  {
261  try {
262  Properties pt = new Properties();
263  String url = PROPERTIES.getProperty("binary_connection_url") + ":"
264  + PROPERTIES.getProperty("default_db") + ":binary_tls";
265 
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);
270 
271  // Connect client 1 whose cert is signed by primary and should work
272  String sslcert_cl2 = PROPERTIES.getProperty("sslcert_cl2");
273  sslcert_cl2 = cl.getResource(sslcert_cl2).getPath();
274  pt.setProperty("sslcert", sslcert_cl2);
275 
276  String sslkey_cl2 = PROPERTIES.getProperty("sslkey_cl2");
277  sslkey_cl2 = cl.getResource(sslkey_cl2).getPath();
278  pt.setProperty("sslkey", sslkey_cl2);
279 
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"));
285 
286  Connection conn = DriverManager.getConnection(url, pt);
287  assertNotEquals(null, conn);
288  conn.close();
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"));
294  }
295  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst2_http_unencrypted ( )
inline

Definition at line 136 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.password, ai.heavy.jdbc.HeavyAIConnectionTest.PROPERTIES, and ai.heavy.jdbc.HeavyAIConnectionTest.user.

136  {
137  try {
138  String url = PROPERTIES.getProperty("http_connection_url") + ":"
139  + PROPERTIES.getProperty("default_db") + ":http";
140  Connection conn = DriverManager.getConnection(url, user, password);
141  assertNotEquals(null, conn);
142  conn.close();
143  boolean closed = conn.isClosed();
144  assertEquals(true, closed);
145  } catch (SQLException sq) {
146  String err = "Connection test failed " + sq.toString();
147  fail(err);
148  }
149  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst3_connect_fail ( )
inline

Definition at line 151 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.password, ai.heavy.jdbc.HeavyAIConnectionTest.PROPERTIES, and ai.heavy.jdbc.HeavyAIConnectionTest.user.

151  {
152  try {
153  String url = PROPERTIES.getProperty("failed_connection_url") + ":"
154  + PROPERTIES.getProperty("default_db");
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) {
160  // for different servers the exact string may be different
161  assertTrue(
162  sq.getMessage().contains("No suitable driver found for jdbc:NOT_heavyai"));
163  return;
164  }
165  String err = "Connection should have thrown";
166  fail(err);
167  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst3a_https_encrypted_without_server_validation_default_truststore ( )
inline

Definition at line 298 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.password, ai.heavy.jdbc.HeavyAIConnectionTest.PROPERTIES, and ai.heavy.jdbc.HeavyAIConnectionTest.user.

298  {
299  try {
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") + ":"
305  + PROPERTIES.getProperty("default_db");
306  Connection conn = DriverManager.getConnection(url, pt);
307  assertNotEquals(null, conn);
308  conn.close();
309  boolean closed = conn.isClosed();
310  assertEquals(true, closed);
311  } catch (SQLException sq) {
312  String err = "Connection test failed " + sq.toString();
313  fail(err);
314  }
315  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst3b_https_encrypted_without_server_validation_supplied_truststore ( )
inline

Definition at line 318 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.password, ai.heavy.jdbc.HeavyAIConnectionTest.PROPERTIES, and ai.heavy.jdbc.HeavyAIConnectionTest.user.

318  {
319  try {
320  ClassLoader cl = getClass().getClassLoader();
321  String trust_store = PROPERTIES.getProperty("server_trust_store");
322  trust_store = cl.getResource(trust_store).getPath();
323 
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"));
328 
329  pt.setProperty("user", user);
330  pt.setProperty("password", password);
331  pt.setProperty("protocol", "https_insecure");
332 
333  String url = PROPERTIES.getProperty("https_connection_url") + ":"
334  + PROPERTIES.getProperty("default_db");
335  Connection conn = DriverManager.getConnection(url, pt);
336  assertNotEquals(null, conn);
337  conn.close();
338  boolean closed = conn.isClosed();
339  assertEquals(true, closed);
340  } catch (SQLException sq) {
341  String err = "Connection test failed " + sq.toString();
342  fail(err);
343  }
344  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst3c_https_encrypted_server_validation_default_truststore ( )
inline

Definition at line 347 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.password, ai.heavy.jdbc.HeavyAIConnectionTest.PROPERTIES, and ai.heavy.jdbc.HeavyAIConnectionTest.user.

347  {
348  try {
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") + ":"
354  + PROPERTIES.getProperty("default_db");
355  Connection conn = DriverManager.getConnection(url, pt);
356  assertNotEquals(null, conn);
357  conn.close();
358  boolean closed = conn.isClosed();
359  assertEquals(true, closed);
360  } catch (SQLException sq) {
361  String err = "Connection test failed " + sq.toString();
362  fail(err);
363  }
364  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst3d_https_encrypted_with_server_validation_supplied_truststore ( )
inline

Definition at line 367 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.password, ai.heavy.jdbc.HeavyAIConnectionTest.PROPERTIES, and ai.heavy.jdbc.HeavyAIConnectionTest.user.

367  {
368  try {
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"));
376 
377  pt.setProperty("user", user);
378  pt.setProperty("password", password);
379  pt.setProperty("protocol", "https");
380 
381  String url = PROPERTIES.getProperty("https_connection_url") + ":"
382  + PROPERTIES.getProperty("default_db");
383 
384  Connection conn = DriverManager.getConnection(url, pt);
385  conn.close();
386  assertNotEquals(null, conn);
387  boolean closed = conn.isClosed();
388  assertEquals(true, closed);
389 
390  assertNotEquals(null, conn);
391  } catch (SQLException sq) {
392  String err = "Connection test failed " + sq.toString();
393  fail(err);
394  }
395  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst3e_https_insecure_encrypted_supplied_truststore_pkiauth_valid ( )
inline

Definition at line 397 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.PROPERTIES.

397  {
398  try {
399  Properties pt = new Properties();
400  String url = PROPERTIES.getProperty("https_connection_url") + ":"
401  + PROPERTIES.getProperty("default_db") + ":https_insecure";
402 
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);
407 
408  String sslcert_cl1 = PROPERTIES.getProperty("sslcert_cl1_pkcs12");
409  sslcert_cl1 = cl.getResource(sslcert_cl1).getPath();
410  pt.setProperty("sslcert", sslcert_cl1);
411 
412  pt.setProperty("sslkey_password", PROPERTIES.getProperty("sslkey_password_cl1"));
413 
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"));
419 
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);
424  conn.close();
425  boolean closed = conn.isClosed();
426  assertEquals(true, closed);
427  } catch (SQLException sq) {
428  String err = "Connection test failed " + sq.toString();
429  fail(err);
430  }
431  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst4_connect_url_override ( )
inline

Definition at line 170 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.password, ai.heavy.jdbc.HeavyAIConnectionTest.PROPERTIES, and ai.heavy.jdbc.HeavyAIConnectionTest.user.

170  {
171  try {
172  String url = PROPERTIES.getProperty("default_db_connection_url") + ":"
173  + PROPERTIES.getProperty("default_db");
174  Properties pt = new Properties();
175  pt.setProperty("user", user);
176  pt.setProperty("password", password);
177  pt.setProperty("db_name", "SomeOtherDB");
178  // Shouldn't fail (url over ride properties.
179  Connection conn = DriverManager.getConnection(url, pt);
180  } catch (SQLException sq) {
181  fail(sq.getMessage());
182  }
183  }
void ai.heavy.jdbc.HeavyAIConnectionTest.tst5_properties_connection ( )
inline

Definition at line 186 of file HeavyAIConnectionTest.java.

References ai.heavy.jdbc.HeavyAIConnectionTest.base_properties.

186  {
187  try {
188  String url = "jdbc:omnisci:" + base_properties.getProperty("host_name");
189  Connection conn = DriverManager.getConnection(url, base_properties);
190  assertNotEquals(null, conn);
191  conn.close();
192  boolean closed = conn.isClosed();
193  assertEquals(true, closed);
194  } catch (SQLException sq) {
195  String err = "Connection test failed " + sq.toString();
196  fail(err);
197  }
198  }

Member Data Documentation

Properties ai.heavy.jdbc.HeavyAIConnectionTest.base_properties
staticpackage

The documentation for this class was generated from the following file: