jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r661637 - in /jackrabbit/branches/1.4/jackrabbit-core: ./ src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java src/test/java/org/apache/jackrabbit/core/fs/AbstractFileSystemTest.java
Date Fri, 30 May 2008 10:30:26 GMT
Author: jukka
Date: Fri May 30 03:30:25 2008
New Revision: 661637

URL: http://svn.apache.org/viewvc?rev=661637&view=rev
Log:
1.4: Merged revision 653417 (JCR-1450)

Modified:
    jackrabbit/branches/1.4/jackrabbit-core/   (props changed)
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
    jackrabbit/branches/1.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/AbstractFileSystemTest.java

Propchange: jackrabbit/branches/1.4/jackrabbit-core/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri May 30 03:30:25 2008
@@ -1 +1 @@
-/jackrabbit/trunk/jackrabbit-core:654078,654514,655917,656240,658583
+/jackrabbit/trunk/jackrabbit-core:653417,654078,654514,655917,656240,658583

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java?rev=661637&r1=661636&r2=661637&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
Fri May 30 03:30:25 2008
@@ -248,6 +248,16 @@
             throw new FileSystemException("Destination exists: " + destPath);
         }
 
+        // Create destination folder if it does not yet exist
+        String[] path = destPath.split(SEPARATOR);
+        String folder = "";
+        for (int i = 1; i < path.length; i++) {
+            folder += SEPARATOR + path[i];
+            if (!exists(folder)) {
+                createFolder(folder);
+            }
+        }
+        
         Map moves = new HashMap();
         moves.put(srcPath, destPath);
         if (getEntry(srcPath).isFolder()) {

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/AbstractFileSystemTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/AbstractFileSystemTest.java?rev=661637&r1=661636&r2=661637&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/AbstractFileSystemTest.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/AbstractFileSystemTest.java
Fri May 30 03:30:25 2008
@@ -214,6 +214,61 @@
         assertEquals("subfolder", list[0]);
     }
 
+    public void testMoveFile_destFolderDoesNotExist() throws Exception {
+        // Create a folder with a file
+        fs.createFolder("/folder");
+        createFile("/folder/file", sampleBytes);
+
+        // Check that the destination folder and file do not exist
+        assertFalse(fs.exists("/folder2"));
+        assertFalse(fs.exists("/folder2/file"));
+
+        // Move the file into a non-existent directory
+        fs.move("/folder/file", "/folder2/file");
+
+        // Check that the file has been moved
+        assertFalse(fs.exists("/folder/file"));
+        assertFalse(fs.isFolder("/folder/file"));
+        assertFalse(fs.isFile("/folder/file"));
+        assertTrue(fs.exists("/folder2/file"));
+        assertFalse(fs.isFolder("/folder2/file"));
+        assertTrue(fs.isFile("/folder2/file"));
+
+        // Check that folder2 has been silently created
+        assertTrue(fs.exists("/folder2"));
+        assertTrue(fs.isFolder("/folder2"));
+        assertFalse(fs.isFile("/folder2"));
+    }
+    
+    public void testMoveFolder_destFolderDoesNotExist() throws Exception {
+        // Create a folder with a file
+        fs.createFolder("/folder");
+        createFile("/folder/file", sampleBytes);
+        // Check that the destination folder and file do not exist
+        assertFalse(fs.exists("/folder2"));
+        assertFalse(fs.exists("/folder2/folder3"));
+        assertFalse(fs.exists("/folder2/folder3/file"));
+
+        // Move the folder into a non-existent directory
+        fs.move("/folder", "/folder2/folder3");
+
+        // Assert
+        assertFalse(fs.exists("/folder"));
+        assertFalse(fs.exists("/folder/file"));
+        
+        assertTrue(fs.exists("/folder2"));
+        assertTrue(fs.isFolder("/folder2"));
+        assertFalse(fs.isFile("/folder2"));
+
+        assertTrue(fs.exists("/folder2/folder3"));
+        assertTrue(fs.isFolder("/folder2/folder3"));
+        assertFalse(fs.isFile("/folder2/folder3"));
+
+        assertTrue(fs.exists("/folder2/folder3/file"));
+        assertFalse(fs.isFolder("/folder2/folder3/file"));
+        assertTrue(fs.isFile("/folder2/folder3/file"));
+    }
+
     private void verifyStreamInput(
             InputStream inputStream, byte[] expectedBytes) throws IOException {
         byte[] resultBytes = new byte[3];



Mime
View raw message