77import org .junit .jupiter .api .BeforeAll ;
88import org .junit .jupiter .api .BeforeEach ;
99import org .junit .jupiter .api .Test ;
10+ import org .junit .jupiter .api .io .TempDir ;
11+
1012
1113import org .apache .maven .cli .MavenCli ;
1214
@@ -25,6 +27,9 @@ public class ExamplesTestIT {
2527 private File projectFolder ;
2628 private MavenCli mavenCli ;
2729
30+ @ TempDir
31+ private File tempFolder ;
32+
2833 private String [] databaseCreationScript = new String [] {
2934 // This is the default database which can be overridden per test
3035 "create table PERSON (ID int not null, NAME varchar(20), primary key (ID))"
@@ -53,6 +58,14 @@ public void test5MinuteTutorial() throws Exception {
5358 assertGeneratedContains ("public class Person" );
5459 }
5560
61+ @ Test
62+ public void testJpaDefault () throws Exception {
63+ prepareProject ("hbm2java/jpa-default" );
64+ assertNotGeneratedYet ();
65+ runGenerateSources ();
66+ assertGeneratedContains ("import jakarta.persistence.Entity;" );
67+ }
68+
5669 private void prepareProject (String projectName ) throws Exception {
5770 projectFolder = new File (baseFolder , projectName );
5871 assertTrue (projectFolder .exists ());
@@ -108,7 +121,7 @@ private static File determineBaseFolder() throws Exception {
108121 }
109122
110123 private void createDatabase () throws Exception {
111- File databaseFile = new File (baseFolder , "database/test.mv.db" );
124+ File databaseFile = new File (tempFolder , "database/test.mv.db" );
112125 assertFalse (databaseFile .exists ());
113126 assertFalse (databaseFile .isFile ());
114127 Connection connection = DriverManager .getConnection (constructJdbcConnectionString ());
@@ -122,8 +135,8 @@ private void createDatabase() throws Exception {
122135 assertTrue (databaseFile .isFile ());
123136 }
124137
125- private static String constructJdbcConnectionString () {
126- return "jdbc:h2:" + baseFolder .getAbsolutePath () + "/database/test;AUTO_SERVER=TRUE" ;
138+ private String constructJdbcConnectionString () {
139+ return "jdbc:h2:" + tempFolder .getAbsolutePath () + "/database/test;AUTO_SERVER=TRUE" ;
127140 }
128141
129142}
0 commit comments