use of ch.cyberduck.core.DisabledTranscriptListener 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.DisabledTranscriptListener 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.DisabledTranscriptListener 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.DisabledTranscriptListener 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.DisabledTranscriptListener in project cyberduck by iterate-ch.
the class SessionBackgroundActionTest method testGetExceptionConnectionCanceledException.
@Test
public void testGetExceptionConnectionCanceledException() {
SessionBackgroundAction<Void> a = new SessionBackgroundAction<Void>(new StatelessSessionPool(new TestLoginConnectionService(), new NullSession(new Host(new TestProtocol(), "t")), new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), new DisabledAlertCallback(), new DisabledProgressListener()) {
@Override
public Void run(final Session<?> session) throws BackgroundException {
throw new ConnectionCanceledException();
}
};
try {
a.call();
fail();
} catch (BackgroundException e) {
// Ignore
}
assertFalse(a.hasFailed());
}
Aggregations