Skip to content
Permalink
Browse files
Fix broken tests.
  • Loading branch information
garydgregory committed May 5, 2022
1 parent d7ac3b0 commit fce2e1ad54caaaa131e6f2f8191be57e1e919b90
Showing 1 changed file with 16 additions and 29 deletions.
@@ -17,6 +17,11 @@
*/
package org.apache.commons.compress.archivers.tar;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -38,10 +43,6 @@
import org.apache.commons.compress.utils.IOUtils;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public class TarFileTest extends AbstractTestCase {

@Test
@@ -144,15 +145,8 @@ public void readsArchiveCompletely_COMPRESS245() {
@Test
public void shouldThrowAnExceptionOnTruncatedEntries() throws Exception {
final File dir = mkdir("COMPRESS-279");
try (final TarFile tarFile = new TarFile(getPath("COMPRESS-279.tar"))) {
int count = 0;
for (final TarArchiveEntry entry : tarFile.getEntries()) {
Files.copy(tarFile.getInputStream(entry), dir.toPath().resolve(String.valueOf(count)));
count++;
}
} finally {
rmdir(dir);
}
assertThrows(IOException.class, () -> new TarFile(getPath("COMPRESS-279.tar")));
rmdir(dir);
}

@Test
@@ -296,38 +290,32 @@ public void testDirectoryWithLongNameEndsWithSlash() throws IOException {

@Test
public void testParseTarWithSpecialPaxHeaders() throws IOException {
try (final TarFile tarFile = new TarFile(getPath("COMPRESS-530.tar"))) {
}
assertThrows(IOException.class, () -> new TarFile(getPath("COMPRESS-530.tar")));
}

@Test
public void testParseTarWithNonNumberPaxHeaders() throws IOException {
try (TarFile tarFile = new TarFile(getPath("COMPRESS-529.tar"))) {
}
assertThrows(IOException.class, () -> new TarFile(getPath("COMPRESS-529.tar")));
}

@Test
public void testParseTarTruncatedInPadding() throws IOException {
try (TarFile tarFile = new TarFile(getPath("COMPRESS-544_truncated_in_padding.tar"))) {
}
public void testParseTarTruncatedInPadding() {
assertThrows(IOException.class, () -> new TarFile(getPath("COMPRESS-544_truncated_in_padding.tar")));
}

@Test
public void testParseTarTruncatedInContent() throws IOException {
try (TarFile tarFile = new TarFile(getPath("COMPRESS-544_truncated_in_content.tar"))) {
}
public void testParseTarTruncatedInContent() {
assertThrows(IOException.class, () -> new TarFile(getPath("COMPRESS-544_truncated_in_content.tar")));
}

@Test
public void testThrowExceptionWithNullEntry() throws IOException {
try (TarFile tarFile = new TarFile(getPath("COMPRESS-554.tar"))) {
}
assertThrows(IOException.class, () -> new TarFile(getPath("COMPRESS-554.tar")));
}

@Test
public void testThrowException() throws IOException {
try (TarFile tarFile = new TarFile(getPath("COMPRESS-553.tar"))) {
}
assertThrows(IOException.class, () -> new TarFile(getPath("COMPRESS-553.tar")));
}

@Test
@@ -358,7 +346,6 @@ public void testCompress558() throws IOException {

@Test
public void rejectsArchivesWithNegativeSizes() throws Exception {
try (TarFile tf = new TarFile(getFile("COMPRESS-569.tar"))) {
}
assertThrows(IOException.class, () -> new TarFile(getFile("COMPRESS-569.tar")));
}
}

0 comments on commit fce2e1a

Please sign in to comment.