@Test
public void duplicateFactoryPostWithInitialFailure() throws Throwable {

    MinimalFactoryTestService factory = (MinimalFactoryTestService) this.host
            .startServiceAndWait(
                    MinimalFactoryTestService.class, UUID.randomUUID().toString());
    URI factoryUri = factory.getUri();
    // issue a request that should fail in handleStart()
    String selfLink = UUID.randomUUID().toString();
    this.host.testStart(1);
    MinimalTestServiceState initialState = (MinimalTestServiceState) this.host
            .buildMinimalTestState();
    initialState.id = null;
    initialState.documentSelfLink = selfLink;
    Operation post = Operation
            .createPost(factoryUri)
            .setBody(initialState)
            .setCompletion(this.host.getExpectedFailureCompletion());
    this.host.send(post);
    this.host.testWait();
    // verify GET to the service fails
    this.host.testStart(1);
    this.host.send(Operation.createGet(UriUtils.extendUri(factoryUri, selfLink)).setCompletion(
            this.host.getExpectedFailureCompletion()));
    this.host.testWait();
    // now post again, this time, it should succeed
    this.host.testStart(1);
    initialState = (MinimalTestServiceState) this.host.buildMinimalTestState();
    initialState.documentSelfLink = selfLink;
    post.setBody(initialState).setCompletion(this.host.getCompletion());
    this.host.send(post);
    this.host.testWait();
}