jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1547805 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreBackupTest.java
Date Wed, 04 Dec 2013 14:32:05 GMT
Author: alexparvulescu
Date: Wed Dec  4 14:32:04 2013
New Revision: 1547805

URL: http://svn.apache.org/r1547805
Log:
OAK-1159 Backup and restore
 - added size check test for shared binaries


Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreBackupTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreBackupTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreBackupTest.java?rev=1547805&r1=1547804&r2=1547805&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreBackupTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreBackupTest.java
Wed Dec  4 14:32:04 2013
@@ -20,12 +20,18 @@ package org.apache.jackrabbit.oak.plugin
 
 import static org.apache.commons.io.FileUtils.deleteQuietly;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
 
+import org.apache.commons.lang.RandomStringUtils;
 import org.apache.jackrabbit.oak.Oak;
+import org.apache.jackrabbit.oak.api.Blob;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.plugins.memory.StringBasedBlob;
 import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent;
 import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore;
 import org.apache.jackrabbit.oak.plugins.segment.file.FileStore;
@@ -95,4 +101,45 @@ public class FileStoreBackupTest {
                 .with(new InitialContent()).createContentRepository();
     }
 
+    @Test
+    public void testSharedContent() throws Exception {
+        FileStore source = new FileStore(src, 256, false);
+
+        NodeStore store = new SegmentNodeStore(source);
+
+        // ~60k
+        Blob blob = new StringBasedBlob(RandomStringUtils.random(10240));
+
+        NodeBuilder builder = store.getRoot().builder();
+        NodeBuilder c1 = builder.child("test-backup");
+        c1.setProperty("blob", blob);
+        NodeBuilder c2 = builder.child("test-backup2");
+        c2.setProperty("blob", blob);
+        store.merge(builder, EmptyHook.INSTANCE, null);
+
+        FileStoreBackup.backup(store, destination);
+        compare(store, destination);
+        source.close();
+
+        Map<String, Long> expected = new HashMap<String, Long>();
+        for (File f : src.listFiles()) {
+            if (f.getName().endsWith(".tar")) {
+                expected.put(f.getName(), f.length());
+            }
+        }
+
+        for (File f : destination.listFiles()) {
+            if(!f.getName().endsWith(".tar")){
+                continue;
+            }
+            assertTrue(f.getName() + " is missing from the backup",
+                    expected.containsKey(f.getName()));
+            assertTrue(
+                    f.getName() + " is expected to have size < "
+                            + expected.get(f.getName()) + " actually is "
+                            + f.length(),
+                    f.length() <= expected.get(f.getName()));
+        }
+
+    }
 }



Mime
View raw message