final Channel ch = b.connect(uri.getHost(), uri.getPort()).sync().channel();
handler.handshakeFuture().sync();
final String uaid = UUIDUtil.newUAID();
final String json = JsonUtil.toJson(new HelloMessageImpl(uaid.toString()));
final ChannelFuture future = ch.writeAndFlush(new TextWebSocketFrame(json));
future.sync();
final TextWebSocketFrame textFrame = handler.getTextFrame();
final HelloResponse fromJson = JsonUtil.fromJson(textFrame.text(), HelloResponseImpl.class);
assertThat(fromJson.getMessageType(), equalTo(MessageType.Type.HELLO));
assertThat(fromJson.getUAID(), equalTo(uaid));
textFrame.release();
final String channelId = UUID.randomUUID().toString();
final String register = JsonUtil.toJson(new RegisterMessageImpl(channelId));
final ChannelFuture registerFuture = ch.writeAndFlush(new TextWebSocketFrame(register));
registerFuture.sync();
final TextWebSocketFrame registerFrame = handler.getTextFrame();
final RegisterResponseImpl registerResponse = JsonUtil.fromJson(registerFrame.text(), RegisterResponseImpl.class);
assertThat(registerResponse.getMessageType(), equalTo(MessageType.Type.REGISTER));
assertThat(registerResponse.getChannelId(), equalTo(channelId));
ch.writeAndFlush(new CloseWebSocketFrame());