From 4a52f5e6ce06cb6717510c6a975d5490be627c98 Mon Sep 17 00:00:00 2001 From: Keuin Date: Tue, 12 Jan 2021 15:03:23 +0800 Subject: Add unit test for Sha256Identifier and ObjectCollection --- .../util/backup/incremental/identifier/ObjectIdentifier.java | 1 + .../util/backup/incremental/identifier/Sha256Identifier.java | 4 ++++ .../util/backup/incremental/identifier/SingleHashIdentifier.java | 1 + 3 files changed, 6 insertions(+) (limited to 'src/main/java/com/keuin/kbackupfabric/util/backup/incremental/identifier') diff --git a/src/main/java/com/keuin/kbackupfabric/util/backup/incremental/identifier/ObjectIdentifier.java b/src/main/java/com/keuin/kbackupfabric/util/backup/incremental/identifier/ObjectIdentifier.java index 62798e1..6744616 100644 --- a/src/main/java/com/keuin/kbackupfabric/util/backup/incremental/identifier/ObjectIdentifier.java +++ b/src/main/java/com/keuin/kbackupfabric/util/backup/incremental/identifier/ObjectIdentifier.java @@ -4,6 +4,7 @@ package com.keuin.kbackupfabric.util.backup.incremental.identifier; * The identifier distinguishing files in the object collection. * It should be based on cryptographic hash function in order to prevent possible attacks to the backup system. * All identifiers should be immutable and implement their own equals method. + * Immutable. */ public interface ObjectIdentifier { String getIdentification(); diff --git a/src/main/java/com/keuin/kbackupfabric/util/backup/incremental/identifier/Sha256Identifier.java b/src/main/java/com/keuin/kbackupfabric/util/backup/incremental/identifier/Sha256Identifier.java index 9f56b0e..64716ed 100644 --- a/src/main/java/com/keuin/kbackupfabric/util/backup/incremental/identifier/Sha256Identifier.java +++ b/src/main/java/com/keuin/kbackupfabric/util/backup/incremental/identifier/Sha256Identifier.java @@ -7,6 +7,10 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Objects; +/** + * Identifier based on sha256. + * Immutable. + */ public class Sha256Identifier extends SingleHashIdentifier { private static final int SHA256_LENGTH = 32; diff --git a/src/main/java/com/keuin/kbackupfabric/util/backup/incremental/identifier/SingleHashIdentifier.java b/src/main/java/com/keuin/kbackupfabric/util/backup/incremental/identifier/SingleHashIdentifier.java index 62ba47c..3b96f79 100644 --- a/src/main/java/com/keuin/kbackupfabric/util/backup/incremental/identifier/SingleHashIdentifier.java +++ b/src/main/java/com/keuin/kbackupfabric/util/backup/incremental/identifier/SingleHashIdentifier.java @@ -8,6 +8,7 @@ import java.util.Arrays; /** * A simple identifier based on a single hash function. + * Immutable. */ public abstract class SingleHashIdentifier implements ObjectIdentifier { -- cgit v1.2.3