### Question:
RouteFactory { public static List<RouteDefinition> loadRoute(String xmlPath) { List<RouteDefinition> routes = null; try { InputSource source = new InputSource(Classes.getResourceAsStream(xmlPath)); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(source); Element element = document.getDocumentElement(); Binder<Node> binder = JAXB_CONTEXT.createBinder(); Object obj = binder.unmarshal(element); injectNamespaces(element, binder); 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 (SAXException e) { throw new SwitchYardException(e); } catch (ParserConfigurationException e) { throw new SwitchYardException(e); } catch (JAXBException e) { throw new SwitchYardException(e); } catch (IOException e) { throw new SwitchYardException(e); } } private  RouteFactory(); static List<RouteDefinition> getRoutes(CamelComponentImplementationModel model); static List<RouteDefinition> loadRoute(String xmlPath); static List<RouteDefinition> createRoute(String className); static List<RouteDefinition> createRoute(String className, String namespace); static List<RouteDefinition> createRoute(Class<?> routeClass); static List<RouteDefinition> createRoute(Class<?> routeClass, String namespace);  }### Answer:
@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()); }