RouteTypeUriResolver implements RouteTypeResolver { @Nullable @Override public RouteType findRouteType(RouteTypeInfo routeTypeInfo) { Assert.notNull(routeTypeInfo, "routeTypeInfo must not be null"); Set<String> uris = new HashSet<>(); Route route = routeTypeInfo.getRoute(); if (route != null && route.getConsumer() != null && route.getConsumer().getEndpoint() != null) { uris.add(routeTypeInfo.getRoute().getConsumer().getEndpoint().getEndpointUri()); } if (routeTypeInfo.getRouteDefinition() != null) { for (FromDefinition fromDefinition : routeTypeInfo.getRouteDefinition().getInputs()) { if (!StringUtils.isBlank(fromDefinition.getUri())) { uris.add(fromDefinition.getUri()); } } } RouteType result = null; for (String uri : uris) { if (!StringUtils.isBlank(uri) && uri.matches(inputUriPattern.getValue())) { result = RouteTypeEnum.INPUT; break; } } return result; }  @Nullable @Override RouteType findRouteType(RouteTypeInfo routeTypeInfo); static final int ORDER; }
@Test public void testFindRouteTypeForRoute() throws Exception { getCamelContext().addRoutes(new AbstractBasicRoute() { @Override protected void doConfigure() throws Exception { from("direct:inputRoute") .routeId("inputTestRouteOne") .log("TestRoute"); from("direct:inputUri") .routeId("inputTestRouteTwo") .log("TestRoute"); from("direct:outputRoute") .routeId("outputTestRouteOne") .log("TestRoute"); } }); assertThat(routeTypeUriResolver.findRouteType( new RouteTypeInfo(getCamelContext().getRoute("inputTestRouteOne"), null, null, null)), is(RouteTypeEnum.INPUT)); assertThat(routeTypeUriResolver.findRouteType( new RouteTypeInfo(getCamelContext().getRoute("inputTestRouteTwo"), null, null, null)), is(RouteTypeEnum.INPUT)); assertThat(routeTypeUriResolver.findRouteType( new RouteTypeInfo(getCamelContext().getRoute("outputTestRouteOne"), null, null, null)), nullValue()); assertThat(routeTypeUriResolver.findRouteType(new RouteTypeInfo(null, null, null, getCamelContext().getRouteDefinition("inputTestRouteOne"))), is(RouteTypeEnum.INPUT)); assertThat(routeTypeUriResolver.findRouteType(new RouteTypeInfo(null, null, null, getCamelContext().getRouteDefinition("inputTestRouteTwo"))), is(RouteTypeEnum.INPUT)); assertThat(routeTypeUriResolver.findRouteType(new RouteTypeInfo(null, null, null, getCamelContext().getRouteDefinition("outputTestRouteOne"))), nullValue()); }