This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karaf.git


The following commit(s) were added to refs/heads/main by this push:
     new ccd37a084 feat(#766): add agent skill to create feature integration 
tests (#767)
ccd37a084 is described below

commit ccd37a084d27e22fb61561ce5a55f2408a3f8e5e
Author: François de Parscau <[email protected]>
AuthorDate: Mon Nov 30 13:43:42 2026 +0100

    feat(#766): add agent skill to create feature integration tests (#767)
    
    Add the camel-karaf-feature-itest skill describing how to write a new
    tests/features/camel-<feature> integration test on top of the shared
    camel-integration-test framework: naming conventions, the six patterns
    used by the existing modules, copy-ready templates, how to run and debug
    the test, and how to triage feature resolution failures.
    
    Include list-untested-features.sh, which lists the camel-* Karaf features
    that have no integration test yet, and reference the skill from AGENTS.md.
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 .claude/skills/camel-karaf-feature-itest/SKILL.md  | 187 +++++++++++
 .../list-untested-features.sh                      |  51 +++
 .../skills/camel-karaf-feature-itest/reference.md  | 362 +++++++++++++++++++++
 AGENTS.md                                          |   7 +
 4 files changed, 607 insertions(+)

diff --git a/.claude/skills/camel-karaf-feature-itest/SKILL.md 
b/.claude/skills/camel-karaf-feature-itest/SKILL.md
new file mode 100644
index 000000000..8be696e78
--- /dev/null
+++ b/.claude/skills/camel-karaf-feature-itest/SKILL.md
@@ -0,0 +1,187 @@
+---
+name: camel-karaf-feature-itest
+description: Create a Pax Exam integration test under tests/features for a 
Camel Karaf feature (camel-<component>) that has none yet, following the shared 
camel-integration-test framework. Use when asked to add, write or scaffold an 
integration test / itest for a Camel component, dataformat or language feature, 
to find which features lack tests, or to check that a feature installs and 
works in Karaf.
+---
+
+# Add a feature integration test (tests/features)
+
+Each module under `tests/features/camel-<feature>` installs one Karaf feature
+in a real Karaf, deploys a small test bundle with a route, and checks a mock
+endpoint. All modules are built on the classes in
+`tests/camel-integration-test` (package `org.apache.karaf.camel.itests`).
+Most of the wiring comes from **naming conventions**, so a new test is often
+only two short classes and a 20-line pom.
+
+Copy-ready templates for every file are in [reference.md](reference.md).
+Read it before you write anything.
+
+## 0. Pick the feature
+
+```bash
+.claude/skills/camel-karaf-feature-itest/list-untested-features.sh
+```
+
+This prints the `camel-*` features in 
`features/src/main/feature/camel-features.xml`
+that no test covers yet. A feature that only appears in
+`additionalRequiredFeatures` of another test (for example `camel-sql`,
+`camel-mongodb`) counts as tested, but you may still give it its own module.
+
+Before you start:
+- Check the feature exists: `grep -n "<feature name='camel-<feature>'" 
features/src/main/feature/camel-features.xml`.
+- Read the upstream Camel component doc and tests
+  (`components/camel-<x>/src/test` in apache/camel) to pick the simplest
+  meaningful round-trip.
+- If you work from a GitHub issue, follow the issue-ownership rules in 
`AGENTS.md`.
+
+## 1. Choose the pattern
+
+Pick the **first** row that fits. Most tests (about 65 of 75) are rows 1–3.
+
+| # | Component kind | Supplier hooks | External resource |
+|---|----------------|----------------|-------------------|
+| 1 | Dataformat / language / transformer (base64, csv, jackson, jq) | 
`consumerEnabled() = false`; producer route transforms then `.toF("mock:%s", 
getResultMockName())` | none, `@RunWith(PaxExam.class)` |
+| 2 | Talks to a server (kafka, couchdb, aws2-*, http, mail) | producer sends, 
`consumerRoute()` reads back; or producer only, ending in the mock | 
Testcontainers `GenericContainerResource`, 
`@RunWith(PaxExamWithExternalResource.class)` |
+| 3 | Consumer only / scheduler (timer, cron, quartz) | `producerEnabled() = 
false`; `consumerRoute()` | none |
+| 4 | Needs an in-JVM server or a free port (ftp, mina, netty) | as 2 | custom 
`ExternalResource`, `AvailablePortProvider` |
+| 5 | Mainly used from Blueprint, or needs beans you can only wire in XML | 
**no supplier**; `OSGI-INF/blueprint/route.xml` | `isBlueprintTest = true` |
+| 6 | Several scenarios for the same feature | several suppliers + ITests 
filtered with `camelRouteSuppliers`, or one `AbstractCamelRouteWithBundleITest` 
with nested route tests | see reference.md §6 |
+
+Rows 1–3 and 5 are about 20 lines of Java each. If yours grows much bigger,
+check that you are not testing Camel itself. The goal is: **does the feature
+install, resolve and work in OSGi**. Camel's own test suite covers how the
+component behaves.
+
+## 2. The naming chain (get this right first)
+
+`CamelSingleFeatureRoute` and `AbstractCamelSingleFeatureRouteSupplier` derive
+everything from class names with `toKebabCase` (`([a-z0-9])([A-Z])` → `$1-$2`,
+lower-cased). For feature `camel-foo-bar`:
+
+| Item | Value |
+|------|-------|
+| Module dir | `tests/features/camel-foo-bar` |
+| `artifactId` (= Bundle-SymbolicName = test bundle name) | 
`camel-foo-bar-test` |
+| ITest class (`src/test/java/org/apache/karaf/camel/itest`) | 
`CamelFooBarITest` |
+| Feature installed (`getCamelFeatureName()`) | `camel-foo-bar` |
+| Supplier class (`src/main/java/org/apache/karaf/camel/test`) | 
`CamelFooBarRouteSupplier` |
+| `@Component(name = …)` | `karaf-camel-foo-bar-test` |
+| Producer entry endpoint | `direct:camel-foo-bar-test` |
+| Result mock | `mock:camel-foo-bar-test` |
+| Producer route id | `producer-camel-foo-bar-test` |
+
+Rules:
+- Write acronyms in camel case: `CamelHttpITest`, not `CamelHTTPITest`.
+  Digits stay attached to what comes before them: `CamelAws2S3ITest` →
+  `camel-aws2-s3`, `CamelPahoMqtt5ITest` → `camel-paho-mqtt5`.
+- If the class name cannot produce the feature name, or the module has several
+  ITests, override `getCamelFeatureName()` / `getTestComponentName()` in the
+  ITest **and** `getTestComponentName()` in the supplier so they still match
+  (see `camel-kafka/CamelKafkaCompressionITest`). A wrong name usually shows up
+  as an `IllegalArgumentException("Feature … is not available")` or a mock
+  that never receives anything.
+- Extra features (a client library, a second component) go in
+  `@CamelKarafTestHint(additionalRequiredFeatures = "camel-xyz")`. Do not
+  override `getRequiredFeatures()` (it is `final`).
+
+## 3. Write the files
+
+1. `tests/features/camel-<feature>/pom.xml`. Use the template. Keep the
+   `../../../src/main/resources` resource (it puts LICENSE and NOTICE in the
+   bundle). Add `org.apache.camel:camel-<x>` with scope `provided` only if the
+   supplier imports its classes. Testcontainers artifacts are `test` scope with
+   `${testcontainers-version}` (2.x module names: `testcontainers-kafka`,
+   `testcontainers-localstack`, …). Look for an existing `*-version` property 
in
+   the root `pom.xml` before adding a new one.
+2. Add `<module>camel-<feature></module>` to `tests/features/pom.xml`,
+   **in alphabetical order**.
+3. Supplier in `src/main/java/org/apache/karaf/camel/test/`. This class goes
+   into the bundle and runs **inside Karaf**.
+4. ITest in `src/test/java/org/apache/karaf/camel/itest/`. External resources
+   (containers, servers) run **outside Karaf**, in the JUnit JVM. Put them in a
+   `public static final class ExternalResourceProviders` nested in the ITest,
+   or in a separate class next to it. Never put them on the ITest class itself.
+   Each `public static` no-arg method that returns an `ExternalResource` is
+   started before Karaf boots.
+5. Test resources (sample files, mapping files) go in `src/test/resources`.
+   Read them in Karaf through `getBaseDir() + "/test-classes/..."`, or with
+   `assertResultFileIsSameAs` for file-based results.
+
+### How values reach Karaf
+
+`resource.setProperty("foo.port", …)` on a resource becomes a **JVM system
+property of the Karaf instance**. Read it in the supplier with
+`System.getProperty("foo.port")`, or in Blueprint with
+`<ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"/>`
+and `$[foo.port]`. Name properties `<component>.<what>` (`kafka.server`,
+`couchdb.port`).
+
+### Writing the test body
+
+- `configureMock(MockEndpoint mock)` sets expectations **before** the producer
+  route is triggered. Prefer `expectedBodiesReceived(...)`. Use
+  `expectedMessageCount(n)` plus checks on `getMockEndpoint().getExchanges()`
+  when the body is not a simple value.
+- The default body sent to `direct:camel-<feature>-test` is the ITest simple
+  class name. Override `getBodyToSend()` for a real payload. Share constants
+  through `public static final` fields on the supplier (the test bundle is on
+  the ITest classpath).
+- One `@Test public void testResultMock()` that calls
+  `assertMockEndpointsSatisfied()` is the norm. Add more only for distinct
+  scenarios.
+- Never use `Thread.sleep`. Use Awaitility with `atMost`, or
+  `mock.setResultWaitTime(...)` for slow back-ends.
+- Pin container images to an exact tag (`confluentinc/cp-kafka:7.6.1`), never
+  `latest`. Use the matching Testcontainers module when there is one,
+  otherwise `GenericContainer` with `withExposedPorts` and a `Wait` strategy.
+- Inside Karaf, `localhost` may fail to resolve for some SDKs (AWS). Use
+  `127.0.0.1` in that case, as the aws2 tests do.
+
+## 4. Build and run
+
+Run this from the repo root. The test resolves the features descriptor and
+`camel-integration-test` from the local Maven repo, so install them first
+(once per change to features or the framework):
+
+```bash
+mvn clean install -DskipTests                                   # once, or 
after editing camel-features.xml
+mvn clean install -f tests/features/camel-<feature>/pom.xml     # build and 
run the new test
+```
+
+Useful flags:
+- `-Ddump.logs.on.failure=true` prints karaf.log when the test fails.
+- `-Dcamel.karaf.itest.debug=5005` makes Karaf wait for a debugger on that 
port.
+- `-Dkeep.docker.images.on.exit=true` keeps pulled images between runs.
+
+The Karaf log is also in
+`tests/features/camel-<feature>/target/exam/<uuid>/data/log/karaf.log`.
+Container tests need a running Docker daemon. Do not run Pax Exam modules in
+parallel (`-T`).
+
+## 5. When it fails: read the cause before you change the test
+
+Finding these failures is the reason the tests exist. Typical causes:
+
+| Symptom in karaf.log / output | Usual fix |
+|-------------------------------|-----------|
+| `Unable to resolve … missing requirement … osgi.wiring.package=…` while 
installing the feature | The **feature** is missing a bundle, or needs a 
`wrap:` instruction. Fix `features/src/main/feature/camel-features.xml`, 
rebuild `features`, rerun. Past examples: #713 tika, #665 elasticsearch, #648 
kafka compression. |
+| Test bundle `camel-<feature>-test` not `Active`, with an `Import-Package` 
error | Supplier imports a package nobody exports. Add the right `provided` 
dependency, or set `camel.karaf.test.additional.imports` in the module pom (see 
camel-cxf, camel-cometd). |
+| `ClassNotFoundException` at runtime for a class loaded by reflection | 
Usually a feature or wrapper problem: an 
`Import-Package`/`DynamicImport-Package` is missing in `components/camel-<x>` 
or the feature. Check whether the fix belongs in camel-karaf or upstream (see 
`AGENTS.md`, Issue Investigation). |
+| `Feature camel-… is not available` | Naming chain mismatch (§2), or the 
features artifact in `~/.m2` is stale. |
+| `No CamelContext could be found` | Supplier `@Component` not activated 
(check the bundle state), or a Blueprint XML error. |
+| Mock not satisfied, no error in the log | Wrong endpoint name 
(`direct:`/`mock:` must be `camel-<feature>-test`), or a property not passed 
from the external resource. |
+
+If a feature fix is needed, it belongs in the same PR. Say so in the PR
+description and commit it as `fix(#NNN): …`.
+
+## 6. Before you finish
+
+- [ ] `mvn clean install -f tests/features/camel-<feature>/pom.xml` passes 
locally.
+      Report the real output; if Docker was not available, say so.
+- [ ] Module is listed alphabetically in `tests/features/pom.xml`.
+- [ ] ASF license header on every new file (copy it from a neighbouring file).
+- [ ] No unused imports, no raw `GenericContainerResource` types when the
+      container type is known, no `Thread.sleep`.
+- [ ] Image tags are pinned. Credentials are test-only constants.
+- [ ] `list-untested-features.sh` no longer lists the feature.
+- [ ] Commit: `feat(#NNN): add camel-<feature> integration test` (or `test:`
+      without an issue). Follow the PR and reviewer rules in `AGENTS.md`.
diff --git a/.claude/skills/camel-karaf-feature-itest/list-untested-features.sh 
b/.claude/skills/camel-karaf-feature-itest/list-untested-features.sh
new file mode 100755
index 000000000..6aecdb553
--- /dev/null
+++ b/.claude/skills/camel-karaf-feature-itest/list-untested-features.sh
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Lists the camel-* Karaf features declared in camel-features.xml that are not
+# exercised by any integration test under tests/features.
+#
+# A feature counts as "tested" when it is the name of a test module, is derived
+# from an ITest class name (CamelFooBarITest -> camel-foo-bar), or is quoted as
+# a string in a test source (getCamelFeatureName(), 
additionalRequiredFeatures).
+#
+# Usage: list-untested-features.sh [--tested]
+#   --tested   print the tested features instead of the untested ones
+
+set -euo pipefail
+
+ROOT="$(git -C "$(dirname "$0")" rev-parse --show-toplevel)"
+FEATURES_XML="$ROOT/features/src/main/feature/camel-features.xml"
+TESTS_DIR="$ROOT/tests/features"
+
+TMP="$(mktemp -d)"
+trap 'rm -rf "$TMP"' EXIT
+
+grep -oE "<feature name=['\"]camel-[^'\"]+" "$FEATURES_XML" \
+    | sed -E "s/.*name=['\"]//" | sort -u > "$TMP/features"
+
+{
+    find "$TESTS_DIR" -mindepth 1 -maxdepth 1 -type d -name 'camel-*' -exec 
basename {} \;
+    grep -rhoE 'Camel[A-Z][A-Za-z0-9]*ITest' --include='*.java' 
--exclude-dir=target "$TESTS_DIR" \
+        | sed -E 's/ITest$//; s/([a-z0-9])([A-Z])/\1-\2/g' | tr '[:upper:]' 
'[:lower:]'
+    grep -rhoE '"camel-[a-z0-9-]+"' --include='*.java' --exclude-dir=target 
"$TESTS_DIR" | tr -d '"'
+} | sort -u > "$TMP/tested"
+
+if [[ "${1:-}" == "--tested" ]]; then
+    comm -12 "$TMP/features" "$TMP/tested"
+else
+    comm -23 "$TMP/features" "$TMP/tested"
+fi
diff --git a/.claude/skills/camel-karaf-feature-itest/reference.md 
b/.claude/skills/camel-karaf-feature-itest/reference.md
new file mode 100644
index 000000000..efea1bd8a
--- /dev/null
+++ b/.claude/skills/camel-karaf-feature-itest/reference.md
@@ -0,0 +1,362 @@
+# Templates and framework reference
+
+Replace `Foo`/`foo` with the feature (for example `camel-foo-bar` → `FooBar` / 
`foo-bar`).
+Each new file starts with the ASF license header. Copy it from any
+neighbouring file; the templates below leave it out.
+
+Existing modules to copy from, by pattern:
+
+| Pattern | Good examples |
+|---------|---------------|
+| 1 Dataformat / language | `camel-base64`, `camel-csv`, `camel-jackson`, 
`camel-gson` |
+| 2 Container back-end | `camel-kafka`, `camel-couchdb`, `camel-aws2-s3`, 
`camel-http` |
+| 3 Consumer only | `camel-core/CamelTimerRouteSupplier`, `camel-quartz` |
+| 4 In-JVM server / free port | `camel-ftp` (`FtpServerResource`) |
+| 5 Blueprint | `camel-jms`, `camel-quartz`, `camel-amqp` |
+| 6 Several scenarios | `camel-kafka` (two ITests), `camel-jcache` (shared 
abstract supplier), `camel-core` (one ITest, nested route tests) |
+
+---
+
+## §1 pom.xml (all patterns)
+
+```xml
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ASF license header -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.camel.karaf</groupId>
+        <artifactId>camel-karaf-features-test</artifactId>
+        <version><!-- same as tests/features/pom.xml --></version>
+    </parent>
+
+    <artifactId>camel-foo-test</artifactId>
+    <name>Apache Camel :: Karaf :: Tests :: Features :: Foo</name>
+
+    <!-- Only if the supplier imports component classes (custom component 
config, constants) -->
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-foo</artifactId>
+            <version>${camel-version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <!-- Only for pattern 2 -->
+        <dependency>
+            <groupId>org.testcontainers</groupId>
+            <artifactId>testcontainers</artifactId> <!-- or 
testcontainers-<module> -->
+            <version>${testcontainers-version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <resources>
+            <!-- Only when the module has src/main/resources (Blueprint XML, 
templates).
+                 Declaring <resources> replaces Maven's default, so list it 
explicitly. -->
+            <resource>
+                <directory>${project.basedir}/src/main/resources</directory>
+            </resource>
+            <!-- Always: LICENSE/NOTICE into the bundle -->
+            <resource>
+                <directory>../../../src/main/resources</directory>
+                <filtering>false</filtering>
+            </resource>
+        </resources>
+    </build>
+</project>
+```
+
+Optional `<properties>` read by the parent's `maven-bundle-plugin`:
+- `camel.karaf.test.additional.imports`: extra `Import-Package` entries, each
+  ending with `,`, for packages bnd cannot see (classes named only in
+  Blueprint XML, or loaded by reflection). Example: `camel-cxf`.
+- `camel.karaf.test.fragment.host`: makes the test bundle a fragment (rarely
+  needed; see `camel-cometd`).
+
+---
+
+## §2 Pattern 1: dataformat / language, no external resource
+
+`src/main/java/org/apache/karaf/camel/test/CamelFooRouteSupplier.java`
+```java
+package org.apache.karaf.camel.test;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.RouteDefinition;
+import 
org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteSupplier;
+import org.apache.karaf.camel.itests.CamelRouteSupplier;
+import org.osgi.service.component.annotations.Component;
+
+@Component(name = "karaf-camel-foo-test", immediate = true, service = 
CamelRouteSupplier.class)
+public class CamelFooRouteSupplier extends 
AbstractCamelSingleFeatureResultMockBasedRouteSupplier {
+
+    public static final String SAMPLE = "Hello Foo";
+
+    @Override
+    protected boolean consumerEnabled() {
+        return false;
+    }
+
+    @Override
+    protected void configureProducer(RouteBuilder builder, RouteDefinition 
producerRoute) {
+        producerRoute.log("Will marshal: ${body}")
+                .marshal().foo()
+                .log("Will unmarshal: ${body}")
+                .unmarshal().foo()
+                .toF("mock:%s", getResultMockName());
+    }
+}
+```
+
+`src/test/java/org/apache/karaf/camel/itest/CamelFooITest.java`
+```java
+package org.apache.karaf.camel.itest;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import 
org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteITest;
+import org.apache.karaf.camel.test.CamelFooRouteSupplier;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class CamelFooITest extends 
AbstractCamelSingleFeatureResultMockBasedRouteITest {
+
+    @Override
+    public String getBodyToSend() {
+        return CamelFooRouteSupplier.SAMPLE;
+    }
+
+    @Override
+    public void configureMock(MockEndpoint mock) {
+        mock.expectedBodiesReceived(CamelFooRouteSupplier.SAMPLE);
+    }
+
+    @Test
+    public void testResultMock() throws Exception {
+        assertMockEndpointsSatisfied();
+    }
+}
+```
+
+---
+
+## §3 Pattern 2: container back-end (producer → server → consumer)
+
+Supplier:
+```java
+@Component(name = "karaf-camel-foo-test", immediate = true, service = 
CamelRouteSupplier.class)
+public class CamelFooRouteSupplier extends 
AbstractCamelSingleFeatureResultMockBasedRouteSupplier {
+
+    private static final String URI = "foo://%s:%s/test".formatted(
+            System.getProperty("foo.host"), System.getProperty("foo.port"));
+
+    // Optional: configure the component programmatically (credentials, 
endpoint override)
+    @Override
+    public void configure(CamelContext camelContext) {
+        // FooComponent foo = new FooComponent(); ... 
camelContext.addComponent("foo", foo);
+    }
+
+    @Override
+    protected void configureProducer(RouteBuilder builder, RouteDefinition 
producerRoute) {
+        producerRoute.setBody(builder.constant("OK")).to(URI);
+    }
+
+    @Override
+    protected Function<RouteBuilder, RouteDefinition> consumerRoute() {
+        // the base class appends .to("mock:camel-foo-test")
+        return builder -> builder.from(URI).log("Received: ${body}");
+    }
+}
+```
+
+ITest:
+```java
+@CamelKarafTestHint(externalResourceProvider = 
CamelFooITest.ExternalResourceProviders.class)
+@RunWith(PaxExamWithExternalResource.class)
+@ExamReactorStrategy(PerClass.class)
+public class CamelFooITest extends 
AbstractCamelSingleFeatureResultMockBasedRouteITest {
+
+    @Override
+    public void configureMock(MockEndpoint mock) {
+        mock.expectedBodiesReceived("OK");
+    }
+
+    @Test
+    public void testResultMock() throws Exception {
+        assertMockEndpointsSatisfied();
+    }
+
+    public static final class ExternalResourceProviders {
+
+        private static final int FOO_PORT = 1234;
+
+        // Prefer a Testcontainers module class (KafkaContainer, 
LocalStackContainer, ...) when one exists
+        public static GenericContainerResource<FooContainer> 
createFooContainer() {
+            FooContainer container = new FooContainer("foo/foo:1.2.3"); // 
pinned tag
+            return new GenericContainerResource<>(container, resource -> {
+                resource.setProperty("foo.host", container.getHost());
+                resource.setProperty("foo.port", 
Integer.toString(container.getMappedPort(FOO_PORT)));
+            });
+        }
+    }
+
+    // GenericContainerResource<T extends GenericContainer<T>> needs a 
self-typed container;
+    // a plain GenericContainer<?> only compiles with raw types (as in 
camel-http), so declare one.
+    public static class FooContainer extends GenericContainer<FooContainer> {
+        public FooContainer(String image) {
+            super(image);
+            withExposedPorts(ExternalResourceProviders.FOO_PORT)
+                    .waitingFor(Wait.forListeningPort());
+        }
+    }
+}
+```
+
+Producer-only variant (request/reply, like `camel-http`): `consumerEnabled() = 
false`
+and end the producer route with `.toF("mock:%s", getResultMockName())`.
+
+---
+
+## §4 Pattern 3: consumer only
+
+```java
+@Override
+protected boolean producerEnabled() {
+    return false;
+}
+
+@Override
+protected Function<RouteBuilder, RouteDefinition> consumerRoute() {
+    return builder -> builder.from("timer://testTimer?repeatCount=1")   // 
your scheduler/consumer URI
+            .setBody(builder.constant("OK"));
+}
+```
+The ITest expects `"OK"`. `triggerProducerRoute()` does nothing when
+`direct:camel-foo-test` does not exist. `expectedBodiesReceived("OK")` also
+fixes the message count to 1. If the consumer can't be limited to one firing,
+use `mock.expectedMinimumMessageCount(1)` and check the first exchange body.
+
+---
+
+## §5 Pattern 4: custom external resource and free ports
+
+```java
+public class FooServerResource extends ExternalResourceWithPrerequisite {
+
+    private final AvailablePortProvider ports = new 
AvailablePortProvider(List.of("foo.port"));
+    private FooServer server;
+
+    @Override
+    protected List<ExternalResource> getPrerequisites() {
+        return List.of(ports);          // started first; its properties are 
copied into this resource
+    }
+
+    @Override
+    protected void doStart() {
+        int port = Integer.parseInt(properties().get("foo.port"));
+        server = new FooServer(port);
+        server.start();
+        setProperty("foo.username", "scott");
+    }
+
+    @Override
+    protected void doStop() {
+        if (server != null) {
+            server.stop();
+        }
+    }
+}
+```
+If you only need a port for a server that runs **inside** Karaf (jetty,
+netty-http), return `new AvailablePortProvider(List.of("foo.port"))` directly
+from `ExternalResourceProviders`. Use `TemporaryFile` for a temp-file path
+property.
+
+---
+
+## §6 Pattern 5: Blueprint
+
+No supplier class. ITest:
+```java
+@CamelKarafTestHint(isBlueprintTest = true)   // + externalResourceProvider / 
additionalRequiredFeatures if needed
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class CamelFooITest extends 
AbstractCamelSingleFeatureResultMockBasedRouteITest { ... same body ... }
+```
+
+`src/main/resources/OSGI-INF/blueprint/route.xml` (remember the extra
+`<resource>` in the pom):
+```xml
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+           
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0";
+           xsi:schemaLocation="
+             http://www.osgi.org/xmlns/blueprint/v1.0.0 
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
+             http://camel.apache.org/schema/blueprint 
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd";>
+
+    <!-- system properties set by external resources -->
+    <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"/>
+
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/blueprint";>
+        <route id="producer-camel-foo-test">
+            <from uri="direct:camel-foo-test"/>
+            <to uri="foo://$[foo.host]:$[foo.port]/test"/>
+        </route>
+        <route id="consumer-camel-foo-test">
+            <from uri="foo://$[foo.host]:$[foo.port]/test"/>
+            <to uri="mock:camel-foo-test"/>
+        </route>
+    </camelContext>
+</blueprint>
+```
+The test finds the first `BlueprintCamelContext` service. If there are several
+contexts, set `camelContextName` in the hint, or use
+`getProvider().getContext("ctx1")` (see `camel-disruptor`).
+
+---
+
+## §7 Pattern 6: several scenarios in one module
+
+**A. Several ITests and suppliers** (`camel-kafka`, `camel-jcache`): give each
+supplier its own `@Component` name and restrict each ITest to its supplier.
+Otherwise every supplier in the bundle starts in every test.
+```java
+@CamelKarafTestHint(camelRouteSuppliers = 
"karaf-camel-kafka-compression-test", externalResourceProvider = ...)
+public class CamelKafkaCompressionITest extends 
AbstractCamelSingleFeatureResultMockBasedRouteITest {
+    @Override public String getCamelFeatureName()  { return "camel-kafka"; }   
    // feature to install
+    @Override public String getTestComponentName() { return 
"camel-kafka-test"; }  // = bundle name, direct:/mock: names
+```
+Then the supplier must also override `getTestComponentName()` (and use
+distinct `direct:`/`mock:` endpoints or route ids if both suppliers could run
+together).
+
+**B. One ITest, nested route tests** (`camel-core`, `camel-disruptor`): extend
+`AbstractCamelRouteWithBundleITest`, implement `getTestBundleName()` and
+`getRequiredFeatures()`, and for each scenario add a nested
+`AbstractCamelSingleFeatureResultMockBasedRoute` (or `…FileBasedRoute`)
+subclass that you call from a `@Test` with `new X(this).testRoutes()`. The
+nested class simple name (`CamelSedaITest`) drives the `direct:`/`mock:` names
+exactly as for top-level ITests.
+
+---
+
+## §8 Framework cheat-sheet (`tests/camel-integration-test`)
+
+| Class | Role |
+|-------|------|
+| `AbstractCamelRouteITest` | Pax Exam config: Karaf + `apache-camel` features 
repo + `scr` + `camel-core` or `camel-blueprint`. Installs the required 
features and bundles in `@Before`, removes them in `@After`. Gives access to 
contexts and templates. |
+| `AbstractCamelRouteWithBundleITest` | Installs 
`target/<testBundleName>-<version>.jar` and checks it is Active. |
+| `AbstractCamelSingleFeatureRouteITest` | Derives the feature, bundle and 
component names from the class name. `getRequiredFeatures()` is final. |
+| `AbstractCamelSingleFeatureResultMockBasedRouteITest` | `@Before`: 
`setupMock()` → `configureMock()` → `triggerProducerRoute()`. `@After`: resets 
the mocks. **The default base class for new tests.** |
+| `AbstractCamelSingleFeatureResultFileBasedRouteITest` | Same, but you assert 
on `target/<component>-test` with `assertResultFileContains` / 
`assertResultFileIsSameAs`. |
+| `AbstractCamelSingleFeatureResultMockBasedRouteSupplier` | Supplier base: 
producer `direct:X` → your code; consumer route → `mock:X`. Hooks: 
`configure(CamelContext)`, `configureProducer`, `consumerRoute`, 
`producerEnabled`, `consumerEnabled`, `cleanUp`. |
+| `CamelSuppliedRouteLauncher` | SCR component in Karaf that creates the 
`supplied-route-launcher` context and adds the routes of every 
`CamelRouteSupplier` service. |
+| `@CamelKarafTestHint` | `externalResourceProvider`, `isBlueprintTest`, 
`additionalRequiredFeatures`, `camelRouteSuppliers`, `ignoreRouteSuppliers`, 
`camelContextName`, `retryOnFailure`, `timeout` (seconds, default 300). |
+| `PaxExamWithExternalResource` | JUnit runner that starts the resources 
before Karaf, passes their `properties()` as Karaf system properties, and stops 
them in reverse order afterwards. |
+| `GenericContainerResource<T>` | Wraps a Testcontainers container. The 
`onStarted` callback publishes properties. `addDependency()` adds a resource 
that starts after the container. |
+| `ExternalResourceWithPrerequisite`, `AvailablePortProvider`, `TemporaryFile` 
| Building blocks for non-container resources. |
diff --git a/AGENTS.md b/AGENTS.md
index a7423b6e3..270c3c47e 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -353,6 +353,13 @@ Features:
 
 Tests:
 - `*Test.java` (JUnit 5); OSGi integration tests use Pax Exam under `tests/`.
+- Per-feature integration tests live in `tests/features/camel-<feature>` and
+  are built on `tests/camel-integration-test`. To add one for a feature that
+  has none, follow
+  
[`.claude/skills/camel-karaf-feature-itest/SKILL.md`](.claude/skills/camel-karaf-feature-itest/SKILL.md)
+  (naming conventions, templates, how to run and debug it).
+  `.claude/skills/camel-karaf-feature-itest/list-untested-features.sh` lists
+  the features that still have no test.
 
 ## Commits
 

Reply via email to