@Test public void testIncorrectProtocolVersion() throws Exception { // Given EmbeddedChannel channel = new EmbeddedChannel(new InitRequestHandler()); InitRequest initRequest = new InitRequest( 42, 1, new HashMap<String, String>() { { put(InitMessage.HOST_PORT_KEY, "0.0.0.0:0"); put(InitMessage.PROCESS_NAME_KEY, "test-process"); } }); channel.writeInbound(initRequest); ErrorMessage error = channel.readOutbound(); assertNotNull(error); assertThat(error.getType(), is(ErrorType.FatalProtocolError)); assertThat(error.getMessage(), containsString("version")); this.expectedClosedChannelException.expect(ClosedChannelException.class); channel.writeOutbound(); }
@Test public void testInvalidCallBeforeInitRequest() throws Exception { // Given EmbeddedChannel channel = new EmbeddedChannel(new InitRequestHandler()); CallRequest callRequest = Fixtures.callRequest(0, false, Unpooled.EMPTY_BUFFER); channel.writeInbound(callRequest); ErrorMessage error = channel.readOutbound(); assertNotNull(error); assertThat(error.getType(), is(ErrorType.FatalProtocolError)); this.expectedClosedChannelException.expect(ClosedChannelException.class); channel.writeOutbound(); }