Uploaded image for project: 'GeoTools'
  1. GeoTools
  2. GEOT-5603

Intermittent build failure with UnfinishedStubbingException in JDBCTransactionStateTest

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: 17-beta
    • Fix Version/s: 15.4, 16.1, 17-beta
    • Component/s: jdbc
    • Labels:
      None
    • Environment:

      Description

      JDBCTransactionStateTest fails intermittently with a mockito UnfinishedStubbingException.

      I can repeat this failure on OpenJDK in Maven and Eclipse by running all the tests for the module.

      Running all tests in modules/library/jdbc failed 69/100 times:

      count=0; for n in `seq 100`; do if ! mvn -o test; then ((count++)); fi; done; echo "n = $n, count = $count"
      

      Running just the affected test has 0/100 failures:

      count=0; for n in `seq 100`; do if ! mvn -o -Dtest=JDBCTransactionStateTest test; then ((count++)); fi; done; echo "n = $n, count = $count"
      

      See also reports:
      http://osgeo-org.1560.x6.nabble.com/JDBC-Transaction-mock-test-keeps-on-failing-on-Travis-td5296780.html

      ------------------------------------------------------------------------------
      Test set: org.geotools.jdbc.JDBCTransactionStateTest
      -------------------------------------------------------------------------------
      Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.063 sec <<< FAILURE! - in org.geotools.jdbc.JDBCTransactionStateTest
      testSetTransactionNullWithInternalConnection(org.geotools.jdbc.JDBCTransactionStateTest)  Time elapsed: 0.027 sec  <<< ERROR!
      org.mockito.exceptions.misusing.UnfinishedStubbingException: 
      Unfinished stubbing detected here:
      -> at org.geotools.jdbc.JDBCTransactionStateTest.setupLogHandler(JDBCTransactionStateTest.java:64)
      
      E.g. thenReturn() may be missing.
      Examples of correct stubbing:
          when(mock.isOk()).thenReturn(true);
          when(mock.isOk()).thenThrow(exception);
          doThrow(exception).when(mock).someVoidMethod();
      Hints:
       1. missing thenReturn()
       2. although stubbed methods may return mocks, you cannot inline mock creation (mock()) call inside a thenReturn method (see issue 53)
      
      	at org.geotools.jdbc.JDBCTransactionStateTest.setupLogHandler(JDBCTransactionStateTest.java:73)
      

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                bencaradocdavies Ben Caradoc-Davies
                Reporter:
                bencaradocdavies Ben Caradoc-Davies
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: