public PomAssert(String content) { this.content = content; this.eng = XMLUnit.newXpathEngine(); Map<String, String> context = new LinkedHashMap<>(); context.put("pom", "http://maven.apache.org/POM/4.0.0"); SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext(context); this.eng.setNamespaceContext(namespaceContext); try { this.doc = XMLUnit.buildControlDocument(content); } catch (Exception ex) { throw new IllegalArgumentException("Cannot parse XML", ex); } this.parentPom = parseParent(); parseProperties(); parseDependencies(); parseBoms(); parseRepositories(); }
@Test public void testRemoveInvalidXMLChars() throws Exception { SimpleFeatureType ft = DataUtilities.createType( TEST.TestFeature.getNamespaceURI(), TEST.TestFeature.getLocalPart(), "the_geom:Point,data:String"); SimpleFeature feature = SimpleFeatureBuilder.build( ft, new Object[] { new WKTReader().read("POINT(0 0)"), "One " + ((char) 0x7) + " test" }, "123"); SimpleFeatureCollection fc = DataUtilities.collection(feature); TestConfiguration configuration = new TestConfiguration(); Encoder encoder = new Encoder(configuration); String result = encoder.encodeAsString(feature, TEST.TestFeature); // System.out.println(result); Document dom = XMLUnit.buildControlDocument(result); assertXpathEvaluatesTo("One test", "//test:data", dom); } }
public static void assertXPathMatches(String message, String regex, String xpath, Reader reader) throws XpathException, SAXException, IOException { Document doc = XMLUnit.buildControlDocument(new InputSource(reader)); assertXPathMatches(message, regex, xpath, doc); }
public static void assertXPathMatches(String message, String regex, String xpath, String xml) throws XpathException, SAXException, IOException { Document doc = XMLUnit.buildControlDocument(xml); assertXPathMatches(message, regex, xpath, doc); }
/** * Assert that a specific XPath does NOT exist in some given XML * @param xPathExpression * @param inXMLString * @see XpathEngine which provides the underlying evaluation mechanism */ public static void assertXpathNotExists(String xPathExpression, String inXMLString) throws IOException, SAXException, XpathException { Document inDocument = XMLUnit.buildControlDocument(inXMLString); assertXpathNotExists(xPathExpression, inDocument); }
/** * Assert that a specific XPath does NOT exist in some given XML * @param inXpathExpression * @param inXMLString * @see XpathEngine which provides the underlying evaluation mechanism */ public static void assertXpathNotExists(String xPathExpression, String inXMLString) throws IOException, SAXException, XpathException { Document inDocument = XMLUnit.buildControlDocument(inXMLString); assertXpathNotExists(xPathExpression, inDocument); }
public static void assertXPathMatches(String message, String regex, String xpath, String xml) throws XpathException, SAXException, IOException { Document doc = XMLUnit.buildControlDocument(xml); assertXPathMatches(message, regex, xpath, doc); }
private int getNumberNonAuditDatastreams(byte [] objectXML) throws Exception { String xmlIn = new String(objectXML, "UTF-8"); Document doc = XMLUnit.buildControlDocument(xmlIn); return getNumberNonAuditDatastreams(doc); }
public static void assertXPathMatches(String message, String regex, String xpath, Reader reader) throws XpathException, SAXException, IOException { Document doc = XMLUnit.buildControlDocument(new InputSource(reader)); assertXPathMatches(message, regex, xpath, doc); }
/** * Assert that a specific XPath exists in some given XML * @param xPathExpression * @param inXMLString * @see XpathEngine which provides the underlying evaluation mechanism */ public static void assertXpathExists(String xPathExpression, String inXMLString) throws IOException, SAXException, XpathException { Document inDocument = XMLUnit.buildControlDocument(inXMLString); assertXpathExists(xPathExpression, inDocument); }
/** * Construct a Diff that compares the XML in a control Document against the * result of a transformation */ public Diff(String control, Transform testTransform) throws IOException, TransformerException, SAXException { this(XMLUnit.buildControlDocument(control), testTransform.getResultDocument()); }
/** * Assert that a specific XPath exists in some given XML * @param xPathExpression * @param control * @see XpathEngine which provides the underlying evaluation mechanism */ public static void assertXpathExists(String xPathExpression, InputSource control) throws IOException, SAXException, XpathException { Document inDocument = XMLUnit.buildControlDocument(control); assertXpathExists(xPathExpression, inDocument); }
/** * Assert that a specific XPath does NOT exist in some given XML * @param xPathExpression * @param control * @see XpathEngine which provides the underlying evaluation mechanism */ public static void assertXpathNotExists(String xPathExpression, InputSource control) throws IOException, SAXException, XpathException { Document inDocument = XMLUnit.buildControlDocument(control); assertXpathNotExists(xPathExpression, inDocument); }
/** * Construct a Diff that compares the XML in a control Document against the * result of a transformation */ public Diff(String control, Transform testTransform) throws IOException, TransformerException, SAXException { this(XMLUnit.buildControlDocument(control), testTransform.getResultDocument()); }
/** * Assert that a specific XPath exists in some given XML * @param inXpathExpression * @param inXMLString * @see XpathEngine which provides the underlying evaluation mechanism */ public static void assertXpathExists(String xPathExpression, String inXMLString) throws IOException, SAXException, XpathException { Document inDocument = XMLUnit.buildControlDocument(inXMLString); assertXpathExists(xPathExpression, inDocument); }
/** * Assert that a specific XPath exists in some given XML * @param inXpathExpression * @param control * @see XpathEngine which provides the underlying evaluation mechanism */ public static void assertXpathExists(String xPathExpression, InputSource control) throws IOException, SAXException, XpathException { Document inDocument = XMLUnit.buildControlDocument(control); assertXpathExists(xPathExpression, inDocument); }
/** * Assert that a specific XPath does NOT exist in some given XML * @param inXpathExpression * @param control * @see XpathEngine which provides the underlying evaluation mechanism */ public static void assertXpathNotExists(String xPathExpression, InputSource control) throws IOException, SAXException, XpathException { Document inDocument = XMLUnit.buildControlDocument(control); assertXpathNotExists(xPathExpression, inDocument); }
/** * Assert that the node lists of two Xpaths in the same document are equal * @param controlXpath * @param testXpath * @param document * @see XpathEngine */ public static void assertXpathsEqual(String controlXpath, String testXpath, InputSource document) throws SAXException, IOException, XpathException { assertXpathsEqual(controlXpath, testXpath, XMLUnit.buildControlDocument(document)); }
public void testEncodeBigDecimal() throws Exception { SimpleFeatureType type = buildTestFeatureType(); SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type); builder.add("theName"); builder.add("theDescription"); builder.add(GML3MockData.point()); builder.add(null); builder.add(null); builder.add(null); builder.add(new BigDecimal("0.000000015")); SimpleFeature feature = builder.buildFeature("fid.1"); TestConfiguration configuration = new TestConfiguration(); Encoder encoder = new Encoder(configuration); encoder.setIndentSize(2); String xml = encoder.encodeAsString(feature, TEST.TestFeature); // System.out.println(xml); Document dom = XMLUnit.buildControlDocument(xml); assertXpathEvaluatesTo("0.000000015", "//test:decimal", dom); }
private Document getDocument(ByteArrayOutputStream out) throws Exception { return XMLUnit.buildControlDocument(new String(out.toByteArray(), "UTF-8")); } }