    @Test
    public void testPost() throws Throwable {

        final AM am = new AM();
        final String ur = "http://foo.bar:" + server.httpPort() + "/foo";
        client.addActivityMonitor(am);
        final DeferredAssertions assertions = new DeferredAssertions();
        final Set<StateType> stateTypes = new HashSet<>();
        final String[] xheader = new String[1];
        ResponseFuture f = client.post()
                .setURL(ur)
                .addHeader(Headers.CONNECTION, Connection.close)
                .setBody("This is a test", MediaType.PLAIN_TEXT_UTF_8)
                .onEvent(new Receiver<State<?>>() {
                    public void receive(State<?> state) {
                        stateTypes.add(state.stateType());
                        if (null != state.stateType()) switch (state.stateType()) {
                            case Finished:
                                DefaultFullHttpResponse d = (DefaultFullHttpResponse) state.get();
                                assertions.add(() -> {
                                    assertTrue(am.started.contains(ur));
                        }); break;
                            case Closed:
                                assertions.add(() -> {
                                    assertTrue(am.ended.contains(ur));
                        }); break;
                            case FullContentReceived:
                                ByteBuf buf = (ByteBuf) state.get();
                                byte[] bytes = new byte[buf.readableBytes()];
                                buf.getBytes(0, bytes);
                                final String content = new String(bytes, CharsetUtil.UTF_8);
                                assertions.add(() -> {
                                    assertEquals("Hey you, This is a test", content);
                        }); break;
                            case HeadersReceived:
                                xheader[0] = ((HttpResponse) state.get()).headers().get("X-foo");
                                break;
                            default:
                                break;
                        }
                    }
                }).execute();
        f.await(5, TimeUnit.SECONDS).throwIfError();
        server.throwLast();
        assertions.exec();
        assertTrue(stateTypes.contains(StateType.Connected));
        assertTrue(stateTypes.contains(StateType.SendRequest));
        assertTrue(stateTypes.contains(StateType.Connecting));
        assertTrue(stateTypes.contains(StateType.ContentReceived));
        assertTrue(stateTypes.contains(StateType.FullContentReceived));
        assertTrue(stateTypes.contains(StateType.HeadersReceived));
        assertFalse(stateTypes.contains(StateType.Cancelled));
        assertFalse(stateTypes.contains(StateType.Error));
        assertEquals("bar", xheader[0]);
    }