@Test
public void replicationInMemoryWithOutOfOrderPostAndUpdates() throws Throwable {

    // This test verifies that if a replica receives
    // replication requests of POST and PATCH/PUT
    // out-of-order, for in-memory services, xenon
    // can still handle it.
    setUp(this.nodeCount);
    this.host.joinNodesAndVerifyConvergence(this.host.getPeerCount());
    this.host.setNodeGroupQuorum(this.nodeCount / 2 + 1);
    for (VerificationHost h : this.host.getInProcessHostMap().values()) {
        h.startServiceAndWait(ExampleNonPersistedService.createFactory(),
                ExampleNonPersistedService.FACTORY_LINK, null);
    }
    ExampleServiceState state = new ExampleServiceState();
    state.name = "testing";
    state.counter = 1L;
    VerificationHost peer = this.host.getPeerHost();
    TestContext ctx = this.host.testCreate(this.serviceCount * this.updateCount);
    for (int i = 0; i < this.serviceCount; i++) {
        Operation post = Operation
                .createPost(peer, ExampleNonPersistedService.FACTORY_LINK)
                .setBody(state)
                .setReferer(this.host.getUri())
                .setCompletion((o, e) -> {
                    if (e != null) {
                        ctx.failIteration(e);
                        return;
                    }
                    ExampleServiceState rsp = o.getBody(ExampleServiceState.class);
                    for (int k = 0; k < this.updateCount; k++) {
                        ExampleServiceState update = new ExampleServiceState();
                        state.counter = (long) k;
                        Operation patch = Operation
                                .createPatch(peer, rsp.documentSelfLink)
                                .setBody(update)
                                .setReferer(this.host.getUri())
                                .setCompletion(ctx.getCompletion());
                        this.host.sendRequest(patch);
                    }
                });
        this.host.sendRequest(post);
    }
    ctx.await();
}