MySQLClient { public synchronized void connect() { eventLoopGroup = new NioEventLoopGroup(1); responseCallback = new DefaultPromise<>(eventLoopGroup.next()); channel = new Bootstrap() .group(eventLoopGroup) .channel(NioSocketChannel.class) .option(ChannelOption.AUTO_READ, true) .handler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(final SocketChannel socketChannel) { socketChannel.pipeline().addLast(new PacketCodec(new MySQLPacketCodecEngine())); socketChannel.pipeline().addLast(new MySQLCommandPacketDecoder()); socketChannel.pipeline().addLast(new MySQLNegotiateHandler(connectInfo.getUsername(), connectInfo.getPassword(), responseCallback)); socketChannel.pipeline().addLast(new MySQLCommandResponseHandler()); } }).connect(connectInfo.getHost(), connectInfo.getPort()).channel(); serverInfo = waitExpectedResponse(ServerInfo.class); }  synchronized void connect(); synchronized boolean execute(final String queryString); synchronized int executeUpdate(final String queryString); synchronized InternalResultSet executeQuery(final String queryString); synchronized void subscribe(final String binlogFileName, final long binlogPosition); synchronized AbstractBinlogEvent poll();  }
@Test public void assertConnect() throws NoSuchFieldException, IllegalAccessException { ServerInfo expected = new ServerInfo(); mockChannelResponse(expected); mysqlClient.connect(); ServerInfo actual = ReflectionUtil.getFieldValueFromClass(mysqlClient, "serverInfo", ServerInfo.class); assertThat(actual, is(expected)); }