Search in sources :

Example 1 with GraphDeleteFeature

use of ch.cyberduck.core.onedrive.features.GraphDeleteFeature in project cyberduck by iterate-ch.

the class GraphReadFeatureTest method testReadInterrupt.

@Test
public void testReadInterrupt() throws Exception {
    final Path drive = new OneDriveHomeFinderService().find();
    final Path test = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    new GraphTouchFeature(session, fileid).touch(test, new TransferStatus());
    // Unknown length in status
    final TransferStatus status = new TransferStatus();
    // Read a single byte
    {
        final InputStream in = new GraphReadFeature(session, fileid).read(test, status, new DisabledConnectionCallback());
        assertNotNull(in.read());
        in.close();
    }
    {
        final InputStream in = new GraphReadFeature(session, fileid).read(test, status, new DisabledConnectionCallback());
        assertNotNull(in);
        in.close();
    }
    new GraphDeleteFeature(session, fileid).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) InputStream(java.io.InputStream) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) GraphReadFeature(ch.cyberduck.core.onedrive.features.GraphReadFeature) GraphDeleteFeature(ch.cyberduck.core.onedrive.features.GraphDeleteFeature) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) GraphTouchFeature(ch.cyberduck.core.onedrive.features.GraphTouchFeature) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 2 with GraphDeleteFeature

use of ch.cyberduck.core.onedrive.features.GraphDeleteFeature in project cyberduck by iterate-ch.

the class GraphReadFeatureTest method testReadRange.

@Test
public void testReadRange() throws Exception {
    final Path drive = new OneDriveHomeFinderService().find();
    final Path test = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    new GraphTouchFeature(session, fileid).touch(test, new TransferStatus());
    final Local local = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random());
    final byte[] content = RandomUtils.nextBytes(1000);
    final OutputStream out = local.getOutputStream(false);
    assertNotNull(out);
    IOUtils.write(content, out);
    out.close();
    new DefaultUploadFeature<>(new GraphWriteFeature(session, fileid)).upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
    final TransferStatus status = new TransferStatus();
    status.setLength(content.length);
    status.setAppend(true);
    status.setOffset(100L);
    final GraphReadFeature read = new GraphReadFeature(session, fileid);
    assertTrue(read.offset(test));
    final InputStream in = read.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 GraphDeleteFeature(session, fileid).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) GraphWriteFeature(ch.cyberduck.core.onedrive.features.GraphWriteFeature) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) Local(ch.cyberduck.core.Local) ByteArrayOutputStream(java.io.ByteArrayOutputStream) GraphTouchFeature(ch.cyberduck.core.onedrive.features.GraphTouchFeature) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) GraphReadFeature(ch.cyberduck.core.onedrive.features.GraphReadFeature) GraphDeleteFeature(ch.cyberduck.core.onedrive.features.GraphDeleteFeature) 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 GraphDeleteFeature

use of ch.cyberduck.core.onedrive.features.GraphDeleteFeature in project cyberduck by iterate-ch.

the class GraphWriteFeatureTest method testWriteSingleByte.

@Test
public void testWriteSingleByte() throws Exception {
    final GraphWriteFeature feature = new GraphWriteFeature(session, fileid);
    final Path container = new OneDriveHomeFinderService().find();
    final byte[] content = RandomUtils.nextBytes(1);
    final TransferStatus status = new TransferStatus();
    status.setLength(content.length);
    final Path file = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final StatusOutputStream<Void> out = feature.write(file, status, new DisabledConnectionCallback());
    final ByteArrayInputStream in = new ByteArrayInputStream(content);
    assertEquals(content.length, IOUtils.copyLarge(in, out));
    in.close();
    out.close();
    assertNull(out.getStatus());
    assertTrue(new DefaultFindFeature(session).find(file));
    final byte[] compare = new byte[content.length];
    final InputStream stream = new GraphReadFeature(session, fileid).read(file, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new GraphDeleteFeature(session, fileid).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) GraphWriteFeature(ch.cyberduck.core.onedrive.features.GraphWriteFeature) 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) GraphReadFeature(ch.cyberduck.core.onedrive.features.GraphReadFeature) GraphDeleteFeature(ch.cyberduck.core.onedrive.features.GraphDeleteFeature) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 4 with GraphDeleteFeature

