@Test
public void synchronizationCollisionWithPosts() throws Throwable {

    // POST requests go through the FactoryService
    // and do not get queued with Synchronization
    // requests, so if synchronization was running
    // while POSTs were happening for the same factory
    // service, we could run into collisions. This test
    // verifies that xenon handles such collisions and
    // POST requests are always successful.
    // Join the nodes with full quorum and wait for nodes to
    // converge and synchronization to complete.
    setUp(this.nodeCount);
    this.host.joinNodesAndVerifyConvergence(this.host.getPeerCount());
    this.host.setNodeGroupQuorum(this.nodeCount);
    this.host.waitForNodeGroupConvergence(this.nodeCount);
    // Find the owner node for /core/examples. We will
    // use it to start on-demand synchronization for
    // this factory
    URI factoryUri = UriUtils.buildUri(this.host.getPeerHost(), ExampleService.FACTORY_LINK);
    waitForReplicatedFactoryServiceAvailable(factoryUri, this.replicationNodeSelector);
    String taskPath = UriUtils.buildUriPath(
            SynchronizationTaskService.FACTORY_LINK,
            UriUtils.convertPathCharsFromLink(ExampleService.FACTORY_LINK));
    VerificationHost owner = this.host.getOwnerPeer(ExampleService.FACTORY_LINK);
    this.host.log(Level.INFO, "Owner of synch-task is %s", owner.getId());
    // Get the membershipUpdateTimeMicros so that we can
    // kick-off the synch-task on-demand.
    URI taskUri = UriUtils.buildUri(owner, taskPath);
    SynchronizationTaskService.State taskState = this.host.getServiceState(
            null, SynchronizationTaskService.State.class, taskUri);
    long membershipUpdateTimeMicros = taskState.membershipUpdateTimeMicros;
    // Start posting and in the middle also start
    // synchronization. All POSTs should succeed!
    ExampleServiceState state = new ExampleServiceState();
    state.name = "testing";
    TestContext ctx = this.host.testCreate(this.serviceCount * 10);
    for (int i = 0; i < this.serviceCount * 10; i++) {
        if (i == 5) {
            startSynchronizationTaskAndWait(owner,
                    ExampleService.FACTORY_LINK, ExampleServiceState.class, membershipUpdateTimeMicros + 1);
        }
        Operation post = Operation
                .createPost(factoryUri)
                .setBody(state)
                .setReferer(this.host.getUri())
                .setCompletion(ctx.getCompletion());
        this.host.sendRequest(post);
    }
    ctx.await();
}