jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r164047 - in /incubator/jackrabbit/trunk: applications/test/ src/java/org/apache/jackrabbit/core/xml/ src/test/org/apache/jackrabbit/test/api/
Date Thu, 21 Apr 2005 12:35:17 GMT
Author: mreutegg
Date: Thu Apr 21 05:35:17 2005
New Revision: 164047

URL: http://svn.apache.org/viewcvs?rev=164047&view=rev
Log:
Fixed broken test cases for system view export.

Modified:
    incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/ImportHandler.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SerializationTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TreeComparator.java

Modified: incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties?rev=164047&r1=164046&r2=164047&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties (original)
+++ incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties Thu Apr 21
05:35:17 2005
@@ -281,6 +281,10 @@
 # specified nodetype must be versionable and allow child nodes of the same type.
 javax.jcr.tck.SerializationTest.testVersioningExceptionSessionFileParent.nodetype=test:versionable
 
+# Test method: testSessionImportXmlOverwriteException
+# requires a node type that does not allow same name siblings
+javax.jcr.tck.SerializationTest.testSessionImportXmlOverwriteException.nodetype=nt:folder
+
 # Test class: ExportSysViewTest
 javax.jcr.tck.ExportSysViewTest.testroot=/testdata
 

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/ImportHandler.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/ImportHandler.java?rev=164047&r1=164046&r2=164047&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/ImportHandler.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/ImportHandler.java
Thu Apr 21 05:35:17 2005
@@ -98,7 +98,7 @@
         // log exception and carry on...
         log.error("error encountered at line: " + e.getLineNumber()
                 + ", column: " + e.getColumnNumber()
-                + " while parsing XML stream", e);
+                + " while parsing XML stream: " + e.toString());
     }
 
     /**
@@ -108,7 +108,7 @@
         // log and re-throw exception
         log.error("fatal error encountered at line: " + e.getLineNumber()
                 + ", column: " + e.getColumnNumber()
-                + " while parsing XML stream", e);
+                + " while parsing XML stream: " + e.toString());
         throw e;
     }
 

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SerializationTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SerializationTest.java?rev=164047&r1=164046&r2=164047&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SerializationTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SerializationTest.java
Thu Apr 21 05:35:17 2005
@@ -33,9 +33,9 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Workspace;
+import javax.jcr.version.VersionException;
 import javax.jcr.lock.Lock;
 import javax.jcr.lock.LockException;
-import javax.jcr.nodetype.ConstraintViolationException;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -98,8 +98,8 @@
         FileInputStream in = new FileInputStream(file);
         try {
             session.importXML(n.getPath(), in, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
-            fail("Importing to a checked-in node must throw a ConstraintViolationException.");
-        } catch (ConstraintViolationException e) {
+            fail("Importing to a checked-in node must throw a VersionException.");
+        } catch (VersionException e) {
             // success
         }
     }
@@ -115,8 +115,8 @@
         FileInputStream in = new FileInputStream(file);
         try {
             session.importXML(n.getPath(), in, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
-            fail("Importing to a child of a checked-in node must throw a ConstraintViolationException.");
-        } catch (ConstraintViolationException e) {
+            fail("Importing to a child of a checked-in node must throw a VersionException.");
+        } catch (VersionException e) {
             // success
         }
     }
@@ -136,7 +136,8 @@
         if (!vNode.isNodeType(mixVersionable)) {
             throw new NotExecutableException("NodeType: " + testNodeType + " is not versionable");
         }
-        Node vChild = vNode.addNode(nodeName2, testNodeType);
+        // add non-versionable child
+        Node vChild = vNode.addNode(nodeName2, ntBase);
         session.save();
         vNode.checkin();
 
@@ -178,7 +179,7 @@
      * Tests whether importing an invalid XML file throws a SAX exception. The
      * file used here is more or less garbage.
      */
