use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class OneDriveMeContextLoginTest method setup.
@Before
public void setup() throws Exception {
final ProtocolFactory factory = new ProtocolFactory(new HashSet<>(Collections.singleton(new OneDriveProtocol())));
final Profile profile = new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/Microsoft OneDrive.cyberduckprofile"));
final Host host = new Host(profile, profile.getDefaultHostname(), new Credentials("cyberduck"));
session = new OneDriveSession(host, new DefaultX509TrustManager(), new DefaultX509KeyManager());
final LoginConnectionService login = new LoginConnectionService(new DisabledLoginCallback() {
@Override
public Credentials prompt(final Host bookmark, final String username, final String title, final String reason, final LoginOptions options) {
fail(reason);
return null;
}
}, new DisabledHostKeyCallback(), new DisabledPasswordStore() {
@Override
public String getPassword(Scheme scheme, int port, String hostname, String user) {
if (user.endsWith("Microsoft OneDrive (cyberduck) OAuth2 Access Token")) {
return System.getProperties().getProperty("onedrive.accesstoken");
}
if (user.endsWith("Microsoft OneDrive (cyberduck) OAuth2 Refresh Token")) {
return System.getProperties().getProperty("onedrive.refreshtoken");
}
return null;
}
@Override
public String getPassword(String hostname, String user) {
return super.getPassword(hostname, user);
}
}, new DisabledProgressListener());
login.check(session, new DisabledCancelCallback());
}
use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class SpectraSingleTransferWorkerTest method testTransferredSizeRepeat.
@Ignore
@Test(expected = ConflictException.class)
public void testTransferredSizeRepeat() throws Exception {
final Local local = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random());
final byte[] content = new byte[98305];
new Random().nextBytes(content);
final OutputStream out = local.getOutputStream(false);
IOUtils.write(content, out);
out.close();
final Host host = new Host(new SpectraProtocol() {
@Override
public Scheme getScheme() {
return Scheme.http;
}
}, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials(System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key")));
final BytecountStreamListener counter = new BytecountStreamListener();
final AtomicBoolean failed = new AtomicBoolean();
final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager()) {
final SpectraWriteFeature write = new SpectraWriteFeature(this) {
@Override
public HttpResponseOutputStream<StorageObject> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
final HttpResponseOutputStream<StorageObject> proxy = super.write(file, status, callback);
if (failed.get()) {
// Second attempt successful
return proxy;
}
return new HttpResponseOutputStream<StorageObject>(new CountingOutputStream(proxy) {
@Override
protected void afterWrite(final int n) throws IOException {
super.afterWrite(n);
if (this.getByteCount() >= 42768L) {
assertTrue(this.getByteCount() < content.length);
// Buffer size
assertEquals(32768L, counter.getSent());
failed.set(true);
throw new SocketTimeoutException();
}
}
}, new S3AttributesAdapter(), status) {
@Override
public StorageObject getStatus() throws BackgroundException {
return proxy.getStatus();
}
@Override
public void close() throws IOException {
super.close();
proxy.close();
}
};
}
};
@Override
@SuppressWarnings("unchecked")
public <T> T _getFeature(final Class<T> type) {
if (type == Write.class) {
return (T) write;
}
if (type == Upload.class) {
return (T) new SpectraUploadFeature(this, write, new SpectraBulkService(this));
}
return super._getFeature(type);
}
};
session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback());
final Path container = new Path("cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final Path test = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
final Transfer t = new UploadTransfer(session.getHost(), test, local);
assertTrue(new SingleTransferWorker(session, session, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt() {
@Override
public TransferAction prompt(final TransferItem file) {
return TransferAction.overwrite;
}
}, new DisabledTransferErrorCallback(), new DisabledProgressListener(), counter, new DisabledLoginCallback(), new DisabledNotificationService()) {
}.run(session));
local.delete();
assertTrue(t.isComplete());
assertEquals(content.length, counter.getSent(), 0L);
assertTrue(failed.get());
assertEquals(content.length, new SpectraAttributesFinderFeature(session).find(test).getSize());
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class SpectraBulkServiceTest method testPreDownloadFolderOnly.
@Test
public void testPreDownloadFolderOnly() throws Exception {
final Host host = new Host(new SpectraProtocol() {
@Override
public Scheme getScheme() {
return Scheme.http;
}
}, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials(System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key")));
final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
final LoginConnectionService service = new LoginConnectionService(new DisabledLoginCallback() {
@Override
public void warn(final Host bookmark, final String title, final String message, final String continueButton, final String disconnectButton, final String preference) {
//
}
}, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
service.connect(session, new DisabledCancelCallback());
final Set<UUID> keys = new SpectraBulkService(session).pre(Transfer.Type.download, Collections.singletonMap(new TransferItem(new Path(String.format("/cyberduck/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.directory))), new TransferStatus()), new DisabledConnectionCallback());
assertTrue(keys.isEmpty());
session.close();
}
use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class SpectraBulkServiceTest method testPreDownloadNotFound.
@Test(expected = NotfoundException.class)
public void testPreDownloadNotFound() throws Exception {
final Host host = new Host(new SpectraProtocol() {
@Override
public Scheme getScheme() {
return Scheme.http;
}
}, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials(System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key")));
final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
final LoginConnectionService service = new LoginConnectionService(new DisabledLoginCallback() {
@Override
public void warn(final Host bookmark, final String title, final String message, final String continueButton, final String disconnectButton, final String preference) {
//
}
}, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
service.connect(session, new DisabledCancelCallback());
new SpectraBulkService(session).pre(Transfer.Type.download, Collections.singletonMap(new TransferItem(new Path(String.format("/cyberduck/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.file))), new TransferStatus().withLength(1L)), new DisabledConnectionCallback());
session.close();
}
use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class SpectraBulkServiceTest method testPreUploadSingleFile.
@Test
public void testPreUploadSingleFile() throws Exception {
final Host host = new Host(new SpectraProtocol() {
@Override
public Scheme getScheme() {
return Scheme.http;
}
}, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials(System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key")));
final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
final LoginConnectionService service = new LoginConnectionService(new DisabledLoginCallback() {
@Override
public void warn(final Host bookmark, final String title, final String message, final String continueButton, final String disconnectButton, final String preference) {
//
}
}, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
service.connect(session, new DisabledCancelCallback());
final Map<TransferItem, TransferStatus> files = new HashMap<>();
final TransferStatus status = new TransferStatus();
final Path file = new Path(String.format("/cyberduck/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.file));
files.put(new TransferItem(file), status.withLength(1L));
final SpectraBulkService bulk = new SpectraBulkService(session);
bulk.pre(Transfer.Type.upload, files, new DisabledConnectionCallback());
assertFalse(status.getParameters().isEmpty());
assertNotNull(status.getParameters().get("job"));
bulk.query(Transfer.Type.upload, file, status);
new SpectraDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
session.close();
}
Aggregations