Search in sources :

Example 1 with BandwidthThrottle

use of ch.cyberduck.core.io.BandwidthThrottle in project cyberduck by iterate-ch.

the class BrickDeleteFeatureTest method testDeleteWithLock.

@Test
public void testDeleteWithLock() throws Exception {
    final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Local local = new Local(System.getProperty("java.io.tmpdir"), test.getName());
    final byte[] random = RandomUtils.nextBytes(2547);
    IOUtils.write(random, local.getOutputStream(false));
    final TransferStatus status = new TransferStatus().withLength(random.length);
    new BrickUploadFeature(session, new BrickWriteFeature(session)).upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledLoginCallback());
    local.delete();
    final String lock = new BrickLockFeature(session).lock(test);
    new BrickDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) Local(ch.cyberduck.core.Local) DefaultHomeFinderService(ch.cyberduck.core.shared.DefaultHomeFinderService) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) 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 2 with BandwidthThrottle

use of ch.cyberduck.core.io.BandwidthThrottle in project cyberduck by iterate-ch.

the class BrickReadFeatureTest method testReadRange.

@Test
public void testReadRange() throws Exception {
    final Path room = new BrickDirectoryFeature(session).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));
    new BrickTouchFeature(session).touch(test, new TransferStatus());
    final Local local = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random());
    final byte[] content = RandomUtils.nextBytes(1023);
    final OutputStream out = local.getOutputStream(false);
    assertNotNull(out);
    IOUtils.write(content, out);
    out.close();
    final TransferStatus upload = new TransferStatus().withLength(content.length);
    upload.setExists(true);
    new BrickUploadFeature(session, new BrickWriteFeature(session)).upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), upload, new DisabledConnectionCallback());
    final TransferStatus status = new TransferStatus();
    status.setLength(content.length);
    status.setAppend(true);
    status.setOffset(100L);
    final InputStream in = new BrickReadFeature(session).read(test, status.withLength(content.length - 100), new DisabledConnectionCallback());
    assertNotNull(in);
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length - 100);
    new StreamCopier(status, status).transfer(in, buffer);
    final byte[] reference = new byte[content.length - 100];
    System.arraycopy(content, 100, reference, 0, content.length - 100);
    assertArrayEquals(reference, buffer.toByteArray());
    in.close();
    new BrickDeleteFeature(session).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) ByteArrayInputStream(java.io.ByteArrayInputStream) CountingInputStream(org.apache.commons.io.input.CountingInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) HttpResponseOutputStream(ch.cyberduck.core.http.HttpResponseOutputStream) OutputStream(java.io.OutputStream) Local(ch.cyberduck.core.Local) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 3 with BandwidthThrottle

use of ch.cyberduck.core.io.BandwidthThrottle in project cyberduck by iterate-ch.

the class BrickCopyFeatureTest method testCopyToExistingFile.

@Test
public void testCopyToExistingFile() throws Exception {
    final Path folder = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    new BrickDirectoryFeature(session).mkdir(folder, new TransferStatus());
    final Path test = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Local local = new Local(System.getProperty("java.io.tmpdir"), test.getName());
    final byte[] random = RandomUtils.nextBytes(2547);
    IOUtils.write(random, local.getOutputStream(false));
    final TransferStatus status = new TransferStatus().withLength(random.length);
    new BrickUploadFeature(session, new BrickWriteFeature(session)).upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledLoginCallback());
    local.delete();
    assertTrue(new BrickFindFeature(session).find(test));
    final Path copy = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    new BrickTouchFeature(session).touch(copy, new TransferStatus());
    new BrickCopyFeature(session).copy(test, copy, new TransferStatus().exists(true), new DisabledConnectionCallback(), new DisabledStreamListener());
    final Find find = new DefaultFindFeature(session);
    assertTrue(find.find(test));
    assertTrue(find.find(copy));
    new BrickDeleteFeature(session).delete(Arrays.asList(test, copy), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) Local(ch.cyberduck.core.Local) DefaultHomeFinderService(ch.cyberduck.core.shared.DefaultHomeFinderService) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Find(ch.cyberduck.core.features.Find) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 4 with BandwidthThrottle

use of ch.cyberduck.core.io.BandwidthThrottle in project cyberduck by iterate-ch.

the class BrickCopyFeatureTest method testCopyFile.

@Test
public void testCopyFile() throws Exception {
    final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Local local = new Local(System.getProperty("java.io.tmpdir"), test.getName());
    final byte[] random = RandomUtils.nextBytes(2547);
    IOUtils.write(random, local.getOutputStream(false));
    final TransferStatus status = new TransferStatus().withLength(random.length);
    new BrickUploadFeature(session, new BrickWriteFeature(session)).upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledLoginCallback());
    local.delete();
    assertTrue(new BrickFindFeature(session).find(test));
    final Path copy = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    new BrickCopyFeature(session).copy(test, copy, new TransferStatus(), new DisabledConnectionCallback(), new DisabledStreamListener());
    assertTrue(new BrickFindFeature(session).find(test));
    assertTrue(new BrickFindFeature(session).find(copy));
    new BrickDeleteFeature(session).delete(Collections.<Path>singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
    new BrickDeleteFeature(session).delete(Collections.<Path>singletonList(copy), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) Local(ch.cyberduck.core.Local) DefaultHomeFinderService(ch.cyberduck.core.shared.DefaultHomeFinderService) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 5 with BandwidthThrottle

use of ch.cyberduck.core.io.BandwidthThrottle in project cyberduck by iterate-ch.

the class SDSDirectS3UploadFeatureTest method testUploadZeroByteFile.

@Test
public void testUploadZeroByteFile() throws Exception {
    final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session);
    final SDSDirectS3UploadFeature feature = new SDSDirectS3UploadFeature(session, nodeid, new SDSDelegatingWriteFeature(session, nodeid, new SDSDirectS3WriteFeature(session, nodeid)));
    final Path room = new SDSDirectoryFeature(session, nodeid).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 local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    final byte[] random = RandomUtils.nextBytes(0);
    final OutputStream out = local.getOutputStream(false);
    IOUtils.write(random, out);
    out.close();
    final TransferStatus status = new TransferStatus();
    status.setLength(random.length);
    feature.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledLoginCallback());
    assertTrue(new SDSFindFeature(session, nodeid).find(test));
    final PathAttributes attributes = new SDSAttributesFinderFeature(session, nodeid).find(test);
    assertEquals(random.length, attributes.getSize());
    new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback());
    local.delete();
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) OutputStream(java.io.OutputStream) PathAttributes(ch.cyberduck.core.PathAttributes) Local(ch.cyberduck.core.Local) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) 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)

Aggregations

Path (ch.cyberduck.core.Path)102 BandwidthThrottle (ch.cyberduck.core.io.BandwidthThrottle)102 Test (org.junit.Test)102 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)100 IntegrationTest (ch.cyberduck.test.IntegrationTest)100 Local (ch.cyberduck.core.Local)99 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)95 Delete (ch.cyberduck.core.features.Delete)94 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)80 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)73 DisabledStreamListener (ch.cyberduck.core.io.DisabledStreamListener)63 InputStream (java.io.InputStream)56 OutputStream (java.io.OutputStream)49 BytecountStreamListener (ch.cyberduck.core.BytecountStreamListener)39 StreamCopier (ch.cyberduck.core.io.StreamCopier)39 ByteArrayOutputStream (java.io.ByteArrayOutputStream)38 PathAttributes (ch.cyberduck.core.PathAttributes)23 ByteArrayInputStream (java.io.ByteArrayInputStream)22 CountingInputStream (org.apache.commons.io.input.CountingInputStream)20 DefaultHomeFinderService (ch.cyberduck.core.shared.DefaultHomeFinderService)17