public void testCarToXml() throws Exception {
   String xml = beanXmlConverter.convertToXml(car);
   XMLUnit.setIgnoreWhitespace(true);
   Diff diff;
   diff = new Diff(TestModel.Car.DEFAULT_XML, xml);
   diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
   XMLAssert.assertXMLEqual(diff, true);
 }
 public void assertXMLEqual(String expectedXml, String resultXml) {
   try {
     Diff diff = new Diff(expectedXml, resultXml);
     diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
     XMLAssert.assertXMLEqual(diff, true);
   } catch (Exception e) {
     throw new RuntimeException("XML Assertion failure", e);
   }
 }
  private void runProjectTest(String projectName, boolean isWeb) throws Exception {
    ResolverConfiguration configuration = new ResolverConfiguration();
    IProject project =
        importProject("test-data/projects/" + projectName + "/pom.xml", configuration);
    waitForJobs();

    project.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
    waitForJobs();

    assertNoErrors(project);

    // make sure we get through an incremental build (SWITCHYARD-1108)
    project.touch(new NullProgressMonitor());
    project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
    waitForJobs();

    assertNoErrors(project);

    assertTrue(
        project
            .getFile("target/classes/META-INF/switchyard.xml")
            .isSynchronized(IResource.DEPTH_ZERO));
    assertTrue(project.getFile("target/classes/META-INF/switchyard.xml").isAccessible());

    assertTrue(!project.getFile("src/main/java/META-INF/MANIFEST.MF").exists());

    Reader sourceReader = null;
    Reader testReader = null;
    try {
      sourceReader =
          new InputStreamReader(
              project.getFile("target/classes/META-INF/switchyard.xml").getContents());
      testReader =
          new InputStreamReader(
              SwitchYardConfigurationTest.class
                  .getClassLoader()
                  .getResourceAsStream(
                      "test-data/validation/"
                          + projectName
                          + (isWeb ? "/WEB-INF/switchyard.xml" : "/META-INF/switchyard.xml")));
      XMLUnit.setIgnoreComments(true);
      XMLUnit.setIgnoreWhitespace(true);
      Diff diff = XMLUnit.compareXML(sourceReader, testReader);
      diff.overrideElementQualifier(new ElementNameAndAttributeQualifier());
      assertTrue(diff.toString(), diff.similar());
    } finally {
      if (sourceReader != null) {
        try {
          sourceReader.close();
        } catch (Exception e) {
          // for codestyle check
          e.fillInStackTrace();
        }
      }
      if (testReader != null) {
        try {
          testReader.close();
        } catch (Exception e) {
          // for codestyle check
          e.fillInStackTrace();
        }
      }
    }
  }