Search in sources :

Example 11 with ListProgressListener

use of ch.cyberduck.core.ListProgressListener 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 12 with ListProgressListener

use of ch.cyberduck.core.ListProgressListener 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 13 with ListProgressListener

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

the class FTPListServiceTest method testListIOFailureStat.

@Test(expected = ConnectionTimeoutException.class)
public void testListIOFailureStat() throws Exception {
    final FTPListService service = new FTPListService(session, null, TimeZone.getDefault());
    service.remove(FTPListService.Command.lista);
    service.remove(FTPListService.Command.mlsd);
    final AtomicBoolean set = new AtomicBoolean();
    service.implementations.put(FTPListService.Command.stat, new ListService() {

        @Override
        public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException {
            if (set.get()) {
                fail();
            }
            set.set(true);
            throw new ConnectionTimeoutException("t", new SocketTimeoutException());
        }
    });
    final Path directory = new FTPWorkdirService(session).find();
    final AttributedList<Path> list = service.list(directory, new DisabledListProgressListener());
}
Also used : Path(ch.cyberduck.core.Path) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) ListService(ch.cyberduck.core.ListService) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ConnectionTimeoutException(ch.cyberduck.core.exception.ConnectionTimeoutException) SocketTimeoutException(java.net.SocketTimeoutException) AttributedList(ch.cyberduck.core.AttributedList) ListProgressListener(ch.cyberduck.core.ListProgressListener) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) FTPWorkdirService(ch.cyberduck.core.ftp.FTPWorkdirService) BackgroundException(ch.cyberduck.core.exception.BackgroundException) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractFTPTest(ch.cyberduck.core.ftp.AbstractFTPTest)

Example 14 with ListProgressListener

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

the class CachingAttributesFinderFeatureTest method testAttributes.

@Test
public void testAttributes() throws Exception {
    final PathCache cache = new PathCache(1);
    final AttributesFinder f = new CachingAttributesFinderFeature(cache, new DefaultAttributesFinderFeature(session));
    final String name = new AlphanumericRandomStringService().random();
    final Path file = new DAVTouchFeature(session).touch(new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
    final Attributes lookup = f.find(file);
    assertEquals(0L, lookup.getSize());
    // Test cache
    assertSame(lookup, new CachingAttributesFinderFeature(cache, new AttributesFinder() {

        @Override
        public PathAttributes find(final Path file, final ListProgressListener listener) {
            fail("Expected cache hit");
            return PathAttributes.EMPTY;
        }
    }).find(file));
    assertEquals(0L, f.find(file).getSize());
    assertTrue(cache.containsKey(file.getParent()));
    // Test wrong type
    try {
        f.find(new Path(new DefaultHomeFinderService(session).find(), name, EnumSet.of(Path.Type.directory)));
        fail();
    } catch (NotfoundException e) {
    // Expected
    }
    new DAVDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : PathCache(ch.cyberduck.core.PathCache) Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) NotfoundException(ch.cyberduck.core.exception.NotfoundException) CachingAttributesFinderFeature(ch.cyberduck.core.CachingAttributesFinderFeature) AttributesFinder(ch.cyberduck.core.features.AttributesFinder) PathAttributes(ch.cyberduck.core.PathAttributes) Attributes(ch.cyberduck.core.Attributes) PathAttributes(ch.cyberduck.core.PathAttributes) DAVDeleteFeature(ch.cyberduck.core.dav.DAVDeleteFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) ListProgressListener(ch.cyberduck.core.ListProgressListener) DAVTouchFeature(ch.cyberduck.core.dav.DAVTouchFeature) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractDAVTest(ch.cyberduck.core.dav.AbstractDAVTest)

Example 15 with ListProgressListener

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

the class SyncTransferTest method testFilterDownload.

@Test
public void testFilterDownload() throws Exception {
    final Path p = new Path("t", EnumSet.of(Path.Type.directory));
    Transfer t = new SyncTransfer(new Host(new TestProtocol()), new TransferItem(p, new NullLocal(System.getProperty("java.io.tmpdir"), "t")));
    final NullSession session = new NullSession(new Host(new TestProtocol())) {

        @Override
        public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
            return AttributedList.emptyList();
        }
    };
    final TransferPathFilter filter = t.filter(session, null, TransferAction.download, new DisabledProgressListener());
    final Path test = new Path(p, "a", EnumSet.of(Path.Type.file));
    assertFalse(filter.accept(test, new NullLocal(System.getProperty("java.io.tmpdir"), "a"), new TransferStatus().exists(true)));
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) NullLocal(ch.cyberduck.core.NullLocal) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) ListProgressListener(ch.cyberduck.core.ListProgressListener) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) Test(org.junit.Test)

Aggregations

ListProgressListener (ch.cyberduck.core.ListProgressListener)49 Path (ch.cyberduck.core.Path)49 Test (org.junit.Test)48 Host (ch.cyberduck.core.Host)43 TestProtocol (ch.cyberduck.core.TestProtocol)43 NullSession (ch.cyberduck.core.NullSession)41 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)30 AttributedList (ch.cyberduck.core.AttributedList)29 NullLocal (ch.cyberduck.core.NullLocal)26 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)25 Find (ch.cyberduck.core.features.Find)14 DisabledUploadSymlinkResolver (ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver)14 PathAttributes (ch.cyberduck.core.PathAttributes)13 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)12 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)11 AttributesFinder (ch.cyberduck.core.features.AttributesFinder)11 Delete (ch.cyberduck.core.features.Delete)10 Session (ch.cyberduck.core.Session)9 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)8 LocalAttributes (ch.cyberduck.core.LocalAttributes)7