Search in sources :

Example 56 with DisabledProgressListener

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());
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) Host(ch.cyberduck.core.Host) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 57 with DisabledProgressListener

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());
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TestProtocol(ch.cyberduck.core.TestProtocol) Host(ch.cyberduck.core.Host) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 58 with DisabledProgressListener

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());
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TestProtocol(ch.cyberduck.core.TestProtocol) Host(ch.cyberduck.core.Host) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 59 with DisabledProgressListener

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());
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) Host(ch.cyberduck.core.Host) CyclicBarrier(java.util.concurrent.CyclicBarrier) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.junit.Test)

Example 60 with DisabledProgressListener

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());
}
Also used : DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) ConnectionCanceledException(ch.cyberduck.core.exception.ConnectionCanceledException) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) StatelessSessionPool(ch.cyberduck.core.pool.StatelessSessionPool) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) TestLoginConnectionService(ch.cyberduck.core.TestLoginConnectionService) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) BackgroundException(ch.cyberduck.core.exception.BackgroundException) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) Test(org.junit.Test)

Aggregations

DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)166 Test (org.junit.Test)147 Host (ch.cyberduck.core.Host)135 Path (ch.cyberduck.core.Path)128 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)103 TestProtocol (ch.cyberduck.core.TestProtocol)95 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)94 NullSession (ch.cyberduck.core.NullSession)68 IntegrationTest (ch.cyberduck.test.IntegrationTest)65 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)59 NullLocal (ch.cyberduck.core.NullLocal)49 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)48 DisabledCancelCallback (ch.cyberduck.core.DisabledCancelCallback)48 DisabledHostKeyCallback (ch.cyberduck.core.DisabledHostKeyCallback)48 Credentials (ch.cyberduck.core.Credentials)43 Delete (ch.cyberduck.core.features.Delete)42 Local (ch.cyberduck.core.Local)40 LoginConnectionService (ch.cyberduck.core.LoginConnectionService)39 DefaultX509KeyManager (ch.cyberduck.core.ssl.DefaultX509KeyManager)36 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)34