Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-7048

Unit tests should not fail if JAVA_HOME set incorrectly

    XMLWordPrintableJSON

Details

    Description

      A number of users have had difficulty recently where SSLContextFactoryTest will fail due to an issue locating the JDK default cacerts truststore. This is usually caused by JAVA_HOME being improperly set. However, this issue was not present before the effort to support Java 11. During that time, the directory structure for Java <=8 and Java >=9 has changed, so there is logic to attempt to detect the version and build the correct path.

      Two improvements should be made:
      1. The tests should include an Assume statement to skip execution if cacerts cannot be located
      1. A clear error message (including the current value of JAVA_HOME) should be printed explaining the issue and providing instructions on how to resolve it

      Example failing output:

      Some notes - I did run into a test failure (that I didn't have before) but
      it was because JAVA_HOME was not set properly. I copy the error in case it
      happens to someone else. This is on recently added tests:
      
      [ERROR] Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed:
      0.666 s <<< FAILURE! - in org.apache.nifi.io.socket.SSLContextFactoryTest
      [ERROR]
      testShouldVerifyKeystoreWithEmptyKeyPassword(org.apache.nifi.io.socket.SSLContextFactoryTest)
      Time elapsed: 0.051 s  <<< ERROR!
      java.io.FileNotFoundException: null/jre/lib/security/cacerts (No such file
      or directory)
      at
      org.apache.nifi.io.socket.SSLContextFactoryTest.testShouldVerifyKeystoreWithEmptyKeyPassword(SSLContextFactoryTest.groovy:162)
      [ERROR]
      testShouldVerifyKeystoreWithDifferentKeyPassword(org.apache.nifi.io.socket.SSLContextFactoryTest)
      Time elapsed: 0.002 s  <<< ERROR!
      java.io.FileNotFoundException: null/jre/lib/security/cacerts (No such file
      or directory)
      at
      org.apache.nifi.io.socket.SSLContextFactoryTest.testShouldVerifyKeystoreWithDifferentKeyPassword(SSLContextFactoryTest.groovy:138)
      [ERROR]
      testShouldVerifyKeystoreWithSameKeyPassword(org.apache.nifi.io.socket.SSLContextFactoryTest)
      Time elapsed: 0.001 s  <<< ERROR!
      java.io.FileNotFoundException: null/jre/lib/security/cacerts (No such file
      or directory)
      at
      org.apache.nifi.io.socket.SSLContextFactoryTest.testShouldVerifyKeystoreWithSameKeyPassword(SSLContextFactoryTest.groovy:113)
      

      Attachments

        Issue Links

          Activity

            People

              alopresto Andy LoPresto
              alopresto Andy LoPresto
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: