Revision: 2147
          http://vexi.svn.sourceforge.net/vexi/?rev=2147&view=rev
Author:   mkpg2
Date:     2007-09-08 17:15:06 -0700 (Sat, 08 Sep 2007)

Log Message:
-----------
TestCase. Tests handling of Entities in XML attributes.
 Done by comparing XML.java to SAX.

Added Paths:
-----------
    trunk/core/org.ibex.util/src_junit/
    trunk/core/org.ibex.util/src_junit/org/
    trunk/core/org.ibex.util/src_junit/org/ibex/
    trunk/core/org.ibex.util/src_junit/org/ibex/util/
    trunk/core/org.ibex.util/src_junit/org/ibex/util/TestXML.java

Added: trunk/core/org.ibex.util/src_junit/org/ibex/util/TestXML.java
===================================================================
--- trunk/core/org.ibex.util/src_junit/org/ibex/util/TestXML.java               
                (rev 0)
+++ trunk/core/org.ibex.util/src_junit/org/ibex/util/TestXML.java       
2007-09-09 00:15:06 UTC (rev 2147)
@@ -0,0 +1,59 @@
+package org.ibex.util;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.HashMap;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import junit.framework.TestCase;
+
+import org.ibex.util.XML;
+import org.ibex.util.Tree.Element;
+import org.ibex.util.XML.Exn;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+
+public class TestXML extends TestCase{
+       
+    static SAXParserFactory factory = SAXParserFactory.newInstance();
+       static class XML_ extends XML{
+        HashMap store = new HashMap();
+               public void characters(char[] ch, int start, int length) throws 
Exn, IOException {}
+               public void endElement(Element e) throws Exn, IOException {}
+               public void startElement(Element e) throws Exn {}
+    }
+       
+    static class SAX_ extends DefaultHandler{
+        HashMap store = new HashMap();
+    }
+    
+       
+       public void testEntitiesInAttributes() throws Exception {
+               XML_ parser = new XML_(){
+                       public void startElement(Element e) throws Exn {
+                               store.put("x", e.getAttributes().getVal(0));
+                       }
+               };
+               SAX_ handler = new SAX_(){
+               public void startElement(String uri, String localName, String 
qName, Attributes attributes) throws SAXException {
+                       store.put("x", attributes.getValue(0));
+               }
+        };
+               String s = "<a x='&lt;'/>";
+               
+               
+               parser.parse( new StringReader(s));
+               System.out.println(parser.store.get("x"));
+               
+               SAXParser saxParser = factory.newSAXParser();
+               saxParser.parse( new ByteArrayInputStream(s.getBytes()), 
handler);
+
+               assertEquals(handler.store.get("x"), parser.store.get("x"));
+               
+       }
+
+}


Property changes on: 
trunk/core/org.ibex.util/src_junit/org/ibex/util/TestXML.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to