Skip to content

Commit a7b1763

Browse files
committed
HBX-3080: Refactor the Gradle integration tests to factor out common code
- Only perform database creation if there is a creation script Signed-off-by: Koen Aers <[email protected]>
1 parent 2476fe8 commit a7b1763

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

gradle/plugin/src/functionalTest/java/org/hibernate/tool/it/gradle/TestTemplate.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,18 @@ protected void createHibernatePropertiesFile() throws Exception {
117117
}
118118

119119
protected void createDatabase() throws Exception {
120-
Connection connection = DriverManager.getConnection(constructJdbcConnectionString());
121-
Statement statement = connection.createStatement();
122-
for (String sql : getDatabaseCreationScript()) {
123-
statement.execute(sql);
120+
String[] sqls = getDatabaseCreationScript();
121+
if ((sqls != null) && (sqls.length > 0)) {
122+
Connection connection = DriverManager.getConnection(constructJdbcConnectionString());
123+
Statement statement = connection.createStatement();
124+
for (String sql : sqls) {
125+
statement.execute(sql);
126+
}
127+
statement.close();
128+
connection.close();
129+
assertTrue(getDatabaseFile().exists());
130+
assertTrue(getDatabaseFile().isFile());
124131
}
125-
statement.close();
126-
connection.close();
127-
assertTrue(getDatabaseFile().exists());
128-
assertTrue(getDatabaseFile().isFile());
129132
}
130133

131134
protected String constructH2DatabaseDependencyLine() {

0 commit comments

Comments
 (0)