From 6d6f0b486ac42b6bd69ddb8862ee3af7b819f3a7 Mon Sep 17 00:00:00 2001 From: Keuin Date: Mon, 15 Feb 2021 17:52:53 +0800 Subject: Add tests. Implementing auto backup and configuration (not finished) --- .../identifier/SingleHashIdentifierTest.java | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/test/java/com/keuin/kbackupfabric/backup/incremental/identifier/SingleHashIdentifierTest.java (limited to 'src/test/java/com/keuin/kbackupfabric/backup/incremental/identifier/SingleHashIdentifierTest.java') diff --git a/src/test/java/com/keuin/kbackupfabric/backup/incremental/identifier/SingleHashIdentifierTest.java b/src/test/java/com/keuin/kbackupfabric/backup/incremental/identifier/SingleHashIdentifierTest.java new file mode 100644 index 0000000..4e15095 --- /dev/null +++ b/src/test/java/com/keuin/kbackupfabric/backup/incremental/identifier/SingleHashIdentifierTest.java @@ -0,0 +1,35 @@ +package com.keuin.kbackupfabric.backup.incremental.identifier; + +import org.junit.Test; + +import java.io.File; +import java.io.IOException; + +import static org.junit.Assert.*; + +public class SingleHashIdentifierTest { + + @Test + public void testEquals() { + SingleHashIdentifier id1 = new ConcreteSingleHashIdentifier(new byte[]{1, 2, 3, 4}, "ahash"); + SingleHashIdentifier id2 = new ConcreteSingleHashIdentifier(new byte[]{1, 2, 3, 4}, "ahash"); + SingleHashIdentifier id3 = new ConcreteSingleHashIdentifier(new byte[]{1, 2, 3}, "ahash"); + SingleHashIdentifier id4 = new ConcreteSingleHashIdentifier(new byte[]{1, 2, 3, 4}, "a"); + assertEquals(id1, id1); + assertEquals(id1, id2); + assertNotEquals(id1, id3); + assertNotEquals(id1, id4); + assertNotEquals(id3, id4); + } + + private static class ConcreteSingleHashIdentifier extends SingleHashIdentifier { + protected ConcreteSingleHashIdentifier(byte[] hash, String type) { + super(hash, type); + } + + @Override + protected byte[] hash(File file) throws IOException { + return new byte[0]; + } + } +} \ No newline at end of file -- cgit v1.2.3