Search in sources :

Example 1 with NullWriteFeature

use of ch.cyberduck.core.NullWriteFeature in project cyberduck by iterate-ch.

the class ResumeFilterTest method testAppendSmallerSize.

@Test
public void testAppendSmallerSize() throws Exception {
    final Host host = new Host(new TestProtocol());
    final NullSession session = new NullSession(host) {

        @Override
        public AttributedList<Path> list(final Path folder, final ListProgressListener listener) throws BackgroundException {
            final AttributedList<Path> list = new AttributedList<>(Collections.singletonList(new Path(folder, "t", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withSize(2L))));
            listener.chunk(folder, list);
            return list;
        }
    };
    final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), session, new UploadFilterOptions(host).withTemporary(true), new DefaultUploadFeature<>(new NullWriteFeature(session)));
    final long size = 3L;
    final Path t = new Path("t", EnumSet.of(Path.Type.file));
    final NullLocal l = new NullLocal("t") {

        @Override
        public LocalAttributes attributes() {
            return new LocalAttributes("t") {

                @Override
                public long getSize() {
                    return size;
                }
            };
        }

        @Override
        public boolean isFile() {
            return true;
        }

        @Override
        public boolean exists() {
            return true;
        }
    };
    assertTrue(f.accept(t, l, new TransferStatus().exists(true)));
    // Remaining length to transfer is 1
    assertEquals(1L, f.prepare(t, l, new TransferStatus().exists(true), new DisabledProgressListener()).getLength());
    // Skip first 2 bytes
    assertEquals(2L, f.prepare(t, l, new TransferStatus().exists(true), new DisabledProgressListener()).getOffset());
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledUploadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver) TestProtocol(ch.cyberduck.core.TestProtocol) NullWriteFeature(ch.cyberduck.core.NullWriteFeature) LocalAttributes(ch.cyberduck.core.LocalAttributes) PathAttributes(ch.cyberduck.core.PathAttributes) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) AttributedList(ch.cyberduck.core.AttributedList) NullLocal(ch.cyberduck.core.NullLocal) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) ListProgressListener(ch.cyberduck.core.ListProgressListener) Test(org.junit.Test)

Example 2 with NullWriteFeature

use of ch.cyberduck.core.NullWriteFeature in project cyberduck by iterate-ch.

the class ResumeFilterTest method testAppendEqualSize.

@Test
public void testAppendEqualSize() throws Exception {
    final Host host = new Host(new TestProtocol());
    final NullSession session = new NullSession(host) {

        @Override
        public AttributedList<Path> list(final Path folder, final ListProgressListener listener) throws BackgroundException {
            final AttributedList<Path> list = new AttributedList<>(Collections.singletonList(new Path(folder, "t", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withSize(3L))));
            listener.chunk(folder, list);
            return list;
        }
    };
    final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), session, new UploadFilterOptions(host).withTemporary(true), new DefaultUploadFeature<Void>(new NullWriteFeature(session)));
    final long size = 3L;
    final Path t = new Path("t", EnumSet.of(Path.Type.file));
    assertFalse(f.accept(t, new NullLocal("t") {

        @Override
        public LocalAttributes attributes() {
            return new LocalAttributes("t") {

                @Override
                public long getSize() {
                    return size;
                }
            };
        }

        @Override
        public boolean isFile() {
            return true;
        }

        @Override
        public boolean exists() {
            return true;
        }
    }, new TransferStatus().exists(true)));
}
Also used : Path(ch.cyberduck.core.Path) DisabledUploadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver) TestProtocol(ch.cyberduck.core.TestProtocol) NullWriteFeature(ch.cyberduck.core.NullWriteFeature) LocalAttributes(ch.cyberduck.core.LocalAttributes) PathAttributes(ch.cyberduck.core.PathAttributes) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) AttributedList(ch.cyberduck.core.AttributedList) NullLocal(ch.cyberduck.core.NullLocal) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) ListProgressListener(ch.cyberduck.core.ListProgressListener) Test(org.junit.Test)

Example 3 with NullWriteFeature

use of ch.cyberduck.core.NullWriteFeature in project cyberduck by iterate-ch.

the class ResumeFilterTest method testAppendLargerSize.

@Test
public void testAppendLargerSize() throws Exception {
    final Host host = new Host(new TestProtocol());
    final NullSession session = new NullSession(host) {

        @Override
        public AttributedList<Path> list(final Path folder, final ListProgressListener listener) throws BackgroundException {
            final AttributedList<Path> list = new AttributedList<>(Collections.singletonList(new Path(folder, "t", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withSize(4L))));
            listener.chunk(folder, list);
            return list;
        }
    };
    final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), session, new UploadFilterOptions(host).withTemporary(true), new DefaultUploadFeature<>(new NullWriteFeature(session)));
    final long size = 3L;
    final Path t = new Path("t", EnumSet.of(Path.Type.file));
    final NullLocal l = new NullLocal("t") {

        @Override
        public boolean exists() {
            return true;
        }

        @Override
        public LocalAttributes attributes() {
            return new LocalAttributes("t") {

                @Override
                public long getSize() {
                    return size;
                }
            };
        }

        @Override
        public boolean isFile() {
            return true;
        }
    };
    assertTrue(f.accept(t, l, new TransferStatus().exists(true)));
    assertFalse(f.prepare(t, l, new TransferStatus().exists(true), new DisabledProgressListener()).isAppend());
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledUploadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver) TestProtocol(ch.cyberduck.core.TestProtocol) NullWriteFeature(ch.cyberduck.core.NullWriteFeature) LocalAttributes(ch.cyberduck.core.LocalAttributes) PathAttributes(ch.cyberduck.core.PathAttributes) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) AttributedList(ch.cyberduck.core.AttributedList) NullLocal(ch.cyberduck.core.NullLocal) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) ListProgressListener(ch.cyberduck.core.ListProgressListener) Test(org.junit.Test)

Aggregations

AttributedList (ch.cyberduck.core.AttributedList)3 Host (ch.cyberduck.core.Host)3 ListProgressListener (ch.cyberduck.core.ListProgressListener)3 LocalAttributes (ch.cyberduck.core.LocalAttributes)3 NullLocal (ch.cyberduck.core.NullLocal)3 NullSession (ch.cyberduck.core.NullSession)3 NullWriteFeature (ch.cyberduck.core.NullWriteFeature)3 Path (ch.cyberduck.core.Path)3 PathAttributes (ch.cyberduck.core.PathAttributes)3 TestProtocol (ch.cyberduck.core.TestProtocol)3 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)3 DisabledUploadSymlinkResolver (ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver)3 Test (org.junit.Test)3 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)2