use of ch.cyberduck.core.NullWriteFeature in project cyberduck by iterate-ch.
the class ResumeFilterTest method testAppendSmallerSize.
@Test
public void testAppendSmallerSize() throws Exception {
final Host host = new Host(new TestProtocol());
final NullSession session = new NullSession(host) {
@Override
public AttributedList<Path> list(final Path folder, final ListProgressListener listener) throws BackgroundException {
final AttributedList<Path> list = new AttributedList<>(Collections.singletonList(new Path(folder, "t", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withSize(2L))));
listener.chunk(folder, list);
return list;
}
};
final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), session, new UploadFilterOptions(host).withTemporary(true), new DefaultUploadFeature<>(new NullWriteFeature(session)));
final long size = 3L;
final Path t = new Path("t", EnumSet.of(Path.Type.file));
final NullLocal l = new NullLocal("t") {
@Override
public LocalAttributes attributes() {
return new LocalAttributes("t") {
@Override
public long getSize() {
return size;
}
};
}
@Override
public boolean isFile() {
return true;
}
@Override
public boolean exists() {
return true;
}
};
assertTrue(f.accept(t, l, new TransferStatus().exists(true)));
// Remaining length to transfer is 1
assertEquals(1L, f.prepare(t, l, new TransferStatus().exists(true), new DisabledProgressListener()).getLength());
// Skip first 2 bytes
assertEquals(2L, f.prepare(t, l, new TransferStatus().exists(true), new DisabledProgressListener()).getOffset());
}
use of ch.cyberduck.core.NullWriteFeature in project cyberduck by iterate-ch.
the class ResumeFilterTest method testAppendEqualSize.
@Test
public void testAppendEqualSize() throws Exception {
final Host host = new Host(new TestProtocol());
final NullSession session = new NullSession(host) {
@Override
public AttributedList<Path> list(final Path folder, final ListProgressListener listener) throws BackgroundException {
final AttributedList<Path> list = new AttributedList<>(Collections.singletonList(new Path(folder, "t", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withSize(3L))));
listener.chunk(folder, list);
return list;
}
};
final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), session, new UploadFilterOptions(host).withTemporary(true), new DefaultUploadFeature<Void>(new NullWriteFeature(session)));
final long size = 3L;
final Path t = new Path("t", EnumSet.of(Path.Type.file));
assertFalse(f.accept(t, new NullLocal("t") {
@Override
public LocalAttributes attributes() {
return new LocalAttributes("t") {
@Override
public long getSize() {
return size;
}
};
}
@Override
public boolean isFile() {
return true;
}
@Override
public boolean exists() {
return true;
}
}, new TransferStatus().exists(true)));
}
use of ch.cyberduck.core.NullWriteFeature in project cyberduck by iterate-ch.
the class ResumeFilterTest method testAppendLargerSize.
@Test
public void testAppendLargerSize() throws Exception {
final Host host = new Host(new TestProtocol());
final NullSession session = new NullSession(host) {
@Override
public AttributedList<Path> list(final Path folder, final ListProgressListener listener) throws BackgroundException {
final AttributedList<Path> list = new AttributedList<>(Collections.singletonList(new Path(folder, "t", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withSize(4L))));
listener.chunk(folder, list);
return list;
}
};
final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), session, new UploadFilterOptions(host).withTemporary(true), new DefaultUploadFeature<>(new NullWriteFeature(session)));
final long size = 3L;
final Path t = new Path("t", EnumSet.of(Path.Type.file));
final NullLocal l = new NullLocal("t") {
@Override
public boolean exists() {
return true;
}
@Override
public LocalAttributes attributes() {
return new LocalAttributes("t") {
@Override
public long getSize() {
return size;
}
};
}
@Override
public boolean isFile() {
return true;
}
};
assertTrue(f.accept(t, l, new TransferStatus().exists(true)));
assertFalse(f.prepare(t, l, new TransferStatus().exists(true), new DisabledProgressListener()).isAppend());
}
Aggregations