jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r468956 - in /jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api: AbstractImportXmlTest.java DocumentViewImportTest.java SerializationTest.java
Date Sun, 29 Oct 2006 19:20:18 GMT
Author: jukka
Date: Sun Oct 29 11:20:17 2006
New Revision: 468956

URL: http://svn.apache.org/viewvc?view=rev&rev=468956
Log:
JCR-602: Removed the Xerces dependency from the TCK tests.

Modified:
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/AbstractImportXmlTest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/DocumentViewImportTest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SerializationTest.java

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/AbstractImportXmlTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/AbstractImportXmlTest.java?view=diff&rev=468956&r1=468955&r2=468956
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/AbstractImportXmlTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/AbstractImportXmlTest.java
Sun Oct 29 11:20:17 2006
@@ -23,9 +23,8 @@
 import org.w3c.dom.Attr;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
 import org.xml.sax.InputSource;
-import org.xml.sax.helpers.XMLReaderFactory;
+import org.xml.sax.helpers.DefaultHandler;
 
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
@@ -38,6 +37,9 @@
 import javax.jcr.PathNotFoundException;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Result;
 import javax.xml.transform.Source;
@@ -245,7 +247,7 @@
      */
     public void importWithHandler(String absPath, Document document,
                                   int uuidBehaviour, boolean withWorkspace)
