@Test public void verifyExtractionTemplateGenerate() throws TestEvalException, SAXException, IOException, TransformerException { for (String entityType : entityTypes) { if (entityType.contains(".json") || entityType.contains(".jpg") || entityType.contains("primary-key-as-a-ref")) { continue; } logger.info("Validating extraction template for:" + entityType); // logger.info(docMgr.read(entityType.replaceAll("\\.(xml|json)", ".tdex"), new // StringHandle()).get()); DOMHandle handle = docMgr.read(entityType.replaceAll("\\.(xml|json)", ".tdex"), new DOMHandle()); Document template = handle.get(); InputStream is = this.getClass().getResourceAsStream("/test-extraction-template/" + entityType); Document filesystemXML = builder.parse(is); // debugOutput(template); XMLUnit.setIgnoreWhitespace(true); XMLAssert.assertXMLEqual( "Must be no validation errors for schema " + entityType + ".", filesystemXML, template); } }
@Test public void testMergeMap() throws Exception { final File filename = new File(srcDir, "merged.xml"); final KeyrefReader keyrefreader = new KeyrefReader(); keyrefreader.read(filename.toURI(), readMap(filename)); final KeyScope act = keyrefreader.getKeyDefinition(); final Map<String, String> exp = new HashMap<String, String>(); exp.put( "toner-specs", "<keydef class=\"+ map/topicref mapgropup-d/keydef \" keys=\"toner-specs\" href=\"toner-type-a-specs.dita\"/>"); exp.put( "toner-handling", "<keydef class=\"+ map/topicref mapgropup-d/keydef \" keys=\"toner-handling\" href=\"toner-type-b-handling.dita\"/>"); exp.put( "toner-disposal", "<keydef class=\"+ map/topicref mapgropup-d/keydef \" keys=\"toner-disposal\" href=\"toner-type-c-disposal.dita\"/>"); TestUtils.resetXMLUnit(); XMLUnit.setIgnoreWhitespace(true); assertEquals(exp.keySet(), act.keySet()); for (Map.Entry<String, String> e : exp.entrySet()) { final Document ev = keyDefToDoc(e.getValue()); final Document av = act.get(e.getKey()).element.getOwnerDocument(); assertXMLEqual(ev, av); } }
/** * Sets the up. * * @throws Exception the exception */ @Before public void setUp() throws Exception { fileAnticipator = new FileAnticipator(); context = JAXBContext.newInstance(TcaDataCollectionConfig.class); marshaller = context.createMarshaller(); unmarshaller = context.createUnmarshaller(); TcaRrd rrd = new TcaRrd(); rrd.addRra("RRA:AVERAGE:0.5:1:3600"); rrd.addRra("RRA:AVERAGE:0.5:300:288"); rrd.addRra("RRA:MIN:0.5:300:288"); rrd.addRra("RRA:MAX:0.5:300:288"); rrd.addRra("RRA:AVERAGE:0.5:900:2880"); rrd.addRra("RRA:MIN:0.5:900:2880"); rrd.addRra("RRA:MAX:0.5:900:2880"); rrd.addRra("RRA:AVERAGE:0.5:3600:4300"); rrd.addRra("RRA:MIN:0.5:3600:4300"); rrd.addRra("RRA:MAX:0.5:3600:4300"); TcaDataCollection tcadc = new TcaDataCollection(); tcadc.setName("default"); tcadc.setRrd(rrd); tcadcc = new TcaDataCollectionConfig(); tcadcc.addDataCollection(tcadc); tcadcc.setRrdRepository("target/snmp/"); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreAttributeOrder(true); XMLUnit.setNormalize(true); }
@Test public void verifyExtractionTempGenNoRequired() throws TestEvalException, SAXException, IOException, TransformerException { String entityType = "no-primary-required.json"; DOMHandle res = new DOMHandle(); logger.info("Validating extraction template for:" + entityType); try { res = evalOneResult("fn:doc( '" + entityType + "')=>es:extraction-template-generate()", res); } catch (TestEvalException e) { throw new RuntimeException(e); } // logger.info(docMgr.read(entityType.replaceAll("\\.(xml|json)", ".tdex"), new // StringHandle()).get()); // DOMHandle handle = docMgr.read(entityType.replaceAll("\\.(xml|json)", ".tdex"), new // DOMHandle()); Document template = res.get(); InputStream is = this.getClass() .getResourceAsStream( "/test-extraction-template/" + entityType.replace(".json", ".xml")); Document filesystemXML = builder.parse(is); // debugOutput(template); XMLUnit.setIgnoreWhitespace(true); XMLAssert.assertXMLEqual( "Must be no validation errors for schema " + entityType + ".", filesystemXML, template); }
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; }
public void setUp() throws Exception { XMLUnit.setIgnoreWhitespace(true); final Document assertionDoc = DocumentUtil.getDocument(getClass().getResourceAsStream("/wstrust/assertion.xml")); assertionElement = (Element) assertionDoc.getFirstChild(); expectedAssertion = new InputSource(getClass().getResourceAsStream("/wstrust/assertion-expected.xml")); }
@BeforeClass public static void setUp() { XMLUnit.setIgnoreComments(true); XMLUnit.setIgnoreAttributeOrder(true); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setNormalizeWhitespace(true); XMLUnit.setCompareUnmatched(false); }
@Before public void setup() { XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreAttributeOrder(true); XMLUnit.setIgnoreComments(true); XMLUnit.setXSLTVersion("2.0"); }
public void testNSStack2() throws Exception { String msg = prefix + m2 + suffix; StringReader strReader = new StringReader(msg); DeserializationContext dser = new DeserializationContext( new InputSource(strReader), null, org.apache.axis.Message.REQUEST); dser.parse(); org.apache.axis.message.SOAPEnvelope env = dser.getEnvelope(); String xml = env.toString(); boolean oldIgnore = XMLUnit.getIgnoreWhitespace(); XMLUnit.setIgnoreWhitespace(true); try { assertXMLIdentical("NSStack invalidated XML canonicalization", new Diff(msg, xml), true); } finally { XMLUnit.setIgnoreWhitespace(oldIgnore); } }
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); }
@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() { MockLogAppender.setupLogging(true); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreAttributeOrder(true); XMLUnit.setIgnoreComments(true); XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true); XMLUnit.setNormalize(true); }
@Test public void testWriteComplete() throws Exception { String old_xml = new StringPuller().pull(COMPLETE_XML, getClass()); SwitchYardModel switchyard = _puller.pull(new StringReader(old_xml)); String new_xml = switchyard.toString(); XMLUnit.setIgnoreWhitespace(true); Diff diff = XMLUnit.compareXML(old_xml, new_xml); Assert.assertTrue(diff.toString(), diff.identical()); }
@Test public void testAudioMD_noMD5() throws Exception { Fits fits = new Fits(); // First generate the FITS output File input = new File("testfiles/test.wav"); FitsOutput fitsOut = fits.examine(input); XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat()); String actualXmlStr = serializer.outputString(fitsOut.getFitsXml()); // Read in the expected XML file Scanner scan = new Scanner(new File("testfiles/output/FITS_test_wav_NO_MD5.xml")); String expectedXmlStr = scan.useDelimiter("\\Z").next(); scan.close(); // Set up XMLUnit XMLUnit.setIgnoreWhitespace(true); XMLUnit.setNormalizeWhitespace(true); Diff diff = new Diff(expectedXmlStr, actualXmlStr); // Initialize attributes or elements to ignore for difference checking diff.overrideDifferenceListener( new IgnoreNamedElementsDifferenceListener( "version", "toolversion", "dateModified", "fslastmodified", "lastmodified", "startDate", "startTime", "timestamp", "fitsExecutionTime", "executionTime", "filepath", "location")); DetailedDiff detailedDiff = new DetailedDiff(diff); // Display any Differences List<Difference> diffs = detailedDiff.getAllDifferences(); if (!diff.identical()) { StringBuffer differenceDescription = new StringBuffer(); differenceDescription.append(diffs.size()).append(" differences"); System.out.println(differenceDescription.toString()); for (Difference difference : diffs) { System.out.println(difference.toString()); } } assertTrue("Differences in XML", diff.identical()); }
protected boolean checkDocs(Document doc1, Document doc2) { XMLUnit.setIgnoreAttributeOrder(true); XMLUnit.setIgnoreWhitespace(true); DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(doc1, doc2)); boolean result = diff.similar(); if (!result) { for (Difference d : (List<Difference>) diff.getAllDifferences()) { System.out.println(d); } } return result; }
@Test public void testReadRecord() throws Exception { XmlRecord xmlRecord = xmlRecordReader.readRecord(); String expectedPayload = getXmlFromFile("/person.xml"); String actualPayload = xmlRecord.getPayload(); XMLUnit.setIgnoreWhitespace(true); Diff diff = new Diff(expectedPayload, actualPayload); assertThat(xmlRecord.getHeader().getNumber()).isEqualTo(1); assertThat(diff.similar()).isTrue(); }
@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); }
@Test public void testGetFlightsXml() throws AirlineException, DatatypeConfigurationException, TransformerException { GetFlightsRequest request = JAXB.unmarshal(getStream("request1.xml"), GetFlightsRequest.class); GetFlightsResponse response = endpoint.getFlights(request); DOMResult domResponse = new DOMResult(); JAXB.marshal(response, domResponse); XMLUnit.setIgnoreWhitespace(true); XMLAssert.assertXMLEqual(getDocument("response1.xml"), (Document) domResponse.getNode()); }
public static void assertSimilarXml(String expectedXml, String xml) { XMLUnit.setIgnoreWhitespace(true); Diff diff; try { diff = XMLUnit.compareXML(xml, expectedXml); } catch (SAXException e) { throw new IllegalArgumentException("Could not run XML comparison", e); } catch (IOException e) { throw new IllegalArgumentException("Could not run XML comparison", e); } String message = "Diff: " + diff.toString() + CharUtils.LF + "XML: " + xml; assertTrue(message, diff.similar()); }
@Test public void test() throws IOException, SAXException { XMLBinding xmlBinding = new XMLBinding().add(getClass().getResourceAsStream("POType-binding.xml")).intiailize(); String poXML = StreamUtils.readStreamAsString(getClass().getResourceAsStream("po.xml")); POType po = xmlBinding.fromXML(new StringSource(poXML), POType.class); StringWriter writer = new StringWriter(); xmlBinding.toXML(po, writer); XMLUnit.setIgnoreWhitespace(true); XMLUnit.compareXML(poXML, writer.toString()); }
@Test public void testKeyrefReader() throws Exception { final File filename = new File(srcDir, "keyrefreader.xml"); // final Set <String> set = new HashSet<String> (); // set.add("blatview"); // set.add("blatfeference"); // set.add("blatintro"); // set.add("keyword"); // set.add("escape"); // set.add("top"); // set.add("nested"); final KeyrefReader keyrefreader = new KeyrefReader(); // keyrefreader.setKeys(set); keyrefreader.read(filename.toURI(), readMap(filename)); final KeyScope act = keyrefreader.getKeyDefinition(); final Map<String, String> exp = new HashMap<String, String>(); exp.put( "blatfeference", "<topicref keys='blatview blatfeference blatintro' href='blatview.dita' navtitle='blatview' locktitle='yes' class='- map/topicref '/>"); exp.put( "blatview", "<topicref keys='blatview blatfeference blatintro' href='blatview.dita' navtitle='blatview' locktitle='yes' class='- map/topicref '/>"); exp.put( "blatintro", "<topicref keys='blatview blatfeference blatintro' href='blatview.dita' navtitle='blatview' locktitle='yes' class='- map/topicref '/>"); exp.put( "keyword", "<topicref keys='keyword' class='- map/topicref '><topicmeta class='- map/topicmeta '><keywords class='- topic/keywords '><keyword class='- topic/keyword '>keyword value</keyword></keywords></topicmeta></topicref>"); exp.put( "escape", "<topicref keys='escape' class='- map/topicref ' navtitle='&<>"''><topicmeta class='- map/topicmeta '><keywords class='- topic/keywords '><keyword class='- topic/keyword '>&<>"'</keyword></keywords></topicmeta></topicref>"); exp.put( "top", "<topicref keys='top' class='- map/topicref ' navtitle='top'><topicmeta class='- map/topicmeta '><keywords class='- topic/keywords '><keyword class='- topic/keyword '>top keyword</keyword></keywords></topicmeta><topicref keys='nested' class='- map/topicref ' navtitle='nested'><topicmeta class='- map/topicmeta '><keywords class='- topic/keywords '><keyword class='- topic/keyword '>nested keyword</keyword></keywords></topicmeta></topicref></topicref>"); exp.put( "nested", "<topicref keys='nested' class='- map/topicref ' navtitle='nested'><topicmeta class='- map/topicmeta '><keywords class='- topic/keywords '><keyword class='- topic/keyword '>nested keyword</keyword></keywords></topicmeta></topicref>"); TestUtils.resetXMLUnit(); XMLUnit.setIgnoreWhitespace(true); assertEquals(exp.keySet(), act.keySet()); for (Map.Entry<String, String> e : exp.entrySet()) { final Document ev = keyDefToDoc(e.getValue()); final Document av = act.get(e.getKey()).element.getOwnerDocument(); assertXMLEqual(ev, av); } }
@Override protected void setUp() throws Exception { XMLUnit.setIgnoreWhitespace(true); phone = new PolycomPhone(); PolycomModel model = new PolycomModel(); model.setMaxLineCount(6); phone.setModel(model); PhoneTestDriver.supplyTestData(phone); m_location = new MemoryProfileLocation(); VelocityProfileGenerator pg = new VelocityProfileGenerator(); pg.setVelocityEngine(TestHelper.getVelocityEngine()); m_pg = pg; }
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreAttributeOrder(true); this.schemaContext = parseSchemas(getYangSchemas()); schemaContext.getModules(); final SchemaService schemaService = createSchemaService(); final DOMStore operStore = InMemoryDOMDataStoreFactory.create("DOM-OPER", schemaService); final DOMStore configStore = InMemoryDOMDataStoreFactory.create("DOM-CFG", schemaService); final EnumMap<LogicalDatastoreType, DOMStore> datastores = new EnumMap<>(LogicalDatastoreType.class); datastores.put(LogicalDatastoreType.CONFIGURATION, configStore); datastores.put(LogicalDatastoreType.OPERATIONAL, operStore); ExecutorService listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(16, 16, "CommitFutures"); final ConcurrentDOMDataBroker cdb = new ConcurrentDOMDataBroker(datastores, listenableFutureExecutor); this.transactionProvider = new TransactionProvider(cdb, sessionIdForReporting); doAnswer( new Answer() { @Override public Object answer(final InvocationOnMock invocationOnMock) throws Throwable { final SourceIdentifier sId = (SourceIdentifier) invocationOnMock.getArguments()[0]; final YangTextSchemaSource yangTextSchemaSource = YangTextSchemaSource.delegateForByteSource( sId, ByteSource.wrap("module test".getBytes())); return Futures.immediateCheckedFuture(yangTextSchemaSource); } }) .when(sourceProvider) .getSource(any(SourceIdentifier.class)); this.currentSchemaContext = new CurrentSchemaContext(schemaService, sourceProvider); }
public void testRoundTrip() throws Exception { StringWriter sw = new StringWriter(); InputStream original = getClass().getClassLoader().getResourceAsStream("testmodel_data.xml"); XMLUnit.setIgnoreWhitespace(true); Collection unmarshalled = (Collection) binding.unmarshal(original); setIds(unmarshalled); binding.marshal(unmarshalled, sw); String expected = IOUtils.toString(getClass().getClassLoader().getResourceAsStream("testmodel_data.xml")); Diff diff = new Diff(expected, sw.toString()); DetailedDiff detail = new DetailedDiff(diff); detail.overrideElementQualifier(new ElementNameAndAttributeQualifier()); assertTrue( detail.getAllDifferences().toString() + ": Original: " + expected + ", Generated: " + sw.toString(), detail.similar()); }
{ XMLUnit.setIgnoreWhitespace(true); }
protected void assertExpected(Method deeracMethod, String file) throws Exception { String expected = readXmlFromFile(file); String actual = serialize(deeracMethod); XMLUnit.setIgnoreWhitespace(true); assertXMLEqual(expected, actual); }
static Diff isSimilarXml(String expectedXml, String xml) throws Exception { XMLUnit.setIgnoreWhitespace(true); return XMLUnit.compareXML(xml, expectedXml); }
@Before public void setUp() { converter = new AtomFeedHttpMessageConverter(); XMLUnit.setIgnoreWhitespace(true); }
@Before public void createView() throws Exception { view = new MyRssFeedView(); setIgnoreWhitespace(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(); } } } }