}
@Test
public void stringifyValidTxns() throws Exception {
// Test with just high water mark
ValidTxnList validTxns = new ValidTxnListImpl("1:");
String asString = validTxns.toString();
Assert.assertEquals("1:", asString);
validTxns = new ValidTxnListImpl(asString);
Assert.assertEquals(1, validTxns.getHighWatermark());
Assert.assertNotNull(validTxns.getOpenTransactions());
Assert.assertEquals(0, validTxns.getOpenTransactions().length);
asString = validTxns.toString();
Assert.assertEquals("1:", asString);
validTxns = new ValidTxnListImpl(asString);
Assert.assertEquals(1, validTxns.getHighWatermark());
Assert.assertNotNull(validTxns.getOpenTransactions());
Assert.assertEquals(0, validTxns.getOpenTransactions().length);
// Test with open transactions
validTxns = new ValidTxnListImpl("10:5:3");
asString = validTxns.toString();
if (!asString.equals("10:3:5") && !asString.equals("10:5:3")) {
Assert.fail("Unexpected string value " + asString);
}
validTxns = new ValidTxnListImpl(asString);
Assert.assertEquals(10, validTxns.getHighWatermark());
Assert.assertNotNull(validTxns.getOpenTransactions());
Assert.assertEquals(2, validTxns.getOpenTransactions().length);
boolean sawThree = false, sawFive = false;
for (long tid : validTxns.getOpenTransactions()) {
if (tid == 3) sawThree = true;
else if (tid == 5) sawFive = true;
else Assert.fail("Unexpected value " + tid);
}
Assert.assertTrue(sawThree);