out.addComponent(msg);
out.writerIndex(out.writerIndex() + msg.readableBytes());
}
InputStream is = new ByteBufInputStream(out);
LzmaInputStream lzmaIs = new LzmaInputStream(is, new Decoder());
byte[] uncompressed = new byte[length];
int remaining = length;
while (remaining > 0) {
int read = lzmaIs.read(uncompressed, length - remaining, remaining);
if (read > 0) {
remaining -= read;
} else {
break;
}
}
assertEquals(0, is.available());
assertEquals(-1, is.read());
assertEquals(-1, lzmaIs.read());
is.close();
lzmaIs.close();
out.release();
return uncompressed;
}