Skip to content

Commit 1e84a77

Browse files
committed
Better JUnit API usage
1 parent d3b9984 commit 1e84a77

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/test/java/org/apache/commons/io/input/UnsynchronizedBufferedInputStreamTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected void tearDown() throws IOException {
8888
*/
8989
@Test
9090
public void test_available() throws IOException {
91-
assertTrue(is.available() == DATA.length(), "Returned incorrect number of available bytes");
91+
assertEquals(DATA.length(), is.available(), "Returned incorrect number of available bytes");
9292

9393
// Test that a closed stream throws an IOE for available()
9494
final BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(new byte[] { 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd' }));
@@ -272,7 +272,7 @@ public void test_markSupported() {
272272
public void test_read() throws IOException {
273273
final InputStreamReader isr = new InputStreamReader(is);
274274
final int c = isr.read();
275-
assertTrue(c == DATA.charAt(0), "read returned incorrect char");
275+
assertEquals(DATA.charAt(0), c, "read returned incorrect char");
276276

277277
final byte[] bytes = new byte[256];
278278
for (int i = 0; i < 256; i++) {
@@ -333,7 +333,7 @@ public int read(final byte[] buf, final int off, final int len) throws IOExcepti
333333
})) {
334334
bufin.read();
335335
final int result = bufin.read(new byte[2], 0, 2);
336-
assertTrue(result == 1, () -> "Incorrect result: " + result);
336+
assertEquals(1, result, () -> "Incorrect result: " + result);
337337
}
338338
}
339339

src/test/java/org/apache/commons/io/input/UnsynchronizedFilterInputStreamTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.apache.commons.io.input;
22

3+
import static org.junit.jupiter.api.Assertions.assertEquals;
34
import static org.junit.jupiter.api.Assertions.assertThrows;
45
import static org.junit.jupiter.api.Assertions.assertTrue;
56

@@ -79,7 +80,7 @@ protected void tearDown() throws IOException {
7980
*/
8081
@Test
8182
public void test_available() throws IOException {
82-
assertTrue(is.available() == DATA.length(), "Returned incorrect number of available bytes");
83+
assertEquals(DATA.length(), is.available(), "Returned incorrect number of available bytes");
8384
}
8485

8586
/**
@@ -117,7 +118,7 @@ public void test_markSupported() {
117118
@Test
118119
public void test_read() throws IOException {
119120
final int c = is.read();
120-
assertTrue(c == DATA.charAt(0), "read returned incorrect char");
121+
assertEquals(DATA.charAt(0), c, "read returned incorrect char");
121122
}
122123

123124
/**

src/test/java/org/apache/commons/io/test/TestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private static void assertEqualContent(final File f0, final File f1)
132132
while (-1 != n0) {
133133
n0 = is0.read(buf0);
134134
n1 = is1.read(buf1);
135-
assertTrue(n0 == n1,
135+
assertEquals(n0, n1,
136136
"The files " + f0 + " and " + f1 +
137137
" have differing number of bytes available (" + n0 + " vs " + n1 + ")");
138138

0 commit comments

Comments
 (0)