use of ch.cyberduck.core.onedrive.features.GraphDeleteFeature in project cyberduck by iterate-ch.

the class GraphWriteFeatureTest method testWriteUmlautZeroLength.

@Test
public void testWriteUmlautZeroLength() throws Exception {
    final GraphWriteFeature feature = new GraphWriteFeature(session, fileid);
    final Path container = new OneDriveHomeFinderService().find();
    final byte[] content = RandomUtils.nextBytes(0);
    final TransferStatus status = new TransferStatus();
    status.setLength(content.length);
    final Path file = new Path(container, String.format("%sä", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.file));
    final StatusOutputStream<Void> out = feature.write(file, status, new DisabledConnectionCallback());
    final ByteArrayInputStream in = new ByteArrayInputStream(content);
    assertEquals(content.length, IOUtils.copyLarge(in, out));
    in.close();
    out.close();
    assertNull(out.getStatus());
    assertTrue(new DefaultFindFeature(session).find(file));
    final byte[] compare = new byte[content.length];
    final InputStream stream = new GraphReadFeature(session, fileid).read(file, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new GraphDeleteFeature(session, fileid).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) GraphWriteFeature(ch.cyberduck.core.onedrive.features.GraphWriteFeature) 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) GraphReadFeature(ch.cyberduck.core.onedrive.features.GraphReadFeature) GraphDeleteFeature(ch.cyberduck.core.onedrive.features.GraphDeleteFeature) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 5 with GraphDeleteFeature

use of ch.cyberduck.core.onedrive.features.GraphDeleteFeature in project cyberduck by iterate-ch.

the class GraphWriteFeatureTest method testWriteZeroLength.

@Test
public void testWriteZeroLength() throws Exception {
    final GraphWriteFeature feature = new GraphWriteFeature(session, fileid);
    final Path container = new OneDriveHomeFinderService().find();
    final byte[] content = RandomUtils.nextBytes(0);
    final TransferStatus status = new TransferStatus();
    status.setLength(content.length);
    final Path file = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final StatusOutputStream<Void> out = feature.write(file, status, new DisabledConnectionCallback());
    final ByteArrayInputStream in = new ByteArrayInputStream(content);
    assertEquals(content.length, IOUtils.copyLarge(in, out));
    in.close();
    out.close();
    assertNull(out.getStatus());
    assertTrue(new DefaultFindFeature(session).find(file));
    final byte[] compare = new byte[content.length];
    final InputStream stream = new GraphReadFeature(session, fileid).read(file, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new GraphDeleteFeature(session, fileid).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) GraphWriteFeature(ch.cyberduck.core.onedrive.features.GraphWriteFeature) 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) GraphReadFeature(ch.cyberduck.core.onedrive.features.GraphReadFeature) GraphDeleteFeature(ch.cyberduck.core.onedrive.features.GraphDeleteFeature) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

Path (ch.cyberduck.core.Path)43 Delete (ch.cyberduck.core.features.Delete)43 GraphDeleteFeature (ch.cyberduck.core.onedrive.features.GraphDeleteFeature)43 IntegrationTest (ch.cyberduck.test.IntegrationTest)43 Test (org.junit.Test)43 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)42 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)41 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)40 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)22 GraphAttributesFinderFeature (ch.cyberduck.core.onedrive.features.GraphAttributesFinderFeature)22 GraphTouchFeature (ch.cyberduck.core.onedrive.features.GraphTouchFeature)21 GraphDirectoryFeature (ch.cyberduck.core.onedrive.features.GraphDirectoryFeature)16 DefaultFindFeature (ch.cyberduck.core.shared.DefaultFindFeature)15 GraphReadFeature (ch.cyberduck.core.onedrive.features.GraphReadFeature)14 InputStream (java.io.InputStream)14 GraphWriteFeature (ch.cyberduck.core.onedrive.features.GraphWriteFeature)12 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)11 ByteArrayInputStream (java.io.ByteArrayInputStream)10 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)9 PathAttributes (ch.cyberduck.core.PathAttributes)9