コード例 #1
0
  @Test
  public void testRollbackSavepoint() throws Exception {
    Txn parent = control.beginTransaction(DESTINATION_TABLE);
    TransactionImpl transaction = new TransactionImpl("user", parent, false, control);

    int res = transaction.setSavePoint("first", null);

    Assert.assertEquals("Wrong txn stack size", 2, res);
    transaction.elevate(DESTINATION_TABLE);
    TxnView first = transaction.getTxn();

    res = transaction.setSavePoint("second", null);

    Assert.assertEquals("Wrong txn stack size", 3, res);
    transaction.elevate(DESTINATION_TABLE);
    Txn second = transaction.getTxn();

    // rollback to first, should rollback second
    res = transaction.rollbackToSavePoint("first", null);

    Assert.assertEquals("Wrong txn stack size", 2, res);

    Assert.assertEquals(Txn.State.ROLLEDBACK, first.getState());
    Assert.assertEquals(Txn.State.ROLLEDBACK, second.getState());
  }
コード例 #2
0
  @Test
  public void testReleaseSavepoint() throws Exception {
    Txn parent = control.beginTransaction(DESTINATION_TABLE);
    TransactionImpl transaction = new TransactionImpl("user", parent, false, control);

    int res = transaction.setSavePoint("first", null);

    Assert.assertEquals("Wrong txn stack size", 2, res);
    transaction.elevate(DESTINATION_TABLE);
    TxnView first = transaction.getTxn();

    res = transaction.setSavePoint("second", null);

    Assert.assertEquals("Wrong txn stack size", 3, res);
    transaction.elevate(DESTINATION_TABLE);
    Txn second = transaction.getTxn();

    // release first, should also commit second
    res = transaction.releaseSavePoint("first", null);

    Assert.assertEquals("Wrong txn stack size", 1, res);

    Assert.assertEquals(Txn.State.COMMITTED, first.getState());
    Assert.assertEquals(Txn.State.COMMITTED, second.getState());
  }