use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class TransferQueueTest method testAddRemove.
@Test
public void testAddRemove() throws Exception {
final TransferQueue queue = new TransferQueue(1);
final DownloadTransfer d1 = new DownloadTransfer(new Host(new TestProtocol()), new Path("/t1", EnumSet.of(Path.Type.directory)), null);
final DownloadTransfer d2 = new DownloadTransfer(new Host(new TestProtocol()), new Path("/t2", EnumSet.of(Path.Type.directory)), null);
queue.add(d1, new DisabledProgressListener());
final CountDownLatch c = new CountDownLatch(1);
new Thread(new Runnable() {
@Override
public void run() {
queue.add(d2, new DisabledProgressListener());
c.countDown();
}
}).start();
assertEquals(1, c.getCount());
queue.remove(d1);
assertTrue(c.await(10, TimeUnit.SECONDS));
assertEquals(0, c.getCount());
}
use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class TransferQueueTest method testResizeMultipleWaiting.
@Test
public void testResizeMultipleWaiting() throws Exception {
final TransferQueue queue = new TransferQueue(1);
final DownloadTransfer d1 = new DownloadTransfer(new Host(new TestProtocol()), new Path("/t1", EnumSet.of(Path.Type.directory)), null);
final DownloadTransfer d2 = new DownloadTransfer(new Host(new TestProtocol()), new Path("/t2", EnumSet.of(Path.Type.directory)), null);
final DownloadTransfer d3 = new DownloadTransfer(new Host(new TestProtocol()), new Path("/t3", EnumSet.of(Path.Type.directory)), null);
queue.add(d1, new DisabledProgressListener());
final CountDownLatch c = new CountDownLatch(2);
final AtomicBoolean set1 = new AtomicBoolean();
final AtomicBoolean set2 = new AtomicBoolean();
new Thread(new Runnable() {
@Override
public void run() {
queue.add(d2, new DisabledProgressListener() {
@Override
public void message(final String message) {
assertEquals("Maximum allowed connections exceeded. Waiting", message);
set1.set(true);
}
});
c.countDown();
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
queue.add(d3, new DisabledProgressListener() {
@Override
public void message(final String message) {
assertEquals("Maximum allowed connections exceeded. Waiting", message);
set2.set(true);
}
});
c.countDown();
}
}).start();
assertEquals(2, c.getCount());
assertFalse(c.await(10, TimeUnit.SECONDS));
assertTrue(set1.get());
assertTrue(set2.get());
queue.resize(3);
assertTrue(c.await(10, TimeUnit.SECONDS));
assertEquals(0, c.getCount());
}
use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class TransferQueueTest method testResize.
@Test
public void testResize() throws Exception {
final TransferQueue queue = new TransferQueue(1);
final DownloadTransfer d1 = new DownloadTransfer(new Host(new TestProtocol()), new Path("/t1", EnumSet.of(Path.Type.directory)), null);
final DownloadTransfer d2 = new DownloadTransfer(new Host(new TestProtocol()), new Path("/t2", EnumSet.of(Path.Type.directory)), null);
queue.add(d1, new DisabledProgressListener());
final CountDownLatch c = new CountDownLatch(1);
final AtomicBoolean set = new AtomicBoolean();
new Thread(new Runnable() {
@Override
public void run() {
queue.add(d2, new DisabledProgressListener() {
@Override
public void message(final String message) {
assertEquals("Maximum allowed connections exceeded. Waiting", message);
set.set(true);
}
});
c.countDown();
}
}).start();
assertEquals(1, c.getCount());
assertFalse(c.await(10, TimeUnit.SECONDS));
queue.resize(2);
assertTrue(c.await(10, TimeUnit.SECONDS));
assertTrue(set.get());
}
use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class TransferQueueTest method testConcurrent.
@Test
public void testConcurrent() throws Exception {
final TransferQueue queue = new TransferQueue(1);
final DownloadTransfer transfer = new DownloadTransfer(new Host(new TestProtocol()), new Path("/t", EnumSet.of(Path.Type.directory)), null);
queue.add(transfer, new DisabledProgressListener());
final AtomicBoolean added = new AtomicBoolean();
final CyclicBarrier wait = new CyclicBarrier(2);
new Thread(new Runnable() {
@Override
public void run() {
queue.add(new DownloadTransfer(new Host(new TestProtocol()), new Path("/t", EnumSet.of(Path.Type.directory)), null), new DisabledProgressListener());
added.set(true);
try {
wait.await();
} catch (InterruptedException | BrokenBarrierException e) {
fail();
}
}
}).start();
assertFalse(added.get());
queue.remove(transfer);
wait.await();
assertTrue(added.get());
}
use of ch.cyberduck.core.DisabledProgressListener 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