Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.security.SecureRandom;
import java.security.Signature;
import java.util.Base64;
import java.util.Arrays;

public class DynamicConfigVerifierTest {

Expand Down Expand Up @@ -131,9 +132,13 @@ private static void createTarGZ() throws FileNotFoundException, IOException {
TarArchiveOutputStream tarOutputStream = null;
try {
String configPath = "src/test/resources/configs/";
File[] files = new File(configPath).listFiles();
Arrays.sort(files);
tarOutputStream = new TarArchiveOutputStream(new GzipCompressorOutputStream(
new BufferedOutputStream(new FileOutputStream(new File(TAR_FILE_PATH)))));
addFileToTarGz(tarOutputStream, configPath, "");
for (File file : files) {
addFileToTarGz(tarOutputStream, file.getAbsolutePath(), "");
}
} finally {
tarOutputStream.finish();
tarOutputStream.close();
Expand All @@ -144,15 +149,16 @@ private static void addFileToTarGz(TarArchiveOutputStream tOut, String path, Str
File f = new File(path);
String entryName = base + f.getName();
TarArchiveEntry tarEntry = new TarArchiveEntry(f, entryName);
tOut.putArchiveEntry(tarEntry);

if (f.isFile()) {
tarEntry.setModTime(0);
tOut.putArchiveEntry(tarEntry);
IOUtils.copy(new FileInputStream(f), tOut);
tOut.closeArchiveEntry();
Comment on lines +155 to 157
} else {
tOut.closeArchiveEntry();
File[] children = f.listFiles();
if (children != null) {
Arrays.sort(children);
for (File child : children) {
addFileToTarGz(tOut, child.getAbsolutePath(), entryName + "/");
}
Expand Down