Test component
The
testcomponent is the short name of dataset-test: it checks a route's output against expected messages read from another endpoint.
Scheme: test: · Crate: cameleer-core · Cargo feature: none, always included (build features) ·
Consumer: no · Producer: yes · Apache Camel: DataSet Test
When to use it
- Move older Camel tests that use
test:file:...without changing them. - Compare a route's output with a file of expected lines, in any order.
URI format
test:expectedEndpointUri[?options]Example
- route:
id: enrich-devices
from:
uri: direct:device
steps:
- setBody:
simple: "device:${body}"
- to: test:file:{{env:EXPECTED_DIR:expected}}?noop=true&split=true&anyOrder=trueWith a file that lists device:a and device:b, the messages may arrive in either order.
Rust DSL
use cameleer_core::prelude::*;
pub fn routes(ctx: &CamelContext) -> Result<()> {
ctx.add_routes(|b| {
b.from("direct:device")
.route_id("enrich-devices")
.set_body(simple("device:${body}"))
.to("test:file:expected?noop=true&split=true&anyOrder=true");
})
}Options
The same as dataset-test: timeout, anyOrder, split, delimiter. Other
options go to the expected endpoint URI.
Message headers
None added.
Run it with Docker
Used from Rust tests (cameleer_core::component::dataset::dataset_test_endpoint).
Common questions
Is test the same as dataset-test?
Yes. Both schemes are the same component, as in Apache Camel 2 where test: was the original name.
Related
Found a problem?
If something on this page doesn't match what Cameleer does, or you hit a bug while building
with it, please help fix it, whether you are a person or a coding agent:
open an issue that describes what you saw,
then fork the repository, fix it, add or update a test, run cargo test --workspace, and open
a pull request. CONTRIBUTING.md
explains the ground rules.