
package org.apache.camel.component.bean;

import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.ProxyBuilder;
import org.apache.camel.builder.RouteBuilder;

public class MyAuditServiceProxyTest extends ContextTestSupport {

    public void testMyAuditServiceProxy() throws Exception {
        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
        getMockEndpoint("mock:result").expectedHeaderReceived("uuid", "1234");

        // must enable binding on proxy
        MyAuditService service = new ProxyBuilder(context).endpoint("direct:proxy").binding(true).build(MyAuditService.class);

        service.auditMessage("1234", "Hello World");

        assertMockEndpointsSatisfied();
    }

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("direct:proxy")
                    .to("mock:result");
            }
        };
    }
}
