Skip to content

Commit 50ab469

Browse files
committed
HBX-3169: Update the use of H2 in the Maven integration tests to 2.4.240 (#5629)
- Handle the 'generateHbm' integration test - Handle the 'generateDao' integration test - Handle the 'hbm2ddl' integration test - Handle the 'hbm2java' integration test - Properly fail with a MojoFailureException when the properties file is not found - Handle the noProperties case - Handle the 'transformHbm' case - Simplify the pom.xml file of the 'transformHbm' integration test - Some additional cleanup of the integration tests - Remove the unneeded reveng.xml files from the integration tests
1 parent c0363bb commit 50ab469

36 files changed

+181
-359
lines changed

maven/src/main/java/org/hibernate/tool/maven/AbstractGenerationMojo.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,7 @@ public void execute() throws MojoFailureException {
9696
Thread.currentThread().setContextClassLoader(createExporterClassLoader(original));
9797
getLog().info("Starting " + this.getClass().getSimpleName() + "...");
9898
RevengStrategy strategy = setupReverseEngineeringStrategy();
99-
if (propertyFile.exists()) {
100-
executeExporter(createJdbcDescriptor(strategy, loadPropertiesFile()));
101-
} else {
102-
getLog().info("Property file '" + propertyFile + "' cannot be found, aborting...");
103-
}
99+
executeExporter(createJdbcDescriptor(strategy, loadPropertiesFile()));
104100
getLog().info("Finished " + this.getClass().getSimpleName() + "!");
105101
} finally {
106102
Thread.currentThread().setContextClassLoader(original);
@@ -134,8 +130,10 @@ private Properties loadPropertiesFile() throws MojoFailureException {
134130
result.load(is);
135131
return result;
136132
} catch (FileNotFoundException e) {
133+
getLog().error("Property file '" + propertyFile + "' cannot be found, aborting...");
137134
throw new MojoFailureException(propertyFile + " not found.", e);
138135
} catch (IOException e) {
136+
getLog().error("Property file '" + propertyFile + "' cannot be loaded, aborting...");
139137
throw new MojoFailureException("Problem while loading " + propertyFile, e);
140138
}
141139
}

test/maven/pom.xml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@
4545
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
4646
<settingsFile>src/it/settings.xml</settingsFile>
4747
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
48-
<postBuildHookScript>verify</postBuildHookScript>
49-
<goal>install</goal>
48+
<goal>generate-sources</goal>
5049
</configuration>
5150
<executions>
5251
<execution>
@@ -56,7 +55,14 @@
5655
</goals>
5756
</execution>
5857
</executions>
59-
</plugin>
58+
<dependencies>
59+
<dependency>
60+
<groupId>com.h2database</groupId>
61+
<artifactId>h2</artifactId>
62+
<version>${h2.version}</version>
63+
</dependency>
64+
</dependencies>
65+
</plugin>
6066
</plugins>
6167
</build>
6268

test/maven/src/it/generateHbm/invoker.properties

Lines changed: 0 additions & 19 deletions
This file was deleted.

test/maven/src/it/generateHbm/pom.xml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@
2323
<artifactId>generateHbm</artifactId>
2424
<version>0.0.1-SNAPSHOT</version>
2525

26-
<properties>
27-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
28-
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
29-
30-
<java.version>1.8</java.version>
31-
<h2.version>1.4.195</h2.version>
32-
</properties>
26+
<dependencies>
27+
<dependency>
28+
<!-- DB Driver of your choice -->
29+
<groupId>com.h2database</groupId>
30+
<artifactId>h2</artifactId>
31+
<version>@h2.version@</version>
32+
</dependency>
33+
</dependencies>
3334

3435
<build>
3536
<plugins>
@@ -50,17 +51,6 @@
5051
</configuration>
5152
</execution>
5253
</executions>
53-
<configuration>
54-
<revengFile>${project.basedir}/src/main/resources/hibernate.reveng.xml</revengFile>
55-
</configuration>
56-
<dependencies>
57-
<dependency>
58-
<!-- DB Driver of your choice -->
59-
<groupId>com.h2database</groupId>
60-
<artifactId>h2</artifactId>
61-
<version>${h2.version}</version>
62-
</dependency>
63-
</dependencies>
6454
</plugin>
6555
</plugins>
6656
</build>

test/maven/src/it/generateHbm/verify.groovy renamed to test/maven/src/it/generateHbm/postbuild.bsh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
import java.io.*;
19-
2018
File file = new File(basedir, "target/generated-sources/Person.hbm.xml");
2119
if (!file.isFile()) {
2220
throw new FileNotFoundException("Could not find generated HBM file: " + file);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Hibernate Tools, Tooling for your Hibernate Projects
3+
*
4+
* Copyright 2018-2025 Red Hat, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" basis,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
import java.sql.DriverManager;
19+
import java.sql.Connection;
20+
21+
String JDBC_CONNECTION = "jdbc:h2:" + basedir + "/test";
22+
String CREATE_PERSON_TABLE = "create table PERSON (ID int not null, NAME varchar(20), primary key (ID))";
23+
24+
Connection connection = DriverManager.getConnection(JDBC_CONNECTION);
25+
connection.createStatement().execute(CREATE_PERSON_TABLE);
26+
connection.close();

test/maven/src/it/generateHbm/src/main/resources/hibernate.properties

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
# See the License for the specific language governing permissions and #
1616
# limitations under the License. #
1717
############################################################################
18-
hibernate.dialect=org.hibernate.dialect.H2Dialect
1918
hibernate.connection.driver_class=org.h2.Driver
20-
hibernate.connection.url=jdbc:h2:./test;DB_CLOSE_ON_EXIT=FALSE
21-
hibernate.connection.username=sa
22-
hibernate.connection.password=
23-
hibernate.connection.pool_size=1
24-
hibernate.show_sql=true
19+
hibernate.connection.url=jdbc:h2:./test
20+
hibernate.default_catalog=TEST
21+
hibernate.default_schema=PUBLIC

test/maven/src/it/generateHbm/src/main/resources/hibernate.reveng.xml

Lines changed: 0 additions & 26 deletions
This file was deleted.
-28 KB
Binary file not shown.

test/maven/src/it/hbm2dao/invoker.properties

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)