incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bbuff...@apache.org
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 GMT
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 @@
 "</pre:Root>\n";
 
 
-
+COMPOUND_NAMESPACE = "<xal xmlns=\"http://www.openxal.org/xal\" xmlns:xal=\"http://www.openxal.org/xal\">\n"
+
+"<xm:modifications xmlns:xm=\"http://www.openxal.org/xmodify\">\n" +
+"<xm:append select=\"/xal\">\n" +
+"<verticalPanel backgroundColor=\"#EEE\" align=\"stretch\" width=\"800px\" height=\"600px\"
fontSize=\"11px\" fontFamily=\"Arial\">\n" +
+"</verticalPanel>\n" +
+"</xm:append> 	  		\n" +
+"</xm:modifications>\n" +
+"</xal>";
 
 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,"") ;



Mime
View raw message