From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20629 invoked by alias); 16 Jan 2006 02:46:43 -0000 Received: (qmail 20621 invoked by uid 22791); 16 Jan 2006 02:46:43 -0000 X-Spam-Check-By: sourceware.org Received: from smtp011.mail.yahoo.com (HELO smtp011.mail.yahoo.com) (216.136.173.31) by sourceware.org (qpsmtpd/0.31) with SMTP; Mon, 16 Jan 2006 02:46:41 +0000 Received: (qmail 67182 invoked from network); 16 Jan 2006 02:46:39 -0000 Received: from unknown (HELO 17925329.rjo.virtua.com.br) (izecksohn@200.179.253.29 with plain) by smtp011.mail.yahoo.com with SMTP; 16 Jan 2006 02:46:38 -0000 From: Pedro Izecksohn To: mauve-discuss@sources.redhat.com Subject: Proposed Mauve test: childNodesLength Date: Mon, 16 Jan 2006 02:46:00 -0000 User-Agent: KMail/1.7.2 Cc: Chris Burdess , Mark Wielaard MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_/VyyDjh+4Bk2frr" Message-Id: <200601160047.59642.izecksohn@yahoo.com> Mailing-List: contact mauve-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: mauve-discuss-owner@sourceware.org X-SW-Source: 2006-q1/txt/msg00009.txt.bz2 --Boundary-00=_/VyyDjh+4Bk2frr Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 24 Two files are attached. --Boundary-00=_/VyyDjh+4Bk2frr Content-Type: text/xml; charset="us-ascii"; name="test.xml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="test.xml" Content-length: 285 ]> This is a Text Node. --Boundary-00=_/VyyDjh+4Bk2frr Content-Type: text/x-java; charset="us-ascii"; name="childNodesLength.java" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="childNodesLength.java" Content-length: 3426 // 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; i0) {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."); } } } --Boundary-00=_/VyyDjh+4Bk2frr--