From xap-commits-return-666-apmail-incubator-xap-commits-archive=incubator.apache.org@incubator.apache.org Sun Nov 05 18:51:12 2006 Return-Path: Delivered-To: apmail-incubator-xap-commits-archive@locus.apache.org Received: (qmail 20562 invoked from network); 5 Nov 2006 18:51:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Nov 2006 18:51:11 -0000 Received: (qmail 71734 invoked by uid 500); 5 Nov 2006 18:51:23 -0000 Delivered-To: apmail-incubator-xap-commits-archive@incubator.apache.org Received: (qmail 71713 invoked by uid 500); 5 Nov 2006 18:51:22 -0000 Mailing-List: contact xap-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: xap-dev@incubator.apache.org Delivered-To: mailing list xap-commits@incubator.apache.org Received: (qmail 71704 invoked by uid 99); 5 Nov 2006 18:51:22 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Nov 2006 10:51:22 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Nov 2006 10:51:09 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 8B8CF1A9846; Sun, 5 Nov 2006 10:50:43 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r471493 - in /incubator/xap/trunk/testsrc/xap/xml: _TestParser.html parserTestStrings.js parserTester.js Date: Sun, 05 Nov 2006 18:50:43 -0000 To: xap-commits@incubator.apache.org From: bbuffone@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061105185043.8B8CF1A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bbuffone Date: Sun Nov 5 10:50:42 2006 New Revision: 471493 URL: http://svn.apache.org/viewvc?view=rev&rev=471493 Log: updated unit tests for parser. added embedded namespace tests and remove the duplicate Attribute test. No longer valid Modified: incubator/xap/trunk/testsrc/xap/xml/_TestParser.html incubator/xap/trunk/testsrc/xap/xml/parserTestStrings.js incubator/xap/trunk/testsrc/xap/xml/parserTester.js Modified: incubator/xap/trunk/testsrc/xap/xml/_TestParser.html URL: http://svn.apache.org/viewvc/incubator/xap/trunk/testsrc/xap/xml/_TestParser.html?view=diff&rev=471493&r1=471492&r2=471493 ============================================================================== --- incubator/xap/trunk/testsrc/xap/xml/_TestParser.html (original) +++ incubator/xap/trunk/testsrc/xap/xml/_TestParser.html Sun Nov 5 10:50:42 2006 @@ -22,20 +22,15 @@ dojo.hostenv.setModulePrefix("dojo", "../dojo/src"); dojo.hostenv.setModulePrefix("xap", "../xap"); dojo.hostenv.setModulePrefix("google", "../google"); - Xap.require("xap.xml.sax.SaxContentHandler"); - Xap.require("xap.xml.sax.SaxParser"); + Xap.require("xap.xml.ParserFactory"); //----------------------------------------------------------------------- // Parser-specific Methods. //----------------------------------------------------------------------- function createDoc(xmlString){ - var handler = new xap.xml.sax.SaxContentHandler(); - var parser = new xap.xml.sax.SaxParser(handler); - - parser.setDocumentHandler( handler ); - parser.parse( xmlString ) ; - return handler._document ; + var parser = xap.xml.ParserFactory.getParser(); + return parser.parse( xmlString ) ; } @@ -129,16 +124,58 @@ } function testEmptyDocument() { - assertSpecificExceptionThrownOnParse(EMPTY_DOCUMENT, - "xap.xml.sax.EmptyDocumentException"); - } + exceptionThrown = false; + try{ + var doc = createDoc(EMPTY_DOCUMENT); + } catch(ee){ + exceptionThrown = true; + } + + assertTrue("An exception should have been thrown for emtpy document.", + exceptionThrown); + } + + function testCompoundNamespacesDocument() { + exceptionThrown = false; + try{ + var doc = createDoc(COMPOUND_NAMESPACE); + + assertTrue("Compound Namespaces: Make sure the root element has a namespace of http://www.openxal.org/xal.", + doc.getRootElement().getNamespaceUri() == "http://www.openxal.org/xal"); + + assertTrue("Compound Namespaces: Make sure the root element has a prefix of \"\".", + doc.getRootElement().getPrefix() == ""); + + assertTrue("Compound Namespaces: Make sure the root element has a namespace of http://www.openxal.org/xmodify.", + doc.getRootElement().childNodes[0].getNamespaceUri() == "http://www.openxal.org/xmodify"); + + assertTrue("Compound Namespaces: Make sure the root element has a prefix of \"\".", + doc.getRootElement().childNodes[0].getPrefix() == "xm"); + } catch(ee){ + exceptionThrown = true; + } + + } + + /* function testDuplicateAttributeNames() { - var doc = createDoc(DUPLICATE_ATTRIBUTES_ON_ELEMENT); - assertEquals("If there are two attributes with the same name, " + - "the second one should take precedence.", - doc.getRootElement().getAttribute("name"), "value2"); + //var doc = createDoc(DUPLICATE_ATTRIBUTES_ON_ELEMENT); + //assertEquals("If there are two attributes with the same name, " + + // "the second one should take precedence.", + // doc.getRootElement().getAttribute("name"), "value2"); + + exceptionThrown = false; + try{ + doc = createDoc(DUPLICATE_ATTRIBUTES_ON_ELEMENT); + } catch(ee){ + exceptionThrown = true; + } + assertTrue("An exception should have been thrown for invalid xml duplicate attributes.", + exceptionThrown); + } + */ function testTextAndCdata() { var doc = createDoc(TEXT_AND_CDATA); @@ -169,7 +206,9 @@ var doc = createDoc(EMPLOYEE_XML); // Made it here, so exceptionThrown = false ; - } catch(ee) {} + } catch(ee) { + alert(ee); + } assertFalse(exceptionThrown) ; /* Breaks unit test coherence.... Modified: incubator/xap/trunk/testsrc/xap/xml/parserTestStrings.js URL: http://svn.apache.org/viewvc/incubator/xap/trunk/testsrc/xap/xml/parserTestStrings.js?view=diff&rev=471493&r1=471492&r2=471493 ============================================================================== --- incubator/xap/trunk/testsrc/xap/xml/parserTestStrings.js (original) +++ incubator/xap/trunk/testsrc/xap/xml/parserTestStrings.js Sun Nov 5 10:50:42 2006 @@ -171,7 +171,14 @@ "\n"; - +COMPOUND_NAMESPACE = "\n" + +"\n" + +"\n" + +"\n" + +"\n" + +" \n" + +"\n" + +""; allParserTestStringNames = new Array(0) ; allParserTestStringNames[0] = "TWO_ROOT_ELEMENTS" ; Modified: incubator/xap/trunk/testsrc/xap/xml/parserTester.js URL: http://svn.apache.org/viewvc/incubator/xap/trunk/testsrc/xap/xml/parserTester.js?view=diff&rev=471493&r1=471492&r2=471493 ============================================================================== --- incubator/xap/trunk/testsrc/xap/xml/parserTester.js (original) +++ incubator/xap/trunk/testsrc/xap/xml/parserTester.js Sun Nov 5 10:50:42 2006 @@ -69,9 +69,7 @@ resultString += "\n"+index+": "+ theStr; try { - var parser = new xap.xml.sax.SaxParser(); - var handler = new xap.xml.sax.SaxContentHandler(); - parser.setDocumentHandler( handler ); + var parser = xap.xml.ParserFactory.getParser(); parser.parse(theStr) ; //result = Xparse(theStr) ; //toXml = retag(result).replace(/<[\/]*ROOT>/g,"") ;