Class InterceptSendToMockEndpointStrategy

  • All Implemented Interfaces:
    org.apache.camel.spi.EndpointStrategy

    public class InterceptSendToMockEndpointStrategy
    extends Object
    implements org.apache.camel.spi.EndpointStrategy
    A EndpointStrategy which is capable of mocking endpoints.

    This strategy will only apply when new endpoints are being created. If you want to replace existing endpoints, you will have to remove them from the CamelContext beforehand.

    • Constructor Detail

      • InterceptSendToMockEndpointStrategy

        public InterceptSendToMockEndpointStrategy()
        Mock all endpoints.
      • InterceptSendToMockEndpointStrategy

        public InterceptSendToMockEndpointStrategy​(String pattern)
        Mock endpoints based on the given pattern.
        Parameters:
        pattern - the pattern.
        See Also:
        EndpointHelper.matchEndpoint(org.apache.camel.CamelContext, String, String)
      • InterceptSendToMockEndpointStrategy

        public InterceptSendToMockEndpointStrategy​(String pattern,
                                                   boolean skip)
        Mock endpoints based on the given pattern.
        Parameters:
        pattern - the pattern.
        skip - true to skip sending after the detour to the original endpoint
        See Also:
        EndpointHelper.matchEndpoint(org.apache.camel.CamelContext, String, String)
    • Method Detail

      • registerEndpoint

        public org.apache.camel.Endpoint registerEndpoint​(String uri,
                                                          org.apache.camel.Endpoint endpoint)
        Specified by:
        registerEndpoint in interface org.apache.camel.spi.EndpointStrategy
      • matchPattern

        protected boolean matchPattern​(String uri,
                                       org.apache.camel.Endpoint endpoint,
                                       String pattern)
        Does the pattern match the endpoint?
        Parameters:
        uri - the uri
        endpoint - the endpoint
        pattern - the pattern
        Returns:
        true to match and therefore intercept, false if not matched and should not intercept
      • onInterceptEndpoint

        protected org.apache.camel.Producer onInterceptEndpoint​(String uri,
                                                                org.apache.camel.Endpoint endpoint,
                                                                org.apache.camel.Endpoint mockEndpoint,
                                                                org.apache.camel.Producer mockProducer)
        Callback when an endpoint was intercepted with the given mock endpoint
        Parameters:
        uri - the uri
        endpoint - the endpoint
        mockEndpoint - the mocked endpoint
        mockProducer - the mock producer
        Returns:
        the mock producer