dbaccess/qa/complex/dbaccess/RowSet.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
New commits: commit 8fde9af18698d85f13294ca0990478b707fc748a Author: Michael Stahl <mst...@redhat.com> Date: Mon Dec 12 23:17:51 2016 +0100 dbaccess: fix testCloneMovesPlusDeletions test JunitTest_dbaccess_complex spuriously fails 1% of the time with: 1) testCloneMovesPlusDeletions(complex.dbaccess.RowSet) java.lang.AssertionError: moving to the next record after |deleteRow| and clone moves failed at complex.dbaccess.RowSet.testCloneMovesPlusDeletions(RowSet.java:756) The problem is that line RowSet.java:750 deleteRow() manages to delete the last row in the set, because the positionRandom() is tricked to position itself on the last row (which it tries not to do), becuase the RowSet is currently positioned past-the-end on a deleted row and the ORowSetBase::impl_getRowCount() is a lying bastard that adds 1 to the result in this special case. Funnily both the ORowSetBase::impl_getRowCount() and the test using positionRandom() were added in CWS rowsetdel. Yay for randomized tests! Change-Id: Ic8c7bfa190f6a5269604cf5b3c338f2d0b64205e (cherry picked from commit ae8bd4267ac2da58f9e476d24e1e894202e92dea) Reviewed-on: https://gerrit.libreoffice.org/32991 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/dbaccess/qa/complex/dbaccess/RowSet.java b/dbaccess/qa/complex/dbaccess/RowSet.java index 2cbf942..e617d25 100644 --- a/dbaccess/qa/complex/dbaccess/RowSet.java +++ b/dbaccess/qa/complex/dbaccess/RowSet.java @@ -528,7 +528,12 @@ public class RowSet extends TestCase */ private int positionRandom() throws SQLException, UnknownPropertyException, WrappedTargetException { - final int position = (new Random()).nextInt(currentRowCount() - 2) + 2; + // note: obviously this should subtract 2 but actually subtract 3 + // because if we have just deleted the current row then + // ORowSetBase::impl_getRowCount() will lie and currentRowCount() + // returns 1 more than the actual number of rows and then + // positionRandom() followed by deleteRow() deletes *last* row + final int position = (new Random()).nextInt(currentRowCount() - 3) + 2; assertTrue("sub task failed: could not position to row no. " + (Integer.valueOf(position)).toString(), m_resultSet.absolute(position)); return m_resultSet.getRow();
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits