@Test
  public void setFilePermissionsTest() throws Exception {
    Properties props = new Properties();
    props.setProperty("store.set.file.permission.enabled", Boolean.toString(true));
    props.setProperty("store.data.file.permission", "rw-rw-r--");
    StoreConfig initialConfig = new StoreConfig(new VerifiableProperties(props));
    File segmentFile = new File(tempDir, "test_segment");
    LogSegmentName segmentName = LogSegmentName.generateFirstSegmentName(true);
    assertTrue("Fail to create segment file", segmentFile.createNewFile());
    segmentFile.deleteOnExit();
    // create log segment instance by writing into brand new file (using initialConfig, file permission = "rw-rw-r--")
    new LogSegment(segmentName, segmentFile, STANDARD_SEGMENT_SIZE, initialConfig, metrics, true);
    Set<PosixFilePermission> filePerm = Files.getPosixFilePermissions(segmentFile.toPath());
    assertEquals("File permissions are not expected", "rw-rw-r--", PosixFilePermissions.toString(filePerm));
    // create log segment instance by reading from existing file (using default store config, file permission = "rw-rw----")
    new LogSegment(segmentName, segmentFile, config, metrics);
    filePerm = Files.getPosixFilePermissions(segmentFile.toPath());
    assertEquals("File permissions are not expected", "rw-rw----", PosixFilePermissions.toString(filePerm));
  }
Test that the file permissions are correctly set based on permissions specified in {@link StoreConfig}.
@throws Exception
ambry-store/src/test/java/com/github/ambry/store/LogSegmentTest.java