Skip to content

[test] Improve test coverage for utils.* classes - #4292

Open
jay1466 wants to merge 1 commit into
apache:mainfrom
jay1466:test-improve-utils-coverage-883
Open

[test] Improve test coverage for utils.* classes#4292
jay1466 wants to merge 1 commit into
apache:mainfrom
jay1466:test-improve-utils-coverage-883

Conversation

@jay1466

@jay1466 jay1466 commented Sep 10, 2026

Copy link
Copy Markdown

Summary

Closes #883 (sub-issue of umbrella #641 – Improve Test Code Coverage for Ignored Classes).

Several utility classes in org.apache.fluss.utils were excluded from the JaCoCo coverage check because they had no tests. This PR adds comprehensive unit tests for them and removes the need for those exclusions by ensuring >= 70% line coverage.

New test classes

Test class Class under test Tests added
AbstractIteratorTest AbstractIterator 7
CollectionUtilsTest CollectionUtils 2
CopyOnWriteMapTest CopyOnWriteMap 11
EncodingUtilsTest EncodingUtils 3
OperatingSystemTest OperatingSystem 4
PropertiesUtilsTest PropertiesUtils 4

Total: 31 new tests, 0 failures.

Minor fix

Fix a copy-paste error in the Javadoc of OperatingSystem.isMac() which incorrectly stated it checks for Windows.

Test Plan

  • All 31 new tests pass: mvn test -Dtest="CollectionUtilsTest,PropertiesUtilsTest,EncodingUtilsTest,AbstractIteratorTest,CopyOnWriteMapTest,OperatingSystemTest" -pl fluss-common
  • Code style verified: mvn spotless:check -pl fluss-common passes.

API and Format

No API or storage format changes.

Documentation

No documentation changes needed.


🤖 AI-assisted changes – reviewed by human developer

Add comprehensive unit tests for utility classes that were previously
excluded from code-coverage checks (apache#883, part of apache#641):

- AbstractIteratorTest: normal iteration, peek, empty, remove,
  idempotent hasNext, failed-state transitions
- CollectionUtilsTest: newHashMapWithExpectedSize, computeRequiredCapacity
  boundary and edge cases (including Integer.MAX_VALUE threshold)
- CopyOnWriteMapTest: all ConcurrentMap operations (put, get, remove,
  clear, putAll, putIfAbsent, conditional remove/replace)
- EncodingUtilsTest: escapeIdentifier, escapeBackticks, escapeSingleQuotes
- OperatingSystemTest: OS detection, isWindows/isMac consistency, enum values
- PropertiesUtilsTest: asPrefixedMap, extractAndRemovePrefix,
  extractPrefix, excludeByPrefix

Also fix a copy-paste error in OperatingSystem.isMac() Javadoc that
incorrectly described it as checking for Windows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Umbrella] Subissue Improve utils.* test coverage

1 participant