Skip to content

Commit

Permalink
POM: Delete the pre-existing DB files before running E2E smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraZizka committed Jun 26, 2023
1 parent 43b9db5 commit a21a2a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
14 changes: 10 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@
<groupId>org.codehaus.mojo</groupId><artifactId>exec-maven-plugin</artifactId><version>3.1.0</version>
<executions>
<execution>
<id>testCrunch-simple</id>
<phase>integration-test</phase>
<goals><goal>exec</goal></goals>
<id>testCrunch-simple</id><phase>integration-test</phase><goals><goal>exec</goal></goals>
<configuration>
<skip>${skipE2E}</skip>
<executable>java</executable>
Expand All @@ -177,7 +175,15 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId><artifactId>maven-clean-plugin</artifactId><version>3.2.0</version>
<!-- Delete the pre-existing DB -->
<executions>
<execution><id>clean-hsqldb-data</id><phase>pre-integration-test</phase><goals><goal>clean</goal></goals>
<configuration><directory>hsqldb/</directory></configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId><artifactId>maven-enforcer-plugin</artifactId><version>3.1.0</version>
Expand Down
15 changes: 6 additions & 9 deletions src/main/kotlin/cz/dynawest/csvcruncher/HsqlDbHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@ package cz.dynawest.csvcruncher

import cz.dynawest.csvcruncher.util.DbUtils.getResultSetColumnNamesAndTypes
import cz.dynawest.csvcruncher.util.HsqldbErrorHandling.throwHintForObjectNotFound
import cz.dynawest.csvcruncher.util.Utils.escapeSql
import cz.dynawest.csvcruncher.util.logger
import org.apache.commons.lang3.StringUtils
import java.io.File
import java.nio.file.Path
import java.sql.Connection
import java.sql.PreparedStatement
import java.sql.ResultSet
import java.sql.SQLException
import java.sql.SQLSyntaxErrorException
import java.sql.*

@Suppress("NAME_SHADOWING")
class HsqlDbHelper(val jdbcConn: Connection) {
Expand All @@ -30,11 +25,13 @@ class HsqlDbHelper(val jdbcConn: Connection) {
try {
log.debug(" Executing SQL: $sql")
jdbcConn.createStatement().use { stmt -> return stmt.executeUpdate(sql) }
} catch (ex: Exception) {
}
// TBD: Handle SQLSyntaxErrorException specifically
catch (ex: Exception) {
var addToMsg = ""
if (true || (ex.message?.contains("for cast") ?: false)) {
// List column names with types.
addToMsg = """
addToMsg = """\n
| Tables and column types:
|${this.formatListOfAvailableTables(true)}""".trimMargin()
}
Expand Down Expand Up @@ -234,4 +231,4 @@ class HsqlDbHelper(val jdbcConn: Connection) {
return sqlQuery
}
}
}
}

0 comments on commit a21a2a1

Please sign in to comment.