Skip to content

Commit 8618ac0

Browse files
cagliostro92christophstrobl
authored andcommitted
Fix FileSystemException in tests.
Closes: #3281
1 parent b82094a commit 8618ac0

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/EclipseLinkMetaAnnotatedQueryMethodIntegrationTests.java

+12-9
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@
1919

2020
import jakarta.persistence.EntityManagerFactory;
2121

22-
import java.io.FileOutputStream;
2322
import java.io.IOException;
2423
import java.io.InputStreamReader;
2524
import java.io.Reader;
2625
import java.nio.charset.StandardCharsets;
26+
import java.nio.file.Files;
2727
import java.nio.file.Path;
2828
import java.util.Properties;
2929

3030
import javax.sql.DataSource;
3131

3232
import org.junit.jupiter.api.AfterAll;
33-
import org.junit.jupiter.api.BeforeEach;
33+
import org.junit.jupiter.api.BeforeAll;
3434
import org.junit.jupiter.api.Test;
3535
import org.junit.jupiter.api.extension.ExtendWith;
3636
import org.springframework.beans.factory.annotation.Autowired;
@@ -58,12 +58,12 @@
5858
import org.springframework.transaction.PlatformTransactionManager;
5959
import org.springframework.transaction.annotation.Transactional;
6060
import 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

Comments
 (0)