### Question:
RouteFactory { public static List<RouteDefinition> createRoute(String className) { return createRoute(className, null); } 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 createRouteFromClass() { List<RouteDefinition> routes = RouteFactory.createRoute(SingleRouteService.class.getName()); Assert.assertNotNull(routes); Assert.assertEquals(1, routes.size()); RouteDefinition route = routes.get(0); Assert.assertEquals(1, route.getInputs().size()); Assert.assertEquals(2, route.getOutputs().size()); }
@Test public void doesntExtendRouteBuilder() { try { RouteFactory.createRoute(DoesntExtendRouteBuilder.class.getName()); Assert.fail("Java DSL class does not extend RouteBuilder " + DoesntExtendRouteBuilder.class.getName()); } catch (RuntimeException ex) { System.err.println("Route class that does not extend RouteBuilder was rejected: " + ex.toString()); } }
@Test public void noRoutesDefined() { try { RouteFactory.createRoute(NoRoutesDefined.class.getName()); Assert.fail("No routes defined in Java DSL class " + NoRoutesDefined.class.getName()); } catch (RuntimeException ex) { System.err.println("Java DSL class without a route was rejected: " + ex.toString()); } }