|
46 | 46 |
|
47 | 47 | import java.net.InetSocketAddress;
|
48 | 48 | import java.net.URL;
|
| 49 | +import java.sql.DatabaseMetaData; |
49 | 50 | import java.sql.ResultSet;
|
50 | 51 | import java.sql.SQLException;
|
51 | 52 | import java.sql.SQLNonTransientConnectionException;
|
52 |
| -import java.sql.Statement; |
53 | 53 | import java.time.Duration;
|
54 | 54 | import java.util.Collections;
|
55 | 55 | import java.util.Objects;
|
|
65 | 65 | import static org.hamcrest.Matchers.instanceOf;
|
66 | 66 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
67 | 67 | import static org.junit.jupiter.api.Assertions.assertFalse;
|
| 68 | +import static org.junit.jupiter.api.Assertions.assertNotEquals; |
68 | 69 | import static org.junit.jupiter.api.Assertions.assertNotNull;
|
69 | 70 | import static org.junit.jupiter.api.Assertions.assertNull;
|
70 | 71 | import static org.junit.jupiter.api.Assertions.assertThrows;
|
@@ -367,4 +368,32 @@ void givenSessionToConnect_andLiquibaseCompliance() throws SQLException {
|
367 | 368 | assertNull(jdbcConnection.getCatalog());
|
368 | 369 | }
|
369 | 370 |
|
| 371 | + @Test |
| 372 | + void givenConnection_whenGetMetaData_getExpectedResultSet() throws Exception { |
| 373 | + initConnection(KEYSPACE); |
| 374 | + assertNotNull(sqlConnection); |
| 375 | + assertNotNull(sqlConnection.getMetaData()); |
| 376 | + |
| 377 | + final DatabaseMetaData dbMetadata = sqlConnection.getMetaData(); |
| 378 | + log.debug("===================================================="); |
| 379 | + log.debug("Connection Metadata"); |
| 380 | + log.debug("===================================================="); |
| 381 | + log.debug("Driver name: {}", dbMetadata.getDriverName()); |
| 382 | + log.debug("Driver version: {}", dbMetadata.getDriverVersion()); |
| 383 | + log.debug("DB name: {}", dbMetadata.getDatabaseProductName()); |
| 384 | + log.debug("DB version: {}", dbMetadata.getDatabaseProductVersion()); |
| 385 | + log.debug("JDBC version: {}.{}", dbMetadata.getJDBCMajorVersion(), dbMetadata.getJDBCMinorVersion()); |
| 386 | + log.debug("===================================================="); |
| 387 | + |
| 388 | + assertEquals("Cassandra JDBC Driver", dbMetadata.getDriverName()); |
| 389 | + assertNotEquals(0, dbMetadata.getDriverMajorVersion()); |
| 390 | + assertNotEquals(0, dbMetadata.getDriverMinorVersion()); |
| 391 | + assertEquals(4, dbMetadata.getJDBCMajorVersion()); |
| 392 | + assertEquals(0, dbMetadata.getJDBCMinorVersion()); |
| 393 | + assertEquals("Cassandra", dbMetadata.getDatabaseProductName()); |
| 394 | + assertThat(dbMetadata.getDriverVersion(), Matchers.matchesPattern("\\d.\\d+.\\d+")); |
| 395 | + assertThat(dbMetadata.getDatabaseProductVersion(), Matchers.matchesPattern("\\d.\\d+.\\d+")); |
| 396 | + sqlConnection.close(); |
| 397 | + } |
| 398 | + |
370 | 399 | }
|
0 commit comments