From: SourceForge.net <no...@so...> - 2008-10-18 08:08:19
|
Bugs item #2141988, was opened at 2008-10-02 10:13 Message generated for change (Comment added) made by cdeneux You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2141988&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: Java 1.1 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Christophe DENEUX (cdeneux) Assigned to: Nobody/Anonymous (nobody) Summary: Qualified values and XMLAssert.assertXpathEvaluatesTo Initial Comment: I try to use XMLAssert.assertXpathEvaluatesTo to check a node value (faulcode value of a SOAP Fault). The value is a qualified value. XMLAssert.assertXpathEvaluatesTo does not work correctly with qualified value. In the namespace context, if you set a prefix different than the one in your XML document, you can't be able to have a successfull test, expect if you set the prefix provided by your XML document. My XML: <?xml version="1.0" encoding="UTF-8"?> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><env:Fault><faultcode>env:Server</faultcode><faultstring>marche pas</faultstring><detail/></env:Fault></env:Body></env:Envelope> My namespace context: final Map<String, String> namespaces = new HashMap<String, String>(); namespaces.put("env11", "http://schemas.xmlsoap.org/soap/envelope/"); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces)); My assert: XMLAssert.assertXpathEvaluatesTo("env11:Server", "//env11:Envelope/env11:Body/env11:Fault/faultcode", faultDocument); ---------------------------------------------------------------------- Comment By: Christophe DENEUX (cdeneux) Date: 2008-10-18 10:08 Message: Yes, right, perhaps can you add a new assert to check qualified values: assertXpathEvaluatesTo(QName, String, Document) ? This assert expects that the value is a qualified value, if not the assert fails. If the qualied value is not the expected one, the assert fails. Example: XMLAssert.assertXpathEvaluatesTo(new QName("http://schemas.xmlsoap.org/soap/envelope/", "Server"), "//env11:Envelope/env11:Body/env11:Fault/faultcode", faultDocument); ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2008-10-09 14:47 Message: Hmm, env:Server is just the textual content of an element from a pure XML point of view. How should XMLUnit know that env: inside some arbitrary text is supposed to be the prefix attached to an XML namespace? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2141988&group_id=23187 |