// Clear out updates table
Result result = connection.executeUpdate("DELETE FROM updates").get();
assertNotNull(result);
// Make sure updates is empty
ResultSet rs = connection.executeQuery("SELECT id FROM updates").get();
assertNotNull(rs);
assertEquals(rs.size(), 0);
connection.beginTransaction();
// Insert a row
result = connection.executeUpdate("INSERT INTO updates (id) VALUES (1)").get();
assertNotNull(result);
assertEquals(result.getAffectedRows(), Long.valueOf(1));
// Make sure we can select the row
rs = connection.executeQuery("SELECT id FROM updates").get();
assertNotNull(rs);
assertEquals(rs.size(), 1);
Value value = rs.get(0).get(0);
assertEquals(value.getInt(), 1);
// Rollback transaction
connection.rollback().get();
// select query should now be empty
rs = connection.executeQuery("SELECT id FROM updates").get();
assertNotNull(rs);
assertEquals(rs.size(), 0);
} finally {
connection.close(true);
}
}