@Test(expected = IllegalArgumentException.class) public void testReadAndCheckByteBufferFail() { byte[] bytes = new byte[Magic.MAGIC.length]; System.arraycopy(Magic.MAGIC, 0, bytes, 0, Magic.MAGIC.length); bytes[bytes.length - 1] = (byte) (bytes[bytes.length - 1] + 1); Magic.readAndCheckMagic(ByteBuffer.wrap(bytes)); }
public static void readAndCheckMagic(ByteBuffer buf) { byte[] magic = new byte[MAGIC.length]; buf.get(magic); for (int i = 0; i < magic.length; i++) { if (magic[i] != MAGIC[i]) { throw new IllegalArgumentException("Magic number mismatch"); } } }
Magic { public static void readAndCheckMagic(ByteBuffer buf) { byte[] magic = new byte[MAGIC.length]; buf.get(magic); for (int i = 0; i < magic.length; i++) { if (magic[i] != MAGIC[i]) { throw new IllegalArgumentException("Magic number mismatch"); } } } }
Magic { public static void readAndCheckMagic(ByteBuffer buf) { byte[] magic = new byte[MAGIC.length]; buf.get(magic); for (int i = 0; i < magic.length; i++) { if (magic[i] != MAGIC[i]) { throw new IllegalArgumentException("Magic number mismatch"); } } }  }
Magic { public static void readAndCheckMagic(ByteBuffer buf) { byte[] magic = new byte[MAGIC.length]; buf.get(magic); for (int i = 0; i < magic.length; i++) { if (magic[i] != MAGIC[i]) { throw new IllegalArgumentException("Magic number mismatch"); } } }  static void readAndCheckMagic(ByteBuffer buf); static void readAndCheckMagic(ByteBuf buf); static void writeMagic(ByteBuf buf); static int length(); }
Magic { public static void readAndCheckMagic(ByteBuffer buf) { byte[] magic = new byte[MAGIC.length]; buf.get(magic); for (int i = 0; i < magic.length; i++) { if (magic[i] != MAGIC[i]) { throw new IllegalArgumentException("Magic number mismatch"); } } }  static void readAndCheckMagic(ByteBuffer buf); static void readAndCheckMagic(ByteBuf buf); static void writeMagic(ByteBuf buf); static int length();  }