use of ch.cyberduck.core.AsciiRandomStringService in project cyberduck by iterate-ch.
the class DropboxWriteFeatureTest method testWriteMSOfficeLock.
@Test(expected = AccessDeniedException.class)
public void testWriteMSOfficeLock() throws Exception {
final DropboxWriteFeature write = new DropboxWriteFeature(session);
final TransferStatus status = new TransferStatus();
final byte[] content = RandomUtils.nextBytes(0);
status.setLength(content.length);
final Path test = new Path(new DefaultHomeFinderService(session).find(), "~$" + new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file));
final OutputStream out = write.write(test, status, new DisabledConnectionCallback());
new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), out);
}
use of ch.cyberduck.core.AsciiRandomStringService in project cyberduck by iterate-ch.
the class AzureDeleteFeatureTest method testDeleteNotFoundBucket.
@Test(expected = NotfoundException.class)
public void testDeleteNotFoundBucket() throws Exception {
final Path container = new Path(new AsciiRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume));
new AzureDeleteFeature(session, null).delete(Collections.singletonList(container), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
use of ch.cyberduck.core.AsciiRandomStringService in project cyberduck by iterate-ch.
the class AzureDeleteFeatureTest method testDeleteKey.
@Test
public void testDeleteKey() throws Exception {
final Path container = new Path(new AsciiRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume));
new AzureDirectoryFeature(session, null).mkdir(container, new TransferStatus());
final Path test = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
new AzureTouchFeature(session, null).touch(test, new TransferStatus());
assertTrue(new AzureFindFeature(session, null).find(test));
new AzureDeleteFeature(session, null).delete(Arrays.asList(container, test), new DisabledLoginCallback(), new Delete.DisabledCallback());
assertFalse(new AzureFindFeature(session, null).find(test));
}
use of ch.cyberduck.core.AsciiRandomStringService in project cyberduck by iterate-ch.
the class B2ObjectListServiceTest method testListLexicographicSortOrderAssumption.
@Test
public void testListLexicographicSortOrderAssumption() throws Exception {
final B2VersionIdProvider fileid = new B2VersionIdProvider(session);
final Path directory = new B2DirectoryFeature(session, fileid).mkdir(new Path(String.format("test-%s", new AsciiRandomStringService().random()), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
assertTrue(new B2ObjectListService(session, fileid).list(directory, new DisabledListProgressListener()).isEmpty());
final List<String> files = Arrays.asList("aa", "0a", "a", "AAA", "B", "~$a", ".c");
for (String f : files) {
new B2TouchFeature(session, fileid).touch(new Path(directory, f, EnumSet.of(Path.Type.file)), new TransferStatus());
}
files.sort(session.getHost().getProtocol().getListComparator());
final AttributedList<Path> list = new B2ObjectListService(session, fileid).list(directory, new DisabledListProgressListener());
for (int i = 0; i < list.size(); i++) {
assertEquals(files.get(i), list.get(i).getName());
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(list.get(i)), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(directory), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
use of ch.cyberduck.core.AsciiRandomStringService in project cyberduck by iterate-ch.
the class B2ObjectListServiceTest method testList.
@Test
public void testList() throws Exception {
final B2VersionIdProvider fileid = new B2VersionIdProvider(session);
final Path bucket = new B2DirectoryFeature(session, fileid).mkdir(new Path(String.format("test-%s", new AsciiRandomStringService().random()), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
final Path file = new Path(bucket, new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file));
final TransferStatus status = new TransferStatus();
status.setChecksum(Checksum.parse("da39a3ee5e6b4b0d3255bfef95601890afd80709"));
final HttpResponseOutputStream<BaseB2Response> out = new B2WriteFeature(session, fileid).write(file, status, new DisabledConnectionCallback());
IOUtils.write(new byte[0], out);
out.close();
final B2FileResponse resopnse = (B2FileResponse) out.getStatus();
final AttributedList<Path> list = new B2ObjectListService(session, fileid).list(bucket, new DisabledListProgressListener());
assertNotNull(list.find(new SimplePathPredicate(file)));
assertEquals(Long.valueOf(1L), list.find(new SimplePathPredicate(file)).attributes().getRevision());
assertEquals(0L, list.find(new SimplePathPredicate(file)).attributes().getSize());
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
assertFalse(new B2ObjectListService(session, fileid).list(bucket, new DisabledListProgressListener()).contains(file));
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(bucket), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Aggregations