コード例 #1
0
  @Test
  public void should_ignore_carriage_returns() throws IOException {
    File linuxFile = file("linux.java", "LINE1\nLINE2\n");
    File windowsFile = file("windows.java", "LINE1\r\nLINE2\r\n");
    File oldMacFile = file("os9.java", "LINE1\rLINE2\r");
    File mixedMode = file("mixed.java", "LINE1\rLINE2\r\n");

    assertThat(sha1.find(linuxFile))
        .isEqualTo(sha1.find(windowsFile))
        .isEqualTo(sha1.find(oldMacFile))
        .isEqualTo(sha1.find(mixedMode))
        .isEqualTo("63193e8d522822e6e209172c9e6c204b9ab7efce");
  }
コード例 #2
0
  @Test
  public void should_be_backward_compatible() throws IOException {
    File file = TestUtils.getResource("UpdateCenter.txt");

    String hash = sha1.find(file);

    assertThat(hash).isEqualTo("0ebb4882683fb4209e9aeb7278dec282a9ca3c3c");
  }
コード例 #3
0
  @Test
  public void should_find_hash() throws IOException {
    File file = file("quickBrownFox.java", "The quick brown fox jumps over the lazy dog");

    String hash = sha1.find(file);

    assertThat(hash).isEqualTo("2fd4e1c67a2d28fced849ee1bb76e7391b93eb12");
  }
コード例 #4
0
  @Test
  public void should_find_hash_of_empty_file() throws IOException {
    File emptyFile = file("empty.java", "");

    String hash = sha1.find(emptyFile);

    assertThat(hash).isEqualTo("da39a3ee5e6b4b0d3255bfef95601890afd80709");
  }
コード例 #5
0
 @Test(expected = FileNotFoundException.class)
 public void should_fail_on_unkown_file() throws IOException {
   sha1.find(new File("UNKNOWN"));
 }