use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.
the class DefaultSessionPoolTest method testCheckReconnectApplicationFailure.
@Test
public void testCheckReconnectApplicationFailure() throws Exception {
final AtomicBoolean interrupt = new AtomicBoolean();
final Host bookmark = new Host(new TestProtocol());
final TestLoginConnectionService connect = new TestLoginConnectionService() {
@Override
public boolean check(final Session<?> session, final CancelCallback callback) {
return true;
}
};
final DefaultSessionPool pool = new DefaultSessionPool(connect, new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), bookmark, new GenericObjectPool<Session>(new PooledSessionFactory(connect, new DisabledX509TrustManager(), new DefaultX509KeyManager(), bookmark, new DefaultVaultRegistry(new DisabledPasswordCallback())) {
@Override
public Session create() {
return new NullSession(bookmark) {
@Override
public void interrupt() throws BackgroundException {
interrupt.set(true);
super.interrupt();
}
};
}
}));
final Session<?> session = pool.borrow(BackgroundActionState.running);
pool.release(session, new BackgroundException("m", "d"));
assertFalse(interrupt.get());
}
use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.
the class DefaultSessionPoolTest method testCheckReconnectSocketFailure.
@Test
public void testCheckReconnectSocketFailure() throws Exception {
final AtomicBoolean interrupt = new AtomicBoolean();
final Host bookmark = new Host(new TestProtocol());
final TestLoginConnectionService connect = new TestLoginConnectionService() {
@Override
public boolean check(final Session<?> session, final CancelCallback callback) {
return true;
}
};
final DefaultSessionPool pool = new DefaultSessionPool(connect, new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), bookmark, new GenericObjectPool<Session>(new PooledSessionFactory(connect, new DisabledX509TrustManager(), new DefaultX509KeyManager(), bookmark, new DefaultVaultRegistry(new DisabledPasswordCallback())) {
@Override
public Session create() {
return new NullSession(bookmark) {
@Override
public void interrupt() throws BackgroundException {
interrupt.set(true);
super.interrupt();
}
};
}
}));
final Session<?> session = pool.borrow(BackgroundActionState.running);
pool.release(session, new BackgroundException("m", new SocketException("m")));
assertTrue(interrupt.get());
}
use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.
the class StatelessSessionPoolTest method testCheckReconnectSocketFailure.
@Test
public void testCheckReconnectSocketFailure() throws Exception {
final AtomicBoolean interrupt = new AtomicBoolean();
final StatelessSessionPool pool = new StatelessSessionPool(new TestLoginConnectionService() {
@Override
public boolean check(final Session<?> session, final CancelCallback callback) {
return true;
}
}, new NullSession(new Host(new TestProtocol())) {
@Override
public void interrupt() throws BackgroundException {
interrupt.set(true);
super.interrupt();
}
}, new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback()));
final Session<?> session = pool.borrow(BackgroundActionState.running);
pool.release(session, new BackgroundException("m", new SocketException("m")));
assertFalse(interrupt.get());
}
use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.
the class RemoteProfilesFinderTest method find.
@Test
public void find() throws Exception {
final ProtocolFactory protocols = new ProtocolFactory(new HashSet<>(Arrays.asList(new TestProtocol() {
@Override
public String getIdentifier() {
return "s3";
}
@Override
public Type getType() {
return Type.s3;
}
@Override
public boolean isEnabled() {
return false;
}
}, new TestProtocol() {
@Override
public String getIdentifier() {
return "davs";
}
@Override
public Type getType() {
return Type.dav;
}
@Override
public boolean isEnabled() {
return false;
}
})));
final ProfilePlistReader reader = new ProfilePlistReader(protocols);
final TestProtocol protocol = new TestProtocol() {
@Override
public String getIdentifier() {
return "davs";
}
@Override
public Scheme getScheme() {
return Scheme.https;
}
@Override
public Type getType() {
return Type.dav;
}
@Override
public boolean isEnabled() {
return false;
}
};
final Host host = new HostParser(protocols, protocol).get("https://svn.cyberduck.io/trunk/profiles");
final NullSession session = new NullSession(host);
session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
final RemoteProfilesFinder finder = new RemoteProfilesFinder(session);
final Set<ProfileDescription> stream = finder.find();
assertTrue(stream.isEmpty());
session.close();
}
use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.
the class SingleTransferWorkerTest method testUploadPrepareOverrideRootDoesNotExist.
@Test
public void testUploadPrepareOverrideRootDoesNotExist() throws Exception {
final Path child = new Path("/t/c", EnumSet.of(Path.Type.file));
final Path root = new Path("/t", EnumSet.of(Path.Type.directory)) {
@Override
public Path getParent() {
return new Path("/", EnumSet.of(Path.Type.directory));
}
};
final NullLocal local = new NullLocal("l") {
@Override
public AttributedList<Local> list() {
AttributedList<Local> l = new AttributedList<Local>();
l.add(new NullLocal(this.getAbsolute(), "c") {
@Override
public boolean exists() {
return true;
}
});
return l;
}
@Override
public boolean exists() {
return true;
}
};
final Transfer t = new UploadTransfer(new Host(new TestProtocol()), root, local) {
@Override
public void transfer(final Session<?> source, final Session<?> destination, final Path file, Local local, final TransferOptions options, final TransferStatus overall, final TransferStatus segment, final ConnectionCallback connectionCallback, final ProgressListener listener, final StreamListener streamListener) {
//
}
};
final NullSession session = new NullSession(new Host(new TestProtocol()));
final SingleTransferWorker worker = new SingleTransferWorker(session, session, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt() {
@Override
public TransferAction prompt(final TransferItem file) {
return TransferAction.overwrite;
}
}, new DisabledTransferErrorCallback(), new DisabledProgressListener(), new DisabledStreamListener(), new DisabledLoginCallback(), new DisabledNotificationService()) {
@Override
public Future<TransferStatus> transfer(final TransferItem item, final TransferAction action) throws BackgroundException {
if (item.remote.equals(root)) {
assertTrue(this.getCache().isCached(new TransferItem(root, local)));
}
super.transfer(new TransferItem(item.remote, new NullLocal("l") {
@Override
public AttributedList<Local> list() {
AttributedList<Local> l = new AttributedList<Local>();
l.add(new NullLocal(this.getAbsolute(), "c"));
return l;
}
}), action);
assertFalse(this.getCache().isCached(new TransferItem(child, local)));
return null;
}
};
worker.run(session);
assertFalse(worker.getCache().isCached(new TransferItem(child, local)));
}
Aggregations