1919
2020import jakarta .persistence .EntityManagerFactory ;
2121
22- import java .io .FileOutputStream ;
2322import java .io .IOException ;
2423import java .io .InputStreamReader ;
2524import java .io .Reader ;
2625import java .nio .charset .StandardCharsets ;
26+ import java .nio .file .Files ;
2727import java .nio .file .Path ;
2828import java .util .Properties ;
2929
3030import javax .sql .DataSource ;
3131
3232import org .junit .jupiter .api .AfterAll ;
33- import org .junit .jupiter .api .BeforeEach ;
33+ import org .junit .jupiter .api .BeforeAll ;
3434import org .junit .jupiter .api .Test ;
3535import org .junit .jupiter .api .extension .ExtendWith ;
3636import org .springframework .beans .factory .annotation .Autowired ;
5858import org .springframework .transaction .PlatformTransactionManager ;
5959import org .springframework .transaction .annotation .Transactional ;
6060import org .springframework .util .FileCopyUtils ;
61- import org .springframework .util .FileSystemUtils ;
6261
6362/**
6463 * Verify that {@link Meta}-annotated methods properly embed comments into EclipseLink queries.
6564 *
6665 * @author Greg Turnquist
66+ * @author Edoardo Patti
6767 * @since 3.0
6868 */
6969@ ExtendWith (SpringExtension .class )
@@ -74,16 +74,19 @@ class EclipseLinkMetaAnnotatedQueryMethodIntegrationTests {
7474 @ Autowired RoleRepositoryWithMeta repository ;
7575
7676 private static final ResourceLoader RESOURCE_LOADER = new DefaultResourceLoader ();
77- private static final String LOG_FILE = "test-eclipselink-meta.log" ;
77+ private static String LOG_FILE ;
7878
79- @ BeforeEach
80- void cleanoutLogfile () throws IOException {
81- new FileOutputStream (LOG_FILE ).close ();
79+ private static Path logFile ;
80+
81+ @ BeforeAll
82+ static void createLogfile () throws IOException {
83+ logFile = Files .createTempFile ("test-eclipselink-meta" , ".log" );
84+ LOG_FILE = logFile .toAbsolutePath ().toString ();
8285 }
8386
8487 @ AfterAll
85- static void deleteLogfile () throws IOException {
86- FileSystemUtils . deleteRecursively ( Path . of ( LOG_FILE ) );
88+ static void deleteLogFile () {
89+ logFile . toFile (). deleteOnExit ( );
8790 }
8891
8992 @ Test // GH-775
0 commit comments