refactor: cleanup project configuration and fix naming inconsistencies
This commit is contained in:
parent
54a305a2d1
commit
fb056bb366
4 changed files with 35 additions and 36 deletions
10
build.gradle
10
build.gradle
|
|
@ -10,14 +10,14 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation group: 'commons-io', name: 'commons-io', version: '2.21.0'
|
implementation 'commons-io:commons-io:2.21.0'
|
||||||
implementation "org.apache.commons:commons-lang3:3.20.0"
|
implementation 'org.apache.commons:commons-lang3:3.20.0'
|
||||||
implementation "org.slf4j:jul-to-slf4j:$sl4j_version"
|
implementation 'org.slf4j:jul-to-slf4j:1.7.35'
|
||||||
implementation "org.slf4j:log4j-over-slf4j:$sl4j_version"
|
implementation 'org.slf4j:log4j-over-slf4j:1.7.35'
|
||||||
|
|
||||||
testImplementation platform('org.junit:junit-bom:6.0.0')
|
testImplementation platform('org.junit:junit-bom:6.0.0')
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||||
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '3.0'
|
testImplementation 'org.hamcrest:hamcrest-library:3.0'
|
||||||
|
|
||||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
sl4j_version=1.7.35
|
|
||||||
|
|
@ -41,7 +41,7 @@ public class SplitZipWriter implements Closeable {
|
||||||
private final int chunkSize;
|
private final int chunkSize;
|
||||||
private final int bufferSize;
|
private final int bufferSize;
|
||||||
private final ZipResult zipResult;
|
private final ZipResult zipResult;
|
||||||
OutputStreamEnhancer outputStreamEnhancer;
|
private OutputStreamEnhancer outputStreamEnhancer;
|
||||||
|
|
||||||
private ZipOutputStream zipOutputStream;
|
private ZipOutputStream zipOutputStream;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,13 +63,13 @@ class SplitZipWriterTest {
|
||||||
ZipResult zipResult;
|
ZipResult zipResult;
|
||||||
String outputFileName = RandomStringUtils.randomAlphanumeric(10);
|
String outputFileName = RandomStringUtils.randomAlphanumeric(10);
|
||||||
String inputFileName = "singleFileSmallerThanChunkSizeToOneZip.txt";
|
String inputFileName = "singleFileSmallerThanChunkSizeToOneZip.txt";
|
||||||
SplitZipWriter postBoxZipFileWriter = new SplitZipWriter(
|
SplitZipWriter splitZipWriter = new SplitZipWriter(
|
||||||
DESTINATION_DIR, outputFileName, ZIP_CHUNK_SIZE_IN_BYTE, ZIP_BUFFER_SIZE_IN_BYTE, (OutputStream outputStream) -> outputStream);
|
DESTINATION_DIR, outputFileName, ZIP_CHUNK_SIZE_IN_BYTE, ZIP_BUFFER_SIZE_IN_BYTE, (OutputStream outputStream) -> outputStream);
|
||||||
try (postBoxZipFileWriter) {
|
try (splitZipWriter) {
|
||||||
postBoxZipFileWriter.write(new ByteArrayInputStream(fileSimpleContent), inputFileName);
|
splitZipWriter.write(new ByteArrayInputStream(fileSimpleContent), inputFileName);
|
||||||
}
|
}
|
||||||
String expectedZippedFileName = outputFileName + "_01.zip";
|
String expectedZippedFileName = outputFileName + "_01.zip";
|
||||||
zipResult = postBoxZipFileWriter.getZipResult();
|
zipResult = splitZipWriter.getZipResult();
|
||||||
File createdZipFile = DESTINATION_DIR.resolve(expectedZippedFileName).toFile();
|
File createdZipFile = DESTINATION_DIR.resolve(expectedZippedFileName).toFile();
|
||||||
|
|
||||||
assertThat(zipResult.getFilenames(), hasSize(1));
|
assertThat(zipResult.getFilenames(), hasSize(1));
|
||||||
|
|
@ -92,13 +92,13 @@ class SplitZipWriterTest {
|
||||||
ZipResult zipResult;
|
ZipResult zipResult;
|
||||||
String outputFileName = RandomStringUtils.randomAlphanumeric(10);
|
String outputFileName = RandomStringUtils.randomAlphanumeric(10);
|
||||||
String inputFileName = "singleFileGreaterThanChunkSizeToOneZip.txt";
|
String inputFileName = "singleFileGreaterThanChunkSizeToOneZip.txt";
|
||||||
SplitZipWriter postBoxZipFileWriter = new SplitZipWriter(
|
SplitZipWriter splitZipWriter = new SplitZipWriter(
|
||||||
DESTINATION_DIR, outputFileName, ZIP_CHUNK_SIZE_IN_BYTE, ZIP_BUFFER_SIZE_IN_BYTE, (OutputStream outputStream) -> outputStream);
|
DESTINATION_DIR, outputFileName, ZIP_CHUNK_SIZE_IN_BYTE, ZIP_BUFFER_SIZE_IN_BYTE, (OutputStream outputStream) -> outputStream);
|
||||||
try (postBoxZipFileWriter) {
|
try (splitZipWriter) {
|
||||||
postBoxZipFileWriter.write(new ByteArrayInputStream(fileSimpleContent), inputFileName);
|
splitZipWriter.write(new ByteArrayInputStream(fileSimpleContent), inputFileName);
|
||||||
}
|
}
|
||||||
String expectedZippedFileNamePartOne = outputFileName + "_01.zip";
|
String expectedZippedFileNamePartOne = outputFileName + "_01.zip";
|
||||||
zipResult = postBoxZipFileWriter.getZipResult();
|
zipResult = splitZipWriter.getZipResult();
|
||||||
assertThat(zipResult.getFilenames(), hasSize(1));
|
assertThat(zipResult.getFilenames(), hasSize(1));
|
||||||
assertThat(zipResult.getFileLengths(), hasSize(1));
|
assertThat(zipResult.getFileLengths(), hasSize(1));
|
||||||
assertTrue(zipResult.getFilenames().contains(expectedZippedFileNamePartOne));
|
assertTrue(zipResult.getFilenames().contains(expectedZippedFileNamePartOne));
|
||||||
|
|
@ -125,14 +125,14 @@ class SplitZipWriterTest {
|
||||||
String inputFileNameTwo = "multipleFileSmallerThanChunkSizeToSingleZip2.txt";
|
String inputFileNameTwo = "multipleFileSmallerThanChunkSizeToSingleZip2.txt";
|
||||||
|
|
||||||
ZipResult zipResult;
|
ZipResult zipResult;
|
||||||
SplitZipWriter postBoxZipFileWriter = new SplitZipWriter(
|
SplitZipWriter splitZipWriter = new SplitZipWriter(
|
||||||
DESTINATION_DIR, outputFileName, ZIP_CHUNK_SIZE_IN_BYTE, ZIP_BUFFER_SIZE_IN_BYTE, (OutputStream outputStream) -> outputStream);
|
DESTINATION_DIR, outputFileName, ZIP_CHUNK_SIZE_IN_BYTE, ZIP_BUFFER_SIZE_IN_BYTE, (OutputStream outputStream) -> outputStream);
|
||||||
try (postBoxZipFileWriter) {
|
try (splitZipWriter) {
|
||||||
postBoxZipFileWriter.write(new ByteArrayInputStream(firstFile), inputFileNameOne);
|
splitZipWriter.write(new ByteArrayInputStream(firstFile), inputFileNameOne);
|
||||||
postBoxZipFileWriter.write(new ByteArrayInputStream(secondFile), inputFileNameTwo);
|
splitZipWriter.write(new ByteArrayInputStream(secondFile), inputFileNameTwo);
|
||||||
}
|
}
|
||||||
|
|
||||||
zipResult = postBoxZipFileWriter.getZipResult();
|
zipResult = splitZipWriter.getZipResult();
|
||||||
String expectedZippedFileNamePartOne = outputFileName + "_01.zip";
|
String expectedZippedFileNamePartOne = outputFileName + "_01.zip";
|
||||||
File createdZip = DESTINATION_DIR.resolve(expectedZippedFileNamePartOne).toFile();
|
File createdZip = DESTINATION_DIR.resolve(expectedZippedFileNamePartOne).toFile();
|
||||||
|
|
||||||
|
|
@ -164,13 +164,13 @@ class SplitZipWriterTest {
|
||||||
String inputFileNameTwo = "multipleFilesTogetherGreaterThanChunkSizeToSingleZip2.txt";
|
String inputFileNameTwo = "multipleFilesTogetherGreaterThanChunkSizeToSingleZip2.txt";
|
||||||
|
|
||||||
ZipResult zipResult;
|
ZipResult zipResult;
|
||||||
SplitZipWriter postBoxZipFileWriter = new SplitZipWriter(
|
SplitZipWriter splitZipWriter = new SplitZipWriter(
|
||||||
DESTINATION_DIR, outputFileName, ZIP_CHUNK_SIZE_IN_BYTE, ZIP_BUFFER_SIZE_IN_BYTE, (OutputStream outputStream) -> outputStream);
|
DESTINATION_DIR, outputFileName, ZIP_CHUNK_SIZE_IN_BYTE, ZIP_BUFFER_SIZE_IN_BYTE, (OutputStream outputStream) -> outputStream);
|
||||||
try (postBoxZipFileWriter) {
|
try (splitZipWriter) {
|
||||||
postBoxZipFileWriter.write(new ByteArrayInputStream(firstFile), inputFileNameOne);
|
splitZipWriter.write(new ByteArrayInputStream(firstFile), inputFileNameOne);
|
||||||
postBoxZipFileWriter.write(new ByteArrayInputStream(secondFile), inputFileNameTwo);
|
splitZipWriter.write(new ByteArrayInputStream(secondFile), inputFileNameTwo);
|
||||||
} finally {
|
} finally {
|
||||||
zipResult = postBoxZipFileWriter.getZipResult();
|
zipResult = splitZipWriter.getZipResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
String expectedZippedFileNamePartOne = outputFileName + "_01.zip";
|
String expectedZippedFileNamePartOne = outputFileName + "_01.zip";
|
||||||
|
|
@ -207,14 +207,14 @@ class SplitZipWriterTest {
|
||||||
String[] originalFileNames = {"multipleBigFilesToMultipleZip1.txt", "multipleBigFilesToMultipleZip2.txt", "multipleBigFilesToMultipleZip3.txt"};
|
String[] originalFileNames = {"multipleBigFilesToMultipleZip1.txt", "multipleBigFilesToMultipleZip2.txt", "multipleBigFilesToMultipleZip3.txt"};
|
||||||
String outputFileName = RandomStringUtils.randomAlphanumeric(10);
|
String outputFileName = RandomStringUtils.randomAlphanumeric(10);
|
||||||
|
|
||||||
SplitZipWriter postBoxZipFileWriter = new SplitZipWriter(
|
SplitZipWriter splitZipWriter = new SplitZipWriter(
|
||||||
DESTINATION_DIR, outputFileName, bigChuckSize, bigBufferSize, (OutputStream outputStream) -> outputStream);
|
DESTINATION_DIR, outputFileName, bigChuckSize, bigBufferSize, (OutputStream outputStream) -> outputStream);
|
||||||
try (postBoxZipFileWriter) {
|
try (splitZipWriter) {
|
||||||
postBoxZipFileWriter.write(new ByteArrayInputStream(firstFile), originalFileNames[0]);
|
splitZipWriter.write(new ByteArrayInputStream(firstFile), originalFileNames[0]);
|
||||||
postBoxZipFileWriter.write(new ByteArrayInputStream(secondFile), originalFileNames[1]);
|
splitZipWriter.write(new ByteArrayInputStream(secondFile), originalFileNames[1]);
|
||||||
postBoxZipFileWriter.write(new ByteArrayInputStream(thirdFile), originalFileNames[2]);
|
splitZipWriter.write(new ByteArrayInputStream(thirdFile), originalFileNames[2]);
|
||||||
} finally {
|
} finally {
|
||||||
zipResult = postBoxZipFileWriter.getZipResult();
|
zipResult = splitZipWriter.getZipResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
String expectedZippedFileNamePartOne = outputFileName + "_01.zip";
|
String expectedZippedFileNamePartOne = outputFileName + "_01.zip";
|
||||||
|
|
@ -274,11 +274,11 @@ class SplitZipWriterTest {
|
||||||
String outputFileName = RandomStringUtils.randomAlphanumeric(10);
|
String outputFileName = RandomStringUtils.randomAlphanumeric(10);
|
||||||
|
|
||||||
ZipResult zipResult;
|
ZipResult zipResult;
|
||||||
try (SplitZipWriter postBoxZipFileWriter = new SplitZipWriter(DESTINATION_DIR, outputFileName, 1000, 2048, (OutputStream outputStream) -> outputStream)) {
|
try (SplitZipWriter splitZipWriter = new SplitZipWriter(DESTINATION_DIR, outputFileName, 1000, 2048, (OutputStream outputStream) -> outputStream)) {
|
||||||
postBoxZipFileWriter.write(new ByteArrayInputStream(content1), "file1");
|
splitZipWriter.write(new ByteArrayInputStream(content1), "file1");
|
||||||
postBoxZipFileWriter.write(new ByteArrayInputStream(content2), "file2");
|
splitZipWriter.write(new ByteArrayInputStream(content2), "file2");
|
||||||
postBoxZipFileWriter.write(new ByteArrayInputStream(content3), "file3");
|
splitZipWriter.write(new ByteArrayInputStream(content3), "file3");
|
||||||
zipResult = postBoxZipFileWriter.getZipResult();
|
zipResult = splitZipWriter.getZipResult();
|
||||||
}
|
}
|
||||||
assertThat("compressible files only containing zeroes should be compressed into one file", zipResult.getFileLengths().size(), is(1));
|
assertThat("compressible files only containing zeroes should be compressed into one file", zipResult.getFileLengths().size(), is(1));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue