1111import java .nio .file .attribute .PosixFilePermissions ;
1212import java .util .Properties ;
1313import java .util .UUID ;
14-
1514import org .junit .jupiter .api .Test ;
1615
1716public class TempLocationManagerTest {
@@ -30,8 +29,10 @@ void testDefault() throws Exception {
3029
3130 @ Test
3231 void testFromConfig () throws Exception {
33- Path myDir = Paths .get (System .getProperty ("java.io.tmpdir" ), UUID .randomUUID ().toString ());
34- Files .createDirectories (myDir );
32+ Path myDir =
33+ Files .createTempDirectory (
34+ "ddprof-test-" ,
35+ PosixFilePermissions .asFileAttribute (PosixFilePermissions .fromString ("rwx------" )));
3536 Properties props = new Properties ();
3637 props .put (ProfilingConfig .PROFILING_TEMP_DIR , myDir .toString ());
3738 ConfigProvider configProvider = ConfigProvider .withPropertiesOverride (props );
@@ -53,9 +54,10 @@ void testFromConfigInvalid() {
5354
5455 @ Test
5556 void testFromConfigNotWritable () throws Exception {
56- Path myDir = Paths .get (System .getProperty ("java.io.tmpdir" ), UUID .randomUUID ().toString ());
57- Files .createDirectories (
58- myDir , PosixFilePermissions .asFileAttribute (PosixFilePermissions .fromString ("r-x------" )));
57+ Path myDir =
58+ Files .createTempDirectory (
59+ "ddprof-test-" ,
60+ PosixFilePermissions .asFileAttribute (PosixFilePermissions .fromString ("r-x------" )));
5961 Properties props = new Properties ();
6062 props .put (ProfilingConfig .PROFILING_TEMP_DIR , myDir .toString ());
6163 ConfigProvider configProvider = ConfigProvider .withPropertiesOverride (props );
@@ -65,8 +67,10 @@ void testFromConfigNotWritable() throws Exception {
6567
6668 @ Test
6769 void testCleanup () throws Exception {
68- Path myDir = Paths .get (System .getProperty ("java.io.tmpdir" ), UUID .randomUUID ().toString ());
69- Files .createDirectories (myDir );
70+ Path myDir =
71+ Files .createTempDirectory (
72+ "ddprof-test-" ,
73+ PosixFilePermissions .asFileAttribute (PosixFilePermissions .fromString ("rwx------" )));
7074 Properties props = new Properties ();
7175 props .put (ProfilingConfig .PROFILING_TEMP_DIR , myDir .toString ());
7276 ConfigProvider configProvider = ConfigProvider .withPropertiesOverride (props );
0 commit comments