1919 */
2020package org .sonarsource .scanner .lib ;
2121
22- import java .io .File ;
2322import java .io .IOException ;
24- import java .nio .charset .StandardCharsets ;
2523import java .nio .file .Files ;
2624import java .nio .file .Path ;
27- import java .util .Properties ;
28- import org .junit .Rule ;
29- import org .junit .Test ;
30- import org .junit .rules .ExpectedException ;
31- import org .junit .rules .TemporaryFolder ;
25+ import org .junit .jupiter .api .Test ;
26+ import org .junit .jupiter .api .io .TempDir ;
3227
3328import static org .assertj .core .api .Assertions .assertThat ;
3429
35- public class UtilsTest {
36- @ Rule
37- public TemporaryFolder temp = new TemporaryFolder ();
38-
39- @ Rule
40- public ExpectedException exception = ExpectedException .none ();
41-
42- @ Test
43- public void write_properties () throws IOException {
44- File f = temp .newFile ();
45- Properties p = new Properties ();
46- p .put ("key" , "value" );
47- Utils .writeProperties (f , p );
48- assertThat (Files .readAllLines (f .toPath (), StandardCharsets .UTF_8 )).contains ("key=value" );
49- }
30+ class UtilsTest {
5031
5132 @ Test
52- public void delete_non_empty_directory () throws IOException {
33+ void delete_non_empty_directory (@ TempDir Path tmp ) throws IOException {
5334 /*-
5435 * Create test structure:
5536 * tmp
@@ -58,7 +39,7 @@ public void delete_non_empty_directory() throws IOException {
5839 * |- folder2
5940 * |- file2
6041 */
61- Path tmpDir = Files .createTempDirectory ("junit" );
42+ Path tmpDir = Files .createTempDirectory (tmp , "junit" );
6243 Path folder1 = tmpDir .resolve ("folder1" );
6344 Files .createDirectories (folder1 );
6445 Path file1 = folder1 .resolve ("file1" );
0 commit comments