This is an automated email from the ASF dual-hosted git repository.
oscerd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new cfab3c41f519 CAMEL-24225: Fix test-visibility guidance that mandates
non-compiling code (#24983)
cfab3c41f519 is described below
commit cfab3c41f51933d5937292a641fe6626a62cf1fb
Author: Andrea Cosentino <[email protected]>
AuthorDate: Tue Jul 21 18:18:28 2026 +0200
CAMEL-24225: Fix test-visibility guidance that mandates non-compiling code
(#24983)
The Test Visibility section instructed agents to drop `public` from
`@Override` methods, which Java forbids (JLS 8.4.8.3). It also shipped a
"Preferred" example that did not compile, and a blanket rule with no carve-out
for base classes extended cross-package or for the released
`components/camel-test/**` and `test-infra/**` artifacts.
The underlying convention is sound and unchanged — only the three incorrect
statements are corrected.
Co-authored-by: Claude Opus 4.8 <[email protected]>
---
AGENTS.md | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/AGENTS.md b/AGENTS.md
index cfdaa97e74d9..82df4cebac3a 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -259,7 +259,14 @@ class MyComponentTest extends CamelTestSupport {
void testSendMessage() { ... }
@Override
- void configure() throws Exception { ... }
+ protected RoutesBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() { // stays public — overrides
RouteBuilder.configure()
+ from("direct:start").to("mock:result");
+ }
+ };
+ }
}
// Avoid — unnecessary public:
@@ -275,8 +282,16 @@ public class MyComponentTest extends CamelTestSupport {
- When modifying an existing test file, remove the `public` modifier from the
class declaration
and from any test methods you touch. Do NOT sweep the entire file — only
change what you are
already modifying.
-- `@BeforeAll`, `@AfterAll`, `@BeforeEach`, `@AfterEach`, and `@Override`
methods follow the
- same rule: drop `public` when adding or modifying them.
+- `@BeforeAll`, `@AfterAll`, `@BeforeEach` and `@AfterEach` methods follow the
same rule: drop
+ `public` when adding or modifying them.
+- **Exception — methods that override or implement a supertype method keep the
supertype's
+ visibility.** Java forbids reducing visibility on an override (JLS 8.4.8.3),
so
+ `public void configure()` in a `RouteBuilder`, and any override of a public
method from
+ `CamelTestSupport` or an implemented interface, MUST stay `public`.
+- **Exception — base and support classes stay `public`** when they are
extended from another
+ package or module (a package-private class cannot be), and anything under
+ `components/camel-test/**` or `test-infra/**` stays `public` because those
are released
+ artifacts consumed by downstream projects and by users' own tests.
- Do NOT create a standalone PR solely to remove `public` from test files in
bulk — apply the
convention incrementally as part of other work.