This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push:
new b6c6b1e71 Replace assert keyword with JUnit assertions
b6c6b1e71 is described below
commit b6c6b1e71087ae3e31d1024069084512a243eed7
Author: Sebb <[email protected]>
AuthorDate: Wed Jul 24 17:26:31 2024 +0100
Replace assert keyword with JUnit assertions
---
.../archivers/sevenz/SevenZOutputFileTest.java | 27 +++++++++++-----------
.../archivers/tar/TarArchiveEntryTest.java | 2 +-
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git
a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java
b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java
index d2c031974..ce7ceb294 100644
---
a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java
+++
b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java
@@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -338,13 +339,13 @@ public class SevenZOutputFileTest extends AbstractTest {
try (SevenZFile archive = SevenZFile.builder().setFile(output).get()) {
SevenZArchiveEntry entry = archive.getNextEntry();
- assert entry != null;
+ assertNotNull(entry, "Entry should not be null");
assertEquals("foo/", entry.getName());
assertTrue(entry.isDirectory());
assertFalse(entry.isAntiItem());
entry = archive.getNextEntry();
- assert entry != null;
+ assertNotNull(entry, "Entry should not be null");
assertEquals("foo/bar", entry.getName());
assertFalse(entry.isDirectory());
assertFalse(entry.isAntiItem());
@@ -355,7 +356,7 @@ public class SevenZOutputFileTest extends AbstractTest {
assertEquals(creationDate, entry.getCreationDate());
entry = archive.getNextEntry();
- assert entry != null;
+ assertNotNull(entry, "Entry should not be null");
assertEquals("foo/bar/boo0", entry.getName());
assertFalse(entry.isDirectory());
assertFalse(entry.isAntiItem());
@@ -366,7 +367,7 @@ public class SevenZOutputFileTest extends AbstractTest {
assertEquals(creationDate, entry.getCreationDate());
entry = archive.getNextEntry();
- assert entry != null;
+ assertNotNull(entry, "Entry should not be null");
assertEquals("foo/bar/boo1", entry.getName());
assertFalse(entry.isDirectory());
assertFalse(entry.isAntiItem());
@@ -377,7 +378,7 @@ public class SevenZOutputFileTest extends AbstractTest {
assertEquals(creationDate, entry.getCreationDate());
entry = archive.getNextEntry();
- assert entry != null;
+ assertNotNull(entry, "Entry should not be null");
assertEquals("foo/bar/boo10000", entry.getName());
assertFalse(entry.isDirectory());
assertFalse(entry.isAntiItem());
@@ -388,7 +389,7 @@ public class SevenZOutputFileTest extends AbstractTest {
assertEquals(creationDate, entry.getCreationDate());
entry = archive.getNextEntry();
- assert entry != null;
+ assertNotNull(entry, "Entry should not be null");
assertEquals("foo/bar/test.txt", entry.getName());
assertFalse(entry.isDirectory());
assertFalse(entry.isAntiItem());
@@ -399,7 +400,7 @@ public class SevenZOutputFileTest extends AbstractTest {
assertEquals(creationDate, entry.getCreationDate());
entry = archive.getNextEntry();
- assert entry != null;
+ assertNotNull(entry, "Entry should not be null");
assertEquals("xyzzy", entry.getName());
assertEquals(1, entry.getSize());
assertFalse(entry.getHasAccessDate());
@@ -407,19 +408,19 @@ public class SevenZOutputFileTest extends AbstractTest {
assertEquals(0, archive.read());
entry = archive.getNextEntry();
- assert entry != null;
+ assertNotNull(entry, "Entry should not be null");
assertEquals("baz/", entry.getName());
assertTrue(entry.isDirectory());
assertTrue(entry.isAntiItem());
entry = archive.getNextEntry();
- assert entry != null;
+ assertNotNull(entry, "Entry should not be null");
assertEquals("baz2/", entry.getName());
assertTrue(entry.isDirectory());
assertTrue(entry.isAntiItem());
entry = archive.getNextEntry();
- assert entry != null;
+ assertNotNull(entry, "Entry should not be null");
assertEquals("dada", entry.getName());
assertEquals(2, entry.getSize());
final byte[] content = new byte[2];
@@ -428,7 +429,7 @@ public class SevenZOutputFileTest extends AbstractTest {
assertEquals(42, content[1]);
assertEquals(17, entry.getWindowsAttributes());
- assert archive.getNextEntry() == null;
+ assertNull(archive.getNextEntry(), "getNextEntry should return
null");
}
}
@@ -446,12 +447,12 @@ public class SevenZOutputFileTest extends AbstractTest {
try (SevenZFile archive = SevenZFile.builder().setFile(output).get()) {
final SevenZArchiveEntry entry = archive.getNextEntry();
- assert entry != null;
+ assertNotNull(entry, "entry should not be null");
assertEquals("foo/", entry.getName());
assertTrue(entry.isDirectory());
assertFalse(entry.isAntiItem());
- assert archive.getNextEntry() == null;
+ assertNull(archive.getNextEntry(), "getnextEntry should return
null");
}
}
diff --git
a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
index 65f9a3af0..cc831f618 100644
---
a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
+++
b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
@@ -276,7 +276,7 @@ public class TarArchiveEntryTest implements TarConstants {
for (final String name : headerNames) {
for (final String value : testValues) {
final Exception exp =
assertThrows(IllegalArgumentException.class, () -> entry.addPaxHeader(name,
value));
- assert exp.getCause().getMessage().startsWith("Corrupted PAX
header. Time field value is invalid");
+ assertTrue(exp.getCause().getMessage().startsWith("Corrupted
PAX header. Time field value is invalid"));
}
}
}