protected XmlModel assertRoutes(File file, int expected, String ns) throws Exception {
    if (ns == null || ns.trim().length() == 0) {
      ns = CamelNamespaces.springNS;
    }
    XmlModel x = assertLoadModel(file, expected);

    // now lets add a route and write it back again...
    DefaultCamelContext tmpContext = new DefaultCamelContext();
    tmpContext.addRoutes(
        new RouteBuilder() {
          @Override
          public void configure() throws Exception {
            from("seda:newFrom").to("seda:newTo");
          }
        });
    x.getContextElement().getRoutes().addAll(tmpContext.getRouteDefinitions());

    List<RouteDefinition> routes = x.getRouteDefinitionList();
    assertEquals("routes: " + routes, expected + 1, routes.size());

    // now lets write to XML      model
    outDir.mkdirs();
    File outFile = new File(outDir, file.getName());
    System.out.println("Generating file: " + outFile);
    tool.marshal(outFile, x);

    assertFileExists(outFile);

    // lets check the file has the correct namespace inside it
    String text = FileCopyUtils.copyToString(new FileReader(outFile));
    assertTrue("Namespace " + ns + " not present in output file\n" + text, text.contains(ns));

    return x;
  }
  protected XmlModel assertLoadModel(File file, int expected) throws Exception {
    System.out.println("Loading file: " + file);
    assertFileExists(file);

    XmlModel x = tool.unmarshal(file);

    System.out.println("Got: " + x);

    List<RouteDefinition> routes = x.getRouteDefinitionList();

    assertEquals("routes: " + routes, expected, routes.size());

    System.out.println("routes: " + routes);
    return x;
  }
 protected void assertValid(XmlModel x) {
   ValidationHandler handler;
   try {
     handler = x.validate();
   } catch (Exception e) {
     throw new RuntimeException(e.getMessage(), e);
   }
   List<SAXParseException> errors = handler.getErrors();
   assertTrue("errors were: " + errors, errors.size() == 0);
 }