@Test
  public void testReadFileContents() throws Exception {

    Path testPath = new Path(TestUtils.createTempDir().getAbsolutePath(), "tempFile");
    FileSystem fs = testPath.getFileSystem(new Configuration());
    fs.create(testPath);

    // 1) Read back empty file
    String emptyString = HadoopStoreBuilderUtils.readFileContents(fs, testPath, 1024);
    Assert.assertEquals(emptyString.length(), 0);

    // 2) Read back random bytes
    byte[] randomBytes = writeRandomData(testPath, 10);

    // Read back data
    Assert.assertEquals(
        HadoopStoreBuilderUtils.readFileContents(fs, testPath, 1024), new String(randomBytes));

    // 3) Write a json string
    fs.delete(testPath, true);
    fs.create(testPath);

    ReadOnlyStorageMetadata metadata = new ReadOnlyStorageMetadata();
    metadata.add(ReadOnlyStorageMetadata.FORMAT, ReadOnlyStorageFormat.READONLY_V2.getCode());

    // Write file contents
    new FileOutputStream(testPath.toString()).write(metadata.toJsonString().getBytes());

    ReadOnlyStorageMetadata readMetadata =
        new ReadOnlyStorageMetadata(HadoopStoreBuilderUtils.readFileContents(fs, testPath, 1024));
    Assert.assertEquals(
        readMetadata.get(ReadOnlyStorageMetadata.FORMAT),
        ReadOnlyStorageFormat.READONLY_V2.getCode());
  }