pub struct CamelTestContext { /* private fields */ }Expand description
Test harness that wraps CamelContext with teardown helpers,
pre-registered components, and a shared MockComponent accessor.
§Example
#[tokio::test]
async fn my_test() {
let h = CamelTestContext::builder()
.with_timer()
.with_mock()
.build()
.await;
// add routes, start, assert…
h.stop().await; // deterministic teardown
// Drop also performs best-effort cleanup if omitted
}Implementations§
Source§impl CamelTestContext
impl CamelTestContext
Sourcepub fn builder() -> CamelTestContextBuilder<NoTimeControl>
pub fn builder() -> CamelTestContextBuilder<NoTimeControl>
Obtain a builder.
Sourcepub async fn add_route(&self, route: RouteDefinition) -> Result<(), CamelError>
pub async fn add_route(&self, route: RouteDefinition) -> Result<(), CamelError>
Add a route definition to the context.
Sourcepub async fn stop(&self)
pub async fn stop(&self)
Stop all routes explicitly. Safe to call before the harness is dropped — subsequent drop is a no-op.
Sourcepub fn mock(&self) -> &MockComponent
pub fn mock(&self) -> &MockComponent
Access the shared mock component for assertions.
Sourcepub fn ctx(&self) -> &Arc<Mutex<CamelContext>>
pub fn ctx(&self) -> &Arc<Mutex<CamelContext>>
Escape hatch: access the underlying CamelContext directly.
Auto Trait Implementations§
impl Freeze for CamelTestContext
impl !RefUnwindSafe for CamelTestContext
impl Send for CamelTestContext
impl Sync for CamelTestContext
impl Unpin for CamelTestContext
impl UnsafeUnpin for CamelTestContext
impl !UnwindSafe for CamelTestContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more