Skip to content

WW-5630 Streamline ConfigParseUtilTest and convert to JUnit 4#1740

Merged
lukaszlenart merged 1 commit into
mainfrom
WW-5630-configparseutil-test-cleanup
Jun 14, 2026
Merged

WW-5630 Streamline ConfigParseUtilTest and convert to JUnit 4#1740
lukaszlenart merged 1 commit into
mainfrom
WW-5630-configparseutil-test-cleanup

Conversation

@lukaszlenart

Copy link
Copy Markdown
Member

Summary

Test-only cleanup of ConfigParseUtilTest, which was added in #1721 (the class-validation caching introduced for WW-5630). The production caching logic in ConfigParseUtil is unchanged — this only improves the test.

  • Collapse redundancy: 12 overlapping cache tests → 5 focused ones (single-loader caching, per-loader isolation incl. the same-toString() case, outer-size bound, inner-size bound, and the negative/not-cached case).
  • Drop the ~80-entry literal: the inner-cache size-bound test now generates synthetic class names in a loop bounded by the per-loader limit (read via the existing helper) instead of hardcoding a giant JDK class-name array.
  • Remove unnecessary reflection: the three behavioral tests assert via load counts only. Reflection is retained solely in the two size-bound tests, where Caffeine exposes no public seam for estimatedSize().
  • JUnit 3 → JUnit 4: @Test/@Before/@After with static org.junit.Assert.*, matching the convention of the newest standalone unit tests in core (e.g. ContainerHolderTest, NamedVariablePatternMatcherTest).

Net: 90 insertions / 183 deletions, 12 tests → 5.

Fixes WW-5630 test-quality follow-up.

Test Plan

  • ./mvnw -pl core clean test -Dtest=ConfigParseUtilTestTests run: 5, Failures: 0, Errors: 0, Skipped: 0
  • ./mvnw -pl core apache-rat:check → BUILD SUCCESS (license headers)
  • core/src/main/java/org/apache/struts2/util/ConfigParseUtil.java unchanged

🤖 Generated with Claude Code

Collapse 12 overlapping cache tests to 5 focused ones, replace the
~80-entry JDK class-name literal with a synthetic-name loop bounded by
the inner-cache limit, and drop reflection from the behavioral tests
(load-count assertions only). Reflection is retained solely in the two
size-bound tests, where Caffeine exposes no public seam.

Production ConfigParseUtil caching logic is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lukaszlenart lukaszlenart enabled auto-merge (squash) June 14, 2026 09:15
@lukaszlenart lukaszlenart merged commit dd830dc into main Jun 14, 2026
6 of 7 checks passed
@lukaszlenart lukaszlenart deleted the WW-5630-configparseutil-test-cleanup branch June 14, 2026 09:16
@sonarqubecloud

Copy link
Copy Markdown

lukaszlenart added a commit that referenced this pull request Jun 14, 2026
…it 4 (#1741)

Port of #1740 to 6.x: 12 overlapping cache tests collapsed to 5 focused
ones, JUnit 3 -> JUnit 4, dropped the ~80-class literal, reflection kept
only in the two size-bound tests. Also reorders the caffeine imports in
ConfigParseUtil to match alphabetical ordering. Production logic unchanged.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant