use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class DefaultComparePathFilterTest method testCompareEqualResultDirectory.
@Test
public void testCompareEqualResultDirectory() throws Exception {
final AtomicBoolean found = new AtomicBoolean();
final Find find = new Find() {
@Override
public boolean find(final Path file, final ListProgressListener listener) {
found.set(true);
return true;
}
};
ComparePathFilter s = new DefaultComparePathFilter(new NullSession(new Host(new TestProtocol())) {
}, TimeZone.getDefault()).withFinder(find);
assertEquals(Comparison.equal, s.compare(new Path("t", EnumSet.of(Path.Type.directory)), new NullLocal("t") {
@Override
public boolean exists() {
return true;
}
}, new DisabledProgressListener()));
assertTrue(found.get());
}
use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class DefaultComparePathFilterTest method testCompareLocalResult.
@Test
public void testCompareLocalResult() throws Exception {
final AtomicBoolean found = new AtomicBoolean();
final AtomicBoolean attr = new AtomicBoolean();
final Find find = new Find() {
@Override
public boolean find(final Path file, final ListProgressListener listener) {
found.set(true);
return true;
}
};
final AttributesFinder attributes = new AttributesFinder() {
@Override
public PathAttributes find(final Path file, final ListProgressListener listener) {
attr.set(true);
return new PathAttributes() {
@Override
public Checksum getChecksum() {
return new Checksum(HashAlgorithm.md5, "b");
}
@Override
public long getSize() {
return 2L;
}
@Override
public long getModificationDate() {
final Calendar c = Calendar.getInstance(TimeZone.getDefault());
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTimeInMillis();
}
};
}
};
ComparePathFilter s = new DefaultComparePathFilter(new NullSession(new Host(new TestProtocol())) {
}, TimeZone.getDefault()).withFinder(find).withAttributes(attributes);
assertEquals(Comparison.local, s.compare(new Path("t", EnumSet.of(Path.Type.file)), new NullLocal("t") {
@Override
public LocalAttributes attributes() {
return new LocalAttributes("t") {
@Override
public Checksum getChecksum() {
return new Checksum(HashAlgorithm.md5, "a");
}
@Override
public long getSize() {
return 1L;
}
@Override
public long getModificationDate() {
return Calendar.getInstance(TimeZone.getDefault()).getTimeInMillis();
}
};
}
@Override
public boolean exists() {
return true;
}
}, new DisabledProgressListener()));
assertTrue(found.get());
assertTrue(attr.get());
}
use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class SDSSingleTransferWorkerTest method testDownloadVersioned.
@Test
public void testDownloadVersioned() throws Exception {
final SDSNodeIdProvider fileid = new SDSNodeIdProvider(session);
final Path room = new SDSDirectoryFeature(session, fileid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
final Path test = new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
final Local localFile = new DefaultTemporaryFileService().create(test.getName());
{
final byte[] content = RandomUtils.nextBytes(39864);
final TransferStatus writeStatus = new TransferStatus().withLength(content.length).withChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(content), new TransferStatus()));
final StatusOutputStream<Node> out = new SDSMultipartWriteFeature(session, fileid).write(test, writeStatus, new DisabledConnectionCallback());
assertNotNull(out);
new StreamCopier(writeStatus, writeStatus).withLimit((long) content.length).transfer(new ByteArrayInputStream(content), out);
out.close();
}
final byte[] content = RandomUtils.nextBytes(39864);
final TransferStatus writeStatus = new TransferStatus().exists(true).withLength(content.length).withChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(content), new TransferStatus()));
final StatusOutputStream<Node> out = new SDSMultipartWriteFeature(session, fileid).write(test, writeStatus, new DisabledConnectionCallback());
assertNotNull(out);
new StreamCopier(writeStatus, writeStatus).withLimit((long) content.length).transfer(new ByteArrayInputStream(content), out);
out.close();
final String versionId = test.attributes().getVersionId();
assertEquals(versionId, new SDSAttributesFinderFeature(session, fileid).find(test).getVersionId());
assertEquals(versionId, new DefaultAttributesFinderFeature(session).find(test).getVersionId());
final Transfer t = new DownloadTransfer(new Host(new TestProtocol()), Collections.singletonList(new TransferItem(test, localFile)), 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));
byte[] compare = new byte[content.length];
assertArrayEquals(content, IOUtils.toByteArray(localFile.getInputStream()));
test.attributes().setVersionId(versionId);
assertEquals(versionId, new DefaultAttributesFinderFeature(session).find(test).getVersionId());
new SDSDeleteFeature(session, fileid).delete(Arrays.asList(test, room), new DisabledLoginCallback(), new Delete.DisabledCallback());
localFile.delete();
session.close();
}
use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.
the class CryptoDropboxSingleTransferWorkerTest method testUpload.
@Test
public void testUpload() throws Exception {
final Path home = new DefaultHomeFinderService(session).find();
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 DropboxFindFeature(session), cryptomator).find(dir1));
assertEquals(content.length, new CryptoAttributesFeature(session, new DefaultAttributesFinderFeature(session), cryptomator).find(file1).getSize());
{
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
final InputStream in = new CryptoReadFeature(session, new DropboxReadFeature(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 DefaultAttributesFinderFeature(session), cryptomator).find(file2).getSize());
{
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
final InputStream in = new CryptoReadFeature(session, new DropboxReadFeature(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 DropboxDeleteFeature(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 SDSSingleTransferWorkerTest method testTransferExistingFolder.
@Test
public void testTransferExistingFolder() throws Exception {
final SDSNodeIdProvider fileid = new SDSNodeIdProvider(session);
final Local folder = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
new DefaultLocalDirectoryFeature().mkdir(folder);
final Path room = new SDSDirectoryFeature(session, fileid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
final Transfer t = new UploadTransfer(session.getHost(), room, folder);
final BytecountStreamListener counter = new BytecountStreamListener();
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));
assertTrue(t.isComplete());
assertTrue(new SDSFindFeature(session, fileid).find(room));
new SDSDeleteFeature(session, fileid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Aggregations