1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package au.com.acegi.xmlformat;
19
20 import static au.com.acegi.xmlformat.IOUtil.hash;
21 import static au.com.acegi.xmlformat.TestUtil.getResource;
22 import static org.hamcrest.CoreMatchers.is;
23 import static org.hamcrest.MatcherAssert.assertThat;
24
25 import java.io.IOException;
26 import java.io.InputStream;
27
28 import org.junit.jupiter.api.Test;
29
30
31
32
33 public class IOTest {
34
35 @Test
36 void hash1() throws IOException {
37 testHash("/test1-in.xml", 459_402_491L);
38 }
39
40 @Test
41 void hash2() throws IOException {
42 testHash("/test2-in.xml", 1_687_393_391L);
43 }
44
45 @Test
46 void hashInvalid() throws IOException {
47 testHash("/invalid.xml", 2_274_913_643L);
48 }
49
50 private void testHash(final String resource, final long expected) throws IOException {
51 try (InputStream in = getResource(resource)) {
52 final long hash = hash(in);
53 assertThat(hash, is(expected));
54 }
55 }
56
57 }