Search in sources :

Example 66 with TestProtocol

use of ch.cyberduck.core.TestProtocol in project cyberduck by iterate-ch.

the class TransferPlistReaderTest method testDeserializeDownload.

@Test
public void testDeserializeDownload() throws Exception {
    final Transfer t = new TransferPlistReader(new ProtocolFactory(Collections.singleton(new TestProtocol()))).read(new Local("src/test/resources/fcea1809-1d75-42f1-92b5-99b38bc1d63e.cyberducktransfer"));
    assertTrue(t instanceof DownloadTransfer);
    assertEquals("s3.amazonaws.com", t.getSource().getHostname());
    assertEquals("/cyberduck/Cyberduck-3.3.zip", t.getRoot().remote.getAbsolute());
    assertEquals("C:\\Users\\Yves Langisch\\Desktop\\Cyberduck-3.3.zip", t.getRoot().local.getAbsolute());
}
Also used : ProtocolFactory(ch.cyberduck.core.ProtocolFactory) TestProtocol(ch.cyberduck.core.TestProtocol) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Local(ch.cyberduck.core.Local) Test(org.junit.Test)

Example 67 with TestProtocol

use of ch.cyberduck.core.TestProtocol in project cyberduck by iterate-ch.

the class TransferPlistReaderTest method testDeserializeUpload.

@Test
public void testDeserializeUpload() throws Exception {
    final Transfer t = new TransferPlistReader(new ProtocolFactory(Collections.singleton(new TestProtocol()))).read(new Local("src/test/resources/c44b5120-8dfe-41af-acd3-da99d87b811f.cyberducktransfer"));
    assertTrue(t instanceof UploadTransfer);
    assertEquals("identity.api.rackspacecloud.com", t.getSource().getHostname());
    assertEquals("/test.cyberduck.ch/bookmarks_en.png", t.getRoot().remote.getAbsolute());
    assertEquals("C:\\Users\\Yves Langisch\\Pictures\\bookmarks_en.png", t.getRoot().local.getAbsolute());
}
Also used : ProtocolFactory(ch.cyberduck.core.ProtocolFactory) TestProtocol(ch.cyberduck.core.TestProtocol) Transfer(ch.cyberduck.core.transfer.Transfer) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Local(ch.cyberduck.core.Local) Test(org.junit.Test)

Example 68 with TestProtocol

use of ch.cyberduck.core.TestProtocol in project cyberduck by iterate-ch.

the class CustomSchemeUrlProviderTest method testCustomSchemes.

@Test
public void testCustomSchemes() {
    Host host = new Host(new TestProtocol() {

        public String[] getSchemes() {
            return new String[] { "c1", "c2" };
        }
    }, "localhost");
    Path path = new Path("/file", EnumSet.of(Path.Type.file));
    final DescriptiveUrlBag list = new CustomSchemeUrlProvider(host).toUrl(path).filter(DescriptiveUrl.Type.provider);
    assertEquals(2, list.size());
    assertTrue(list.contains(new DescriptiveUrl(URI.create("c1://localhost/file"))));
    assertTrue(list.contains(new DescriptiveUrl(URI.create("c2://localhost/file"))));
}
Also used : Path(ch.cyberduck.core.Path) TestProtocol(ch.cyberduck.core.TestProtocol) DescriptiveUrl(ch.cyberduck.core.DescriptiveUrl) DescriptiveUrlBag(ch.cyberduck.core.DescriptiveUrlBag) Host(ch.cyberduck.core.Host) Test(org.junit.Test)

Example 69 with TestProtocol

use of ch.cyberduck.core.TestProtocol in project cyberduck by iterate-ch.

the class SegmentRetryCallableTest method testRetry.

@Test
public void testRetry() throws Exception {
    final AtomicInteger count = new AtomicInteger();
    final SegmentRetryCallable<Void> c = new SegmentRetryCallable<Void>(new Host(new TestProtocol()), 2, 0, new BackgroundExceptionCallable<Void>() {

        @Override
        public Void call() throws BackgroundException {
            throw new ConnectionRefusedException("d", new SocketException());
        }
    }, new TransferStatus(), new BytecountStreamListener()) {

        @Override
        public boolean retry(final BackgroundException failure, final ProgressListener progress, final BackgroundActionState cancel) {
            count.incrementAndGet();
            return super.retry(failure, progress, cancel);
        }
    };
    try {
        c.call();
        fail();
    } catch (ConnectionRefusedException e) {
    // Expected
    }
    assertEquals(3, count.get());
}
Also used : SocketException(java.net.SocketException) TestProtocol(ch.cyberduck.core.TestProtocol) BackgroundActionState(ch.cyberduck.core.threading.BackgroundActionState) Host(ch.cyberduck.core.Host) ConnectionRefusedException(ch.cyberduck.core.exception.ConnectionRefusedException) BytecountStreamListener(ch.cyberduck.core.BytecountStreamListener) ProgressListener(ch.cyberduck.core.ProgressListener) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BackgroundException(ch.cyberduck.core.exception.BackgroundException) Test(org.junit.Test)

Example 70 with TestProtocol

use of ch.cyberduck.core.TestProtocol in project cyberduck by iterate-ch.

the class SyncTransferTest method testAction.

@Test
public void testAction() throws Exception {
    final Path p = new Path("t", EnumSet.of(Path.Type.directory));
    Transfer t = new SyncTransfer(new Host(new TestProtocol()), new TransferItem(p, new NullLocal("p", "t") {

        @Override
        public boolean exists() {
            return true;
        }

        @Override
        public AttributedList<Local> list() {
            return new AttributedList<Local>(Collections.<Local>singletonList(new NullLocal("p", "a")));
        }
    }));
    final AtomicBoolean prompt = new AtomicBoolean();
    final NullSession session = new NullSession(new Host(new TestProtocol()));
    assertNull(t.action(session, null, false, false, new DisabledTransferPrompt() {

        @Override
        public TransferAction prompt(final TransferItem file) {
            prompt.set(true);
            return null;
        }
    }, new DisabledListProgressListener()));
    assertTrue(prompt.get());
}
Also used : Path(ch.cyberduck.core.Path) TestProtocol(ch.cyberduck.core.TestProtocol) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) NullLocal(ch.cyberduck.core.NullLocal) Local(ch.cyberduck.core.Local) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AttributedList(ch.cyberduck.core.AttributedList) NullLocal(ch.cyberduck.core.NullLocal) Test(org.junit.Test)

Aggregations

TestProtocol (ch.cyberduck.core.TestProtocol)253 Test (org.junit.Test)251 Host (ch.cyberduck.core.Host)230 Path (ch.cyberduck.core.Path)173 NullSession (ch.cyberduck.core.NullSession)131 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)107 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)96 Local (ch.cyberduck.core.Local)79 NullLocal (ch.cyberduck.core.NullLocal)76 ListProgressListener (ch.cyberduck.core.ListProgressListener)44 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)35 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)34 AttributedList (ch.cyberduck.core.AttributedList)33 ProtocolFactory (ch.cyberduck.core.ProtocolFactory)29 Transfer (ch.cyberduck.core.transfer.Transfer)28 DisabledUploadSymlinkResolver (ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver)28 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)27 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)27 VaultCredentials (ch.cyberduck.core.vault.VaultCredentials)27 UploadTransfer (ch.cyberduck.core.transfer.UploadTransfer)25