LittleEndianDataInput implements DataInput { @Override public final void readFully(final byte b[]) throws IOException { readFully(b, 0, b.length); } LittleEndianDataInput(final InputStream in); @Override final int readUnsignedShort(); final long readUnsignedInt(); @Override final boolean readBoolean(); @Override final byte readByte(); @Override final int readUnsignedByte(); @Override final short readShort(); @Override final char readChar(); @Override final int readInt(); @Override final long readLong(); @Override final float readFloat(); @Override final double readDouble(); @Override final void readFully(final byte b[]); @Override final void readFully(final byte b[], final int off, final int len); @Override final int skipBytes(final int n); @Override final String readLine(); @Override final String readUTF(); final void close(); final int available(); public int CHAR_SIZE; }
@Test public void testReadFully1() throws Exception { in.addBytesAvailable(11111); littleEndien.readFully(array); }
@Test public void testReadFully2() throws Exception { in.addBytesAvailable(11240); littleEndien.readFully(array, 0, 4); }
@Test public void testReadFully3() throws Exception { array = new byte[30003]; final Thread testThread = new Thread(() -> { try { littleEndien.readFully(array); } catch (final IOException e) { e.printStackTrace(); fail("ioexception"); } }); testThread.start(); in.addBytesAvailable(10000); assertTrue("still alive", testThread.isAlive()); Thread.sleep(6); in.addBytesAvailable(10001); assertTrue("still alive", testThread.isAlive()); in.addBytesAvailable(10002); testThread.join(); }
@Test(expected = EOFException.class) public void testReadFully4() throws Exception { in.setEof(true); littleEndien.readFully(array); }