summaryrefslogtreecommitdiff
path: root/src/test/java/com/keuin/kbackupfabric/util/backup/incremental/ObjectCollectionSerializerTest.java
blob: 0edfe0158edce9adbf2d37f5a084539736dcb3c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.keuin.kbackupfabric.util.backup.incremental;

import com.keuin.kbackupfabric.util.backup.incremental.identifier.Sha256Identifier;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

import static org.junit.Assert.assertEquals;

public class ObjectCollectionSerializerTest {
    @Test
    public void testSerializationConsistency() throws IOException {
        ObjectCollectionFactory<Sha256Identifier> factory =
                new ObjectCollectionFactory<>(Sha256Identifier.getFactory());
        ObjectCollection collection =
                factory.fromDirectory(new File("./testfile/ObjectCollectionFactoryTest"));
        File file = new File("./testfile/serialized");
        if (file.exists()) {
            Files.delete(file.toPath());
        }
        ObjectCollectionSerializer.toFile(collection, file);
        ObjectCollection collection2 = ObjectCollectionSerializer.fromFile(file);
        Files.delete(file.toPath());
        assertEquals(collection, collection2);
    }

}