Search in sources :

Example 21 with DisabledProgressListener

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

the class SynchronizationPathFilterTest method testPrepare.

@Test
public void testPrepare() throws Exception {
    final Path test = new Path("/t/a", EnumSet.of(Path.Type.file));
    Session session = new NullSession(new Host(new TestProtocol()));
    final NullLocal local = new NullLocal(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()) {

        @Override
        public boolean isSymbolicLink() {
            return false;
        }

        @Override
        public LocalAttributes attributes() {
            return new LocalAttributes(this.getAbsolute()) {

                @Override
                public long getSize() {
                    return 1L;
                }
            };
        }

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

        @Override
        public boolean exists() {
            return true;
        }
    };
    final SynchronizationPathFilter mirror = new SynchronizationPathFilter(new DefaultComparePathFilter(session, TimeZone.getDefault()), new OverwriteFilter(new DownloadSymlinkResolver(Collections.<TransferItem>emptyList()), session), new ch.cyberduck.core.transfer.upload.OverwriteFilter(new UploadSymlinkResolver(null, Collections.<TransferItem>emptyList()), session), TransferAction.mirror);
    assertTrue(mirror.accept(test, local, new TransferStatus().exists(true)));
    final TransferStatus status = mirror.prepare(test, local, new TransferStatus().exists(true), new DisabledProgressListener());
    assertNotNull(status);
    assertEquals(1L, status.getLength());
    final SynchronizationPathFilter download = new SynchronizationPathFilter(new DefaultComparePathFilter(session, TimeZone.getDefault()), new OverwriteFilter(new DownloadSymlinkResolver(Collections.<TransferItem>emptyList()), session), new ch.cyberduck.core.transfer.upload.OverwriteFilter(new UploadSymlinkResolver(null, Collections.<TransferItem>emptyList()), session), TransferAction.download);
    assertFalse(download.accept(test, local, new TransferStatus().exists(true)));
    final SynchronizationPathFilter upload = new SynchronizationPathFilter(new DefaultComparePathFilter(session, TimeZone.getDefault()), new OverwriteFilter(new DownloadSymlinkResolver(Collections.<TransferItem>emptyList()), session), new ch.cyberduck.core.transfer.upload.OverwriteFilter(new UploadSymlinkResolver(null, Collections.<TransferItem>emptyList()), session), TransferAction.upload);
    assertTrue(upload.accept(test, local, new TransferStatus().exists(true)));
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) LocalAttributes(ch.cyberduck.core.LocalAttributes) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) DownloadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DownloadSymlinkResolver) DefaultComparePathFilter(ch.cyberduck.core.synchronization.DefaultComparePathFilter) NullLocal(ch.cyberduck.core.NullLocal) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) UploadSymlinkResolver(ch.cyberduck.core.transfer.symlink.UploadSymlinkResolver) OverwriteFilter(ch.cyberduck.core.transfer.download.OverwriteFilter) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) Test(org.junit.Test)

Example 22 with DisabledProgressListener

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

the class CompareFilterTest method testAcceptDirectory.

@Test
public void testAcceptDirectory() throws Exception {
    final Host host = new Host(new TestProtocol());
    final CompareFilter filter = new CompareFilter(new DisabledUploadSymlinkResolver(), new NullSession(host), new UploadFilterOptions(host), new DisabledProgressListener(), new DefaultComparePathFilter(new NullSession(host), null) {

        @Override
        public Comparison compare(final Path file, final Local local, final ProgressListener listener) {
            return Comparison.equal;
        }
    });
    assertTrue(filter.accept(new Path("/n", EnumSet.of(Path.Type.directory)), new NullLocal("/n") {

        @Override
        public boolean exists() {
            return true;
        }
    }, new TransferStatus().exists(true)));
}
Also used : DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) Path(ch.cyberduck.core.Path) DisabledUploadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver) TestProtocol(ch.cyberduck.core.TestProtocol) NullSession(ch.cyberduck.core.NullSession) NullLocal(ch.cyberduck.core.NullLocal) Local(ch.cyberduck.core.Local) Host(ch.cyberduck.core.Host) DefaultComparePathFilter(ch.cyberduck.core.synchronization.DefaultComparePathFilter) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) ProgressListener(ch.cyberduck.core.ProgressListener) Comparison(ch.cyberduck.core.synchronization.Comparison) NullLocal(ch.cyberduck.core.NullLocal) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Test(org.junit.Test)

Example 23 with DisabledProgressListener

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

the class WritePermissionWorkerTest method testRunRecursiveRetainDirectoryExecute.

@Test
@Ignore
public void testRunRecursiveRetainDirectoryExecute() throws Exception {
    final PermissionOverwrite permission = new PermissionOverwrite(new PermissionOverwrite.Action(true, true, false), new PermissionOverwrite.Action(false, true, false), new PermissionOverwrite.Action(false, true, false));
    final Path a = new Path("a", EnumSet.of(Path.Type.directory), new TestPermissionAttributes(Permission.Action.all));
    final WritePermissionWorker worker = new WritePermissionWorker(Collections.singletonList(a), permission, new BooleanRecursiveCallback<Permission>(true), new DisabledProgressListener());
    worker.run(new NullSession(new Host(new TestProtocol())) {

        @Override
        public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
            if (file.equals(a)) {
                final AttributedList<Path> children = new AttributedList<Path>();
                final Path d = new Path("d", EnumSet.of(Path.Type.directory));
                d.attributes().setPermission(new Permission(744));
                children.add(d);
                children.add(new Path("f", EnumSet.of(Path.Type.file)));
                return children;
            }
            return AttributedList.emptyList();
        }

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

                    @Override
                    public void setUnixOwner(final Path file, final String owner) {
                        throw new UnsupportedOperationException();
                    }

                    @Override
                    public void setUnixGroup(final Path file, final String group) {
                        throw new UnsupportedOperationException();
                    }

                    @Override
                    public Permission getUnixPermission(final Path file) {
                        throw new UnsupportedOperationException();
                    }

                    @Override
                    public void setUnixPermission(final Path file, final Permission permission) {
                        switch(file.getName()) {
                            case "a":
                                assertEquals(new Permission(644), permission);
                                break;
                            case "d":
                                assertEquals(new Permission(544), permission);
                                break;
                            case "f":
                                assertEquals(new Permission(644), permission);
                                break;
                            default:
                                fail();
                                break;
                        }
                    }
                };
            }
            return super._getFeature(type);
        }
    });
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestPermissionAttributes(ch.cyberduck.core.TestPermissionAttributes) TestProtocol(ch.cyberduck.core.TestProtocol) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) UnixPermission(ch.cyberduck.core.features.UnixPermission) DefaultUnixPermissionFeature(ch.cyberduck.core.shared.DefaultUnixPermissionFeature) AttributedList(ch.cyberduck.core.AttributedList) UnixPermission(ch.cyberduck.core.features.UnixPermission) Permission(ch.cyberduck.core.Permission) PermissionOverwrite(ch.cyberduck.core.PermissionOverwrite) ListProgressListener(ch.cyberduck.core.ListProgressListener) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 24 with DisabledProgressListener

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

the class WritePermissionWorkerTest method testRetainStickyBit.

@Test
public void testRetainStickyBit() throws Exception {
    final PermissionOverwrite permission = new PermissionOverwrite(new PermissionOverwrite.Action(true, true, true), new PermissionOverwrite.Action(null, false, false), new PermissionOverwrite.Action(true, false, false));
    final Path path = new Path("a", EnumSet.of(Path.Type.directory));
    path.attributes().setPermission(new Permission(Permission.Action.none, Permission.Action.read, Permission.Action.none, true, false, false));
    final WritePermissionWorker worker = new WritePermissionWorker(Collections.singletonList(path), permission, new BooleanRecursiveCallback<Permission>(true), new DisabledProgressListener());
    worker.run(new NullSession(new Host(new TestProtocol())) {

        @Override
        public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
            final AttributedList<Path> children = new AttributedList<Path>();
            // File has all set
            children.add(new Path("b", EnumSet.of(Path.Type.file), new TestPermissionAttributes(Permission.Action.all)));
            return children;
        }

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

                    @Override
                    public void setUnixOwner(final Path file, final String owner) {
                        throw new UnsupportedOperationException();
                    }

                    @Override
                    public void setUnixGroup(final Path file, final String group) {
                        throw new UnsupportedOperationException();
                    }

                    @Override
                    public Permission getUnixPermission(final Path file) {
                        throw new UnsupportedOperationException();
                    }

                    @Override
                    public void setUnixPermission(final Path file, final Permission permission) {
                        assertEquals(new Permission(1744), permission);
                    }
                };
            }
            return super._getFeature(type);
        }
    });
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) TestPermissionAttributes(ch.cyberduck.core.TestPermissionAttributes) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) UnixPermission(ch.cyberduck.core.features.UnixPermission) DefaultUnixPermissionFeature(ch.cyberduck.core.shared.DefaultUnixPermissionFeature) AttributedList(ch.cyberduck.core.AttributedList) UnixPermission(ch.cyberduck.core.features.UnixPermission) Permission(ch.cyberduck.core.Permission) PermissionOverwrite(ch.cyberduck.core.PermissionOverwrite) ListProgressListener(ch.cyberduck.core.ListProgressListener) Test(org.junit.Test)

Example 25 with DisabledProgressListener

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

the class AbstractS3DirectSDSTest method setup.

@Before
public void setup() throws Exception {
    session = new SDSSession(new Host(new SDSProtocol(), "duck.dracoon.com", new Credentials(System.getProperties().getProperty("sds.user"), System.getProperties().getProperty("sds.key"))), new DisabledX509TrustManager(), new DefaultX509KeyManager());
    session.enableMetrics();
    final LoginConnectionService connect = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) throws LoginCanceledException {
            throw new LoginCanceledException();
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
    connect.check(session, new DisabledCancelCallback());
}
Also used : DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) LoginConnectionService(ch.cyberduck.core.LoginConnectionService) LoginCanceledException(ch.cyberduck.core.exception.LoginCanceledException) Host(ch.cyberduck.core.Host) LoginOptions(ch.cyberduck.core.LoginOptions) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) Credentials(ch.cyberduck.core.Credentials) Before(org.junit.Before)

Aggregations

DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)166 Test (org.junit.Test)147 Host (ch.cyberduck.core.Host)135 Path (ch.cyberduck.core.Path)128 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)103 TestProtocol (ch.cyberduck.core.TestProtocol)95 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)94 NullSession (ch.cyberduck.core.NullSession)68 IntegrationTest (ch.cyberduck.test.IntegrationTest)65 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)59 NullLocal (ch.cyberduck.core.NullLocal)49 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)48 DisabledCancelCallback (ch.cyberduck.core.DisabledCancelCallback)48 DisabledHostKeyCallback (ch.cyberduck.core.DisabledHostKeyCallback)48 Credentials (ch.cyberduck.core.Credentials)43 Delete (ch.cyberduck.core.features.Delete)42 Local (ch.cyberduck.core.Local)40 LoginConnectionService (ch.cyberduck.core.LoginConnectionService)39 DefaultX509KeyManager (ch.cyberduck.core.ssl.DefaultX509KeyManager)36 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)34