Skip to content

Commit ff48e46

Browse files
committed
Fix tests
1 parent 06ae694 commit ff48e46

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

dd-java-agent/agent-profiling/profiling-controller/src/test/java/com/datadog/profiling/controller/TempLocationManagerTest.java

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,14 @@ void testDefault() throws Exception {
3838
@Test
3939
void testFromConfig() throws Exception {
4040
Path myDir = Paths.get(System.getProperty("java.io.tmpdir"), "test1");
41-
try {
42-
Files.createDirectories(myDir);
43-
Properties props = new Properties();
44-
props.put(ProfilingConfig.PROFILING_TEMP_DIR, myDir.toString());
45-
ConfigProvider configProvider = ConfigProvider.withPropertiesOverride(props);
46-
TempLocationManager tempLocationManager = new TempLocationManager(configProvider);
47-
Path tempDir = tempLocationManager.getTempDir();
48-
assertNotNull(tempDir);
49-
assertTrue(tempDir.toString().startsWith(myDir.toString()));
50-
} finally {
51-
// make sure to delete the test directory
52-
Files.delete(myDir);
53-
}
41+
Files.createDirectories(myDir);
42+
Properties props = new Properties();
43+
props.put(ProfilingConfig.PROFILING_TEMP_DIR, myDir.toString());
44+
ConfigProvider configProvider = ConfigProvider.withPropertiesOverride(props);
45+
TempLocationManager tempLocationManager = new TempLocationManager(configProvider);
46+
Path tempDir = tempLocationManager.getTempDir();
47+
assertNotNull(tempDir);
48+
assertTrue(tempDir.toString().startsWith(myDir.toString()));
5449
}
5550

5651
@Test
@@ -66,18 +61,13 @@ void testFromConfigInvalid() {
6661
@Test
6762
void testFromConfigNotWritable() throws Exception {
6863
Path myDir = Paths.get(System.getProperty("java.io.tmpdir"), "test3");
69-
try {
70-
Files.createDirectories(
71-
myDir,
72-
PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("r-x------")));
73-
Properties props = new Properties();
74-
props.put(ProfilingConfig.PROFILING_TEMP_DIR, myDir.toString());
75-
ConfigProvider configProvider = ConfigProvider.withPropertiesOverride(props);
76-
TempLocationManager tempLocationManager = new TempLocationManager(configProvider);
77-
assertThrows(IllegalStateException.class, tempLocationManager::getTempDir);
78-
} finally {
79-
// make sure to delete the test directory
80-
Files.delete(myDir);
81-
}
64+
Files.createDirectories(
65+
myDir,
66+
PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("r-x------")));
67+
Properties props = new Properties();
68+
props.put(ProfilingConfig.PROFILING_TEMP_DIR, myDir.toString());
69+
ConfigProvider configProvider = ConfigProvider.withPropertiesOverride(props);
70+
TempLocationManager tempLocationManager = new TempLocationManager(configProvider);
71+
assertThrows(IllegalStateException.class, tempLocationManager::getTempDir);
8272
}
8373
}

0 commit comments

Comments
 (0)