Пример #1
0
  private boolean isdifferent(Document testDoc, Document controlDoc) {
    boolean isdifferent = false;

    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreComments(true);
    XMLUnit.setNormalize(true);

    Diff myDiff = new Diff(controlDoc, testDoc);
    DetailedDiff myComparisonController = new DetailedDiff(myDiff);
    DifferenceEngine engine = new DifferenceEngine(myComparisonController);
    XmlDifferenceListener listener = new XmlDifferenceListener();
    ElementNameAndAttributeQualifier myElementQualifier = new ElementNameAndAttributeQualifier();
    try { // debug
      engine.compare(
          controlDoc.getDocumentElement(),
          testDoc.getDocumentElement(),
          listener,
          myElementQualifier);
    } catch (NullPointerException ne) {
      LOG.error("NPE: " + ne.getMessage(), ne);
    }

    isdifferent = listener.called();
    return isdifferent;
  }
 @BeforeClass
 public static void setUp() {
   XMLUnit.setIgnoreComments(true);
   XMLUnit.setIgnoreAttributeOrder(true);
   XMLUnit.setIgnoreWhitespace(true);
   XMLUnit.setNormalizeWhitespace(true);
   XMLUnit.setCompareUnmatched(false);
 }
Пример #3
0
  @Before
  public void setup() {

    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreAttributeOrder(true);
    XMLUnit.setIgnoreComments(true);
    XMLUnit.setXSLTVersion("2.0");
  }
 @Before
 public void setUp() throws Exception {
   XMLUnit.setIgnoreComments(true);
   XMLUnit.setIgnoreWhitespace(true);
   XMLUnit.setIgnoreAttributeOrder(true);
   XMLUnit.setNormalizeWhitespace(true);
   XMLUnit.setNormalize(true);
 }
Пример #5
0
 @Before
 public void setUp() {
   MockLogAppender.setupLogging(true);
   XMLUnit.setIgnoreWhitespace(true);
   XMLUnit.setIgnoreAttributeOrder(true);
   XMLUnit.setIgnoreComments(true);
   XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true);
   XMLUnit.setNormalize(true);
 }
 @BeforeDeploy
 public void setProperties() {
   // Carga un puerto libre para levantar el servidor jetty embebido
   if (null != System.getProperty("jettyPortSwitchyard")) {
     propMixIn.set("jettyPort", System.getProperty("jettyPortSwitchyard"));
   } else {
     propMixIn.set("jettyPort", JETTY_SWITCHYARD_DEFAULT_PORT);
   }
   // Configuro XMLUnit
   XMLUnit.setIgnoreWhitespace(true);
   XMLUnit.setIgnoreAttributeOrder(true);
   XMLUnit.setIgnoreComments(true);
 }
  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();
        }
      }
    }
  }