Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7197

Strange behaviour during parent() method invocation on the non existent node (XmlSlurper).

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.3.7
    • Fix Version/s: None
    • Component/s: XML Processing
    • Labels:
      None
    • Environment:
      Ubuntu 13.04, Groovy Console.

      Description

      I've migrated from Grails 2.2.5 (Groovy 2.0.8) to Grails 2.4.4 (Groovy 2.3.7) and some of my tests related to XmlSlurper start fail.

      Maybe it's normal behavior for now, but doesn't look so. Here is an simple example which easily can be run in groovy console.

      def testedXml = '''
      <a>
        <b>
          <c>some cool text</c>
        </b>
      </a>
      '''
      
      def root = new XmlSlurper().parseText(testedXml)
      
      def dNode = root.b.c.d
      
      //Use-case #1
      assert dNode.isEmpty()
      assert dNode.parent().name() == 'c'
      def cNode = dNode.parent()
      assert cNode.name() == 'c'
      // assume that node 'c' has node 'b' as parent
      assert cNode.parent().name() == 'b' // FAILED!
      
      //Use-case #2
      // Even if we try to convert from NodeParents to exect node.
      cNode = dNode.parent().getAt(0)
      assert cNode.name() == 'c'
      // assume that parent for node 'c' is 'b'
      assert cNode.parent().name() == 'b'// FAILED!
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              dnim Sergey Korsik
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: