public void setUp() throws Exception { super.setUp(); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreComments(true); setErrorMessage(null); }
private void compareXML(String expected, String actual) throws Exception { setNormalizeWhitespace(true); setIgnoreWhitespace(true); setIgnoreComments(true); setIgnoreAttributeOrder(false); Diff diff = XMLUnit.compareXML(expected, actual); if (!(diff.similar() && diff.identical())) { System.out.println(actual); DetailedDiff detDiff = new DetailedDiff(diff); @SuppressWarnings("rawtypes") List differences = detDiff.getAllDifferences(); StringBuilder diffLines = new StringBuilder(); for (Object object : differences) { Difference difference = (Difference) object; diffLines.append(difference.toString() + '\n'); } throw new IllegalArgumentException("Actual XML differs from expected: \n" + diffLines.toString()); } } }
/** * Receives to {@link String} representation of two XML files and verify that they are semantically equivalent * * @param expected the reference content * @param actual the actual content * @throws Exception if comparison fails */ public static void compareXML(String expected, String actual) throws Exception { XMLUnit.setNormalizeWhitespace(true); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreComments(true); XMLUnit.setIgnoreAttributeOrder(false); Diff diff = XMLUnit.compareXML(expected, actual); if (!(diff.similar() && diff.identical())) { System.out.println(actual); DetailedDiff detDiff = new DetailedDiff(diff); @SuppressWarnings("rawtypes") List differences = detDiff.getAllDifferences(); StringBuilder diffLines = new StringBuilder(); for (Object object : differences) { Difference difference = (Difference) object; diffLines.append(difference.toString() + '\n'); } throw new IllegalArgumentException("Actual XML differs from expected: \n" + diffLines.toString()); } }
/** * Configure XML Unit parameters for comparing XML - override this to adjust the defaults */ protected void configureXmlUnit() { XMLUnit.setIgnoreWhitespace(true); XMLUnit.setNormalizeWhitespace(true); XMLUnit.setIgnoreComments(true); }
protected void checkXmlStructure(String xmlunitPage, String pageCode) throws SAXException, IOException { InputStream expectedPageCode = testClass.get().getJavaClass().getResourceAsStream(xmlunitPage); XMLUnit.setNormalizeWhitespace(true); XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreComments(true); Diff xmlDiff = new Diff(new InputStreamReader(expectedPageCode), new StringReader(pageCode)); xmlDiff.overrideDifferenceListener(getDifferenceListener()); if (!xmlDiff.similar()) { System.out.println("=== ACTUAL PAGE CODE ==="); System.out.println(pageCode); System.out.println("======== ERROR ========="); System.out.println(xmlDiff.toString()); System.out.println("========================"); fail("XML was not similar:" + xmlDiff.toString()); } }
public static void initXmlUnit() { XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreAttributeOrder(true); XMLUnit.setIgnoreComments(true); XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true); XMLUnit.setNormalize(true); }
private void configureXmlUnit() { XMLUnit.setIgnoreComments(true); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setNormalizeWhitespace(true); XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true); XMLUnit.setCompareUnmatched(false); XMLUnit.setIgnoreAttributeOrder(true); }
/** * This will be run once before each method. Cannot use @Before and @BeforeClass, as this is Junit 3.x here. */ public void setUp() { log.info("\n\n\n === Executing test " + getName() + "\n"); // Overriding some XMLUnit's non-sense defaults (especially the white spaces!) XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreComments(true); }
private void configureXmlUnit() { XMLUnit.setIgnoreComments(true); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setNormalizeWhitespace(true); XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true); XMLUnit.setCompareUnmatched(false); XMLUnit.setIgnoreAttributeOrder(true); }
@Before public void before() throws Exception { tempReg.addNamedTemplate("tempReg", TemplateCompiler.compileTemplate(getClass().getResourceAsStream(dataformat + ".mvt"), (Map<String, Class<? extends Node>>)null)); TemplateRuntime.execute(tempReg.getNamedTemplate("tempReg"), null, tempReg); XMLUnit.setIgnoreComments(true); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreAttributeOrder(true); XMLUnit.setNormalizeWhitespace(true); XMLUnit.setNormalize(true); if (!StringUtils.isEmpty(copyToDataFormat)) { writer = new PrintWriter(new BufferedWriter(new FileWriter(copyToDataFormat + ".mvt", true))); } }
public void setUp() throws Exception { super.setUp(); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreComments(true); setErrorMessage(null); }
@Before public void before() throws Exception { tempReg.addNamedTemplate( "tempReg", TemplateCompiler.compileTemplate( getClass().getResourceAsStream( dataformat + ".mvt" ), (Map<String, Class<? extends Node>>) null ) ); TemplateRuntime.execute( tempReg.getNamedTemplate( "tempReg" ), null, tempReg ); XMLUnit.setIgnoreComments( true ); XMLUnit.setIgnoreWhitespace( true ); XMLUnit.setIgnoreAttributeOrder( true ); XMLUnit.setNormalizeWhitespace( true ); XMLUnit.setNormalize( true ); if ( !StringUtils.isEmpty( copyToDataFormat ) ) { writer = new PrintWriter( new BufferedWriter( new FileWriter( copyToDataFormat + ".mvt", true ) ) ); } }
@BeforeClass public static void setUpClass() { XMLUnit.setCompareUnmatched(true); XMLUnit.setIgnoreAttributeOrder(true); XMLUnit.setIgnoreComments(true); XMLUnit.setIgnoreWhitespace(true); }
@Override public boolean matchesSafely(Source source) { String test = convertToString(source); XMLUnit.setIgnoreAttributeOrder(true); XMLUnit.setIgnoreComments(true); XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setNormalize(true); XMLUnit.setNormalizeWhitespace(true); try { return new Diff(control, test).identical(); } catch (SAXException e) { return false; } catch (IOException e) { return false; } }
@Override public void setUp() throws Exception { super.setUp(); XMLUnit.setIgnoreComments( true ); XMLUnit.setIgnoreWhitespace( true ); XMLUnit.setIgnoreAttributeOrder( true ); XMLUnit.setNormalizeWhitespace( true ); XMLUnit.setNormalize( true ); }
@Before public void setUp() throws Exception { XMLUnit.setIgnoreComments( true ); XMLUnit.setIgnoreWhitespace( true ); XMLUnit.setIgnoreAttributeOrder( true ); XMLUnit.setNormalizeWhitespace( true ); XMLUnit.setNormalize( true ); }
@Before public void setUp() throws Exception { XMLUnit.setIgnoreComments(true); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreAttributeOrder(true); XMLUnit.setNormalizeWhitespace(true); XMLUnit.setNormalize(true); }
@Override public void setUp() throws Exception { super.setUp(); XMLUnit.setIgnoreComments(true); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreAttributeOrder(true); XMLUnit.setNormalizeWhitespace(true); XMLUnit.setNormalize(true); }
@Override @Before public void setUp() throws Exception { XMLUnit.setIgnoreComments(true); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreAttributeOrder(true); XMLUnit.setNormalizeWhitespace(true); XMLUnit.setNormalize(true); XStreamXML.SORT_MAPS = true; // allows us to test results easier }
@Before public void setUp() throws Exception { XMLUnit.setIgnoreComments( true ); XMLUnit.setIgnoreWhitespace( true ); XMLUnit.setIgnoreAttributeOrder( true ); XMLUnit.setNormalizeWhitespace( true ); XMLUnit.setNormalize( true ); }