コード例 #1
0
  @Test
  public void testSavepointsAreActive() 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);

    Txn parent2 = control.beginTransaction();

    long[] ids = txnStore.getActiveTransactionIds(parent2, DESTINATION_TABLE);
    Assert.assertEquals("Incorrect size", 2, ids.length);
    Assert.assertArrayEquals(
        "Incorrect values", new long[] {parent.getTxnId(), transaction.getTxn().getTxnId()}, ids);

    res = transaction.rollbackToSavePoint("first", null);

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

    ids = txnStore.getActiveTransactionIds(parent2, DESTINATION_TABLE);
    Assert.assertEquals("Incorrect size", 1, ids.length);
    Assert.assertArrayEquals("Incorrect values", new long[] {parent.getTxnId()}, ids);
  }