WPInputStream extends InputStream { public int readWPShort() throws IOException { int ch1 = in.read(); int ch2 = in.read(); if ((ch1 | ch2) < 0) { throw new EOFException(); } return (ch2 << 8) + (ch1 << 0); } WPInputStream(InputStream in); int readWPShort(); long readWPLong(); byte readWPByte(); void skipWPByte(int numOfBytes); char readWPChar(); String readWPString(int length); String readWPHexString(int numOfBytes); String readWPHex(); int readWP(); @Override int read(); @Override int read(byte[] b); @Override int read(byte[] b, int off, int len); @Override long skip(long n); @Override int available(); @Override void close(); @Override synchronized void mark(int readlimit); @Override synchronized void reset(); @Override boolean markSupported();  }
@Test public void testReadShort() throws Exception { try (WPInputStream wpInputStream = emptyWPStream()) { wpInputStream.readWPShort(); fail("should have thrown EOF"); } catch (EOFException e) { } }