Skip to main content

Crate camel_component_mock

Crate camel_component_mock 

Source
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§

ExchangeAssert
A handle for making synchronous assertions on a recorded exchange.
MockComponent
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.
MockConfig
Configuration for MockComponent.
MockEndpoint
A mock endpoint that records all exchanges sent to it.
MockEndpointInner
The actual data behind a mock endpoint. Shared across all MockEndpoint instances created with the same name via MockComponent.
MockExpectations
Expectations set on a mock endpoint for batch-style assertion.