MonitoredFile { public MonitoredFile(File file) { this.file = file; this.stream = null; this.checksum = null; this.mimetype = null; } MonitoredFile(File file); File getFile(); boolean exists(); String getName(); String getAbsolutePath(); long length(); URI toURI(); long getStreamBytesRead(); MonitoredInputStream getStream(); String getChecksum(); String getMimetype();  }
@Test public void testMonitoredFile() throws Exception { assertEquals(file.getName(), mFile.getName()); assertEquals(file.length(), mFile.length()); assertEquals(file.exists(), mFile.exists()); assertEquals(file.getAbsolutePath(), mFile.getAbsolutePath()); assertEquals(file.toURI(), mFile.toURI()); MimetypeUtil mimeUtil = new MimetypeUtil(); assertEquals(mimeUtil.getMimeType(file), mFile.getMimetype()); ChecksumUtil cksumUtil = new ChecksumUtil(ChecksumUtil.Algorithm.MD5); assertEquals(cksumUtil.generateChecksum(file), mFile.getChecksum()); MonitoredInputStream stream = mFile.getStream(); assertNotNull(stream); assertEquals(0, mFile.getStreamBytesRead()); stream.read(); assertEquals(1, mFile.getStreamBytesRead()); }