### Question:
JarResourceFile extends FileSystemFile { @Override public long getLength() { try { return resource.contentLength(); } catch (IOException e) { log.error("Cannot evaluate resource file {} content length",resource.getFilename(),e); } return 0; } JarResourceFile(Resource resource, boolean isExecutable); @Override boolean isFile(); @Override long getLength(); @Override InputStream getInputStream(); @Override long getLastAccessTime(); @Override long getLastModifiedTime(); @Override int getPermissions();  }### Answer:
@Test public void getLength () throws Exception { long contentLength; doReturn((contentLength = new Random().nextLong())).when(resource).contentLength(); assertEquals(contentLength, jarResourceFile.getLength()); }
@Test public void getLengthIOException () throws Exception { doThrow(new IOException()).when(resource).contentLength(); assertEquals(0, jarResourceFile.getLength()); }