Package org.apache.harmony.xnet.provider.jsse

Examples of org.apache.harmony.xnet.provider.jsse.Finished


*/
public class FinishedTest extends TestCase {

    public void testFinished() throws Exception {
        byte[] bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2 };
        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) {
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.harmony.xnet.provider.jsse.Finished

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.