AkServerUtil { public static int getInt(byte[] bytes, int index) { return (bytes[index] & 0xFF) | (bytes[index + 1] & 0xFF) << 8 | (bytes[index + 2] & 0xFF) << 16 | (bytes[index + 3] & 0xFF) << 24; }  static long getSignedIntegerByWidth(final byte[] bytes, final int index, final int width); static long getUnsignedIntegerByWidth(final byte[] bytes, final int index, final int width); static int putIntegerByWidth(byte[] destination, int destinationIndex, int width, long value); static byte getByte(byte[] bytes, int index); static short getUByte(byte[] bytes, int index); static short getShort(byte[] bytes, int index); static int getUShort(byte[] bytes, int index); static int getMediumInt(byte[] bytes, int index); static int getUMediumInt(byte[] bytes, int index); static int getInt(byte[] bytes, int index); static long getUInt(byte[] bytes, int index); static long getLong(byte[] bytes, int index); static BigInteger getULong(byte[] bytes, int index); static void putByte(byte[] bytes, int index, int value); static void putShort(byte[] bytes, int index, int value); static void putMediumInt(byte[] bytes, int index, int value); static void putInt(byte[] bytes, int index, int value); static void putLong(byte[] bytes, int index, long value); static String dump(byte[] b, int offset, int size); static String hex(byte[] bytes, int start, int length); static StringBuilder hex(StringBuilder sb, long value, int length); static void hex(AkibanAppender sb, byte[] bytes, int start,
            int length); static void printRuntimeInfo(); final static boolean cleanUpDirectory(final File file); final static boolean cleanUpFiles(final File[] files); static String decodeMySQLString(byte[] bytes, final int offset,
            final int width, final FieldDef fieldDef); static ByteSource byteSourceForMySQLString(byte[] bytes, final int offset,
                                                      final int width, final FieldDef fieldDef); static ByteBuffer byteBufferForMySQLString(byte[] bytes, final int offset,
                                           final int width, final FieldDef fieldDef); static int varWidth(final int length); static boolean equals(final Object a, final Object b); static int hashCode(final Object o); final static String NEW_LINE; }
@Test public void getSignedInt() { assertEquals( 0, AkServerUtil.getInt(byteArray(0x00, 0x00, 0x00, 0x00), 0)); assertEquals( 1, AkServerUtil.getInt(byteArray(0x01, 0x00, 0x00, 0x00), 0)); assertEquals( 2147483647, AkServerUtil.getInt(byteArray(0xFF, 0xFF, 0xFF, 0x7F), 0)); assertEquals(-2147483648, AkServerUtil.getInt(byteArray(0x00, 0x00, 0x00, 0x80), 0)); assertEquals( -2, AkServerUtil.getInt(byteArray(0xFE, 0xFF, 0xFF, 0xFF), 0)); assertEquals( -1, AkServerUtil.getInt(byteArray(0xFF, 0xFF, 0xFF, 0xFF), 0)); }