Skip to content

Commit cb19625

Browse files
committed
HBX-3169: Update the use of H2 in the Maven integration tests to 2.4.240 (hibernate#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 1917776 commit cb19625

34 files changed

+120
-202
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
@@ -98,11 +98,7 @@ public void execute() throws MojoFailureException {
9898
Thread.currentThread().setContextClassLoader(createExporterClassLoader(original));
9999
getLog().info("Starting " + this.getClass().getSimpleName() + "...");
100100
RevengStrategy strategy = setupReverseEngineeringStrategy();
101-
if (propertyFile.exists()) {
102-
executeExporter(createJdbcDescriptor(strategy, loadPropertiesFile()));
103-
} else {
104-
getLog().info("Property file '" + propertyFile + "' cannot be found, aborting...");
105-
}
101+
executeExporter(createJdbcDescriptor(strategy, loadPropertiesFile()));
106102
getLog().info("Finished " + this.getClass().getSimpleName() + "!");
107103
} finally {
108104
Thread.currentThread().setContextClassLoader(original);
@@ -136,8 +132,10 @@ private Properties loadPropertiesFile() throws MojoFailureException {
136132
result.load(is);
137133
return result;
138134
} catch (FileNotFoundException e) {
135+
getLog().error("Property file '" + propertyFile + "' cannot be found, aborting...");
139136
throw new MojoFailureException(propertyFile + " not found.", e);
140137
} catch (IOException e) {
138+
getLog().error("Property file '" + propertyFile + "' cannot be loaded, aborting...");
141139
throw new MojoFailureException("Problem while loading " + propertyFile, e);
142140
}
143141
}

test/maven/pom.xml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
5050
<settingsFile>src/it/settings.xml</settingsFile>
5151
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
52-
<postBuildHookScript>verify</postBuildHookScript>
53-
<goal>install</goal>
52+
<goal>generate-sources</goal>
5453
</configuration>
5554
<executions>
5655
<execution>
@@ -60,7 +59,14 @@
6059
</goals>
6160
</execution>
6261
</executions>
63-
</plugin>
62+
<dependencies>
63+
<dependency>
64+
<groupId>com.h2database</groupId>
65+
<artifactId>h2</artifactId>
66+
<version>${h2.version}</version>
67+
</dependency>
68+
</dependencies>
69+
</plugin>
6470
</plugins>
6571
</build>
6672

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

Lines changed: 0 additions & 2 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
@@ -8,13 +8,14 @@
88
<artifactId>hbm2ddl</artifactId>
99
<version>0.0.1-SNAPSHOT</version>
1010

11-
<properties>
12-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13-
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
14-
15-
<java.version>1.8</java.version>
16-
<h2.version>1.4.195</h2.version>
17-
</properties>
11+
<dependencies>
12+
<dependency>
13+
<!-- DB Driver of your choice -->
14+
<groupId>com.h2database</groupId>
15+
<artifactId>h2</artifactId>
16+
<version>@h2.version@</version>
17+
</dependency>
18+
</dependencies>
1819

1920
<build>
2021
<plugins>
@@ -35,17 +36,6 @@
3536
</configuration>
3637
</execution>
3738
</executions>
38-
<configuration>
39-
<revengFile>${project.basedir}/src/main/resources/hibernate.reveng.xml</revengFile>
40-
</configuration>
41-
<dependencies>
42-
<dependency>
43-
<!-- DB Driver of your choice -->
44-
<groupId>com.h2database</groupId>
45-
<artifactId>h2</artifactId>
46-
<version>${h2.version}</version>
47-
</dependency>
48-
</dependencies>
4939
</plugin>
5040
</plugins>
5141
</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
@@ -1,5 +1,3 @@
1-
import java.io.*;
2-
31
File file = new File(basedir, "target/generated-sources/Person.hbm.xml");
42
if (!file.isFile()) {
53
throw new FileNotFoundException("Could not find generated HBM file: " + file);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import java.sql.DriverManager;
2+
import java.sql.Connection;
3+
4+
String JDBC_CONNECTION = "jdbc:h2:" + basedir + "/test";
5+
String CREATE_PERSON_TABLE = "create table PERSON (ID int not null, NAME varchar(20), primary key (ID))";
6+
7+
Connection connection = DriverManager.getConnection(JDBC_CONNECTION);
8+
connection.createStatement().execute(CREATE_PERSON_TABLE);
9+
connection.close();
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
hibernate.dialect=org.hibernate.dialect.H2Dialect
21
hibernate.connection.driver_class=org.h2.Driver
3-
hibernate.connection.url=jdbc:h2:./test;DB_CLOSE_ON_EXIT=FALSE
4-
hibernate.connection.username=sa
5-
hibernate.connection.password=
6-
hibernate.connection.pool_size=1
7-
hibernate.show_sql=true
2+
hibernate.connection.url=jdbc:h2:./test
3+
hibernate.default_catalog=TEST
4+
hibernate.default_schema=PUBLIC

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

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

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

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

0 commit comments

Comments
 (0)