|
22 | 22 | import java.io.File; |
23 | 23 | import java.io.IOException; |
24 | 24 |
|
25 | | -import org.gradle.testkit.runner.BuildResult; |
26 | | -import org.hibernate.tool.gradle.test.func.utils.FuncTestConstants; |
27 | | -import org.hibernate.tool.gradle.test.func.utils.FuncTestTemplate; |
| 25 | +import org.hibernate.tool.it.gradle.TestTemplate; |
| 26 | +import org.junit.jupiter.api.BeforeEach; |
28 | 27 | import org.junit.jupiter.api.Test; |
29 | 28 |
|
30 | | -class GenerateHbmTest extends FuncTestTemplate implements FuncTestConstants { |
| 29 | +class GenerateHbmTest extends TestTemplate { |
31 | 30 |
|
32 | | - private static final String BUILD_FILE_HIBERNATE_TOOLS_SECTION = |
33 | | - "hibernateTools {\n" + |
34 | | - " packageName = 'foo.model'\n" + |
35 | | - "}\n"; |
36 | | - |
37 | | - @Override |
38 | | - public String getBuildFileHibernateToolsSection() { |
39 | | - return BUILD_FILE_HIBERNATE_TOOLS_SECTION; |
| 31 | + @BeforeEach |
| 32 | + public void beforeEach() { |
| 33 | + setGradleTaskToPerform("generateHbm"); |
| 34 | + setDatabaseCreationScript(new String[] { |
| 35 | + "create table FOO (ID int not null, BAR varchar(20), primary key (ID))" |
| 36 | + }); |
40 | 37 | } |
41 | 38 |
|
42 | | - @Test |
43 | | - void testGenerateHbm() throws IOException { |
44 | | - performTask("generateHbm", true); |
45 | | - } |
46 | | - |
47 | | - @Override |
48 | | - protected void verifyBuild(BuildResult buildResult) { |
49 | | - try { |
50 | | - File generatedSourcesFolder = new File(projectDir, "generated-sources"); |
51 | | - assertTrue(buildResult.getOutput().contains( |
52 | | - "Starting HBM export to directory: " + generatedSourcesFolder.getCanonicalPath())); |
53 | | - assertTrue(generatedSourcesFolder.exists()); |
54 | | - assertTrue(generatedSourcesFolder.isDirectory()); |
55 | | - File fooFile = new File(generatedSourcesFolder, "foo/model/Foo.hbm.xml"); |
56 | | - assertTrue(fooFile.exists()); |
57 | | - assertTrue(fooFile.isFile()); |
58 | | - } catch (Exception e) { |
59 | | - throw new RuntimeException(e); |
60 | | - } |
| 39 | + @Test |
| 40 | + void testGenerateHbm() throws Exception { |
| 41 | + setHibernateToolsExtensionSection( |
| 42 | + "hibernateTools { \n" + |
| 43 | + " packageName = 'foo.model'\n" + |
| 44 | + "}" |
| 45 | + ); |
| 46 | + createProjectAndExecuteGradleCommand(); |
| 47 | + File generatedSourcesFolder = new File(getProjectDir(), "app/generated-sources"); |
| 48 | + assertTrue(getBuildResult().getOutput().contains("Starting HBM export to directory: ")); |
| 49 | + assertTrue(generatedSourcesFolder.exists()); |
| 50 | + assertTrue(generatedSourcesFolder.isDirectory()); |
| 51 | + File fooFile = new File(generatedSourcesFolder, "foo/model/Foo.hbm.xml"); |
| 52 | + assertTrue(fooFile.exists()); |
| 53 | + assertTrue(fooFile.isFile()); |
61 | 54 | } |
62 | 55 |
|
63 | 56 | } |
0 commit comments