use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.
the class SessionBackgroundActionTest method testRetrySocket.
@Test
public void testRetrySocket() {
final BackgroundException failure = new BackgroundException(new SocketTimeoutException(""));
SessionBackgroundAction<Void> a = new SessionBackgroundAction<Void>(new StatelessSessionPool(new TestLoginConnectionService(), new NullSession(new Host(new TestProtocol(), "t")), new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), new AlertCallback() {
@Override
public boolean alert(final Host repeatableBackgroundAction, final BackgroundException f, final StringBuilder transcript) {
assertEquals(failure, f);
return false;
}
}, new DisabledProgressListener()) {
@Override
public Void run(final Session<?> session) throws BackgroundException {
throw failure;
}
};
}
use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.
the class TransferBackgroundActionTest method testWorkerImplementationDefaultConcurrent.
@Test
public void testWorkerImplementationDefaultConcurrent() {
final AbstractController controller = new AbstractController() {
@Override
public void invoke(final MainAction runnable, final boolean wait) {
runnable.run();
}
};
final Host host = new Host(new TestProtocol(), "l");
host.setTransfer(Host.TransferType.concurrent);
assertEquals(ConcurrentTransferWorker.class, new TransferBackgroundAction(controller, new StatelessSessionPool(new TestLoginConnectionService(), new NullSession(host), new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), SessionPool.DISCONNECTED, new TransferAdapter(), new UploadTransfer(host, Collections.emptyList()), new TransferOptions()).worker.getClass());
assertEquals(ConcurrentTransferWorker.class, new TransferBackgroundAction(controller, new StatelessSessionPool(new TestLoginConnectionService(), new NullSession(host), new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), SessionPool.DISCONNECTED, new TransferAdapter(), new DownloadTransfer(host, Collections.emptyList()), new TransferOptions()).worker.getClass());
}
use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.
the class CopyTransferTest method testList.
@Test
public void testList() throws Exception {
Transfer t = new CopyTransfer(new Host(new TestProtocol()), new Host(new TestProtocol()), new HashMap<>(Collections.singletonMap(new Path("/s", EnumSet.of(Path.Type.directory)), new Path("/t", EnumSet.of(Path.Type.directory)))));
final NullSession session = new NullSession(new Host(new TestProtocol())) {
@Override
public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
final AttributedList<Path> children = new AttributedList<Path>();
children.add(new Path("/s/c", EnumSet.of(Path.Type.file)));
return children;
}
};
assertEquals(Collections.singletonList(new TransferItem(new Path("/s/c", EnumSet.of(Path.Type.file)))), t.list(session, new Path("/s", EnumSet.of(Path.Type.directory)), null, new DisabledListProgressListener()));
}
use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.
the class DeleteWorkerTest method testCompileRecursiveDeleteSupportedMultipleFilesAsArgument.
@Test
public void testCompileRecursiveDeleteSupportedMultipleFilesAsArgument() 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(), Arrays.asList(new Path("/t", EnumSet.of(Path.Type.directory)), new Path("/t/a", EnumSet.of(Path.Type.file)), new Path("/t/d", EnumSet.of(Path.Type.directory)), new Path("/t/d", EnumSet.of(Path.Type.directory)), new Path("/t/d/b", EnumSet.of(Path.Type.file))), PathCache.empty(), new DisabledProgressListener());
assertEquals(1, worker.run(session).size());
}
use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.
the class DeleteWorkerTest method testSymlink.
@Test
public void testSymlink() 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("/s", EnumSet.of(Path.Type.directory, AbstractPath.Type.symboliclink)), new ArrayList<>(files.keySet()).get(0));
}
@Override
public boolean isRecursive() {
return false;
}
};
}
return super._getFeature(type);
}
@Override
public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
fail();
return null;
}
};
final DeleteWorker worker = new DeleteWorker(new DisabledLoginCallback(), Collections.singletonList(new Path("/s", EnumSet.of(Path.Type.directory, AbstractPath.Type.symboliclink))), PathCache.empty(), new DisabledProgressListener());
worker.run(session);
}
Aggregations