public void test_newTx_readWrite_02(){
  final MockTransactionService service=newFixture();
  try {
    assertEquals(0,service.getActiveCount());
    assertEquals(0,service.getReadWriteActiveCount());
    assertEquals(0,service.getReadOnlyActiveCount());
    assertNull(service.getEarliestActiveTx());
    final long t0=service.nextTimestamp();
    final long tx=service.newTx(ITx.UNISOLATED);
    final long t1=service.nextTimestamp();
    assertTrue(TimestampUtility.isReadWriteTx(tx));
    assertTrue(Math.abs(tx) > t0);
    assertTrue(Math.abs(tx) < t1);
    assertEquals(1,service.getActiveCount());
    assertEquals(1,service.getReadWriteActiveCount());
    assertEquals(0,service.getReadOnlyActiveCount());
    assertNotNull(service.getEarliestActiveTx());
    assertEquals(tx,service.getEarliestActiveTx().tx);
    final TxState txState=service.getTxState(tx);
{
      assertNotNull(txState);
      assertEquals(tx,txState.tx);
      assertTrue(txState.isActive());
      assertFalse(txState.isReadOnly());
      assertFalse(txState.isPrepared());
      assertFalse(txState.isComplete());
    }
    service.commit(tx);
    assertEquals(0,service.getActiveCount());
    assertEquals(1,service.getStartCount());
    assertEquals(0,service.getAbortCount());
    assertEquals(1,service.getCommitCount());
    assertEquals(0,service.getReadWriteActiveCount());
    assertEquals(0,service.getReadOnlyActiveCount());
    assertNull(service.getEarliestActiveTx());
{
      assertNull(service.getTxState(tx));
      assertFalse(txState.isActive());
      assertFalse(txState.isAborted());
      assertTrue(txState.isCommitted());
      assertFalse(txState.isPrepared());
      assertTrue(txState.isComplete());
    }
  }
  finally {
    service.destroy();
  }
}

public void test_newTx_readWrite_02 ( ) { final MockTransactionService service = newFixture ( ) ; try { assertEquals ( 0 , service . getActiveCount ( ) ) ; assertEquals ( 0 , service . getReadWriteActiveCount ( ) ) ; assertEquals ( 0 , service . getReadOnlyActiveCount ( ) ) ; assertNull ( service . getEarliestActiveTx ( ) ) ; final long t0 = service . nextTimestamp ( ) ; final long tx = service . newTx ( ITx . UNISOLATED ) ; final long t1 = service . nextTimestamp ( ) ; assertTrue ( TimestampUtility . isReadWriteTx ( tx ) ) ; assertTrue ( Math . abs ( tx ) > t0 ) ; assertTrue ( Math . abs ( tx ) < t1 ) ; assertEquals ( 1 , service . getActiveCount ( ) ) ; assertEquals ( 1 , service . getReadWriteActiveCount ( ) ) ; assertEquals ( 0 , service . getReadOnlyActiveCount ( ) ) ; assertNotNull ( service . getEarliestActiveTx ( ) ) ; assertEquals ( tx , service . getEarliestActiveTx ( ) . tx ) ; final TxState txState = service . getTxState ( tx ) ; { assertNotNull ( txState ) ; assertEquals ( tx , txState . tx ) ; assertTrue ( txState . isActive ( ) ) ; assertFalse ( txState . isReadOnly ( ) ) ; assertFalse ( txState . isPrepared ( ) ) ; assertFalse ( txState . isComplete ( ) ) ; } service . commit ( tx ) ; assertEquals ( 0 , service . getActiveCount ( ) ) ; assertEquals ( 1 , service . getStartCount ( ) ) ; assertEquals ( 0 , service . getAbortCount ( ) ) ; assertEquals ( 1 , service . getCommitCount ( ) ) ; assertEquals ( 0 , service . getReadWriteActiveCount ( ) ) ; assertEquals ( 0 , service . getReadOnlyActiveCount ( ) ) ; assertNull ( service . getEarliestActiveTx ( ) ) ; { assertNull ( service . getTxState ( tx ) ) ; assertFalse ( txState . isActive ( ) ) ; assertFalse ( txState . isAborted ( ) ) ; assertTrue ( txState . isCommitted ( ) ) ; assertFalse ( txState . isPrepared ( ) ) ; assertTrue ( txState . isComplete ( ) ) ; } } finally { service . destroy ( ) ; } }
create a new read - write tx and then commit it .
