コード例 #1
0
ファイル: TestFile.java プロジェクト: GeehomThor/shadow
 public TestFile file(Object... path) {
   try {
     return new TestFile(this, path);
   } catch (RuntimeException e) {
     throw new RuntimeException(
         String.format(
             "Could not locate file '%s' relative to '%s'.", Arrays.toString(path), this),
         e);
   }
 }
コード例 #2
0
ファイル: TestFile.java プロジェクト: GeehomThor/shadow
 public TestFile assertIsCopyOf(TestFile other) {
   assertIsFile();
   other.assertIsFile();
   assertEquals(
       String.format("%s is not the same length as %s", this, other),
       other.length(),
       this.length());
   assertTrue(
       String.format("%s does not have the same content as %s", this, other),
       Arrays.equals(getHash("MD5"), other.getHash("MD5")));
   return this;
 }
コード例 #3
0
ファイル: TestFile.java プロジェクト: GeehomThor/shadow
  /** Asserts that this file contains exactly the given set of descendants. */
  public TestFile assertHasDescendants(String... descendants) {
    Set<String> actual = new TreeSet<String>();
    assertIsDir();
    visit(actual, "", this);
    Set<String> expected = new TreeSet<String>(Arrays.asList(descendants));

    Set<String> extras = new TreeSet<String>(actual);
    extras.removeAll(expected);
    Set<String> missing = new TreeSet<String>(expected);
    missing.removeAll(actual);

    assertEquals(
        String.format(
            "For dir: %s, extra files: %s, missing files: %s, expected: %s",
            this, extras, missing, expected),
        expected,
        actual);

    return this;
  }
コード例 #4
0
ファイル: TestFile.java プロジェクト: GeehomThor/shadow
 public ExecOutput exec(Object... args) {
   return new TestFileHelper(this).execute(Arrays.asList(args), null);
 }
コード例 #5
0
ファイル: TestFile.java プロジェクト: GeehomThor/shadow
 public void assertContentsHaveChangedSince(Snapshot snapshot) {
   Snapshot now = snapshot();
   assertTrue(
       String.format("contents of %s have not changed", this),
       !Arrays.equals(now.hash, snapshot.hash));
 }
コード例 #6
0
ファイル: TestFile.java プロジェクト: GeehomThor/shadow
 public void assertHasChangedSince(Snapshot snapshot) {
   Snapshot now = snapshot();
   assertTrue(now.modTime != snapshot.modTime || !Arrays.equals(now.hash, snapshot.hash));
 }
コード例 #7
0
ファイル: TestFile.java プロジェクト: GeehomThor/shadow
 public TestFile writelns(String... lines) {
   return writelns(Arrays.asList(lines));
 }