Class CamelContextTestHelper

java.lang.Object
org.apache.camel.test.junit5.util.CamelContextTestHelper

public final class CamelContextTestHelper extends Object
  • Field Details

    • ROUTE_COVERAGE_ENABLED

      public static final String ROUTE_COVERAGE_ENABLED
      JVM system property which can be set to true to turn on dumping route coverage statistics.
      See Also:
    • ROUTE_DUMP_ENABLED

      public static final String ROUTE_DUMP_ENABLED
      JVM system property which can be set to true to turn on dumping routes as xml or yaml
      See Also:
  • Method Details

    • createCamelContext

      public static org.apache.camel.CamelContext createCamelContext(org.apache.camel.spi.Registry registry) throws Exception
      Throws:
      Exception
    • setupDebugger

      public static void setupDebugger(org.apache.camel.CamelContext context, org.apache.camel.spi.Breakpoint breakpoint)
    • setupRoutes

      public static void setupRoutes(org.apache.camel.CamelContext context, org.apache.camel.RoutesBuilder[] builders) throws Exception
      Configures routes on the given context
      Parameters:
      context - the context to add the routes to
      builders - an array of route builders
      Throws:
      Exception
    • lookupEndpoint

      public static org.apache.camel.component.mock.MockEndpoint lookupEndpoint(org.apache.camel.CamelContext context, String uri, boolean create, String target)
      Lookup endpoint with the given URI on the context
      Parameters:
      context - the context to lookup endpoints
      uri - the endpoint URI
      create - whether to create the endpoint if it does not exist
      target - the query-stripped normalized URI
      Returns:
      the MockEndpoint instance associated with the normalized URI (aka target)
    • enableAutoMocking

      public static void enableAutoMocking(org.apache.camel.CamelContext context, String pattern, String mockAndSkipPattern) throws Exception
      Enables auto mocking
      Throws:
      Exception
    • enableAutoStub

      public static void enableAutoStub(org.apache.camel.CamelContext context, String pattern)
      Enables auto stub
    • configurePropertiesComponent

      public static void configurePropertiesComponent(org.apache.camel.CamelContext context, Properties extra, org.apache.camel.spi.PropertiesSource propertiesSource, Boolean ignore)
      Configure the PropertiesComponent from the given context
      Parameters:
      context - the context with the PropertiesComponent to configure
      extra - override properties to use (if any)
      propertiesSource - custom properties source to use to load/lookup properties
      ignore - whether to ignore missing properties locations
    • configureIncludeExcludePatterns

      public static void configureIncludeExcludePatterns(org.apache.camel.CamelContext context, String include, String exclude)
      Configure route filtering patterns
      Parameters:
      context - the context to configure the patterns
      include - the inclusion pattern
      exclude - the exclusion pattern
    • startCamelContext

      public static void startCamelContext(org.apache.camel.CamelContext context) throws Exception
      Start the given context
      Parameters:
      context - the context to start
      Throws:
      Exception
    • startCamelContextOrService

      public static void startCamelContextOrService(org.apache.camel.CamelContext context, org.apache.camel.Service camelContextService) throws Exception
      Starts a CamelContext or a service managing the CamelContext. The service takes priority if provided.
      Parameters:
      context - the context to start
      camelContextService - the service managing the CamelContext
      Throws:
      Exception
    • replaceFromEndpoints

      public static void replaceFromEndpoints(org.apache.camel.model.ModelCamelContext context, Map<String,String> fromEndpoints) throws Exception
      Replaces the 'from' endpoints of the given context with the ones from the provided map
      Parameters:
      context - the context to have the 'from' endpoints replaced
      fromEndpoints - the map with the new endpoint Uris
      Throws:
      Exception
    • isSkipAutoStartContext

      public static boolean isSkipAutoStartContext(TestExecutionConfiguration configuration)
    • isRouteCoverageEnabled

      public static boolean isRouteCoverageEnabled(boolean legacyDumpCoverage)
    • getRouteDump

      public static String getRouteDump(String legacyDumpRoute)