@Test
  public void testTransactionBatchCommitRegex() throws Exception {
    String regex = "([^,]*),(.*)";
    StrictRegexWriter writer = StrictRegexWriter.newBuilder()
      .withRegex(regex)
      .build();
    HiveStreamingConnection connection = HiveStreamingConnection.newBuilder()
      .withDatabase(dbName)
      .withTable(tblName)
      .withStaticPartitionValues(partitionVals)
      .withAgentInfo("UT_" + Thread.currentThread().getName())
      .withHiveConf(conf)
      .withRecordWriter(writer)
      .withTransactionBatchSize(10)
      .connect();

    // 1st Txn
    connection.beginTransaction();
    Assert.assertEquals(HiveStreamingConnection.TxnState.OPEN,
        connection.getCurrentTransactionState());
    connection.write("1,Hello streaming".getBytes());
    connection.commitTransaction();

    checkDataWritten(partLoc, 1, 10, 1, 1, "{1, Hello streaming}");

    Assert.assertEquals(HiveStreamingConnection.TxnState.COMMITTED,
        connection.getCurrentTransactionState());

    // 2nd Txn
    connection.beginTransaction();
    Assert.assertEquals(HiveStreamingConnection.TxnState.OPEN,
        connection.getCurrentTransactionState());
    connection.write("2,Welcome to streaming".getBytes());

    // data should not be visible
    checkDataWritten(partLoc, 1, 10, 1, 1, "{1, Hello streaming}");

    connection.commitTransaction();

    checkDataWritten(partLoc, 1, 10, 1, 1, "{1, Hello streaming}",
      "{2, Welcome to streaming}");

    connection.close();
    Assert.assertEquals(HiveStreamingConnection.TxnState.INACTIVE,
        connection.getCurrentTransactionState());

    // To Unpartitioned table
    regex = "([^:]*):(.*)";
    writer = StrictRegexWriter.newBuilder()
      .withRegex(regex)
      .build();

    connection = HiveStreamingConnection.newBuilder()
      .withDatabase(dbName2)
      .withTable(tblName2)
      .withAgentInfo("UT_" + Thread.currentThread().getName())
      .withHiveConf(conf)
      .withRecordWriter(writer)
      .connect();

    // 1st Txn
    connection.beginTransaction();
    Assert.assertEquals(HiveStreamingConnection.TxnState.OPEN,
        connection.getCurrentTransactionState());
    connection.write("1:Hello streaming".getBytes());
    connection.commitTransaction();

    Assert.assertEquals(HiveStreamingConnection.TxnState.COMMITTED,
        connection.getCurrentTransactionState());
    connection.close();
  }
check that transactions that have not heartbeated and timedout get properly aborted

@throws Exception
streaming/src/test/org/apache/hive/streaming/TestStreaming.java