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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations