@SuppressWarnings("deprecation")
@Test
public void testPacketLength() throws SSLException, NoSuchAlgorithmException {

    SSLEngine engineLE = newEngine();
    SSLEngine engineBE = newEngine();
    ByteBuffer empty = ByteBuffer.allocate(0);
    ByteBuffer cTOsLE = ByteBuffer.allocate(17 * 1024).order(ByteOrder.LITTLE_ENDIAN);
    ByteBuffer cTOsBE = ByteBuffer.allocate(17 * 1024);
    assertTrue(engineLE.wrap(empty, cTOsLE).bytesProduced() > 0);
    cTOsLE.flip();
    assertTrue(engineBE.wrap(empty, cTOsBE).bytesProduced() > 0);
    cTOsBE.flip();
    ByteBuf bufferLE = Unpooled.buffer().order(ByteOrder.LITTLE_ENDIAN).writeBytes(cTOsLE);
    ByteBuf bufferBE = Unpooled.buffer().writeBytes(cTOsBE);
    // Test that the packet-length for BE and LE is the same
    assertEquals(getEncryptedPacketLength(bufferBE, 0), getEncryptedPacketLength(bufferLE, 0));
    assertEquals(getEncryptedPacketLength(new ByteBuffer[] { bufferBE.nioBuffer() }, 0),
            getEncryptedPacketLength(new ByteBuffer[] { bufferLE.nioBuffer().order(ByteOrder.LITTLE_ENDIAN) }, 0));
}