Reduce dependency on commons-io and commons-codec (#10614)
Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
@@ -19,11 +19,15 @@ import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Comparator;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -82,13 +86,26 @@ public class MapTransformationServiceTest {
|
||||
public void setUp() throws IOException {
|
||||
processor = new TestableMapTransformationService();
|
||||
processor.activate(bundleContext);
|
||||
FileUtils.copyDirectory(new File(SRC_FOLDER), new File(CONFIG_FOLDER));
|
||||
copyDirectory(SRC_FOLDER, CONFIG_FOLDER);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() throws IOException {
|
||||
processor.deactivate();
|
||||
FileUtils.deleteDirectory(new File(CONFIG_FOLDER));
|
||||
|
||||
try (Stream<Path> walk = Files.walk(Path.of(CONFIG_FOLDER))) {
|
||||
walk.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
|
||||
}
|
||||
}
|
||||
|
||||
private void copyDirectory(String from, String to) throws IOException {
|
||||
Files.walk(Paths.get(from)).forEach(fromPath -> {
|
||||
Path toPath = Paths.get(to, fromPath.toString().substring(from.length()));
|
||||
try {
|
||||
Files.copy(fromPath, toPath);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user