use of ch.cyberduck.core.vault.DefaultVaultRegistry in project cyberduck by iterate-ch.
the class DefaultSessionPoolTest method testConnectRefuse.
@Test(expected = ConnectionRefusedException.class)
public void testConnectRefuse() throws Exception {
final DefaultSessionPool pool = new DefaultSessionPool(new TestLoginConnectionService() {
@Override
public boolean check(final Session<?> session, final CancelCallback callback) throws BackgroundException {
throw new ConnectionRefusedException("t", new RuntimeException());
}
}, new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), new Host(new TestProtocol(), "t"));
pool.borrow(BackgroundActionState.running);
}
use of ch.cyberduck.core.vault.DefaultVaultRegistry 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.vault.DefaultVaultRegistry 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.vault.DefaultVaultRegistry 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.vault.DefaultVaultRegistry in project cyberduck by iterate-ch.
the class SessionListWorkerTest method testCacheNotFoundWithController.
@Test
public void testCacheNotFoundWithController() throws Exception {
final Host host = new Host(new TestProtocol(), "localhost");
final Session<?> session = new NullTransferSession(host);
final PathCache cache = new PathCache(1);
final SessionListWorker worker = new SessionListWorker(cache, new Path("/home/notfound", EnumSet.of(Path.Type.directory)), new DisabledListProgressListener());
final Controller c = new AbstractController() {
@Override
public void invoke(final MainAction runnable, final boolean wait) {
runnable.run();
}
};
final Future<AttributedList<Path>> task = c.background(new WorkerBackgroundAction<AttributedList<Path>>(c, new StatelessSessionPool(new TestLoginConnectionService(), session, new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), worker));
assertTrue(task.get().isEmpty());
}
Aggregations