@Test public void testReadWrite() throws Exception { final TransferStatus status = new TransferStatus(); final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); final byte[] content = "test".getBytes(StandardCharsets.UTF_8); final OutputStream out = local.getOutputStream(false); IOUtils.write(content, out); out.close(); status.setLength(content.length); final Path test = new Path(new DefaultHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final HttpUploadFeature upload = new DAVUploadFeature(new DAVWriteFeature(session)); upload.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledConnectionCallback()); assertTrue(session.getFeature(Find.class).find(test)); assertEquals(content.length, new DAVListService(session).list(test.getParent(), new DisabledListProgressListener()).get(test).attributes().getSize(), 0L); assertEquals(content.length, new DAVWriteFeature(session).append(test, status.getLength(), PathCache.empty()).size, 0L); { final byte[] buffer = new byte[content.length]; IOUtils.readFully(new DAVReadFeature(session).read(test, new TransferStatus(), new DisabledConnectionCallback()), buffer); assertArrayEquals(content, buffer); } { final byte[] buffer = new byte[content.length - 1]; final InputStream in = new DAVReadFeature(session).read(test, new TransferStatus().length(content.length - 1L).append(true).skip(1L), new DisabledConnectionCallback()); IOUtils.readFully(in, buffer); in.close(); final byte[] reference = new byte[content.length - 1]; System.arraycopy(content, 1, reference, 0, content.length - 1); assertArrayEquals(reference, buffer); } new DAVDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public HttpResponseOutputStream<String> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final List<Header> headers = this.getHeaders(file, status); return this.write(file, headers, status); }
DAVWriteFeature extends AbstractHttpWriteFeature<String> implements Write<String> { @Override public HttpResponseOutputStream<String> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final List<Header> headers = this.getHeaders(file, status); return this.write(file, headers, status); } }
DAVWriteFeature extends AbstractHttpWriteFeature<String> implements Write<String> { @Override public HttpResponseOutputStream<String> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final List<Header> headers = this.getHeaders(file, status); return this.write(file, headers, status); } DAVWriteFeature(final DAVSession session);  DAVWriteFeature(final DAVSession session, final boolean expect);  DAVWriteFeature(final DAVSession session, final Find finder, final AttributesFinder attributes, final boolean expect); }
DAVWriteFeature extends AbstractHttpWriteFeature<String> implements Write<String> { @Override public HttpResponseOutputStream<String> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final List<Header> headers = this.getHeaders(file, status); return this.write(file, headers, status); } DAVWriteFeature(final DAVSession session);  DAVWriteFeature(final DAVSession session, final boolean expect);  DAVWriteFeature(final DAVSession session, final Find finder, final AttributesFinder attributes, final boolean expect); @Override HttpResponseOutputStream<String> write(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override boolean temporary(); @Override boolean random(); }
DAVWriteFeature extends AbstractHttpWriteFeature<String> implements Write<String> { @Override public HttpResponseOutputStream<String> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final List<Header> headers = this.getHeaders(file, status); return this.write(file, headers, status); } DAVWriteFeature(final DAVSession session);  DAVWriteFeature(final DAVSession session, final boolean expect);  DAVWriteFeature(final DAVSession session, final Find finder, final AttributesFinder attributes, final boolean expect); @Override HttpResponseOutputStream<String> write(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override boolean temporary(); @Override boolean random();  }