|
16 | 16 | import org.hibernate.tool.api.metadata.MetadataDescriptorFactory;
|
17 | 17 | import org.junit.jupiter.api.AfterEach;
|
18 | 18 | import org.junit.jupiter.api.BeforeEach;
|
| 19 | +import org.junit.jupiter.api.Disabled; |
19 | 20 | import org.junit.jupiter.api.Test;
|
20 | 21 | import org.junit.jupiter.api.io.TempDir;
|
21 | 22 |
|
22 | 23 | public class GenerateJavaMojoTest {
|
23 | 24 |
|
24 |
| - private static final String JDBC_CONNECTION = "jdbc:h2:mem:test"; |
25 | 25 | private static final String CREATE_PERSON_TABLE =
|
26 | 26 | "create table PERSON (ID int not null, NAME varchar(20), primary key (ID))";
|
27 | 27 | private static final String CREATE_ITEM_TABLE =
|
@@ -122,17 +122,21 @@ public void testGenerateJavaWithoutGenerics() throws Exception {
|
122 | 122 | }
|
123 | 123 |
|
124 | 124 | private void createDatabase() throws Exception {
|
125 |
| - Connection connection = DriverManager.getConnection(JDBC_CONNECTION); |
| 125 | + Connection connection = DriverManager.getConnection(constructJdbcConnectionString()); |
126 | 126 | Statement statement = connection.createStatement();
|
127 | 127 | statement.execute(CREATE_PERSON_TABLE);
|
128 | 128 | statement.execute(CREATE_ITEM_TABLE);
|
| 129 | + statement.close(); |
| 130 | + connection.close(); |
129 | 131 | }
|
130 | 132 |
|
131 | 133 | private void dropDatabase() throws Exception {
|
132 |
| - Connection connection = DriverManager.getConnection(JDBC_CONNECTION); |
| 134 | + Connection connection = DriverManager.getConnection(constructJdbcConnectionString()); |
133 | 135 | Statement statement = connection.createStatement();
|
134 | 136 | statement.execute(DROP_ITEM_TABLE);
|
135 | 137 | statement.execute(DROP_PERSON_TABLE);
|
| 138 | + statement.close(); |
| 139 | + connection.close(); |
136 | 140 | }
|
137 | 141 |
|
138 | 142 | private void createGenerateJavaMojo() throws Exception {
|
@@ -161,10 +165,14 @@ private MetadataDescriptor createMetadataDescriptor() {
|
161 | 165 |
|
162 | 166 | private Properties createProperties() {
|
163 | 167 | Properties result = new Properties();
|
164 |
| - result.put("hibernate.connection.url", JDBC_CONNECTION); |
| 168 | + result.put("hibernate.connection.url", constructJdbcConnectionString()); |
165 | 169 | result.put("hibernate.default_catalog", "TEST");
|
166 | 170 | result.put("hibernate.default_schema", "PUBLIC");
|
167 | 171 | return result;
|
168 | 172 | }
|
169 | 173 |
|
| 174 | + private String constructJdbcConnectionString() { |
| 175 | + return "jdbc:h2:" + tempDir.getAbsolutePath() + "/database/test;AUTO_SERVER=TRUE"; |
| 176 | + } |
| 177 | + |
170 | 178 | }
|
0 commit comments