IntegerSerializer extends AbstractSerializer<Integer> { @Override public Integer fromBytes(byte[] bytes) { ByteBuffer bb = ByteBuffer.allocate(4).put(bytes, 0, 4); bb.rewind(); return bb.getInt(); }  static IntegerSerializer get(); @Override ByteBuffer toByteBuffer(Integer obj); @Override Integer fromByteBuffer(ByteBuffer byteBuffer); @Override Integer fromBytes(byte[] bytes);  }
@Test public void testFromCassandraAsBytes() { assertEquals(new Integer(1), ext.fromBytes(ByteBufferUtil.bytes(1).array())); assertEquals(new Integer(-1), ext.fromBytes(ByteBufferUtil.bytes(-1).array())); assertEquals(new Integer(0), ext.fromBytes(ByteBufferUtil.bytes(0).array())); assertEquals(new Integer(Integer.MAX_VALUE), ext.fromBytes(ByteBufferUtil.bytes(Integer.MAX_VALUE).array())); assertEquals(new Integer(Integer.MIN_VALUE), ext.fromBytes(ByteBufferUtil.bytes(Integer.MIN_VALUE).array())); }