@Test(expected = NotfoundException.class) public void testReadNotFound() throws Exception { final LocalSession session = new LocalSession(new Host(new LocalProtocol(), new LocalProtocol().getDefaultHostname())); session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback()); session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback()); final TransferStatus status = new TransferStatus(); final Path workdir = new LocalHomeFinderFeature(session).find(); new LocalReadFeature(session).read(new Path(workdir, "nosuchname", EnumSet.of(Path.Type.file)), status, new DisabledConnectionCallback()); }
@Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final FileChannel channel = FileChannel.open(session.toPath(file), StandardOpenOption.READ); channel.position(status.getOffset()); return Channels.newInputStream(channel); } catch(IOException e) { throw new LocalExceptionMappingService().map("Download {0} failed", e, file); } }
LocalReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final FileChannel channel = FileChannel.open(session.toPath(file), StandardOpenOption.READ); channel.position(status.getOffset()); return Channels.newInputStream(channel); } catch(IOException e) { throw new LocalExceptionMappingService().map("Download {0} failed", e, file); } } }
LocalReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final FileChannel channel = FileChannel.open(session.toPath(file), StandardOpenOption.READ); channel.position(status.getOffset()); return Channels.newInputStream(channel); } catch(IOException e) { throw new LocalExceptionMappingService().map("Download {0} failed", e, file); } } LocalReadFeature(final LocalSession session); }
LocalReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final FileChannel channel = FileChannel.open(session.toPath(file), StandardOpenOption.READ); channel.position(status.getOffset()); return Channels.newInputStream(channel); } catch(IOException e) { throw new LocalExceptionMappingService().map("Download {0} failed", e, file); } } LocalReadFeature(final LocalSession session); @Override InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override boolean offset(final Path file); }
LocalReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final FileChannel channel = FileChannel.open(session.toPath(file), StandardOpenOption.READ); channel.position(status.getOffset()); return Channels.newInputStream(channel); } catch(IOException e) { throw new LocalExceptionMappingService().map("Download {0} failed", e, file); } } LocalReadFeature(final LocalSession session); @Override InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override boolean offset(final Path file);  }