jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r615950 - /jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/xml/ImportContentHandlerTest.java
Date Mon, 28 Jan 2008 16:56:17 GMT
Author: jukka
Date: Mon Jan 28 08:56:15 2008
New Revision: 615950

URL: http://svn.apache.org/viewvc?rev=615950&view=rev
Log:
JCR-1343: Replace use of Xerces by JAXP to implement SAX DocumentHandler
    - Improved test case, previous one was throwing an NPE
      because of the null attributes argument to startElement()

Modified:
    jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/xml/ImportContentHandlerTest.java

Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/xml/ImportContentHandlerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/xml/ImportContentHandlerTest.java?rev=615950&r1=615949&r2=615950&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/xml/ImportContentHandlerTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/xml/ImportContentHandlerTest.java
Mon Jan 28 08:56:15 2008
@@ -18,32 +18,32 @@
  */
 package org.apache.jackrabbit.rmi.xml;
 
-import java.io.UnsupportedEncodingException;
-
 import javax.jcr.RepositoryException;
 
 import junit.framework.TestCase;
 
 import org.apache.jackrabbit.rmi.xml.ImportContentHandler;
-import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
 
 public class ImportContentHandlerTest extends TestCase {
 
-    public void testImportContentHandler() throws RepositoryException, SAXException {
+    public void testImportContentHandler() throws Exception {
         // fail test if handler cannot be set up
         DummyImportContentHandler ch = new DummyImportContentHandler();
 
         // these may throw SAXException
         ch.startDocument();
-        ch.startElement(null, "sample", "sample", null);
-        ch.endElement(null, "sample", "sample");
+        ch.startPrefixMapping("foo", "http://example.com/ns/foo");
+        ch.startElement(
+                "http://example.com/ns/foo", "sample", "foo:sample",
+                new AttributesImpl());
+        ch.endElement("http://example.com/ns/foo", "sample", "foo:sample");
+        ch.endPrefixMapping("foo");
         ch.endDocument();
 
-        byte[] xml = ch.getXML();
-        assertNotNull("Serialized XML is null", xml);
-        assertTrue("Serialized XML is empty", xml.length > 0);
-
-        // for the moment we don't actually care for the concrete contents
+        String xml = new String(ch.getXML(), "UTF-8");
+        assertTrue(xml.contains(
+                "<foo:sample xmlns:foo=\"http://example.com/ns/foo\"/>"));
     }
 
     private static class DummyImportContentHandler extends ImportContentHandler {



Mime
View raw message