@Test
  public void testNotOverwrite() throws IOException {
    Path file = new Path("/" + name.getMethodName());
    try (FSDataOutputStream out1 = FS.create(file)) {
      try {
        FS.create(file, false);
        fail("Should fail as there is a file with the same name which is being written");
      } catch (RemoteException e) {
        // expected
        assertThat(e.unwrapRemoteException(), instanceOf(AlreadyBeingCreatedException.class));
      }
    }
  }
Used to confirm that it is OK to overwrite a file which is being written currently.
hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestOverwriteFileUnderConstruction.java