Expand description
§camel-component-mock
Mock component for rust-camel — testing utility that records received exchanges for later assertion, useful for verifying route output in tests.
Main types: MockComponent, MockEndpoint, MockProducer, MockExpectations.
§Example
use camel_component_mock::MockComponent;
use camel_component_api::{Component, NoOpComponentContext, Exchange, Message};
// Create a mock component and endpoint
let component = MockComponent::new();
let endpoint = component
.create_endpoint("mock:result", &NoOpComponentContext)
.unwrap();
// In a real route, the producer would be used as a Tower service.
// After sending exchanges, you can inspect them:
let inner = component.get_endpoint("result").unwrap();
// inner.assert_exchange_count(1).await;
// inner.exchange(0).assert_body_text("hello");Structs§
- Exchange
Assert - A handle for making synchronous assertions on a recorded exchange.
- Mock
Component - The Mock component is a testing utility that records every exchange it receives via its producer. It exposes helpers to inspect and assert on the recorded exchanges.
- Mock
Config - Configuration for
MockComponent. - Mock
Endpoint - A mock endpoint that records all exchanges sent to it.
- Mock
Endpoint Inner - The actual data behind a mock endpoint. Shared across all
MockEndpointinstances created with the same name viaMockComponent. - Mock
Expectations - Expectations set on a mock endpoint for batch-style assertion.