summaryrefslogtreecommitdiff
path: root/src/test/java/com/keuin/kbackupfabric
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/keuin/kbackupfabric')
-rw-r--r--src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionFactoryTest.java23
-rw-r--r--src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionSerializerTest.java24
-rw-r--r--src/test/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethodTest.java15
3 files changed, 53 insertions, 9 deletions
diff --git a/src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionFactoryTest.java b/src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionFactoryTest.java
index 9a2a73c..16fb258 100644
--- a/src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionFactoryTest.java
+++ b/src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionFactoryTest.java
@@ -25,10 +25,29 @@ public class ObjectCollectionFactoryTest {
}
@Test
- public void fromDirectory() {
+ public void fromDirectory1() {
+ fromDirectory(1);
+ }
+
+ @Test
+ public void fromDirectory2() {
+ fromDirectory(2);
+ }
+
+ @Test
+ public void fromDirectory4() {
+ fromDirectory(4);
+ }
+
+ @Test
+ public void fromDirectory8() {
+ fromDirectory(8);
+ }
+
+ public void fromDirectory(int threads) {
try {
ObjectCollectionFactory<Sha256Identifier> factory =
- new ObjectCollectionFactory<>(Sha256Identifier.getFactory());
+ new ObjectCollectionFactory<>(Sha256Identifier.getFactory(), threads);
ObjectCollection collection =
factory.fromDirectory(new File("./testfile/ObjectCollectionFactoryTest"));
diff --git a/src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionSerializerTest.java b/src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionSerializerTest.java
index bd25215..33f5a9c 100644
--- a/src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionSerializerTest.java
+++ b/src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionSerializerTest.java
@@ -10,10 +10,30 @@ import java.nio.file.Files;
import static org.junit.Assert.assertEquals;
public class ObjectCollectionSerializerTest {
+
+ @Test
+ public void testSerializationConsistency1() throws IOException {
+ testSerializationConsistency(1);
+ }
+
+ @Test
+ public void testSerializationConsistency2() throws IOException {
+ testSerializationConsistency(2);
+ }
+
+ @Test
+ public void testSerializationConsistency4() throws IOException {
+ testSerializationConsistency(4);
+ }
+
@Test
- public void testSerializationConsistency() throws IOException {
+ public void testSerializationConsistency8() throws IOException {
+ testSerializationConsistency(8);
+ }
+
+ public void testSerializationConsistency(int threads) throws IOException {
ObjectCollectionFactory<Sha256Identifier> factory =
- new ObjectCollectionFactory<>(Sha256Identifier.getFactory());
+ new ObjectCollectionFactory<>(Sha256Identifier.getFactory(), threads);
ObjectCollection collection =
factory.fromDirectory(new File("./testfile/ObjectCollectionFactoryTest"));
File file = new File("./testfile/serialized");
diff --git a/src/test/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethodTest.java b/src/test/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethodTest.java
index 30f2d44..2b4bd94 100644
--- a/src/test/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethodTest.java
+++ b/src/test/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethodTest.java
@@ -1,5 +1,6 @@
package com.keuin.kbackupfabric.operation.backup.method;
+import com.keuin.kbackupfabric.operation.backup.feedback.IncrementalBackupFeedback;
import org.apache.commons.codec.digest.DigestUtils;
import org.junit.Test;
@@ -20,9 +21,9 @@ public class ConfiguredIncrementalBackupMethodTest {
private final String destDirectoryName = "destination";
private final String indexFileName = "index";
- private final double directoryFactor = 0.02;
- private final double fileFactor = 0.05;
- private final int maxRandomFileSizeBytes = 1024 * 1024 * 16;
+ private final double directoryFactor = 0.03;
+ private final double fileFactor = 0.04;
+ private final int maxRandomFileSizeBytes = 1024 * 1024 * 4;
private final Function<Integer, Integer> scaleDecayFunc = (x) -> x - 1;
@Test
@@ -66,11 +67,15 @@ public class ConfiguredIncrementalBackupMethodTest {
testTempPath,
destPath.toString()
);
- method.backup();
+ IncrementalBackupFeedback feedback = method.backup();
+ assertNotNull("Feedback should not be null.", feedback);
+ if (!feedback.isSuccess())
+ fail("Failed to backup. Cannot perform test.");
+ assertTrue("Index file was not generated by backup.", new File(testTempPath, indexFileName).exists());
// delete src
forceDelete(sourcePath.toFile());
- assertFalse(sourcePath.toFile().isDirectory());
+ assertFalse(sourcePath.toFile().exists());
// restore src
if (!method.restore())