use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class CryptoS3SingleTransferWorkerTest method testUpload.
@Test
public void testUpload() throws Exception {
final Path home = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.volume, Path.Type.directory));
final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
final Path dir1 = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
final Local localDirectory1 = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random());
new DefaultLocalDirectoryFeature().mkdir(localDirectory1);
final byte[] content = RandomUtils.nextBytes(62768);
final Path file1 = new Path(dir1, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
final Local localFile1 = new Local(localDirectory1, file1.getName());
final OutputStream out1 = localFile1.getOutputStream(false);
IOUtils.write(content, out1);
out1.close();
final Path file2 = new Path(dir1, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
final Local localFile2 = new Local(localDirectory1, file2.getName());
final OutputStream out2 = localFile2.getOutputStream(false);
IOUtils.write(content, out2);
out2.close();
final CryptoVault cryptomator = new CryptoVault(vault);
cryptomator.create(session, new VaultCredentials("test"), new DisabledPasswordStore(), vaultVersion);
session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
final Transfer t = new UploadTransfer(new Host(new TestProtocol()), Collections.singletonList(new TransferItem(dir1, localDirectory1)), new NullFilter<>());
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(), new DisabledStreamListener(), new DisabledLoginCallback(), new DisabledNotificationService()) {
}.run(session));
assertTrue(new CryptoFindFeature(session, new S3FindFeature(session), cryptomator).find(dir1));
assertEquals(content.length, new CryptoAttributesFeature(session, new S3AttributesFinderFeature(session), cryptomator).find(file1).getSize());
{
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
final InputStream in = new CryptoReadFeature(session, new S3ReadFeature(session), cryptomator).read(file1, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(in, buffer);
assertArrayEquals(content, buffer.toByteArray());
}
assertEquals(content.length, new CryptoAttributesFeature(session, new S3AttributesFinderFeature(session), cryptomator).find(file2).getSize());
{
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
final InputStream in = new CryptoReadFeature(session, new S3ReadFeature(session), cryptomator).read(file1, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(in, buffer);
assertArrayEquals(content, buffer.toByteArray());
}
cryptomator.getFeature(session, Delete.class, new S3DefaultDeleteFeature(session)).delete(Arrays.asList(file1, file2, dir1, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
localFile1.delete();
localFile2.delete();
localDirectory1.delete();
}
use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class MoveWorkerTest method testMoveFile.
@Test
public void testMoveFile() throws Exception {
final Path home = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final Path source = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
final Path target = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
new S3TouchFeature(session).touch(source, new TransferStatus().withMime("application/cyberduck"));
new S3AccessControlListFeature(session).setPermission(source, new Acl(new Acl.UserAndRole(new Acl.Owner("80b9982b7b08045ee86680cc47f43c84bf439494a89ece22b5330f8a49477cf6"), new Acl.Role(Acl.Role.FULL)), new Acl.UserAndRole(new Acl.GroupUser("http://acs.amazonaws.com/groups/global/AllUsers"), new Acl.Role(Acl.Role.READ))));
assertTrue(new S3FindFeature(session).find(source));
final MoveWorker worker = new MoveWorker(Collections.singletonMap(source, target), new SessionPool.SingleSessionPool(session), PathCache.empty(), new DisabledProgressListener(), new DisabledLoginCallback());
worker.run(session);
assertFalse(new S3FindFeature(session).find(source));
assertTrue(new S3FindFeature(session).find(target));
assertEquals("application/cyberduck", new S3MetadataFeature(session, new S3AccessControlListFeature(session)).getMetadata(target).get("Content-Type"));
assertTrue(new S3AccessControlListFeature(session).getPermission(target).asList().contains(new Acl.UserAndRole(new Acl.Owner("80b9982b7b08045ee86680cc47f43c84bf439494a89ece22b5330f8a49477cf6"), new Acl.Role(Acl.Role.FULL))));
assertTrue(new S3AccessControlListFeature(session).getPermission(target).asList().contains(new Acl.UserAndRole(new Acl.GroupUser(Acl.GroupUser.EVERYONE), new Acl.Role(Acl.Role.READ))));
new DeleteWorker(new DisabledLoginCallback(), Collections.singletonList(target), PathCache.empty(), new DisabledProgressListener()).run(session);
session.close();
}
use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class MoveWorkerTest method testMoveVersionedDirectory.
@Test
public void testMoveVersionedDirectory() throws Exception {
final Path bucket = new Path("versioning-test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final Path sourceDirectory = new S3DirectoryFeature(session, new S3WriteFeature(session)).mkdir(new Path(bucket, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
final Path targetDirectory = new S3DirectoryFeature(session, new S3WriteFeature(session)).mkdir(new Path(bucket, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
final S3TouchFeature touch = new S3TouchFeature(session);
Path test = touch.touch(new Path(sourceDirectory, new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
assertTrue(new S3FindFeature(session).find(test));
final S3DefaultDeleteFeature delete = new S3DefaultDeleteFeature(session);
delete.delete(Collections.singletonList(new Path(test).withAttributes(PathAttributes.EMPTY)), new DisabledPasswordCallback(), new Delete.DisabledCallback());
assertTrue(new S3FindFeature(session).find(test));
test = touch.touch(test, new TransferStatus());
assertTrue(new S3FindFeature(session).find(test));
final S3VersionedObjectListService list = new S3VersionedObjectListService(session);
final AttributedList<Path> versioned = list.list(sourceDirectory, new DisabledListProgressListener());
final Map<Path, Path> files = new HashMap<>();
for (Path source : versioned) {
files.put(source, new Path(targetDirectory, source.getName(), source.getType(), source.attributes()));
}
final Map<Path, Path> result = new MoveWorker(files, new SessionPool.SingleSessionPool(session), PathCache.empty(), new DisabledProgressListener(), new DisabledLoginCallback()).run(session);
assertEquals(3, result.size());
for (Map.Entry<Path, Path> entry : result.entrySet()) {
assertFalse(new S3FindFeature(session).find(entry.getKey()));
assertTrue(new S3FindFeature(session).find(entry.getValue()));
}
new DeleteWorker(new DisabledLoginCallback(), Collections.singletonList(targetDirectory), PathCache.empty(), new DisabledProgressListener()).run(session);
session.close();
}
use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class SpectraBulkServiceTest method testPreUploadDirectoryFile.
@Test
public void testPreUploadDirectoryFile() 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 Path directory = new Path(String.format("/cyberduck/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.directory));
final TransferStatus directoryStatus = new TransferStatus().withLength(0L);
files.put(new TransferItem(directory), directoryStatus);
final TransferStatus fileStatus = new TransferStatus().withLength(1L);
files.put(new TransferItem(new Path(directory, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file))), fileStatus);
final SpectraBulkService bulk = new SpectraBulkService(session);
final Set<UUID> set = bulk.pre(Transfer.Type.upload, files, new DisabledConnectionCallback());
assertEquals(1, set.size());
assertEquals(1, bulk.query(Transfer.Type.upload, directory, directoryStatus).size());
assertEquals(1, bulk.query(Transfer.Type.upload, directory, fileStatus).size());
for (TransferItem item : files.keySet()) {
new SpectraDeleteFeature(session).delete(Collections.singletonList(item.remote), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
session.close();
}
use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class SpectraBulkServiceTest method testPreUploadMultipleLargeFile.
@Test
public void testPreUploadMultipleLargeFile() 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();
files.put(new TransferItem(new Path(String.format("/cyberduck/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.file))), // 11GB
status.withLength(118111600640L));
files.put(new TransferItem(new Path(String.format("/cyberduck/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.file))), // 11GB
status.withLength(118111600640L));
final SpectraBulkService bulk = new SpectraBulkService(session);
bulk.pre(Transfer.Type.upload, files, new DisabledConnectionCallback());
assertFalse(status.getParameters().isEmpty());
assertNotNull(status.getParameters().get("job"));
for (TransferItem file : files.keySet()) {
final List<TransferStatus> list = bulk.query(Transfer.Type.upload, file.remote, status);
assertFalse(list.isEmpty());
long offset = 0;
for (TransferStatus s : list) {
assertEquals(offset, s.getOffset());
offset += s.getLength();
assertTrue(s.getLength() > 0);
}
}
for (TransferItem item : files.keySet()) {
new SpectraDeleteFeature(session).delete(Collections.singletonList(item.remote), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
session.close();
}
Aggregations