/*
* Class under test for int engineDoFinal(ByteBuffer, ByteBuffer)
*/
public void testEngineDoFinalByteBufferByteBuffer() throws Exception {
NullCipherSpi spi = new NullCipherSpi();
byte[] b = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
ByteBuffer inbuf = ByteBuffer.wrap(b,0,b.length);
ByteBuffer outbuf = ByteBuffer.allocate(6);
try {
spi.engineDoFinal(null, outbuf);
fail("No expected NullPointerException");
} catch (NullPointerException e) {
}
try {
spi.engineDoFinal(inbuf, null);
fail("No expected NullPointerException");
} catch (NullPointerException e) {
}
inbuf.get();
inbuf.get();
inbuf.get();
inbuf.get();
int result = spi.engineDoFinal(inbuf, outbuf);
assertEquals("incorrect result", b.length - 4, result);
for (int i = 0; i < result; i++) {
assertEquals("incorrect outbuf", i + 4, outbuf.get(i));
}
inbuf = ByteBuffer.wrap(b,0,b.length);
outbuf = ByteBuffer.allocate(5);
inbuf.get();
inbuf.get();
inbuf.get();
inbuf.get();
try {
spi.engineDoFinal(inbuf, outbuf);
fail("No expected ShortBufferException");
} catch (ShortBufferException e) {
}
}