You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "oscerd (via GitHub)" <gi...@apache.org> on 2026/07/21 13:11:12 UTC

[PR] CAMEL-24225: Fix test-visibility guidance that mandates non-compiling code [camel]

oscerd opened a new pull request, #24983:
URL: https://github.com/apache/camel/pull/24983

   ## Motivation
   
   The `Test Visibility: Drop public From Test Classes and Methods` section recently added to `AGENTS.md` (symlinked as `CLAUDE.md`) contains three statements that instruct agents to write code which does not compile. Since this file is consumed as normative instructions by AI coding agents, the defects propagate straight into contributions.
   
   The underlying convention is correct and is **not** changed here — JUnit 5 genuinely does not require `public`, and the repo already has ~750 package-private test classes. Only the incorrect statements are fixed.
   
   ## What was wrong
   
   **1. Dropping `public` from `@Override` methods is illegal Java.**
   
   The rule listed `@Override` alongside `@BeforeEach`/`@AfterEach`. Reducing visibility on an overriding method violates JLS 8.4.8.3. Verified with `javac`:
   
   ```
   error: configure() in Sub cannot override configure() in Base
     attempting to assign weaker access privileges; was public
   ```
   
   `RouteBuilder.configure()` is `public abstract` (`core/camel-core-model/src/main/java/org/apache/camel/builder/RouteBuilder.java:200`), and there are ~8,900 anonymous `RouteBuilder` overrides under `src/test`. The ~27 `src/test` overrides of `configureContext` / `configureTest` are also affected, since interface methods are implicitly public.
   
   **2. The "Preferred" example did not compile.**
   
   It showed `@Override void configure()` on a `CamelTestSupport` subclass. `CamelTestSupport` has no `configure()` method — only `configureContext()` and `configureTest()` — so the `@Override` fails outright; read instead as `RouteBuilder.configure()`, it fails with the weaker-access error above.
   
   Replaced with the actual idiom, which is already visible at `CamelTestSupport.java:356`: `createRouteBuilder()` returning an anonymous `RouteBuilder` whose `configure()` stays `public`.
   
   **3. No carve-out for cross-package or released test-support classes.**
   
   A package-private class cannot be extended from another package. This repo has 183 `public abstract class` declarations under `src/test`; `ContextTestSupport` alone is imported ~2,500 times, including across modules via the published test-jar.
   
   More seriously, "test classes" is ambiguous enough that an agent could apply the rule to `components/camel-test/**` and `test-infra/**`. Those live in `src/main`, deploy normally, and are consumed by camel-quarkus, camel-spring-boot and by users' own tests — stripping `public` there would be a breaking API change.
   
   ## Changes
   
   Docs only, `AGENTS.md`, +18/-3:
   
   - Replaced the broken example with the `createRouteBuilder()` idiom, annotated to show why `configure()` stays `public`.
   - Removed `@Override` from the drop-`public` list and added an explicit exception for methods that override or implement a supertype method.
   - Added an explicit exception for base/support classes extended cross-package or cross-module, and for `components/camel-test/**` and `test-infra/**`.
   
   No build files, no Java, no generated files touched.
   
   ---
   
   _Claude Code on behalf of @oscerd_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24225: Fix test-visibility guidance that mandates non-compiling code [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #24983:
URL: https://github.com/apache/camel/pull/24983#issuecomment-5034475234

   :star2: Thank you for your contribution to the Apache Camel project! :star2:
     :robot: CI automation will test this PR automatically.
   
     :camel: Apache Camel Committers, please review the following items:
   
     * First-time contributors **require MANUAL approval** for the GitHub Actions to run
     * You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot although they are normally detected and executed by CI.
     * You can label PRs using `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
     * Build and test logs are available in the summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
     
     :warning: Be careful when sharing logs. Review their contents before sharing them publicly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24225: Fix test-visibility guidance that mandates non-compiling code [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd merged PR #24983:
URL: https://github.com/apache/camel/pull/24983


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org