### Question:
NativeIO { public static native void chmod(String path, int mode) throws IOException;  static boolean isAvailable(); static native FileDescriptor open(String path, int flags, int mode); static native Stat fstat(FileDescriptor fd); static native void chmod(String path, int mode); static final int O_RDONLY; static final int O_WRONLY; static final int O_RDWR; static final int O_CREAT; static final int O_EXCL; static final int O_NOCTTY; static final int O_TRUNC; static final int O_APPEND; static final int O_NONBLOCK; static final int O_SYNC; static final int O_ASYNC; static final int O_FSYNC; static final int O_NDELAY; }### Answer:
@Test public void testChmod() throws Exception { try { NativeIO.chmod("/this/file/doesnt/exist", 777); fail("Chmod of non-existent file didn't fail"); } catch (NativeIOException nioe) { assertEquals(Errno.ENOENT, nioe.getErrno()); } File toChmod = new File(TEST_DIR, "testChmod"); assertTrue("Create test subject", toChmod.exists() || toChmod.mkdir()); NativeIO.chmod(toChmod.getAbsolutePath(), 0777); assertPermissions(toChmod, 0777); NativeIO.chmod(toChmod.getAbsolutePath(), 0000); assertPermissions(toChmod, 0000); NativeIO.chmod(toChmod.getAbsolutePath(), 0644); assertPermissions(toChmod, 0644); }