Skip to content

Commit

Permalink
Skip test if driver not loaded instead
Browse files Browse the repository at this point in the history
  • Loading branch information
cheenamalhotra committed Jun 9, 2021
1 parent 62cc9ac commit c32ac37
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -77,7 +77,7 @@
<dbcp2.version>2.7.0</dbcp2.version>
<slf4j.nop.version>1.7.30</slf4j.nop.version>
<gemini.mock.version>2.1.0.RELEASE</gemini.mock.version>
<h2.version>1.4.197</h2.version>
<h2.version>1.4.200</h2.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>${project.build.sourceEncoding}</project.reporting.outputEncoding>
Expand Down
Expand Up @@ -463,16 +463,15 @@ private void validateValuesRepetitiveCM(DBConnection con, DBTable sourceTable,
}
}

private void validateMapping(String sourceType, String destType,
String data) throws SQLException, ClassNotFoundException {
Class.forName("org.h2.Driver");
Random rand = new Random();
String sourceTable = "sourceTable" + rand.nextInt(Integer.MAX_VALUE);
String destTable = TestUtils
.escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("destTable")));
try (Connection sourceCon = DriverManager.getConnection("jdbc:h2:~/test", "sa", "");
Connection destCon = DriverManager.getConnection(connectionString);
Statement sourceStmt = sourceCon.createStatement(); Statement destStmt = destCon.createStatement();
private void validateMapping(String sourceType, String destType, String data) throws SQLException, ClassNotFoundException {
try {
Class.forName("org.h2.Driver");
String sourceTable = "sourceTable" + new Random().nextInt(Integer.MAX_VALUE);
String destTable = TestUtils.escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("destTable")));
try (Connection sourceCon = DriverManager.getConnection("jdbc:h2:~/test", "sa", "");
Connection destCon = DriverManager.getConnection(connectionString);
Statement sourceStmt = sourceCon.createStatement();
Statement destStmt = destCon.createStatement();
SQLServerBulkCopy bulkCopy = new SQLServerBulkCopy(destCon)) {
try {
bulkCopy.setDestinationTableName(destTable);
Expand All @@ -493,5 +492,10 @@ private void validateMapping(String sourceType, String destType,
TestUtils.dropTableIfExists(destTable, destStmt);
}
}
} catch (SQLException e) {
if(e.getMessage().contains("No suitable driver found for jdbc:h2:~/test")) {
System.err.println(e.getMessage());
}else throw e;
}
}
}

0 comments on commit c32ac37

Please sign in to comment.