Search in sources :

Example 61 with AsciiRandomStringService

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);
}
Also used : Path(ch.cyberduck.core.Path) AsciiRandomStringService(ch.cyberduck.core.AsciiRandomStringService) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) DefaultHomeFinderService(ch.cyberduck.core.shared.DefaultHomeFinderService) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) AbstractDropboxTest(ch.cyberduck.core.AbstractDropboxTest) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 62 with AsciiRandomStringService

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());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) AsciiRandomStringService(ch.cyberduck.core.AsciiRandomStringService) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 63 with AsciiRandomStringService

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));
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) AsciiRandomStringService(ch.cyberduck.core.AsciiRandomStringService) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 64 with AsciiRandomStringService

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());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) AsciiRandomStringService(ch.cyberduck.core.AsciiRandomStringService) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 65 with AsciiRandomStringService

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());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) AsciiRandomStringService(ch.cyberduck.core.AsciiRandomStringService) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) SimplePathPredicate(ch.cyberduck.core.SimplePathPredicate) BaseB2Response(synapticloop.b2.response.BaseB2Response) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) B2FileResponse(synapticloop.b2.response.B2FileResponse) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

AsciiRandomStringService (ch.cyberduck.core.AsciiRandomStringService)66 Path (ch.cyberduck.core.Path)64 Test (org.junit.Test)64 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)61 IntegrationTest (ch.cyberduck.test.IntegrationTest)56 Delete (ch.cyberduck.core.features.Delete)52 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)51 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)22 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)18 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)12 Host (ch.cyberduck.core.Host)8 ByteArrayInputStream (java.io.ByteArrayInputStream)8 StreamCopier (ch.cyberduck.core.io.StreamCopier)7 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)6 NullLocal (ch.cyberduck.core.NullLocal)5 NullTransferSession (ch.cyberduck.core.NullTransferSession)5 SimplePathPredicate (ch.cyberduck.core.SimplePathPredicate)5 TestProtocol (ch.cyberduck.core.TestProtocol)5 DisabledStreamListener (ch.cyberduck.core.io.DisabledStreamListener)5 DefaultHomeFinderService (ch.cyberduck.core.shared.DefaultHomeFinderService)5