JAL-3130 adapted getdown src. attempt 2. first attempt failed due to cp'ed .git files
[jalview.git] / getdown / src / getdown / core / src / it / java / com / threerings / getdown / tests / DigesterIT.java
1 //
2 // Getdown - application installer, patcher and launcher
3 // Copyright (C) 2004-2018 Getdown authors
4 // https://github.com/threerings/getdown/blob/master/LICENSE
5
6 package com.threerings.getdown.tests;
7
8 import java.io.File;
9 import java.nio.charset.StandardCharsets;
10 import java.nio.file.*;
11 import java.util.Arrays;
12 import java.util.List;
13
14 import org.junit.*;
15 import static org.junit.Assert.*;
16
17 import com.threerings.getdown.tools.Digester;
18
19 public class DigesterIT {
20
21     @Test
22     public void testDigester () throws Exception {
23         Path appdir = Paths.get("src/it/resources/testapp");
24         Digester.createDigests(appdir.toFile(), null, null, null);
25
26         Path digest = appdir.resolve("digest.txt");
27         List<String> digestLines = Files.readAllLines(digest, StandardCharsets.UTF_8);
28         Files.delete(digest);
29
30         Path digest2 = appdir.resolve("digest2.txt");
31         List<String> digest2Lines = Files.readAllLines(digest2, StandardCharsets.UTF_8);
32         Files.delete(digest2);
33
34         assertEquals(Arrays.asList(
35             "getdown.txt = 779c74fb4b251e18faf6e240a0667964",
36             "testapp.jar = 404dafa55e78b25ec0e3a936357b1883",
37             "funny%test dir/some=file.txt = d8e8fca2dc0f896fd7cb4cb0031ba249",
38             "crazyhashfile#txt = f29d23fd5ab1781bd8d0760b3a516f16",
39             "foo.jar = 46ca4cc9079d9d019bb30cd21ebbc1ec",
40             "script.sh = f66e8ea25598e67e99c47d9b0b2a2cdf",
41             "digest.txt = f5561d85e4d80cc85883963897e58ff6"
42         ), digestLines);
43
44         assertEquals(Arrays.asList(
45             "getdown.txt = 4f0c657895c3c3a35fa55bf5951c64fa9b0694f8fc685af3f1d8635c639e066b",
46             "testapp.jar = c9cb1906afbf48f8654b416c3f831046bd3752a76137e5bf0a9af2f790bf48e0",
47             "funny%test dir/some=file.txt = f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2",
48             "crazyhashfile#txt = 6816889f922de38f145db215a28ad7c5e1badf7354b5cdab225a27486789fa3b",
49             "foo.jar = ea188b872e0496debcbe00aaadccccb12a8aa9b025bb62c130cd3d9b8540b062",
50             "script.sh = cca1c5c7628d9bf7533f655a9cfa6573d64afb8375f81960d1d832dc5135c988",
51             "digest2.txt = 70b442c9f56660561921da3368e1a206f05c379182fab3062750b7ddcf303407"
52         ), digest2Lines);
53     }
54 }