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);
}
});
}
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);
}
});
}
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());
}
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());
}
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)));
}
Aggregations