-    public void testInvalidXmlThrowsSaxException() {
+    public void testInvalidXmlThrowsSaxException() throws IOException {
         StringReader in = new StringReader("<this is not a <valid> <xml> file/>");
         ContentHandler ih = null;
         try {
@@ -189,6 +190,7 @@
         }
         helpTestSaxException(ih, in, "session");
 
+        in = new StringReader("<this is not a <valid> <xml> file/>");
         try {
             ih = workspace.getImportContentHandler(treeComparator.targetFolder, 0);
         } catch (RepositoryException e) {
@@ -204,7 +206,7 @@
      * @param in
      */
     private void helpTestSaxException(ContentHandler ih, Reader in, String mode) {
-        XMLReader parser = null;
+        XMLReader parser;
         try {
             parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
             parser.setContentHandler(ih);
@@ -270,26 +272,27 @@
     }
 
     /**
-     * Tries to overwrite an existing node. This only works for nodes that do
-     * not allow same-name siblings.
+     * Tries to overwrite an existing node.
+     * @tck.config nodetype name of a node type, that does not allow same name
+     *  siblings. The node type must allow child nodes of its own type.
+     * @tck.config nodename1 name for a node of type <code>nodetype</code>.
+     * @tck.config nodename2 name for a node of type <code>nodetype</code>.
      */
     public void testSessionImportXmlOverwriteException() throws RepositoryException, IOException
{
-        //If deserialization would overwrite an existing item, an ItemExistsException is
thrown.
+        // If deserialization would overwrite an existing item, an ItemExistsException is
thrown.
 
-        //create a folder node and a child node
-        Node folder = null, subfolder = null;
+        // create a folder node and a child node
+        Node folder;
+        Node subfolder;
         FileOutputStream out;
-        FileInputStream in = null;
-        folder = testRootNode.addNode("myFolder", "nt:folder");
-        subfolder = folder.addNode("mySubFolder", "nt:folder");
+        FileInputStream in;
+        folder = testRootNode.addNode(nodeName1, testNodeType);
+        subfolder = folder.addNode(nodeName1, testNodeType);
         session.save();
         out = new FileOutputStream(file);
         session.exportSystemView(subfolder.getPath(), out, true, true);
-        subfolder.addNode("mySubSubFolder", "nt:folder");
-        subfolder.remove();
-        session.save();
+        out.close();
         in = new FileInputStream(file);
-
         try {
             session.importXML(folder.getPath(), in,
                     ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
@@ -304,7 +307,7 @@
      * Makes sure that importing into the session does not save anything if the
      * session is closed.
      */
-    public void testSessionImportXml() throws RepositoryException, IOException {
+    public void testSessionImportXml() throws Exception {
         FileInputStream in = new FileInputStream(file);
         exportRepository(SAVEBINARY, RECURSE);
         session.importXML(treeComparator.targetFolder, in,
@@ -312,10 +315,11 @@
 
         // after logout/login, no nodes are in the session
         session.logout();
-        superuser = null; //so tearDown won't fail
+        superuser = null; // so tearDown won't fail
 
         session = helper.getReadWriteSession();
-        treeComparator.compare(treeComparator.CHECK_EMPTY);
+        Node targetFolder = (Node) session.getItem(treeComparator.targetFolder);
+        assertFalse("Session.importXML() must not save imported nodes.", targetFolder.hasNodes());
     }
 
     public void testExportSysView_stream_workspace_skipBinary_noRecurse() throws IOException,
RepositoryException {

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java?rev=164047&r1=164046&r2=164047&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java Thu Apr
21 05:35:17 2005
@@ -128,6 +128,7 @@
         suite.addTestSuite(CheckPermissionTest.class);
 
         suite.addTestSuite(DocumentViewImportTest.class);
+        suite.addTestSuite(SerializationTest.class);
 
         return suite;
     }

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TreeComparator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TreeComparator.java?rev=164047&r1=164046&r2=164047&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TreeComparator.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TreeComparator.java
Thu Apr 21 05:35:17 2005
@@ -408,6 +408,10 @@
                 fail("Cannot access property information: " + e);
             }
 
+            if (propertyValueMayChange(pName)) {
+                continue;
+            }
+
             Property pb = null;
             try {
                 pb = b.getProperty(pName);



Mime
View raw message