From 28506a9bf97faeee6ab82361b0ae0f1531a753ef Mon Sep 17 00:00:00 2001 From: Kai Morich Date: Mon, 19 Feb 2024 07:24:30 +0100 Subject: [PATCH] assert warning cleanup --- .../hoho/android/usbserial/DeviceTest.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/usbSerialForAndroid/src/androidTest/java/com/hoho/android/usbserial/DeviceTest.java b/usbSerialForAndroid/src/androidTest/java/com/hoho/android/usbserial/DeviceTest.java index ca50ec7e..28273425 100644 --- a/usbSerialForAndroid/src/androidTest/java/com/hoho/android/usbserial/DeviceTest.java +++ b/usbSerialForAndroid/src/androidTest/java/com/hoho/android/usbserial/DeviceTest.java @@ -44,7 +44,6 @@ import org.junit.After; import org.junit.AfterClass; -import org.junit.Assert; import org.junit.Assume; import org.junit.Before; import org.junit.BeforeClass; @@ -66,13 +65,13 @@ import java.util.concurrent.TimeUnit; import static org.hamcrest.CoreMatchers.anyOf; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -1059,16 +1058,16 @@ public void readBufferSize() throws Exception { telnet.write("1aaa".getBytes()); data = usb.read(4); - Assert.assertThat(data, equalTo("1aaa".getBytes())); + assertThat(data, equalTo("1aaa".getBytes())); telnet.write(new byte[16]); try { data = usb.read(16); if (usb.serialDriver instanceof Cp21xxSerialDriver && usb.serialDriver.getPorts().size() == 1) - Assert.assertNotEquals(0, data.length); // can be shorter or full length + assertNotEquals(0, data.length); // can be shorter or full length else if (usb.serialDriver instanceof ProlificSerialDriver) - Assert.assertTrue("expected > 0 and < 16 byte, got " + data.length, data.length > 0 && data.length < 16); + assertTrue("expected > 0 and < 16 byte, got " + data.length, data.length > 0 && data.length < 16); else // ftdi, ch340, cp2105 - Assert.assertEquals(0, data.length); + assertEquals(0, data.length); } catch (IOException ignored) { } if (purge) { @@ -1105,18 +1104,18 @@ else if (usb.serialDriver instanceof ProlificSerialDriver) telnet.write("2aaa".getBytes()); data = usb.read(4, 8); - Assert.assertThat(data, equalTo("2aaa".getBytes())); + assertThat(data, equalTo("2aaa".getBytes())); telnet.write(new byte[16]); data = usb.read(16, 8); if (usb.serialDriver instanceof Cp21xxSerialDriver && usb.serialDriver.getPorts().size() == 1) - Assert.assertNotEquals(0, data.length); // can be shorter or full length + assertNotEquals(0, data.length); // can be shorter or full length else if (usb.serialDriver instanceof ProlificSerialDriver) - Assert.assertTrue("sporadic issue! expected > 0 and < 16 byte, got " + data.length, data.length > 0 && data.length < 16); + assertTrue("sporadic issue! expected > 0 and < 16 byte, got " + data.length, data.length > 0 && data.length < 16); else // ftdi, ch340, cp2105 - Assert.assertEquals(0, data.length); + assertEquals(0, data.length); telnet.write("2ccc".getBytes()); data = usb.read(4); - // Assert.assertThat(data, equalTo("1ccc".getBytes())); // unpredictable here. typically '2ccc' but sometimes '' or byte[16] + // assertThat(data, equalTo("1ccc".getBytes())); // unpredictable here. typically '2ccc' but sometimes '' or byte[16] if(data.length != 4) { if (purge) { usb.serialPort.purgeHwBuffers(true, true);