Coder Social home page Coder Social logo

xml-matchers's People

Contributors

davidehringer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

xml-matchers's Issues

XpathReturnType missing for NodeList

I need an XpathReturnType for xpath expressions that match a node list:

public static XpathReturnType<NodeList> returningAnXmlNodeList() {
      return new XpathReturnType<NodeList>() {
              @Override
              QName evaluationMode() {
                      return XPathConstants.NODESET;
              }};
   }

Original issue reported on code.google.com by [email protected] on 27 Oct 2011 at 4:47

Prefixes and sort order are checked too restrictive

The attached maven project proofs (JUnit test included) that prefixes and sort 
orders are checked too restrictive. AFAIK, according to the XML specifications 
it plays no role whether prefixes are used or not, or what name these have, as 
long as they refer to the same namespace URL.

Out of this assumption result the bugs I found:

(1) Test fails because expected was "D:" but actual was "d:".
(2) Test fails because expected was "D:" but actual was "P:".
(3) Test fails because expected was "D:" but actual was default namespace.

Another bug I found is that AFAIK the order of XML elements plays no role 
unless a specific order is specified explicitly using a schema:

(4) Test fails due to different order of elements, but no schema is provided to 
enforce this.

Original issue reported on code.google.com by headcrashing on 29 Jan 2013 at 9:41

Attachments:

XPath 2.0 is not supported

Looks like XPath 2.0 is not supported:

assertThat(
  XmlConverters.the(xml),
  org.xmlmatchers.XmlMatchers.hasXPath("//a[ends-with(@id, '-test')]")
);

Leads to:

java.lang.IllegalArgumentException: Invalid XPath : //a[ends-with(@id, '-test')]
    at org.xmlmatchers.xpath.HasXPath.<init>(HasXPath.java:81)
    at org.xmlmatchers.xpath.HasXPath.<init>(HasXPath.java:63)
    at org.xmlmatchers.xpath.HasXPath.<init>(HasXPath.java:58)
    at org.xmlmatchers.xpath.HasXPath.hasXPath(HasXPath.java:146)
    at org.xmlmatchers.XmlMatchers.hasXPath(XmlMatchers.java:27)
        .........

Original issue reported on code.google.com by yegor256 on 6 Jul 2011 at 9:05

XpathReturnType.returningAnXmlNode() returns an XpathReturnType<String>, not <Source>

The function `returningAnXmlNode` has the signature:

    public static XpathReturnType<String> returningAnXmlNode()

This seems odd, given that it matches against a `Source` object. Somehow, JDK 7 
manages to compile it regardless, but it still seems incorrect.

IntelliJ IDEA flags it as an error and refuses to build it. This is not a 
massive concern, as it can still be built through the command line (though it 
is quite annoying).

I might be missing something, but if not, could we update the signature (and 
implementation) to return an XpathReturnType<Source>?

Thanks for an excellent library.

โ€” Samir.

Original issue reported on code.google.com by [email protected] on 18 Sep 2014 at 3:37

XpathReturnType.returningAnXmlNode() does not have a very usable return type

The following test example show how you can't do what you might think you want 
to do.

    @Test
    @Ignore("Using a Source breaks this use case")
    public void theResultOfTheXpathCanMatchedUsingEquivalentToWhenTheResultIsAnXmlFragment() {
//      assertThat(
//              xml,
//              hasXPath("/mountains/mountain[@id='a']/name",
//                      returningAnXmlNode(),
//                      equivalentTo("<name>Everest</name>")));
    }

    @Test
    @Ignore("Using a Source breaks this use case")
    public void matchingNodesCanBeTestedForEquivalence() {
//      assertThat(
//              xml,
//              hasXPath(
//                      "/mountains/mountain[@id='a']/name",
//                      returningAnXmlNode(),
//                      equivalentTo("<name><!-- some comment -->Everest</name>")));
    }



Original issue reported on code.google.com by [email protected] on 17 Feb 2013 at 10:31

DOMSource used in "the" does not have useful toString method

This leads to hard to debug assertion failures. Maybe this method could be 
improved:

public static Source the(Node node) {
 return new DOMSource(node);
}

Possibly it could be implemented as

public static Source the(Node node) {
 return new DOMSource(node){
            @Override
            public String toString()
            {
               return node.toString();
            }};
}

Original issue reported on code.google.com by [email protected] on 27 Oct 2011 at 3:58

XpathReturnType does not allow new return types to be added

org.xmlmatchers.xpath.XpathReturnType.evaluationMode() is marked as package 
visibility. 

public abstract class XpathReturnType<T> {
    abstract QName evaluationMode();
}

If it were "protected" visibility new XpathReturnTypes could be added:

public abstract class XpathReturnType<T> {
    protected abstract QName evaluationMode();
}


Original issue reported on code.google.com by [email protected] on 27 Oct 2011 at 4:49

StringSource uses default encoding when calling getBytes() on XML-String

The problem arises when I create a test that reads XML from a string, does some 
processing and then uses XmlMatchers to validate the resulting XML.

It works fine when running in an UTF-8 environment, but on my ISO-8859-1 build 
server the test fails with: MalformedByteSequenceException: Invalid byte 1 of 
1-byte UTF-8 sequence. Coming from within the StringSource constructor.

When creating the ByteArrayInputStream for the DocumentBuilder, you currently 
call String.getBytes(). I would like to see an alternative constructor that 
allows passing a Charset so we can call String.getBytes(Charset) instead. 

This way we got full control over the encoding used.

Original issue reported on code.google.com by [email protected] on 13 Dec 2012 at 7:40

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.