Skip to content

Commit a0d27a6

Browse files
committed
Remove dead code
1 parent 98495b2 commit a0d27a6

2 files changed

Lines changed: 5 additions & 36 deletions

File tree

lib/src/main/java/org/sonarsource/scanner/lib/Utils.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,19 @@
1919
*/
2020
package org.sonarsource.scanner.lib;
2121

22-
import java.io.File;
23-
import java.io.FileOutputStream;
2422
import java.io.IOException;
25-
import java.io.OutputStream;
2623
import java.nio.file.FileVisitResult;
2724
import java.nio.file.Files;
2825
import java.nio.file.Path;
2926
import java.nio.file.SimpleFileVisitor;
3027
import java.nio.file.attribute.BasicFileAttributes;
31-
import java.util.Properties;
3228

3329
public class Utils {
3430

3531
private Utils() {
3632
// only util static methods
3733
}
3834

39-
static void writeProperties(File outputFile, Properties p) {
40-
try (OutputStream output = new FileOutputStream(outputFile)) {
41-
p.store(output, "Generated by sonar-runner");
42-
} catch (Exception e) {
43-
throw new IllegalStateException("Fail to export sonar-runner properties", e);
44-
}
45-
}
46-
4735
public static void deleteQuietly(Path f) {
4836
try {
4937
Files.walkFileTree(f, new DeleteQuietlyFileVisitor());

lib/src/test/java/org/sonarsource/scanner/lib/UtilsTest.java

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,18 @@
1919
*/
2020
package org.sonarsource.scanner.lib;
2121

22-
import java.io.File;
2322
import java.io.IOException;
24-
import java.nio.charset.StandardCharsets;
2523
import java.nio.file.Files;
2624
import 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

3328
import 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

Comments
 (0)