Example usage for io.netty.handler.ssl SslHandshakeCompletionEvent SslHandshakeCompletionEvent

List of usage examples for io.netty.handler.ssl SslHandshakeCompletionEvent SslHandshakeCompletionEvent

Introduction

In this page you can find the example usage for io.netty.handler.ssl SslHandshakeCompletionEvent SslHandshakeCompletionEvent.

Prototype

public SslHandshakeCompletionEvent(Throwable cause) 

Source Link

Document

Creates a new event that indicates an unsuccessful handshake.

Usage

From source file:io.grpc.netty.ProtocolNegotiatorsTest.java

License:Apache License

@Test
public void tlsHandler_userEventTriggeredSslEvent_handshakeFailure() throws Exception {
    ChannelHandler handler = new ServerTlsHandler(grpcHandler, sslContext);
    pipeline.addLast(handler);//from   w  ww .j  a  va  2s. c o m
    channelHandlerCtx = pipeline.context(handler);
    Object sslEvent = new SslHandshakeCompletionEvent(new RuntimeException("bad"));

    final AtomicReference<Throwable> error = new AtomicReference<>();
    ChannelHandler errorCapture = new ChannelInboundHandlerAdapter() {
        @Override
        public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
            error.set(cause);
        }
    };

    pipeline.addLast(errorCapture);

    pipeline.fireUserEventTriggered(sslEvent);

    // No h2 protocol was specified, so there should be an error, (normally handled by WBAEH)
    assertThat(error.get()).hasMessageThat().contains("bad");
    ChannelHandlerContext grpcHandlerCtx = pipeline.context(grpcHandler);
    assertNull(grpcHandlerCtx);
}