Skip to content
Permalink
Browse files
Continue porting from JUnit 4 to JUnit 5.
  • Loading branch information
garydgregory committed Dec 27, 2021
1 parent 82ac0e1 commit e5a4a4b9f3717588a318e05a7be74e445a052ff1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
@@ -18,6 +18,9 @@
*/
package org.apache.commons.compress.archivers.examples;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
@@ -27,8 +30,6 @@
import java.nio.channels.SeekableByteChannel;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Stream;

import org.apache.commons.compress.AbstractTestCase;
@@ -39,16 +40,9 @@
import org.apache.commons.compress.archivers.ArchiveStreamFactory;
import org.apache.commons.compress.utils.IOUtils;
import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized.Parameters;
import org.junit.runners.Parameterized;

import static java.nio.charset.StandardCharsets.*;

public class ParameterizedArchiverTest extends AbstractTestCase {

@@ -144,14 +138,14 @@ private void verifyContent(final String format) throws IOException, ArchiveExcep
}

private void assertDir(final String expectedName, final ArchiveEntry entry) {
Assert.assertNotNull(expectedName + " does not exists", entry);
assertNotNull(entry, () -> expectedName + " does not exists");
Assert.assertEquals(expectedName + "/", entry.getName());
Assert.assertTrue(expectedName + " is not a directory", entry.isDirectory());
}

private void assertHelloWorld(final String expectedName, final String suffix, final ArchiveEntry entry, final InputStream is)
throws IOException {
Assert.assertNotNull(expectedName + " does not exists", entry);
assertNotNull(entry, () -> expectedName + " does not exists");
Assert.assertEquals(expectedName, entry.getName());
Assert.assertFalse(expectedName + " is a directory", entry.isDirectory());
final byte[] expected = ("Hello, world " + suffix).getBytes(UTF_8);
@@ -18,6 +18,9 @@
*/
package org.apache.commons.compress.archivers.examples;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
@@ -29,14 +32,11 @@
import org.apache.commons.compress.AbstractTestCase;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveException;
import org.apache.commons.compress.archivers.StreamingNotSupportedException;
import org.apache.commons.compress.archivers.sevenz.SevenZFile;
import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static java.nio.charset.StandardCharsets.*;

public class SevenZArchiverTest extends AbstractTestCase {
private File target;

@@ -106,14 +106,14 @@ private void verifyContent() throws IOException {
}

private void assertDir(final String expectedName, final ArchiveEntry entry) {
Assert.assertNotNull(expectedName + " does not exists", entry);
assertNotNull(entry, () -> expectedName + " does not exists");
Assert.assertEquals(expectedName + "/", entry.getName());
Assert.assertTrue(expectedName + " is not a directory", entry.isDirectory());
}

private void assertHelloWorld(final String expectedName, final String suffix, final ArchiveEntry entry, final SevenZFile z)
throws IOException {
Assert.assertNotNull(expectedName + " does not exists", entry);
assertNotNull(entry, () -> expectedName + " does not exists");
Assert.assertEquals(expectedName, entry.getName());
Assert.assertFalse(expectedName + " is a directory", entry.isDirectory());
final byte[] expected = ("Hello, world " + suffix).getBytes(UTF_8);

0 comments on commit e5a4a4b

Please sign in to comment.