Skip to content

WW-3447 test(convention): cover action-mapping flags with no tests - #2003

Merged
lukaszlenart merged 1 commit into
mainfrom
WW-3447-convention-flag-coverage
Oct 10, 2026
Merged

lukaszlenart merged 1 commit into
mainfrom
WW-3447-convention-flag-coverage

Conversation

@lukaszlenart

Copy link
Copy Markdown
Member

Fixes WW-3447

Summary

The ticket (2010) says the convention plugin has no tests. That is no longer true: the plugin has 16 test classes. Some of the constants in struts-plugin.xml were still never set in any test, though, so only their default value was ever exercised. This PR adds an on/off test pair for the six that change how actions get mapped:

Constant Default case Flipped case
struts.convention.action.alwaysMapExecute unannotated execute() next to an @Action method is not mapped it is mapped too
struts.convention.action.checkImplementsAction an Action implementor without the suffix is mapped it is ignored
struts.convention.action.mapAllMatches a suffixed class with no execute() is not mapped it is mapped with a null method
struts.convention.action.disableScanning configured packages are scanned nothing is mapped
struts.convention.package.locators.disable locator packages are scanned locators are ignored
struts.convention.action.eagerLoading ObjectFactory does not load action classes it loads each found class

The new tests sit in PackageBasedActionConfigBuilderTest, which already uses the JUnit 3 style, and use three fixture classes under org.apache.struts2.convention.flags.*.

Three constants are left out on purpose: classes.reload, includeJars and exclude.parentClassLoader. They depend on classloaders and jar scanning, and a unit test wouldn't prove much about them.

Verification

  • ./mvnw test -DskipAssembly -pl plugins/convention passes.
  • To check the tests actually catch something, I forced each flag's check in PackageBasedActionConfigBuilder to true and then to false (12 runs). Every run failed the test written for that flag. The production code is unchanged in this PR.

Test-only change; no production code touched.

🤖 Generated with Claude Code

Add on/off tests for alwaysMapExecute, checkImplementsAction,
mapAllMatches, disableScanning, package.locators.disable and
eagerLoading in PackageBasedActionConfigBuilderTest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@lukaszlenart
lukaszlenart marked this pull request as ready for review October 10, 2026 11:18
@lukaszlenart
lukaszlenart merged commit cca45de into main Oct 10, 2026
16 checks passed
@lukaszlenart
lukaszlenart deleted the WW-3447-convention-flag-coverage branch October 10, 2026 11:18
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