示例#1
0
 private String loadJsonArrayFromFile(Path input) throws IOException {
   Optional<String> result = filesystem.readFileIfItExists(input);
   if (result.isPresent()) {
     return result.get();
   } else {
     throw new IOException("Error loading " + input.toString());
   }
 }
  @Test
  public void testPackagedResourceOnIndividualFile() throws IOException {
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    PackagedResource packagedResource =
        PackagedResourceTestUtil.getPackagedResource(filesystem, "testdata/packaged_resource_one");

    assertThat(packagedResource.getFilenamePath().toString(), is("packaged_resource_one"));

    assertThat(
        packagedResource.getResourceIdentifier(),
        is(
            "com.facebook.buck.testutil.packaged_resource.PackagedResourceTestUtil"
                + "#testdata/packaged_resource_one"));

    String fileContent = filesystem.readFileIfItExists(packagedResource.get()).get();
    assertThat(fileContent, is("abc"));
  }