-            throws RepositoryException, SAXException, IOException {
+            throws Exception {
 
         serialize(document);
         BufferedInputStream bin = new BufferedInputStream(new FileInputStream(file));
@@ -256,11 +258,15 @@
         } else {
             handler = session.getImportContentHandler(absPath, uuidBehaviour);
         }
-        XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
-        parser.setContentHandler(handler);
 
-        InputSource source = new InputSource(bin);
-        parser.parse(source);
+        SAXParserFactory factory = SAXParserFactory.newInstance();
+        factory.setNamespaceAware(true);
+        factory.setFeature(
+                "http://xml.org/sax/features/namespace-prefixes", false);
+
+        SAXParser parser = factory.newSAXParser();
+        parser.parse(new InputSource(bin), (DefaultHandler) handler);
+
         if (!withWorkspace) {
             session.save();
         }
@@ -355,9 +361,10 @@
      * @throws RepositoryException
      * @throws IOException
      */
-    public void importRefNodeDocument(String absPath, String uuid, int uuidBehaviour,
-                                      boolean withWorkspace, boolean withHandler)
-            throws RepositoryException, IOException, SAXException {
+    public void importRefNodeDocument(
+            String absPath, String uuid, int uuidBehaviour,
+            boolean withWorkspace, boolean withHandler)
+            throws Exception {
 
         Document document = dom.newDocument();
         Element root = document.createElement(rootElem);

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/DocumentViewImportTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/DocumentViewImportTest.java?view=diff&rev=468956&r1=468955&r2=468956
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/DocumentViewImportTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/DocumentViewImportTest.java
Sun Oct 29 11:20:17 2006
@@ -60,29 +60,25 @@
         super.tearDown();
     }
 
-    public void testWorkspaceImportXml() throws RepositoryException,
-            IOException, SAXException, NotExecutableException {
+    public void testWorkspaceImportXml() throws Exception {
         withHandler = false;
         withWorkspace = WORKSPACE;
         doTestImportXML();
     }
 
-    public void testSessionImportXml() throws RepositoryException,
-            IOException, SAXException, NotExecutableException {
+    public void testSessionImportXml() throws Exception {
         withHandler = false;
         withWorkspace = SESSION;
         doTestImportXML();
     }
 
-    public void testWorkspaceGetImportContentHandler() throws RepositoryException,
-            SAXException, IOException, NotExecutableException {
+    public void testWorkspaceGetImportContentHandler() throws Exception {
         withHandler = true;
         withWorkspace = SESSION;
         doTestGetImportContentHandler();
     }
 
-    public void testSessionGetImportContentHandler() throws RepositoryException,
-            SAXException, IOException, NotExecutableException {
+    public void testSessionGetImportContentHandler() throws Exception {
         withHandler = true;
         withWorkspace = WORKSPACE;
         doTestGetImportContentHandler();
@@ -102,8 +98,7 @@
      * @throws SAXException
      * @throws NotExecutableException
      */
-    public void doTestImportXML() throws RepositoryException, IOException,
-            SAXException, NotExecutableException {
+    public void doTestImportXML() throws Exception {
 
         importXML(target, createSimpleDocument(), uuidBehaviour, withWorkspace);
 
@@ -130,8 +125,7 @@
      * @throws IOException
      * @throws NotExecutableException
      */
-    public void doTestGetImportContentHandler() throws RepositoryException,
-            SAXException, IOException, NotExecutableException {
+    public void doTestGetImportContentHandler() throws Exception {
 
         importWithHandler(target, createSimpleDocument(), uuidBehaviour, withWorkspace);
 
@@ -145,8 +139,7 @@
     }
 
 
-    private void performTests() throws RepositoryException, SAXException,
-            IOException, NotExecutableException {
+    private void performTests() throws Exception {
 
         checkImportSimpleXMLTree();
         checkNamespaceAdded();
@@ -285,8 +278,7 @@
      * Checks {@link ImportUUIDBehavior#IMPORT_UUID_CREATE_NEW} i.e. that a node
      * receives a new uuid when imported in any case.
      */
-    public void checkImportDocumentView_IMPORT_UUID_CREATE_NEW()
-            throws RepositoryException, IOException, SAXException, NotExecutableException
{
+    public void checkImportDocumentView_IMPORT_UUID_CREATE_NEW() throws Exception {
 
         String uuid = createReferenceableNode(referenced);
         // import a document with a element having the same uuid as the node referenced
@@ -304,7 +296,7 @@
      * the existing node is removed in case of uuid collision.
      */
     public void checkImportDocumentView_IMPORT_UUID_COLLISION_REMOVE_EXISTING()
-            throws RepositoryException, IOException, SAXException, NotExecutableException
{
+            throws Exception {
 
         String uuid = createReferenceableNode(referenced);
         // import a document with a element having the same uuid as the node referenced
@@ -334,7 +326,7 @@
      * collision occurs.
      */
     public void checkImportDocumentView_IMPORT_UUID_COLLISION_REPLACE_EXISTING()
-            throws RepositoryException, IOException, SAXException, NotExecutableException
{
+            throws Exception {
 
         String uuid = createReferenceableNode(referenced);
         // import a document with a element having the same uuid as the node referenced
@@ -359,7 +351,7 @@
      * @throws IOException
      */
     public void checkImportDocumentView_IMPORT_UUID_COLLISION_THROW()
-            throws RepositoryException, IOException, SAXException, NotExecutableException
{
+            throws Exception {
 
         String uuid = createReferenceableNode(referenced);
         try {
@@ -390,7 +382,7 @@
      * parent of the import target.
      */
     public void doTestSameUUIDAtAncestor(boolean withWorkspace, boolean withHandler)
-            throws RepositoryException, IOException, SAXException, NotExecutableException
{
+            throws Exception {
 
         String uuid = createReferenceableNode(referenced);
         Node node = testRootNode.getNode(referenced);
@@ -417,23 +409,19 @@
         }
     }
 
-    public void testSameUUIDAtAncestorWorkspaceHandler()
-            throws RepositoryException, IOException, SAXException, NotExecutableException
{
+    public void testSameUUIDAtAncestorWorkspaceHandler() throws Exception {
         doTestSameUUIDAtAncestor(WORKSPACE, CONTENTHANDLER);
     }
 
-    public void testSameUUIDAtAncestorWorkspace()
-            throws RepositoryException, IOException, SAXException, NotExecutableException
{
+    public void testSameUUIDAtAncestorWorkspace() throws Exception {
         doTestSameUUIDAtAncestor(WORKSPACE, STREAM);
     }
 
-    public void testSameUUIDAtAncestorSessionHandler()
-            throws RepositoryException, IOException, SAXException, NotExecutableException
 {
+    public void testSameUUIDAtAncestorSessionHandler() throws Exception  {
         doTestSameUUIDAtAncestor(SESSION, CONTENTHANDLER);
     }
 
-    public void testSameUUIDAtAncestorSession()
-            throws RepositoryException, IOException, SAXException, NotExecutableException
{
+    public void testSameUUIDAtAncestorSession() throws Exception {
         doTestSameUUIDAtAncestor(SESSION, STREAM);
     }
 }

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SerializationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SerializationTest.java?view=diff&rev=468956&r1=468955&r2=468956
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SerializationTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SerializationTest.java
Sun Oct 29 11:20:17 2006
@@ -19,11 +19,9 @@
 import org.apache.jackrabbit.test.AbstractJCRTest;
 import org.apache.jackrabbit.test.NotExecutableException;
 import org.xml.sax.ContentHandler;
-import org.xml.sax.ErrorHandler;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
+import org.xml.sax.helpers.DefaultHandler;
 
 import javax.jcr.ImportUUIDBehavior;
 import javax.jcr.InvalidSerializedDataException;
@@ -37,6 +35,10 @@
 import javax.jcr.lock.Lock;
 import javax.jcr.lock.LockException;
 import javax.jcr.version.VersionException;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -122,7 +124,7 @@
     }
 
     public void doTestVersioningExceptionFileParent(boolean useWorkspace, boolean useHandler)
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+            throws Exception {
         Node n = initVersioningException(true);
 
         FileInputStream in = new FileInputStream(file);
@@ -137,7 +139,7 @@
     }
 
     public void doTestVersioningExceptionFileChild(boolean useWorkspace, boolean useHandler)
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+            throws Exception {
         Node n = initVersioningException(false);
 
         FileInputStream in = new FileInputStream(file);
@@ -151,43 +153,35 @@
         }
     }
 
-    public void testVersioningExceptionFileParentWorkspaceContentHandler()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testVersioningExceptionFileParentWorkspaceContentHandler() throws Exception
{
         doTestVersioningExceptionFileParent(WORKSPACE, CONTENTHANDLER);
     }
 
-    public void testVersioningExceptionFileParentSessionContentHandler()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testVersioningExceptionFileParentSessionContentHandler() throws Exception
{
         doTestVersioningExceptionFileParent(SESSION, CONTENTHANDLER);
     }
 
-    public void testVersioningExceptionFileParentWorkspace()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testVersioningExceptionFileParentWorkspace() throws Exception {
         doTestVersioningExceptionFileParent(WORKSPACE, STREAM);
     }
 
-    public void testVersioningExceptionFileParentSession()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testVersioningExceptionFileParentSession() throws Exception {
         doTestVersioningExceptionFileParent(SESSION, STREAM);
     }
 
-    public void testVersioningExceptionFileChildWorkspaceContentHandler()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testVersioningExceptionFileChildWorkspaceContentHandler() throws Exception
{
         doTestVersioningExceptionFileChild(WORKSPACE, CONTENTHANDLER);
     }
 
-    public void testVersioningExceptionFileChildSessionContentHandler()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testVersioningExceptionFileChildSessionContentHandler() throws Exception
{
         doTestVersioningExceptionFileChild(SESSION, CONTENTHANDLER);
     }
 
-    public void testVersioningExceptionFileChildWorkspace()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testVersioningExceptionFileChildWorkspace() throws Exception {
         doTestVersioningExceptionFileChild(WORKSPACE, STREAM);
     }
 
-    public void testVersioningExceptionFileChildSession()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testVersioningExceptionFileChildSession() throws Exception {
         doTestVersioningExceptionFileChild(SESSION, STREAM);
     }
 
@@ -196,7 +190,7 @@
      * Tests whether importing a tree respects locking.
      */
     public void doTestLockException(boolean useWorkspace, boolean useHandler)
-            throws RepositoryException, IOException, SAXException {
+            throws Exception {
         Repository repository = session.getRepository();
         exportRepository(SKIPBINARY, RECURSE);
         if (isSupported(Repository.OPTION_LOCKING_SUPPORTED)) {
@@ -219,23 +213,19 @@
         }
     }
 
-    public void testLockExceptionWorkspaceWithHandler()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testLockExceptionWorkspaceWithHandler() throws Exception {
         doTestVersioningExceptionFileChild(WORKSPACE, CONTENTHANDLER);
     }
 
-    public void testLockExceptionSessionWithHandler()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testLockExceptionSessionWithHandler() throws Exception {
         doTestVersioningExceptionFileChild(SESSION, CONTENTHANDLER);
     }
 
-    public void testLockExceptionWorkspace()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testLockExceptionWorkspace() throws Exception {
         doTestVersioningExceptionFileChild(WORKSPACE, STREAM);
     }
 
-    public void testLockExceptionSession()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testLockExceptionSession() throws Exception {
         doTestVersioningExceptionFileChild(SESSION, STREAM);
     }
 
@@ -244,7 +234,8 @@
      * Tests whether importing an invalid XML file throws a SAX exception. The
      * file used here is more or less garbage.
      */
-    public void testInvalidXmlThrowsSaxException() throws IOException {
+    public void testInvalidXmlThrowsSaxException()
+            throws IOException, ParserConfigurationException {
         StringReader in = new StringReader("<this is not a <valid> <xml> file/>");
         ContentHandler ih = null;
         try {
@@ -270,17 +261,16 @@
      * @param ih
      * @param in
      */
-    private void helpTestSaxException(ContentHandler ih, Reader in, String mode) {
-        XMLReader parser = null;
+    private void helpTestSaxException(ContentHandler ih, Reader in, String mode)
+            throws IOException, ParserConfigurationException {
         try {
-            parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
-            parser.setContentHandler(ih);
-            parser.setErrorHandler((ErrorHandler) ih);
-            try {
-                parser.parse(new InputSource(in));
-            } catch (IOException e) {
-                fail("Input stream not available for parsing: " + e);
-            }
+            SAXParserFactory factory = SAXParserFactory.newInstance();
+            factory.setNamespaceAware(true);
+            factory.setFeature(
+                    "http://xml.org/sax/features/namespace-prefixes", false);
+
+            SAXParser parser = factory.newSAXParser();
+            parser.parse(new InputSource(in), (DefaultHandler) ih);
             fail("Parsing an invalid XML file with via " + mode + " ContentHandler did not
throw a SAXException.");
         } catch (SAXException e) {
             // success
@@ -389,7 +379,7 @@
      * not allow same-name siblings.
      */
     public void doTestOverwriteException(boolean useWorkspace, boolean useHandler)
-            throws RepositoryException, IOException, SAXException, NotExecutableException
{
+            throws Exception {
         //If deserialization would overwrite an existing item,
         // an ItemExistsException respective a SAXException is thrown.
 
@@ -426,23 +416,19 @@
         }
     }
 
-    public void testOverwriteExceptionWorkspaceWithHandler()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testOverwriteExceptionWorkspaceWithHandler() throws Exception {
         doTestOverwriteException(WORKSPACE, CONTENTHANDLER);
     }
 
-    public void testOverwriteExceptionSessionWithHandler()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testOverwriteExceptionSessionWithHandler() throws Exception {
         doTestOverwriteException(SESSION, CONTENTHANDLER);
     }
 
-    public void testOverwriteExceptionWorkspace()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testOverwriteExceptionWorkspace() throws Exception {
         doTestOverwriteException(WORKSPACE, STREAM);
     }
 
-    public void testOverwriteExceptionSession()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testOverwriteExceptionSession() throws Exception {
         doTestOverwriteException(SESSION, STREAM);
     }
 
@@ -459,7 +445,7 @@
      * @throws IOException
      */
     public void doTestNodeTypeConstraintViolation(boolean useWorkspace, boolean useHandler)
-            throws RepositoryException, FileNotFoundException, IOException, SAXException
{
+            throws Exception {
 
         treeComparator.createExampleTree();
         Node node = testRootNode.addNode("ntBase", ntBase);
@@ -491,23 +477,19 @@
     }
 
 
-    public void testNodeTypeConstraintViolationWorkspaceWithHandler()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testNodeTypeConstraintViolationWorkspaceWithHandler() throws Exception {
         doTestNodeTypeConstraintViolation(WORKSPACE, CONTENTHANDLER);
     }
 
-    public void testNodeTypeConstraintViolationSessionWithHandler()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testNodeTypeConstraintViolationSessionWithHandler() throws Exception {
         doTestNodeTypeConstraintViolation(SESSION, CONTENTHANDLER);
     }
 
-    public void testNodeTypeConstraintViolationWorkspace()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testNodeTypeConstraintViolationWorkspace() throws Exception {
         doTestNodeTypeConstraintViolation(WORKSPACE, STREAM);
     }
 
-    public void testNodeTypeConstraintViolationSession()
-            throws RepositoryException, NotExecutableException, IOException, SAXException
{
+    public void testNodeTypeConstraintViolationSession() throws Exception {
         doTestNodeTypeConstraintViolation(SESSION, STREAM);
     }
 
@@ -540,7 +522,7 @@
      * Makes sure that importing into the session does not save anything if the
      * session is closed.
      */
-    public void testSessionGetContentHandler() throws RepositoryException, IOException, SAXException
{
+    public void testSessionGetContentHandler() throws Exception {
         FileInputStream in = new FileInputStream(file);
         try {
             exportRepository(SAVEBINARY, RECURSE);
@@ -572,21 +554,20 @@
      * @throws IOException
      */
     public void doImport(String absPath, FileInputStream in, boolean useWorkspace, boolean
useHandler)
-            throws RepositoryException, IOException, SAXException {
+            throws Exception {
         if (useHandler) {
+            SAXParserFactory factory = SAXParserFactory.newInstance();
+            factory.setNamespaceAware(true);
+            factory.setFeature(
+                    "http://xml.org/sax/features/namespace-prefixes", false);
+
+            SAXParser parser = factory.newSAXParser();
             if (useWorkspace) {
                 ContentHandler ih = workspace.getImportContentHandler(absPath, 0);
-                XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
-                parser.setContentHandler(ih);
-                parser.setErrorHandler((ErrorHandler) ih);
-                parser.parse(new InputSource(in));
+                parser.parse(new InputSource(in), (DefaultHandler) ih);
             } else {
                 ContentHandler ih = session.getImportContentHandler(absPath, 0);
-
-                XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
-                parser.setContentHandler(ih);
-                parser.setErrorHandler((ErrorHandler) ih);
-                parser.parse(new InputSource(in));
+                parser.parse(new InputSource(in), (DefaultHandler) ih);
                 session.save();
             }
         } else {
@@ -600,81 +581,83 @@
     }
 
     public void doImportNoSave(String absPath, FileInputStream in, boolean useHandler)
-            throws RepositoryException, IOException, SAXException {
+            throws Exception {
         if (useHandler) {
-            ContentHandler ih = session.getImportContentHandler(absPath, 0);
+            SAXParserFactory factory = SAXParserFactory.newInstance();
+            factory.setNamespaceAware(true);
+            factory.setFeature(
+                    "http://xml.org/sax/features/namespace-prefixes", false);
 
-            XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
-            parser.setContentHandler(ih);
-            parser.setErrorHandler((ErrorHandler) ih);
-            parser.parse(new InputSource(in));
+            SAXParser parser = factory.newSAXParser();
+            ContentHandler ih = session.getImportContentHandler(absPath, 0);
+            parser.parse(new InputSource(in), (DefaultHandler) ih);
         } else {
             session.importXML(absPath, in, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
         }
     }
 //------------< System view export import tests >-----------------------------------
 
-    public void testExportSysView_stream_workspace_skipBinary_noRecurse() throws IOException,
RepositoryException {
+    public void testExportSysView_stream_workspace_skipBinary_noRecurse() throws Exception
{
         doTest(STREAM, WORKSPACE, SKIPBINARY, NORECURSE);
     }
 
-    public void testExportSysView_stream_workspace_skipBinary_recurse() throws IOException,
RepositoryException {
+    public void testExportSysView_stream_workspace_skipBinary_recurse() throws Exception
{
         doTest(STREAM, WORKSPACE, SKIPBINARY, RECURSE);
     }
 
-    public void testExportSysView_stream_workspace_saveBinary_noRecurse() throws IOException,
RepositoryException {
+    public void testExportSysView_stream_workspace_saveBinary_noRecurse() throws Exception
{
         doTest(STREAM, WORKSPACE, SAVEBINARY, NORECURSE);
     }
 
-    public void testExportSysView_stream_workspace_saveBinary_recurse() throws IOException,
RepositoryException {
+    public void testExportSysView_stream_workspace_saveBinary_recurse() throws Exception
{
         doTest(STREAM, WORKSPACE, SAVEBINARY, RECURSE);
     }
 
-    public void testExportSysView_stream_session_skipBinary_noRecurse() throws IOException,
RepositoryException {
+    public void testExportSysView_stream_session_skipBinary_noRecurse() throws Exception
{
         doTest(STREAM, SESSION, SKIPBINARY, NORECURSE);
     }
 
-    public void testExportSysView_stream_session_skipBinary_recurse() throws IOException,
RepositoryException {
+    public void testExportSysView_stream_session_skipBinary_recurse() throws Exception {
         doTest(STREAM, SESSION, SKIPBINARY, RECURSE);
     }
 
-    public void testExportSysView_stream_session_saveBinary_noRecurse() throws IOException,
RepositoryException {
+    public void testExportSysView_stream_session_saveBinary_noRecurse() throws Exception
{
         doTest(STREAM, SESSION, SAVEBINARY, NORECURSE);
     }
 
-    public void testExportSysView_stream_session_saveBinary_recurse() throws IOException,
RepositoryException {
+    public void testExportSysView_stream_session_saveBinary_recurse() throws Exception {
         doTest(STREAM, SESSION, SAVEBINARY, RECURSE);
     }
 
-    public void testExportSysView_handler_workspace_skipBinary_noRecurse() throws IOException,
RepositoryException {
+    public void testExportSysView_handler_workspace_skipBinary_noRecurse() throws Exception
{
         doTest(CONTENTHANDLER, WORKSPACE, SKIPBINARY, NORECURSE);
     }
 
-    public void testExportSysView_handler_workspace_skipBinary_recurse() throws IOException,
RepositoryException {
+    public void testExportSysView_handler_workspace_skipBinary_recurse() throws Exception
{
         doTest(CONTENTHANDLER, WORKSPACE, SKIPBINARY, RECURSE);
     }
 
-    public void testExportSysView_handler_workspace_saveBinary_noRecurse() throws IOException,
RepositoryException {
+    public void testExportSysView_handler_workspace_saveBinary_noRecurse() throws Exception
{
         doTest(CONTENTHANDLER, WORKSPACE, SAVEBINARY, NORECURSE);
     }
 
-    public void testExportSysView_handler_workspace_saveBinary_recurse() throws IOException,
RepositoryException {
+    public void testExportSysView_handler_workspace_saveBinary_recurse() throws Exception
{
         doTest(CONTENTHANDLER, WORKSPACE, SAVEBINARY, RECURSE);
     }
 
-    public void testExportSysView_handler_session_skipBinary_noRecurse() throws IOException,
RepositoryException {
+    public void testExportSysView_handler_session_skipBinary_noRecurse() throws Exception
{
         doTest(CONTENTHANDLER, SESSION, SKIPBINARY, NORECURSE);
     }
 
-    public void testExportSysView_handler_session_skipBinary_recurse() throws IOException,
RepositoryException {
+    public void testExportSysView_handler_session_skipBinary_recurse() throws Exception {
         doTest(CONTENTHANDLER, SESSION, SKIPBINARY, RECURSE);
     }
 
-    public void testExportSysView_handler_session_saveBinary_noRecurse() throws IOException,
RepositoryException {
+    public void testExportSysView_handler_session_saveBinary_noRecurse() throws Exception
{
         doTest(CONTENTHANDLER, SESSION, SAVEBINARY, NORECURSE);
     }
 
-    public void testExportSysView_handler_session_saveBinary_recurse() throws IOException,
RepositoryException {
+    public void testExportSysView_handler_session_saveBinary_recurse() throws Exception {
         doTest(CONTENTHANDLER, SESSION, SAVEBINARY, RECURSE);
     }
 
@@ -692,7 +675,7 @@
      *                   subtree
      */
     private void doTest(boolean handler, boolean workspace, boolean skipBinary, boolean noRecurse)
-            throws RepositoryException, IOException {
+            throws Exception {
         exportRepository(skipBinary, noRecurse);
         importRepository(handler, workspace);
         treeComparator.showTree();
@@ -728,38 +711,24 @@
      * @param workspace  True = import into workspace, false = import into
      *                   session
      */
-    public void importRepository(boolean useHandler, boolean workspace) throws RepositoryException,
IOException {
-        FileInputStream in = null;
-        try {
-            in = new FileInputStream(file);
-        } catch (FileNotFoundException e) {
-            fail("Input file not opened: " + e);
-        }
-
+    public void importRepository(boolean useHandler, boolean workspace) throws Exception
{
+        FileInputStream in = new FileInputStream(file);
         try {
             if (useHandler) {
+                SAXParserFactory factory = SAXParserFactory.newInstance();
+                factory.setNamespaceAware(true);
+                factory.setFeature(
+                        "http://xml.org/sax/features/namespace-prefixes", false);
+
+                SAXParser parser = factory.newSAXParser();
                 if (workspace) {
                     ContentHandler ih = this.workspace.getImportContentHandler(treeComparator.targetFolder,
0);
-                    try {
-                        XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
-                        parser.setContentHandler(ih);
-                        parser.setErrorHandler((ErrorHandler) ih);
-                        parser.parse(new InputSource(in));
-                    } catch (SAXException e) {
-                        fail("Error while parsing the imported repository: " + e);
-                    }
+                    parser.parse(new InputSource(in), (DefaultHandler) ih);
                 } else {
                     ContentHandler ih = session.getImportContentHandler(treeComparator.targetFolder,
                             ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
-                    try {
-                        XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
-                        parser.setContentHandler(ih);
-                        parser.setErrorHandler((ErrorHandler) ih);
-                        parser.parse(new InputSource(in));
-                        session.save();
-                    } catch (SAXException e) {
-                        fail("Error while parsing the imported repository: " + e);
-                    }
+                    parser.parse(new InputSource(in), (DefaultHandler) ih);
+                    session.save();
                 }
             } else {
                 if (workspace) {
@@ -770,6 +739,8 @@
                     session.save();
                 }
             }
+        } catch (SAXException e) {
+            fail("Error while parsing the imported repository: " + e);
         } finally {
             in.close();
         }



Mime
View raw message