Search in sources :

Example 11 with GraphTouchFeature

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

the class GraphReadFeatureTest method testReadRangeUnknownLength.

@Test
public void testReadRangeUnknownLength() 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(-1L);
    status.setAppend(true);
    status.setOffset(100L);
    final InputStream in = new GraphReadFeature(session, fileid).read(test, status, 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 12 with GraphTouchFeature

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

the class GraphTimestampFeatureTest method testSetTimestamp.

@Test
public void testSetTimestamp() throws Exception {
    final Path drive = new OneDriveHomeFinderService().find();
    final Path file = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    new GraphTouchFeature(session, fileid).touch(file, new TransferStatus().withMime("x-application/cyberduck"));
    assertNotNull(new GraphAttributesFinderFeature(session, fileid).find(file));
    final long modified = Instant.now().minusSeconds(5 * 24 * 60 * 60).getEpochSecond() * 1000;
    new GraphTimestampFeature(session, fileid).setTimestamp(file, modified);
    assertEquals(modified, new GraphAttributesFinderFeature(session, fileid).find(file).getModificationDate());
    assertEquals(modified, new DefaultAttributesFinderFeature(session).find(file).getModificationDate());
    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) GraphTouchFeature(ch.cyberduck.core.onedrive.features.GraphTouchFeature) GraphTimestampFeature(ch.cyberduck.core.onedrive.features.GraphTimestampFeature) DefaultAttributesFinderFeature(ch.cyberduck.core.shared.DefaultAttributesFinderFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) GraphDeleteFeature(ch.cyberduck.core.onedrive.features.GraphDeleteFeature) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 13 with GraphTouchFeature

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

the class GraphTouchFeatureTest method testTouchUmlaut.

@Test
public void testTouchUmlaut() throws Exception {
    final Path file = new Path(new OneDriveHomeFinderService().find(), String.format("%sä", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.file));
    new GraphTouchFeature(session, fileid).touch(file, new TransferStatus());
    assertNotNull(new GraphAttributesFinderFeature(session, fileid).find(file));
    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) 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 14 with GraphTouchFeature

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

the class GraphTouchFeatureTest method testWhitespaceTouch.

@Test
public void testWhitespaceTouch() throws Exception {
    final RandomStringService randomStringService = new AlphanumericRandomStringService();
    final Path file = new Path(new OneDriveHomeFinderService().find(), String.format("%s %s", randomStringService.random(), randomStringService.random()), EnumSet.of(Path.Type.file));
    new GraphTouchFeature(session, fileid).touch(file, new TransferStatus().withMime("x-application/cyberduck"));
    assertNotNull(new GraphAttributesFinderFeature(session, fileid).find(file));
    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) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) RandomStringService(ch.cyberduck.core.RandomStringService) 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 15 with GraphTouchFeature

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

the class GraphTouchFeatureTest method testTouchEqualSign.

@Test
public void testTouchEqualSign() throws Exception {
    final Path file = new Path(new OneDriveHomeFinderService().find(), String.format("%s====", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.file));
    new GraphTouchFeature(session, fileid).touch(file, new TransferStatus());
    assertNotNull(new GraphAttributesFinderFeature(session, fileid).find(file));
    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) 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)

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