Skip to content

Commit

Permalink
Rename variables and add name to temporary file
Browse files Browse the repository at this point in the history
  • Loading branch information
tdrwenski committed May 23, 2024
1 parent cb9679e commit f597274
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cdm/zarr/src/test/java/thredds/inventory/zarr/TestMFileZip.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ public static List<Integer[]> getTestParameters() {
}

@Parameterized.Parameter(0)
public int expectedSize;
public int entrySize;

@Parameterized.Parameter(1)
public int expectedNumberOfFiles;
public int numberOfEntries;

@Test
public void shouldWriteZipToStream() throws IOException {
try (ZipFile zipFile = createTemporaryZipFile(expectedSize, expectedNumberOfFiles)) {
try (ZipFile zipFile = createTemporaryZipFile("TestWriteZip", entrySize, numberOfEntries)) {
final MFileZip mFile = new MFileZip(zipFile.getName());

final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Expand All @@ -60,15 +60,15 @@ public void shouldWriteZipToStream() throws IOException {
public static class TestMFileZipNonParameterized {
@Test
public void shouldReturnTrueForExistingFile() throws IOException {
try (ZipFile zipFile = createTemporaryZipFile(2, 0)) {
try (ZipFile zipFile = createTemporaryZipFile("TestExists", 2, 0)) {
final MFileZip mFile = new MFileZip(zipFile.getName());
assertThat(mFile.exists()).isEqualTo(true);
}
}

@Test
public void shouldGetLastModified() throws IOException {
try (ZipFile zipFile = createTemporaryZipFile(20, 1)) {
try (ZipFile zipFile = createTemporaryZipFile("TestLastModified", 20, 1)) {
final MFileZip mFile = new MFileZip(zipFile.getName());
assertThat(mFile.getLastModified()).isGreaterThan(0);
assertThat(mFile.getLastModified()).isEqualTo(new File(zipFile.getName()).lastModified());
Expand All @@ -77,7 +77,7 @@ public void shouldGetLastModified() throws IOException {

@Test
public void shouldGetLengthForZipFile() throws IOException {
try (ZipFile zipFile = createTemporaryZipFile(30, 1)) {
try (ZipFile zipFile = createTemporaryZipFile("TestLength", 30, 1)) {
final MFileZip mFile = new MFileZip(zipFile.getName());
assertThat(mFile.getLength()).isGreaterThan(30);
assertThat(mFile.getLength()).isEqualTo(new File(zipFile.getName()).length());
Expand All @@ -94,8 +94,8 @@ public void shouldProvideForZipExtensions() {
}
}

private static ZipFile createTemporaryZipFile(int size, int numberOfFiles) throws IOException {
final File zipFile = tempFolder.newFile("TestMFileZip" + size + "-" + numberOfFiles + ".zip");
private static ZipFile createTemporaryZipFile(String name, int size, int numberOfFiles) throws IOException {
final File zipFile = tempFolder.newFile(name + "-" + size + "-" + numberOfFiles + ".zip");

try (FileOutputStream fos = new FileOutputStream(zipFile.getPath());
ZipOutputStream zipOS = new ZipOutputStream(fos)) {
Expand Down

0 comments on commit f597274

Please sign in to comment.