RouteFactory { public static List<RouteDefinition> loadRoute(String xmlPath, SwitchYardCamelContext camelContext, PropertyResolver propertyResolver) { List<RouteDefinition> routes = null; try { Object obj = CamelModelFactory.createCamelModelObjectFromXML(xmlPath); if (obj instanceof CamelContextFactoryBean) { routes = processCamelContextElement((CamelContextFactoryBean)obj, camelContext); } else if (obj instanceof RoutesDefinition) { routes = ((RoutesDefinition)obj).getRoutes(); } else if (obj instanceof RouteDefinition) { routes = new ArrayList<RouteDefinition>(1); routes.add((RouteDefinition)obj); } if (routes == null) { CamelComponentMessages.MESSAGES.noRoutesFoundInXMLFile(xmlPath); } return routes; } catch (Exception e) { throw new SwitchYardException(e); } } private  RouteFactory(); static List<RouteDefinition> getRoutes(CamelComponentImplementationModel model, SwitchYardCamelContext camelContext); static List<RouteDefinition> loadRoute(String xmlPath, SwitchYardCamelContext camelContext,
            PropertyResolver propertyResolver); static List<RouteDefinition> loadRoute(String xmlPath); static List<RouteDefinition> createRoute(String className); static List<RouteDefinition> createRoute(String className, String namespace); static List<RouteDefinition> createRoute(String className, SwitchYardCamelContext camelContext, String namespace); static List<RouteDefinition> createRoute(Class<?> routeClass); static List<RouteDefinition> createRoute(Class<?> routeClass, SwitchYardCamelContext camelContext, String namespace); static List<RouteDefinition> createRoute(RouteBuilder routeBuilder, SwitchYardCamelContext camelContext, String namespace);  }
@Test public void noRoutesDefinedXML() { try { RouteFactory.loadRoute("org/switchyard/component/camel/deploy/not-a-route.xml"); } catch (SwitchYardException syEx) { System.err.println("Invalid Camel XML definition rejected: " + syEx.toString()); } }
@Test public void singleRouteXML() { List<RouteDefinition> routes = RouteFactory.loadRoute("org/switchyard/component/camel/deploy/route.xml"); Assert.assertEquals(1, routes.size()); }
@Test public void multiRouteXML() { List<RouteDefinition> routes = RouteFactory.loadRoute("org/switchyard/component/camel/deploy/routes.xml"); Assert.assertEquals(2, routes.size()); }