use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.
the class ResumeFilterTest method testSkip.
@Test
public void testSkip() throws Exception {
final Path file = new Path("t", EnumSet.of(Path.Type.file));
final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), new NullSession(new Host(new TestProtocol())) {
@Override
@SuppressWarnings("unchecked")
public <T> T _getFeature(final Class<T> type) {
if (type == Find.class) {
return (T) new Find() {
@Override
public boolean find(final Path file, final ListProgressListener listener) {
return true;
}
};
}
return super._getFeature(type);
}
@Override
public AttributedList<Path> list(final Path parent, final ListProgressListener listener) {
return new AttributedList<>(Collections.singletonList(file));
}
});
file.attributes().setSize(1L);
assertFalse(f.accept(file, new NullLocal("a") {
@Override
public boolean exists() {
return true;
}
@Override
public LocalAttributes attributes() {
return new LocalAttributes("t") {
@Override
public long getSize() {
return 1L;
}
};
}
}, new TransferStatus().exists(true)));
}
use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.
the class ResumeFilterTest method testPrepare0.
@Test
public void testPrepare0() throws Exception {
final Host host = new Host(new TestProtocol());
final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), new NullSession(host), new UploadFilterOptions(host).withTemporary(true));
final Path t = new Path("t", EnumSet.of(Path.Type.file));
t.attributes().setSize(0L);
final TransferStatus status = f.prepare(t, new NullLocal("t"), new TransferStatus().exists(true), new DisabledProgressListener());
assertFalse(status.isAppend());
assertNotNull(status.getRename().remote);
assertEquals(0L, status.getOffset());
}
use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.
the class SkipFilterTest method testNotFound.
@Test(expected = NotfoundException.class)
public void testNotFound() throws Exception {
SkipFilter f = new SkipFilter(new DisabledUploadSymlinkResolver(), new NullSession(new Host(new TestProtocol())) {
@Override
public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
return AttributedList.emptyList();
}
});
f.withAttributes(new AttributesFinder() {
@Override
public PathAttributes find(final Path file, final ListProgressListener listener) {
return file.attributes();
}
});
assertFalse(f.accept(new Path("a", EnumSet.of(Path.Type.file)), new NullLocal("a") {
@Override
public boolean exists() {
return false;
}
}, new TransferStatus().exists(true)));
}
use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.
the class DeleteWorkerTest method testCompileDefault.
@Test
public void testCompileDefault() throws Exception {
final Session session = new NullSession(new Host(new TestProtocol())) {
@Override
@SuppressWarnings("unchecked")
public <T> T _getFeature(final Class<T> type) {
if (type == Delete.class) {
return (T) new Delete() {
@Override
public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) {
assertEquals(new Path("/t/a", EnumSet.of(Path.Type.file)), new ArrayList<>(files.keySet()).get(0));
assertEquals(new Path("/t/d/b", EnumSet.of(Path.Type.file)), new ArrayList<>(files.keySet()).get(1));
assertEquals(new Path("/t/d", EnumSet.of(Path.Type.directory)), new ArrayList<>(files.keySet()).get(2));
assertEquals(new Path("/t", EnumSet.of(Path.Type.directory)), new ArrayList<>(files.keySet()).get(3));
}
};
}
return super._getFeature(type);
}
@Override
public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
if (file.equals(new Path("/t", EnumSet.of(Path.Type.directory)))) {
return new AttributedList<Path>(Arrays.asList(new Path("/t/a", EnumSet.of(Path.Type.file)), new Path("/t/d", EnumSet.of(Path.Type.directory))));
}
if (file.equals(new Path("/t/d", EnumSet.of(Path.Type.directory)))) {
return new AttributedList<Path>(Collections.singletonList(new Path("/t/d/b", EnumSet.of(Path.Type.file))));
}
fail();
return null;
}
};
final DeleteWorker worker = new DeleteWorker(new DisabledLoginCallback(), Collections.singletonList(new Path("/t", EnumSet.of(Path.Type.directory))), PathCache.empty(), new DisabledProgressListener());
assertEquals(4, worker.run(session).size());
}
use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.
the class DeleteWorkerTest method testCompileRecursiveDeleteSupported.
@Test
public void testCompileRecursiveDeleteSupported() throws Exception {
final Session session = new NullSession(new Host(new TestProtocol())) {
@Override
@SuppressWarnings("unchecked")
public <T> T _getFeature(final Class<T> type) {
if (type == Delete.class) {
return (T) new Delete() {
@Override
public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) {
assertEquals(1, files.size());
assertEquals(new Path("/t", EnumSet.of(Path.Type.directory)), new ArrayList<>(files.keySet()).get(0));
}
@Override
public boolean isRecursive() {
return true;
}
};
}
return super._getFeature(type);
}
@Override
public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
if (file.equals(new Path("/t", EnumSet.of(Path.Type.directory)))) {
return new AttributedList<Path>(Arrays.asList(new Path("/t/a", EnumSet.of(Path.Type.file)), new Path("/t/d", EnumSet.of(Path.Type.directory))));
}
if (file.equals(new Path("/t/d", EnumSet.of(Path.Type.directory)))) {
return new AttributedList<Path>(Collections.singletonList(new Path("/t/d/b", EnumSet.of(Path.Type.file))));
}
fail();
return null;
}
};
final DeleteWorker worker = new DeleteWorker(new DisabledLoginCallback(), Collections.singletonList(new Path("/t", EnumSet.of(Path.Type.directory))), PathCache.empty(), new DisabledProgressListener());
assertEquals(1, worker.run(session).size());
}
Aggregations