@Override
  public void testLocksOnPutKeyVal() throws Exception {
    LockTestData tl = lockTestData;
    Cache<String, String> cache = tl.cache;
    DummyTransactionManager tm = (DummyTransactionManager) tl.tm;
    tm.begin();
    cache.put("k", "v");
    tm.getTransaction().runPrepare();
    assertLocked("k");
    tm.getTransaction().runCommit(false);
    tm.suspend();

    assertNoLocks();

    tm.begin();
    assertEquals(cache.get("k"), "v");

    assertNotLocked("k");
    tm.commit();

    assertNoLocks();

    tm.begin();
    cache.remove("k");
    tm.getTransaction().runPrepare();
    assertLocked("k");
    tm.getTransaction().runCommit(false);

    assertNoLocks();
  }
 /**
  * Get the systemwide used TransactionManager
  *
  * @return TransactionManager
  */
 public TransactionManager getTransactionManager() {
   if (!lookupDone) doLookups();
   if (tm != null) return tm;
   if (lookupFailed) {
     // fall back to a dummy from Infinispan
     tm = DummyTransactionManager.getInstance();
     log.warn("Falling back to DummyTransactionManager from Infinispan");
   }
   return tm;
 }
  protected void doTest(final SplitMode splitMode, boolean txFail, boolean discard)
      throws Exception {
    waitForClusterToForm(OPTIMISTIC_TX_CACHE_NAME);

    final KeyInfo keyInfo = createKeys(OPTIMISTIC_TX_CACHE_NAME);
    final Cache<Object, String> originator = cache(0, OPTIMISTIC_TX_CACHE_NAME);
    final FilterCollection filterCollection =
        createFilters(OPTIMISTIC_TX_CACHE_NAME, discard, getCommandClass(), splitMode);

    Future<Void> put =
        fork(
            () -> {
              final DummyTransactionManager transactionManager =
                  (DummyTransactionManager) originator.getAdvancedCache().getTransactionManager();
              transactionManager.begin();
              keyInfo.putFinalValue(originator);
              final DummyTransaction transaction = transactionManager.getTransaction();
              transaction.runPrepare();
              transaction.runCommit(forceRollback());
              transaction.throwRollbackExceptionIfAny();
              return null;
            });

    filterCollection.await(30, TimeUnit.SECONDS);
    splitMode.split(this);
    filterCollection.unblock();

    try {
      put.get();
      assertFalse(txFail);
    } catch (ExecutionException e) {
      assertTrue(txFail);
    }

    checkLocksDuringPartition(splitMode, keyInfo, discard);

    mergeCluster(OPTIMISTIC_TX_CACHE_NAME);
    finalAsserts(OPTIMISTIC_TX_CACHE_NAME, keyInfo, txFail ? INITIAL_VALUE : FINAL_VALUE);
  }