@Test public void testRun() throws Exception { final Path d = new Path("/d", EnumSet.of(Path.Type.directory)); d.attributes().setSize(-1L); final ReadSizeWorker worker = new ReadSizeWorker(Collections.singletonList(d)) { @Override public void cleanup(final Long result) { } }; assertEquals(0L, worker.run(new NullSession(new Host(new TestProtocol()))), 0L); }
@Override public Long run(final Session<?> session) throws BackgroundException { for(Path next : files) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } if(-1 == next.attributes().getSize()) { continue; } total += next.attributes().getSize(); } return total; }
ReadSizeWorker extends Worker<Long> { @Override public Long run(final Session<?> session) throws BackgroundException { for(Path next : files) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } if(-1 == next.attributes().getSize()) { continue; } total += next.attributes().getSize(); } return total; } }
ReadSizeWorker extends Worker<Long> { @Override public Long run(final Session<?> session) throws BackgroundException { for(Path next : files) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } if(-1 == next.attributes().getSize()) { continue; } total += next.attributes().getSize(); } return total; } ReadSizeWorker(final List<Path> files); }
ReadSizeWorker extends Worker<Long> { @Override public Long run(final Session<?> session) throws BackgroundException { for(Path next : files) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } if(-1 == next.attributes().getSize()) { continue; } total += next.attributes().getSize(); } return total; } ReadSizeWorker(final List<Path> files); @Override Long run(final Session<?> session); @Override String getActivity(); @Override Long initialize(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); }
ReadSizeWorker extends Worker<Long> { @Override public Long run(final Session<?> session) throws BackgroundException { for(Path next : files) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } if(-1 == next.attributes().getSize()) { continue; } total += next.attributes().getSize(); } return total; } ReadSizeWorker(final List<Path> files); @Override Long run(final Session<?> session); @Override String getActivity(); @Override Long initialize(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }