Search in sources :

Example 1 with DefaultFindFeature

use of ch.cyberduck.core.shared.DefaultFindFeature in project cyberduck by iterate-ch.

the class B2TouchFeatureTest method testTouchEncryptedDefaultFeature.

@Test
public void testTouchEncryptedDefaultFeature() throws Exception {
    final Path home = new Path("/test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final CryptoVault cryptomator = new CryptoVault(new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)));
    final Path vault = cryptomator.create(session, new VaultCredentials("test"), new DisabledPasswordStore(), vaultVersion);
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final B2VersionIdProvider fileid = new B2VersionIdProvider(session);
    final Path test = new CryptoTouchFeature<>(session, new DefaultTouchFeature<>(new B2WriteFeature(session, fileid)), new B2WriteFeature(session, fileid), cryptomator).touch(new Path(vault, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)), new TransferStatus());
    assertNotNull(test.attributes().getVersionId());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
    cryptomator.getFeature(session, Delete.class, new B2DeleteFeature(session, fileid)).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) B2VersionIdProvider(ch.cyberduck.core.b2.B2VersionIdProvider) B2WriteFeature(ch.cyberduck.core.b2.B2WriteFeature) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) DefaultTouchFeature(ch.cyberduck.core.shared.DefaultTouchFeature) B2DeleteFeature(ch.cyberduck.core.b2.B2DeleteFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) AbstractB2Test(ch.cyberduck.core.b2.AbstractB2Test) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 2 with DefaultFindFeature

use of ch.cyberduck.core.shared.DefaultFindFeature in project cyberduck by iterate-ch.

the class BufferWriteFeatureTest method testWriteZeroLength.

@Test
public void testWriteZeroLength() throws Exception {
    final BoxFileidProvider fileid = new BoxFileidProvider(session);
    final BufferWriteFeature feature = new BufferWriteFeature(session);
    final byte[] content = RandomUtils.nextBytes(0);
    final TransferStatus status = new TransferStatus();
    status.setLength(-1L);
    final Path file = new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final StatusOutputStream<Void> out = feature.write(file, status, new DisabledConnectionCallback());
    final ByteArrayInputStream in = new ByteArrayInputStream(content);
    new StreamCopier(status, status).transfer(in, out);
    assertNull(out.getStatus());
    assertTrue(new DefaultFindFeature(session).find(file));
    final byte[] compare = new byte[content.length];
    final InputStream stream = new BoxReadFeature(session, fileid).read(file, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new BoxDeleteFeature(session, fileid).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) BufferWriteFeature(ch.cyberduck.core.shared.BufferWriteFeature) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 3 with DefaultFindFeature

use of ch.cyberduck.core.shared.DefaultFindFeature in project cyberduck by iterate-ch.

the class BufferWriteFeatureTest method testWrite.

@Test
public void testWrite() throws Exception {
    final BoxFileidProvider fileid = new BoxFileidProvider(session);
    final BufferWriteFeature feature = new BufferWriteFeature(session);
    final byte[] content = RandomUtils.nextBytes(5 * 1024);
    final TransferStatus status = new TransferStatus();
    status.setLength(content.length);
    final Path file = new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final StatusOutputStream<Void> out = feature.write(file, status, new DisabledConnectionCallback());
    final ByteArrayInputStream in = new ByteArrayInputStream(content);
    final BytecountStreamListener count = new BytecountStreamListener();
    new StreamCopier(status, status).withListener(count).transfer(in, out);
    assertEquals(content.length, count.getSent());
    assertEquals(content.length, status.getLength());
    assertNull(out.getStatus());
    assertTrue(new DefaultFindFeature(session).find(file));
    final byte[] compare = new byte[content.length];
    final InputStream stream = new BoxReadFeature(session, fileid).read(file, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new BoxDeleteFeature(session, fileid).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) BytecountStreamListener(ch.cyberduck.core.BytecountStreamListener) ByteArrayInputStream(java.io.ByteArrayInputStream) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) BufferWriteFeature(ch.cyberduck.core.shared.BufferWriteFeature) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 4 with DefaultFindFeature

use of ch.cyberduck.core.shared.DefaultFindFeature in project cyberduck by iterate-ch.

the class BoxMultipartWriteFeatureTest method testWriteMultiplePartsExisting.

@Test
public void testWriteMultiplePartsExisting() throws Exception {
    final BoxFileidProvider fileid = new BoxFileidProvider(session);
    final BoxMultipartWriteFeature feature = new BoxMultipartWriteFeature(session, fileid);
    // Makes sure to test overwrite
    final Path file = new BoxTouchFeature(session, fileid).touch(new Path(Home.ROOT, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
    final byte[] content = RandomUtils.nextBytes(21 * 1024 * 1024);
    final TransferStatus status = new TransferStatus().withRemote(file.attributes()).exists(true).withChecksum(feature.checksum(file, new TransferStatus()).compute(new ByteArrayInputStream(content), new TransferStatus())).withLength(content.length);
    final HttpResponseOutputStream<File> out = feature.write(file, status, new DisabledConnectionCallback());
    final ByteArrayInputStream in = new ByteArrayInputStream(content);
    final TransferStatus progress = new TransferStatus();
    final BytecountStreamListener count = new BytecountStreamListener();
    new StreamCopier(new TransferStatus(), progress).withListener(count).transfer(in, out);
    assertEquals(content.length, count.getSent());
    in.close();
    out.close();
    assertNotNull(out.getStatus());
    assertTrue(new DefaultFindFeature(session).find(file));
    assertTrue(new BoxFindFeature(session, fileid).find(file));
    final PathAttributes attributes = new BoxAttributesFinderFeature(session, fileid).find(file);
    assertEquals(content.length, attributes.getSize());
    final byte[] compare = new byte[content.length];
    final InputStream stream = new BoxReadFeature(session, fileid).read(file, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new BoxDeleteFeature(session, fileid).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) PathAttributes(ch.cyberduck.core.PathAttributes) BytecountStreamListener(ch.cyberduck.core.BytecountStreamListener) ByteArrayInputStream(java.io.ByteArrayInputStream) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) File(ch.cyberduck.core.box.io.swagger.client.model.File) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 5 with DefaultFindFeature

use of ch.cyberduck.core.shared.DefaultFindFeature in project cyberduck by iterate-ch.

the class BoxMultipartWriteFeatureTest method testWriteMultipleParts.

@Test
public void testWriteMultipleParts() throws Exception {
    final BoxFileidProvider fileid = new BoxFileidProvider(session);
    final BoxMultipartWriteFeature feature = new BoxMultipartWriteFeature(session, fileid);
    // Makes sure to test overwrite
    final Path file = new Path(Home.ROOT, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final byte[] content = RandomUtils.nextBytes(21 * 1024 * 1024);
    final TransferStatus status = new TransferStatus().withRemote(file.attributes()).exists(false).withChecksum(feature.checksum(file, new TransferStatus()).compute(new ByteArrayInputStream(content), new TransferStatus())).withLength(content.length);
    final HttpResponseOutputStream<File> out = feature.write(file, status, new DisabledConnectionCallback());
    final ByteArrayInputStream in = new ByteArrayInputStream(content);
    final TransferStatus progress = new TransferStatus();
    final BytecountStreamListener count = new BytecountStreamListener();
    new StreamCopier(new TransferStatus(), progress).withListener(count).transfer(in, out);
    assertEquals(content.length, count.getSent());
    in.close();
    out.close();
    assertNotNull(out.getStatus());
    assertTrue(new DefaultFindFeature(session).find(file));
    assertTrue(new BoxFindFeature(session, fileid).find(file));
    final PathAttributes attributes = new BoxAttributesFinderFeature(session, fileid).find(file);
    assertEquals(content.length, attributes.getSize());
    final byte[] compare = new byte[content.length];
    final InputStream stream = new BoxReadFeature(session, fileid).read(file, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new BoxDeleteFeature(session, fileid).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) PathAttributes(ch.cyberduck.core.PathAttributes) BytecountStreamListener(ch.cyberduck.core.BytecountStreamListener) ByteArrayInputStream(java.io.ByteArrayInputStream) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) File(ch.cyberduck.core.box.io.swagger.client.model.File) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

DefaultFindFeature (ch.cyberduck.core.shared.DefaultFindFeature)218 Test (org.junit.Test)213 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)212 IntegrationTest (ch.cyberduck.test.IntegrationTest)210 Path (ch.cyberduck.core.Path)206 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)201 Delete (ch.cyberduck.core.features.Delete)201 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)186 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)123 VaultCredentials (ch.cyberduck.core.vault.VaultCredentials)77 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)76 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)72 CryptoFindFeature (ch.cyberduck.core.cryptomator.features.CryptoFindFeature)72 DefaultVaultRegistry (ch.cyberduck.core.vault.DefaultVaultRegistry)72 ByteArrayInputStream (java.io.ByteArrayInputStream)62 StreamCopier (ch.cyberduck.core.io.StreamCopier)51 Directory (ch.cyberduck.core.features.Directory)45 InputStream (java.io.InputStream)43 DefaultHomeFinderService (ch.cyberduck.core.shared.DefaultHomeFinderService)36 PathAttributes (ch.cyberduck.core.PathAttributes)28