@Test void testReadAvailableBytes_with_null() throws Exception { assertThrows(NullPointerException.class, () -> { StreamUtil.readAvailableBytes(null); }); }
@Test void testReadAvailableBytes_with_inputstream() throws Exception { final byte[] input = "jodd".getBytes(); final int expected_length = 4; final byte[] expected_array = new byte[]{106,111,100,100}; final byte[] actual = StreamUtil.readAvailableBytes(new ByteArrayInputStream(input)); // asserts assertNotNull(actual); assertEquals(expected_length, actual.length); assertArrayEquals(expected_array, actual); }
@Test void testReadAvailableBytes_with_inputstream_from_empty_byte_arry() throws Exception { final byte[] input = new byte[]{}; final int expected_length = 0; final byte[] expected_array = new byte[]{}; final byte[] actual = StreamUtil.readAvailableBytes(new ByteArrayInputStream(input)); // asserts assertNotNull(actual); assertEquals(expected_length, actual.length); assertArrayEquals(expected_array, actual); }