Finished message = new Finished(bytes);
assertEquals("incorrect type", Handshake.FINISHED, message.getType());
assertTrue("incorrect CertificateVerify", Arrays.equals(message
.getData(), bytes));
HandshakeIODataStream out = new HandshakeIODataStream();
message.send(out);
byte[] encoded = out.getData(1000);
assertEquals("incorrect out data length", message.length(),
encoded.length);
HandshakeIODataStream in = new HandshakeIODataStream();
in.append(encoded);
Finished message_2 = new Finished(in, message.length());
assertTrue("incorrect message decoding", Arrays.equals(message
.getData(), message_2.getData()));
in.append(encoded);
try {
message_2 = new Finished(in, message.length() - 1);
fail("Small length: No expected AlertException");
} catch (AlertException e) {
}
in.append(encoded);
in.append(new byte[] { 1, 2, 3 });
try {
message_2 = new Finished(in, message.length() + 3);
fail("Extra bytes: No expected AlertException ");
} catch (AlertException e) {
}