Repository navigation
Minor: Move StringUtil tests to opennlp-api, share test fixtures, reject null in StringUtil.isEmpty and isBlank - #1361
Conversation
StringUtilTest moves from opennlp-tools to opennlp-api/src/test. StringUtil.isBlank rejects null with IllegalArgumentException. opennlp-api publishes a test-jar with RestoreDefaultLocale, ResetWhitespaceMode and PinWhitespaceMode, used by 15 test classes.
isBlank now rejects null with IllegalArgumentException, isEmpty next to it still throws NullPointerException and the Javadoc claims it returns true for null. The changed test fails on the current code: StringUtilTest.testIsEmptyWithNullString Unexpected exception type thrown, expected: IllegalArgumentException but was: NullPointerException Signed-off-by: Kristian Rickert <kristian@apache.org>
… the test-jar isEmpty rejects null with IllegalArgumentException and documents the parameter, the return value and the exception; the old Javadoc said it returned true for null, which it never did. The opennlp-api test-jar dependency in the formats and cli poms names ${project.groupId} like the other opennlp dependencies in those files. Signed-off-by: Kristian Rickert <kristian@apache.org>
|
Another small edit: we should throw IAE instead of NPE, so fixed it and made tests to prove the fix. Fixed demonstrated with the red/green commits:
Are you ok if we change the title to: "Move StringUtil tests to opennlp-api, share test fixtures, reject null in StringUtil.isEmpty and isBlank"? Since the null handling of Original solution description by AI, edited and hand validated by me:
|
|
Thx for review. Updated the description and title. |
…entChecks move (#1362) #1353 removed the private StringUtil.requireNonNullArg while #1361 added two callers of it, so opennlp-api no longer compiles on main. Both now call ArgumentChecks.requireNonNullArg.
Moves
StringUtilTestfromopennlp-toolstoopennlp-apiand publishes anopennlp-apitest-jar with sharedLocaleandWhitespaceModetest extensions, which replace copies in 15 test classes.StringUtil.isEmptyandisBlanknow reject null withIllegalArgumentExceptionlike their siblings; before, both threw aNullPointerException, contrary to theisEmptyJavadoc.