Search in sources :

Example 21 with NullSession

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

the class ResumeFilterTest method testSkip.

@Test
public void testSkip() throws Exception {
    final Path file = new Path("t", EnumSet.of(Path.Type.file));
    final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), new NullSession(new Host(new TestProtocol())) {

        @Override
        @SuppressWarnings("unchecked")
        public <T> T _getFeature(final Class<T> type) {
            if (type == Find.class) {
                return (T) new Find() {

                    @Override
                    public boolean find(final Path file, final ListProgressListener listener) {
                        return true;
                    }
                };
            }
            return super._getFeature(type);
        }

        @Override
        public AttributedList<Path> list(final Path parent, final ListProgressListener listener) {
            return new AttributedList<>(Collections.singletonList(file));
        }
    });
    file.attributes().setSize(1L);
    assertFalse(f.accept(file, new NullLocal("a") {

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

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

                @Override
                public long getSize() {
                    return 1L;
                }
            };
        }
    }, new TransferStatus().exists(true)));
}
Also used : Path(ch.cyberduck.core.Path) DisabledUploadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver) TestProtocol(ch.cyberduck.core.TestProtocol) LocalAttributes(ch.cyberduck.core.LocalAttributes) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) AttributedList(ch.cyberduck.core.AttributedList) NullLocal(ch.cyberduck.core.NullLocal) Find(ch.cyberduck.core.features.Find) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) ListProgressListener(ch.cyberduck.core.ListProgressListener) Test(org.junit.Test)

Example 22 with NullSession

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

the class ResumeFilterTest method testPrepare0.

@Test
public void testPrepare0() throws Exception {
    final Host host = new Host(new TestProtocol());
    final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), new NullSession(host), new UploadFilterOptions(host).withTemporary(true));
    final Path t = new Path("t", EnumSet.of(Path.Type.file));
    t.attributes().setSize(0L);
    final TransferStatus status = f.prepare(t, new NullLocal("t"), new TransferStatus().exists(true), new DisabledProgressListener());
    assertFalse(status.isAppend());
    assertNotNull(status.getRename().remote);
    assertEquals(0L, status.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) NullLocal(ch.cyberduck.core.NullLocal) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) Test(org.junit.Test)

Example 23 with NullSession

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

the class SkipFilterTest method testNotFound.

@Test(expected = NotfoundException.class)
public void testNotFound() throws Exception {
    SkipFilter f = new SkipFilter(new DisabledUploadSymlinkResolver(), new NullSession(new Host(new TestProtocol())) {

        @Override
        public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
            return AttributedList.emptyList();
        }
    });
    f.withAttributes(new AttributesFinder() {

        @Override
        public PathAttributes find(final Path file, final ListProgressListener listener) {
            return file.attributes();
        }
    });
    assertFalse(f.accept(new Path("a", EnumSet.of(Path.Type.file)), new NullLocal("a") {

        @Override
        public boolean exists() {
            return false;
        }
    }, new TransferStatus().exists(true)));
}
Also used : Path(ch.cyberduck.core.Path) DisabledUploadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver) TestProtocol(ch.cyberduck.core.TestProtocol) AttributesFinder(ch.cyberduck.core.features.AttributesFinder) 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 24 with NullSession

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

the class DeleteWorkerTest method testCompileDefault.

