public inbox for mauve-discuss@sourceware.org
 help / color / mirror / Atom feed
* Proposed Mauve test: childNodesLength
@ 2006-01-16  2:46 Pedro Izecksohn
  2006-01-16 15:15 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Pedro Izecksohn @ 2006-01-16  2:46 UTC (permalink / raw)
  To: mauve-discuss; +Cc: Chris Burdess, Mark Wielaard

[-- Attachment #1: Type: text/plain, Size: 24 bytes --]

Two files are attached.

[-- Attachment #2: test.xml --]
[-- Type: text/xml, Size: 285 bytes --]

<?xml version="1.0" standalone="yes"?>
<!DOCTYPE a [
<!ELEMENT a (b, kedit)>
<!ELEMENT b (#PCDATA)>
<!NOTATION kedit SYSTEM "kedit">
]>
<a>
	<!--This is a Comment.-->
	<b>This is a Text Node.</b>
	<?kedit This is a Processing Instruction. ?>
	<![CDATA[This is a CDATA section.]]>
</a>

[-- Attachment #3: childNodesLength.java --]
[-- Type: text/x-java, Size: 3426 bytes --]

// Tags: JDK1.4

// Tests some Node kinds if method .getChildNodes().getLength() return correctly.
// By: Pedro Izecksohn & Mark Wielaard

// Part of the Mauve project.

// Mauve is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.

// Mauve is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING.  If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor
// Boston, MA  02110-1301, USA.

package gnu.testlet.org.w3c.dom;

import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
import gnu.testlet.ResourceNotFoundException;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.*;

public class childNodesLength implements Testlet
{

  TestHarness harness;
  boolean passed;

  private void checkNode (Node node)
  {
    int nChilds = node.getChildNodes().getLength();

    if (
         (node instanceof CDATASection)||
         (node instanceof Comment)||
         (node instanceof DocumentType)||
         (node instanceof Notation)||
         (node instanceof ProcessingInstruction)||
         (node instanceof Text)
       )
    {
      harness.check (nChilds==0, node.getClass().getName());
    }
  }

  private void recurse (NodeList nl)
  {
    for (int i=0; i<nl.getLength(); i++)
    {

      Node node = nl.item (i);
      if (node==null) {continue;}

      checkNode (node);

      if (node instanceof DocumentType)
      {
        DocumentType dt = (DocumentType) node;
        NamedNodeMap nnm = dt.getNotations();

        for (int j=0; j<nnm.getLength(); j++)
        {
          checkNode((Notation)nnm.item(j));
        }
      }

      NodeList nl2 = node.getChildNodes();
      int nChilds = nl2.getLength();
      if (nChilds>0) {recurse (nl2);}
    }
  }

  public void test (TestHarness harness)
  {

    this.harness=harness;

    passed=true;

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

    DocumentBuilder db = null;
    try
    {
      db = dbf.newDocumentBuilder();
    }
    catch (javax.xml.parsers.ParserConfigurationException pce)
    {
      harness.debug (pce);
      harness.check(false);
      return;
    }

    // I need a xml file to parse.
    InputStream input = null;

    try
    {
      input = harness.getResourceStream ("gnu#testlet#org#w3c#dom#test.xml");
    }
    catch (ResourceNotFoundException rnfe)
    {
      harness.debug (rnfe);
      harness.check(false);
      return;
    }

    Document document = null;
    try
    {
      document = db.parse(input);
    }
    catch (Exception e)
    {
      harness.debug (e);
      harness.check(false);
      return;
    }

    recurse (document.getChildNodes());

    if (passed)
    {
      harness.check (true, "All Node kinds tested implement .getChildNodes().getLength() correctly.");
    }
    else
    {
      harness.fail ("Some Node kind does NOT implement .getChildNodes().getLength() correctly.");
    }

  }

}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Proposed Mauve test: childNodesLength
  2006-01-16  2:46 Proposed Mauve test: childNodesLength Pedro Izecksohn
@ 2006-01-16 15:15 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2006-01-16 15:15 UTC (permalink / raw)
  To: Pedro Izecksohn; +Cc: mauve-discuss, Chris Burdess

[-- Attachment #1: Type: text/plain, Size: 1072 bytes --]

Hi Pedro,

On Mon, 2006-01-16 at 00:47 -0400, Pedro Izecksohn wrote:
> Two files are attached.

Thanks! I have committed them as follows:

2006-01-16  Pedro Izecksohn  <izecksohn@yahoo.com>

        * gnu/testlet/org/w3c/dom/childNodesLength.java: New test.
        * gnu/testlet/org/w3c/dom/test.xml: New data file.

Of course a couple of these tests still fail against GNU Classpath dom
implementation till we get your patch for that in.

BTW. We are trying to setup the DOM test suites are at

    http://www.w3.org/DOM/Test/

We currently test against Level 3 Core (although we could test
against Level 2 HTML and Level 3 Load and Save as well).

See our current results at:
http://builder.classpath.org/xml/dom.html

It would be ideal if we can turn these tests into mauve like PASS/FAIL
results. Then we can more easily create automatic regression reports
with the existing scripts on builder.classpath.org.

Maybe you are interesting at looking at the tests and the results (we
still have a lot of failures there)?

Cheers,

Mark

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-01-16 15:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-16  2:46 Proposed Mauve test: childNodesLength Pedro Izecksohn
2006-01-16 15:15 ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).