### Question:
INodeFile extends INode implements BlockCollection { public static INodeFile valueOf(INode inode, String path) throws IOException { if (inode == null) { throw new FileNotFoundException("File does not exist: " + path); } if (!(inode instanceof INodeFile)) { throw new FileNotFoundException("Path is not a file: " + path); } return (INodeFile)inode; } INodeFile(PermissionStatus permissions, BlockInfo[] blklist,
                      short replication, long modificationTime,
                      long atime, long preferredBlockSize); static INodeFile valueOf(INode inode, String path); @Override short getBlockReplication(); @Override long getPreferredBlockSize(); @Override BlockInfo[] getBlocks(); void setBlock(int idx, BlockInfo blk); @Override String getName(); @Override BlockInfo getLastBlock(); @Override int numBlocks();  }### Answer:
@Test public void testValueOf () throws IOException { final String path = "/testValueOf"; final PermissionStatus perm = new PermissionStatus( userName, null, FsPermission.getDefault()); final short replication = 3; { final INode from = null; try { INodeFile.valueOf(from, path); fail(); } catch(FileNotFoundException fnfe) { assertTrue(fnfe.getMessage().contains("File does not exist")); } try { INodeFileUnderConstruction.valueOf(from, path); fail(); } catch(FileNotFoundException fnfe) { assertTrue(fnfe.getMessage().contains("File does not exist")); } } { final INode from = new INodeFile( perm, null, replication, 0L, 0L, preferredBlockSize); final INodeFile f = INodeFile.valueOf(from, path); assertTrue(f == from); try { INodeFileUnderConstruction.valueOf(from, path); fail(); } catch(IOException ioe) { assertTrue(ioe.getMessage().contains("File is not under construction")); } } { final INode from = new INodeFileUnderConstruction( perm, replication, 0L, 0L, "client", "machine", null); final INodeFile f = INodeFile.valueOf(from, path); assertTrue(f == from); final INodeFileUnderConstruction u = INodeFileUnderConstruction.valueOf( from, path); assertTrue(u == from); } { final INode from = new INodeDirectory(perm, 0L); try { INodeFile.valueOf(from, path); fail(); } catch(FileNotFoundException fnfe) { assertTrue(fnfe.getMessage().contains("Path is not a file")); } try { INodeFileUnderConstruction.valueOf(from, path); fail(); } catch(FileNotFoundException fnfe) { assertTrue(fnfe.getMessage().contains("Path is not a file")); } } }