private void doEscapeTestHelper(
      String data, boolean useBatch, boolean includeInKey, TableRequestOptions options)
      throws StorageException {
    Class1 ref = new Class1();
    ref.setA(data);
    ref.setPartitionKey(includeInKey ? "temp" + data : "temp");
    ref.setRowKey(UUID.randomUUID().toString());

    if (useBatch) {
      TableBatchOperation batch = new TableBatchOperation();
      batch.insert(ref);
      this.table.execute(batch, options, null);
    } else {
      this.table.execute(TableOperation.insert(ref), options, null);
    }

    TableResult res = null;

    if (useBatch) {
      TableBatchOperation batch = new TableBatchOperation();
      batch.retrieve(ref.getPartitionKey(), ref.getRowKey(), Class1.class);
      res = this.table.execute(batch, options, null).get(0);
    } else {
      res =
          this.table.execute(
              TableOperation.retrieve(ref.getPartitionKey(), ref.getRowKey(), Class1.class),
              options,
              null);
    }

    Class1 retObj = res.getResultAsType();
    assertEquals(ref.getA(), retObj.getA());
    assertEquals(ref.getPartitionKey(), retObj.getPartitionKey());

    ref.setEtag(retObj.getEtag());
    ref.setB(data);

    // Merge
    if (useBatch) {
      TableBatchOperation batch = new TableBatchOperation();
      batch.merge(ref);
      this.table.execute(batch, options, null);
    } else {
      this.table.execute(TableOperation.merge(ref), options, null);
    }

    if (useBatch) {
      TableBatchOperation batch = new TableBatchOperation();
      batch.retrieve(ref.getPartitionKey(), ref.getRowKey(), Class1.class);
      res = this.table.execute(batch, options, null).get(0);
    } else {
      res =
          this.table.execute(
              TableOperation.retrieve(ref.getPartitionKey(), ref.getRowKey(), Class1.class),
              options,
              null);
    }

    retObj = res.getResultAsType();
    assertEquals(ref.getA(), retObj.getA());
    assertEquals(ref.getB(), retObj.getB());

    // Replace
    ref.setEtag(retObj.getEtag());
    ref.setC(data);

    if (useBatch) {
      TableBatchOperation batch = new TableBatchOperation();
      batch.replace(ref);
      this.table.execute(batch, options, null);
    } else {
      this.table.execute(TableOperation.replace(ref), options, null);
    }

    if (useBatch) {
      TableBatchOperation batch = new TableBatchOperation();
      batch.retrieve(ref.getPartitionKey(), ref.getRowKey(), Class1.class);
      res = this.table.execute(batch, options, null).get(0);
    } else {
      res =
          this.table.execute(
              TableOperation.retrieve(ref.getPartitionKey(), ref.getRowKey(), Class1.class),
              options,
              null);
    }

    retObj = res.getResultAsType();
    assertEquals(ref.getA(), retObj.getA());
    assertEquals(ref.getB(), retObj.getB());
    assertEquals(ref.getC(), retObj.getC());

    if (useBatch) {
      TableBatchOperation batch = new TableBatchOperation();
      batch.delete(retObj);
      res = this.table.execute(batch, options, null).get(0);
    } else {
      res = this.table.execute(TableOperation.delete(retObj), options, null);
    }
  }