public void test_newTx_readWrite_03(){
  final MockTransactionService service=newFixture();
  try {
    assertEquals(0,service.getActiveCount());
    assertEquals(0,service.getReadWriteActiveCount());
    assertEquals(0,service.getReadOnlyActiveCount());
    assertNull(service.getEarliestActiveTx());
    final long tx1=service.newTx(ITx.UNISOLATED);
    assertEquals(tx1,service.getEarliestActiveTx().tx);
    final TxState txState1=service.getTxState(tx1);
{
      assertNotNull(txState1);
      assertEquals(tx1,txState1.tx);
      assertTrue(txState1.isActive());
      assertFalse(txState1.isReadOnly());
      assertFalse(txState1.isPrepared());
      assertFalse(txState1.isComplete());
    }
    final long tx2=service.newTx(ITx.UNISOLATED);
    assertTrue(Math.abs(tx1) < Math.abs(tx2));
    assertEquals(tx1,service.getEarliestActiveTx().tx);
    final TxState txState2=service.getTxState(tx2);
{
      assertNotNull(txState2);
      assertEquals(tx2,txState2.tx);
      assertTrue(txState2.isActive());
      assertFalse(txState2.isReadOnly());
      assertFalse(txState2.isPrepared());
      assertFalse(txState2.isComplete());
    }
    assertEquals(2,service.getActiveCount());
    assertEquals(2,service.getReadWriteActiveCount());
    assertEquals(0,service.getReadOnlyActiveCount());
    service.commit(tx2);
{
      assertNull(service.getTxState(tx2));
      assertFalse(txState2.isActive());
      assertFalse(txState2.isAborted());
      assertTrue(txState2.isCommitted());
      assertFalse(txState2.isPrepared());
      assertTrue(txState2.isComplete());
    }
    assertEquals(1,service.getActiveCount());
    assertEquals(1,service.getReadWriteActiveCount());
    assertEquals(0,service.getReadOnlyActiveCount());
    assertEquals(tx1,service.getEarliestActiveTx().tx);
    service.commit(tx1);
{
      assertNull(service.getTxState(tx1));
      assertFalse(txState1.isActive());
      assertFalse(txState1.isAborted());
      assertTrue(txState1.isCommitted());
      assertFalse(txState1.isPrepared());
      assertTrue(txState1.isComplete());
    }
    assertEquals(0,service.getActiveCount());
    assertEquals(2,service.getStartCount());
    assertEquals(0,service.getAbortCount());
    assertEquals(2,service.getCommitCount());
    assertEquals(0,service.getReadWriteActiveCount());
    assertEquals(0,service.getReadOnlyActiveCount());
    assertNull(service.getEarliestActiveTx());
  }
  finally {
    service.destroy();
  }
}

public void test_newTx_readWrite_03 ( ) { final MockTransactionService service = newFixture ( ) ; try { assertEquals ( 0 , service . getActiveCount ( ) ) ; assertEquals ( 0 , service . getReadWriteActiveCount ( ) ) ; assertEquals ( 0 , service . getReadOnlyActiveCount ( ) ) ; assertNull ( service . getEarliestActiveTx ( ) ) ; final long tx1 = service . newTx ( ITx . UNISOLATED ) ; assertEquals ( tx1 , service . getEarliestActiveTx ( ) . tx ) ; final TxState txState1 = service . getTxState ( tx1 ) ; { assertNotNull ( txState1 ) ; assertEquals ( tx1 , txState1 . tx ) ; assertTrue ( txState1 . isActive ( ) ) ; assertFalse ( txState1 . isReadOnly ( ) ) ; assertFalse ( txState1 . isPrepared ( ) ) ; assertFalse ( txState1 . isComplete ( ) ) ; } final long tx2 = service . newTx ( ITx . UNISOLATED ) ; assertTrue ( Math . abs ( tx1 ) < Math . abs ( tx2 ) ) ; assertEquals ( tx1 , service . getEarliestActiveTx ( ) . tx ) ; final TxState txState2 = service . getTxState ( tx2 ) ; { assertNotNull ( txState2 ) ; assertEquals ( tx2 , txState2 . tx ) ; assertTrue ( txState2 . isActive ( ) ) ; assertFalse ( txState2 . isReadOnly ( ) ) ; assertFalse ( txState2 . isPrepared ( ) ) ; assertFalse ( txState2 . isComplete ( ) ) ; } assertEquals ( 2 , service . getActiveCount ( ) ) ; assertEquals ( 2 , service . getReadWriteActiveCount ( ) ) ; assertEquals ( 0 , service . getReadOnlyActiveCount ( ) ) ; service . commit ( tx2 ) ; { assertNull ( service . getTxState ( tx2 ) ) ; assertFalse ( txState2 . isActive ( ) ) ; assertFalse ( txState2 . isAborted ( ) ) ; assertTrue ( txState2 . isCommitted ( ) ) ; assertFalse ( txState2 . isPrepared ( ) ) ; assertTrue ( txState2 . isComplete ( ) ) ; } assertEquals ( 1 , service . getActiveCount ( ) ) ; assertEquals ( 1 , service . getReadWriteActiveCount ( ) ) ; assertEquals ( 0 , service . getReadOnlyActiveCount ( ) ) ; assertEquals ( tx1 , service . getEarliestActiveTx ( ) . tx ) ; service . commit ( tx1 ) ; { assertNull ( service . getTxState ( tx1 ) ) ; assertFalse ( txState1 . isActive ( ) ) ; assertFalse ( txState1 . isAborted ( ) ) ; assertTrue ( txState1 . isCommitted ( ) ) ; assertFalse ( txState1 . isPrepared ( ) ) ; assertTrue ( txState1 . isComplete ( ) ) ; } assertEquals ( 0 , service . getActiveCount ( ) ) ; assertEquals ( 2 , service . getStartCount ( ) ) ; assertEquals ( 0 , service . getAbortCount ( ) ) ; assertEquals ( 2 , service . getCommitCount ( ) ) ; assertEquals ( 0 , service . getReadWriteActiveCount ( ) ) ; assertEquals ( 0 , service . getReadOnlyActiveCount ( ) ) ; assertNull ( service . getEarliestActiveTx ( ) ) ; } finally { service . destroy ( ) ; } }
create two read - write transactions and commit both .
