Skip to content

Commit

Permalink
Use FileUtils.deleteQuietly in tests (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr authored Aug 27, 2024
1 parent 37bfcb5 commit 578833f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.iceberg.BaseTable;
import org.apache.iceberg.PartitionData;
Expand Down Expand Up @@ -117,23 +117,7 @@ public static void setup(
realm = PolarisConnectionExtension.getTestRealm(PolarisApplicationIntegrationTest.class);

testDir = Path.of("build/test_data/iceberg/" + realm);
if (Files.exists(testDir)) {
if (Files.isDirectory(testDir)) {
Files.walk(testDir)
.sorted(Comparator.reverseOrder())
.forEach(
path -> {
try {
Files.delete(path);
} catch (IOException e) {
throw new RuntimeException(e);
}
});

} else {
Files.delete(testDir);
}
}
FileUtils.deleteQuietly(testDir.toFile());
Files.createDirectories(testDir);
PolarisApplicationIntegrationTest.userToken = userToken.token();
PolarisApplicationIntegrationTest.snowmanCredentials = snowmanCredentials;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import org.apache.commons.io.FileUtils;
import org.apache.iceberg.BaseTable;
import org.apache.iceberg.CatalogProperties;
import org.apache.iceberg.Schema;
Expand Down Expand Up @@ -135,23 +135,7 @@ public static void setup() throws IOException {
realm = PolarisConnectionExtension.getTestRealm(PolarisRestCatalogIntegrationTest.class);

Path testDir = Path.of("build/test_data/iceberg/" + realm);
if (Files.exists(testDir)) {
if (Files.isDirectory(testDir)) {
Files.walk(testDir)
.sorted(Comparator.reverseOrder())
.forEach(
path -> {
try {
Files.delete(path);
} catch (IOException e) {
throw new RuntimeException(e);
}
});

} else {
Files.delete(testDir);
}
}
FileUtils.deleteQuietly(testDir.toFile());
Files.createDirectories(testDir);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import org.apache.commons.io.FileUtils;
import org.apache.iceberg.CatalogProperties;
import org.apache.iceberg.catalog.SessionCatalog;
import org.apache.iceberg.rest.HTTPClient;
Expand Down Expand Up @@ -97,23 +97,7 @@ public static void setup() throws IOException {
realm = PolarisConnectionExtension.getTestRealm(PolarisRestCatalogViewIntegrationTest.class);

Path testDir = Path.of("build/test_data/iceberg/" + realm);
if (Files.exists(testDir)) {
if (Files.isDirectory(testDir)) {
Files.walk(testDir)
.sorted(Comparator.reverseOrder())
.forEach(
path -> {
try {
Files.delete(path);
} catch (IOException e) {
throw new RuntimeException(e);
}
});

} else {
Files.delete(testDir);
}
}
FileUtils.deleteQuietly(testDir.toFile());
Files.createDirectories(testDir);
}

Expand Down

0 comments on commit 578833f

Please sign in to comment.