@Test
public void testCompileDefault() throws Exception {
    final Session session = new NullSession(new Host(new TestProtocol())) {

        @Override
        @SuppressWarnings("unchecked")
        public <T> T _getFeature(final Class<T> type) {
            if (type == Delete.class) {
                return (T) new Delete() {

                    @Override
                    public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) {
                        assertEquals(new Path("/t/a", EnumSet.of(Path.Type.file)), new ArrayList<>(files.keySet()).get(0));
                        assertEquals(new Path("/t/d/b", EnumSet.of(Path.Type.file)), new ArrayList<>(files.keySet()).get(1));
                        assertEquals(new Path("/t/d", EnumSet.of(Path.Type.directory)), new ArrayList<>(files.keySet()).get(2));
                        assertEquals(new Path("/t", EnumSet.of(Path.Type.directory)), new ArrayList<>(files.keySet()).get(3));
                    }
                };
            }
            return super._getFeature(type);
        }

        @Override
        public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
            if (file.equals(new Path("/t", EnumSet.of(Path.Type.directory)))) {
                return new AttributedList<Path>(Arrays.asList(new Path("/t/a", EnumSet.of(Path.Type.file)), new Path("/t/d", EnumSet.of(Path.Type.directory))));
            }
            if (file.equals(new Path("/t/d", EnumSet.of(Path.Type.directory)))) {
                return new AttributedList<Path>(Collections.singletonList(new Path("/t/d/b", EnumSet.of(Path.Type.file))));
            }
            fail();
            return null;
        }
    };
    final DeleteWorker worker = new DeleteWorker(new DisabledLoginCallback(), Collections.singletonList(new Path("/t", EnumSet.of(Path.Type.directory))), PathCache.empty(), new DisabledProgressListener());
    assertEquals(4, worker.run(session).size());
}
Also used : Delete(ch.cyberduck.core.features.Delete) AbstractPath(ch.cyberduck.core.AbstractPath) Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) PasswordCallback(ch.cyberduck.core.PasswordCallback) AttributedList(ch.cyberduck.core.AttributedList) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) PasswordCallback(ch.cyberduck.core.PasswordCallback) ListProgressListener(ch.cyberduck.core.ListProgressListener) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) Test(org.junit.Test)

Example 25 with NullSession

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

the class DeleteWorkerTest method testCompileRecursiveDeleteSupported.

@Test
public void testCompileRecursiveDeleteSupported() throws Exception {
    final Session session = new NullSession(new Host(new TestProtocol())) {

        @Override
        @SuppressWarnings("unchecked")
        public <T> T _getFeature(final Class<T> type) {
            if (type == Delete.class) {
                return (T) new Delete() {

                    @Override
                    public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) {
                        assertEquals(1, files.size());
                        assertEquals(new Path("/t", EnumSet.of(Path.Type.directory)), new ArrayList<>(files.keySet()).get(0));
                    }

                    @Override
                    public boolean isRecursive() {
                        return true;
                    }
                };
            }
            return super._getFeature(type);
        }

        @Override
        public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
            if (file.equals(new Path("/t", EnumSet.of(Path.Type.directory)))) {
                return new AttributedList<Path>(Arrays.asList(new Path("/t/a", EnumSet.of(Path.Type.file)), new Path("/t/d", EnumSet.of(Path.Type.directory))));
            }
            if (file.equals(new Path("/t/d", EnumSet.of(Path.Type.directory)))) {
                return new AttributedList<Path>(Collections.singletonList(new Path("/t/d/b", EnumSet.of(Path.Type.file))));
            }
            fail();
            return null;
        }
    };
    final DeleteWorker worker = new DeleteWorker(new DisabledLoginCallback(), Collections.singletonList(new Path("/t", EnumSet.of(Path.Type.directory))), PathCache.empty(), new DisabledProgressListener());
    assertEquals(1, worker.run(session).size());
}
Also used : Delete(ch.cyberduck.core.features.Delete) AbstractPath(ch.cyberduck.core.AbstractPath) Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) PasswordCallback(ch.cyberduck.core.PasswordCallback) AttributedList(ch.cyberduck.core.AttributedList) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) PasswordCallback(ch.cyberduck.core.PasswordCallback) ListProgressListener(ch.cyberduck.core.ListProgressListener) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) Test(org.junit.Test)

Aggregations

Host (ch.cyberduck.core.Host)128 NullSession (ch.cyberduck.core.NullSession)128 TestProtocol (ch.cyberduck.core.TestProtocol)128 Test (org.junit.Test)127 Path (ch.cyberduck.core.Path)118 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)81 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)69 NullLocal (ch.cyberduck.core.NullLocal)59 ListProgressListener (ch.cyberduck.core.ListProgressListener)40 AttributedList (ch.cyberduck.core.AttributedList)32 DisabledUploadSymlinkResolver (ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver)27 Local (ch.cyberduck.core.Local)24 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)24 ConnectionCallback (ch.cyberduck.core.ConnectionCallback)19 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)18 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)17 Session (ch.cyberduck.core.Session)17 VaultCredentials (ch.cyberduck.core.vault.VaultCredentials)17 HashMap (java.util.HashMap)14 LocalAttributes (ch.cyberduck.core.LocalAttributes)13