Search in sources :

Example 1 with GraphTouchFeature

use of ch.cyberduck.core.onedrive.features.GraphTouchFeature 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 GraphTouchFeature

use of ch.cyberduck.core.onedrive.features.GraphTouchFeature 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 GraphTouchFeature

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

the class GraphAttributesFinderFeatureTest method testFindFile.

@Test
public void testFindFile() throws Exception {
    final Path file = new Path(new OneDriveHomeFinderService().find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    new GraphTouchFeature(session, fileid).touch(file, new TransferStatus().withMime("x-application/cyberduck"));
    final PathAttributes attributes = new GraphAttributesFinderFeature(session, fileid).find(file);
    assertNotNull(attributes);
    assertNotEquals(-1L, attributes.getSize());
    assertNotEquals(-1L, attributes.getCreationDate());
    assertNotEquals(-1L, attributes.getModificationDate());
    assertNotNull(attributes.getETag());
    assertNull(attributes.getVersionId());
    assertNotNull(attributes.getLink());
    assertNotNull(attributes.getFileId());
    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) GraphAttributesFinderFeature(ch.cyberduck.core.onedrive.features.GraphAttributesFinderFeature) PathAttributes(ch.cyberduck.core.PathAttributes) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) GraphDeleteFeature(ch.cyberduck.core.onedrive.features.GraphDeleteFeature) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) GraphTouchFeature(ch.cyberduck.core.onedrive.features.GraphTouchFeature) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 4 with GraphTouchFeature

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

the class GraphAttributesFinderFeatureTest method testChangedFileId.

@Test
public void testChangedFileId() throws Exception {
    final GraphFileIdProvider fileid = new GraphFileIdProvider(session);
    final Path drive = new OneDriveHomeFinderService().find();
    final Path test = new GraphTouchFeature(session, fileid).touch(new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
    final String previousnodeid = test.attributes().getFileId();
    new GraphDeleteFeature(session, fileid).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
    final String latestnodeid = new GraphTouchFeature(session, fileid).touch(new Path(drive, test.getName(), EnumSet.of(Path.Type.file)), new TransferStatus()).attributes().getFileId();
    assertNotNull(latestnodeid);
    // Assume previously seen but changed on server
    fileid.cache(test, previousnodeid);
    final GraphAttributesFinderFeature f = new GraphAttributesFinderFeature(session, fileid);
    assertEquals(latestnodeid, f.find(test).getFileId());
    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) GraphFileIdProvider(ch.cyberduck.core.onedrive.features.GraphFileIdProvider) GraphAttributesFinderFeature(ch.cyberduck.core.onedrive.features.GraphAttributesFinderFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) GraphDeleteFeature(ch.cyberduck.core.onedrive.features.GraphDeleteFeature) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) GraphTouchFeature(ch.cyberduck.core.onedrive.features.GraphTouchFeature) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 5 with GraphTouchFeature

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

the class GraphCopyFeatureTest method testCopyToExistingFile.

@Test
public void testCopyToExistingFile() throws Exception {
    final Path folder = new GraphDirectoryFeature(session, fileid).mkdir(new Path(new OneDriveHomeFinderService().find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
    final Path test = new GraphTouchFeature(session, fileid).touch(new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
    final Path copy = new GraphTouchFeature(session, fileid).touch(new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
    new GraphCopyFeature(session, fileid).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 GraphDeleteFeature(session, fileid).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) GraphTouchFeature(ch.cyberduck.core.onedrive.features.GraphTouchFeature) GraphCopyFeature(ch.cyberduck.core.onedrive.features.GraphCopyFeature) GraphDirectoryFeature(ch.cyberduck.core.onedrive.features.GraphDirectoryFeature) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Find(ch.cyberduck.core.features.Find) 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

AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)22 Path (ch.cyberduck.core.Path)22 GraphTouchFeature (ch.cyberduck.core.onedrive.features.GraphTouchFeature)22 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)22 IntegrationTest (ch.cyberduck.test.IntegrationTest)22 Test (org.junit.Test)22 Delete (ch.cyberduck.core.features.Delete)21 GraphDeleteFeature (ch.cyberduck.core.onedrive.features.GraphDeleteFeature)21 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)20 GraphAttributesFinderFeature (ch.cyberduck.core.onedrive.features.GraphAttributesFinderFeature)13 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)12 GraphDirectoryFeature (ch.cyberduck.core.onedrive.features.GraphDirectoryFeature)7 GraphMoveFeature (ch.cyberduck.core.onedrive.features.GraphMoveFeature)5 GraphReadFeature (ch.cyberduck.core.onedrive.features.GraphReadFeature)5 InputStream (java.io.InputStream)5 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)4 AttributesFinder (ch.cyberduck.core.features.AttributesFinder)4 Move (ch.cyberduck.core.features.Move)4 Touch (ch.cyberduck.core.features.Touch)4 DisabledStreamListener (ch.cyberduck.core.io.DisabledStreamListener)4