@Test
public void putWithFailureAndCacheValidation() throws Throwable {

    setUpHost(false);
    List<Service> services = this.host.doThroughputServiceStart(
            1, MinimalTestService.class, this.host.buildMinimalTestState(),
            EnumSet.of(Service.ServiceOption.PERSISTENCE), null);
    // Write state that exceeds the default serialization limit and observe exception
    URI uri = services.get(0).getUri();
    MinimalTestServiceState largeBody = new MinimalTestServiceState();
    Random r = new Random();
    byte[] data = new byte[ServiceDocumentDescription.DEFAULT_SERIALIZED_STATE_LIMIT * 2];
    r.nextBytes(data);
    largeBody.id = printBase64Binary(data);
    this.host.testStart(1);
    Operation put = Operation
            .createPut(uri)
            .setBody(largeBody)
            .setCompletion(
                    (o, e) -> {
                        if (e == null) {
                            this.host.failIteration(new IllegalStateException(
                                    "Request should have failed"));
                            return;
                        }
                        ServiceErrorResponse rsp = o.getErrorResponseBody();
                        if (!rsp.message.contains("size limit")) {
                            this.host.failIteration(new IllegalStateException(
                                    "Error message not expected"));
                            return;
                        }
                        this.host.completeIteration();
                    });
    this.host.send(put);
    this.host.testWait();
    this.host.doServiceUpdates(Action.PUT, 1,
            EnumSet.of(TestProperty.LARGE_PAYLOAD, TestProperty.FORCE_FAILURE),
            services);
    Map<URI, MinimalTestServiceState> states = this.host.getServiceState(null,
            MinimalTestServiceState.class, services);
    for (MinimalTestServiceState s : states.values()) {
        if (s.documentVersion > 0) {
            throw new IllegalStateException("version should have not incremented");
        }
    }
}