MySQLPacketPayload implements PacketPayload { public long readIntLenenc() { int firstByte = readInt1(); if (firstByte < 0xfb) { return firstByte; } if (0xfb == firstByte) { return 0; } if (0xfc == firstByte) { return readInt2(); } if (0xfd == firstByte) { return readInt3(); } return byteBuf.readLongLE(); }  int readInt1(); void writeInt1(final int value); int readInt2(); void writeInt2(final int value); int readInt3(); void writeInt3(final int value); int readInt4(); void writeInt4(final int value); long readInt6(); void writeInt6(final int value); long readInt8(); void writeInt8(final long value); long readIntLenenc(); void writeIntLenenc(final long value); long readLong(final int length); String readStringLenenc(); byte[] readStringLenencByBytes(); void writeStringLenenc(final String value); void writeBytesLenenc(final byte[] value); String readStringFix(final int length); byte[] readStringFixByBytes(final int length); void writeStringFix(final String value); void writeBytes(final byte[] value); String readStringVar(); void writeStringVar(final String value); String readStringNul(); byte[] readStringNulByBytes(); void writeStringNul(final String value); byte[] readStringEOFByBytes(); String readStringEOF(); void writeStringEOF(final String value); void skipReserved(final int length); void writeReserved(final int length); @Override void close();  }
@Test public void assertReadIntLenencWithOneByte() { when(byteBuf.readUnsignedByte()).thenReturn((short) 1); assertThat(new MySQLPacketPayload(byteBuf).readIntLenenc(), is(1L)); }
@Test public void assertReadIntLenencWithZero() { when(byteBuf.readUnsignedByte()).thenReturn((short) 0xfb); assertThat(new MySQLPacketPayload(byteBuf).readIntLenenc(), is(0L)); }
@Test public void assertReadIntLenencWithTwoBytes() { when(byteBuf.readUnsignedByte()).thenReturn((short) 0xfc); when(byteBuf.readUnsignedShortLE()).thenReturn(100); assertThat(new MySQLPacketPayload(byteBuf).readIntLenenc(), is(100L)); }
@Test public void assertReadIntLenencWithThreeBytes() { when(byteBuf.readUnsignedByte()).thenReturn((short) 0xfd); when(byteBuf.readUnsignedMediumLE()).thenReturn(99999); assertThat(new MySQLPacketPayload(byteBuf).readIntLenenc(), is(99999L)); }
@Test public void assertReadIntLenencWithFourBytes() { when(byteBuf.readUnsignedByte()).thenReturn((short) 0xff); when(byteBuf.readLongLE()).thenReturn(Long.MAX_VALUE); assertThat(new MySQLPacketPayload(byteBuf).readIntLenenc(), is(Long.MAX_VALUE)); }