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());
}
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());
}
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"))));
}
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());
}
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());
}
Aggregations