use of ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver in project cyberduck by iterate-ch.
the class OverwriteFilterTest method testOverrideFileWithDirectory.
@Test(expected = AccessDeniedException.class)
public void testOverrideFileWithDirectory() throws Exception {
final AbstractUploadFilter f = new OverwriteFilter(new DisabledUploadSymlinkResolver(), new NullSession(new Host(new TestProtocol()))).withFinder(new Find() {
@Override
public boolean find(final Path file, final ListProgressListener listener) {
if (file.getType().contains(Path.Type.file)) {
return true;
}
return false;
}
});
f.prepare(new Path("a", EnumSet.of(Path.Type.directory)), new NullLocal(System.getProperty("java.io.tmpdir")), new TransferStatus().exists(true), new DisabledProgressListener());
}
use of ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver in project cyberduck by iterate-ch.
the class OverwriteFilterTest method testAcceptNotFoundDirectory.
@Test(expected = NotfoundException.class)
public void testAcceptNotFoundDirectory() throws Exception {
final OverwriteFilter f = new OverwriteFilter(new DisabledUploadSymlinkResolver(), new NullSession(new Host(new TestProtocol())));
// Local file does not exist
assertFalse(f.accept(new Path("a", EnumSet.of(Path.Type.directory)) {
}, new NullLocal("t") {
@Override
public boolean exists() {
return false;
}
}, new TransferStatus()));
}
use of ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver in project cyberduck by iterate-ch.
the class OverwriteFilterTest method testAcceptNotFoundFile.
@Test(expected = NotfoundException.class)
public void testAcceptNotFoundFile() throws Exception {
final OverwriteFilter f = new OverwriteFilter(new DisabledUploadSymlinkResolver(), new NullSession(new Host(new TestProtocol())));
// Local file does not exist
assertFalse(f.accept(new Path("a", EnumSet.of(Path.Type.file)) {
}, new NullLocal("t") {
@Override
public boolean exists() {
return false;
}
}, new TransferStatus()));
}
use of ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver in project cyberduck by iterate-ch.
the class RenameExistingFilterTest method testTemporaryDirectoryUpload.
@Test
public void testTemporaryDirectoryUpload() throws Exception {
final Path file = new Path("/t", EnumSet.of(Path.Type.directory));
final AtomicBoolean found = new AtomicBoolean();
final AtomicBoolean moved = new AtomicBoolean();
final Find find = new Find() {
@Override
public boolean find(final Path f, final ListProgressListener listener) {
if (f.equals(file)) {
found.set(true);
return true;
}
return false;
}
};
final AttributesFinder attributes = new AttributesFinder() {
@Override
public PathAttributes find(final Path file, final ListProgressListener listener) {
return new PathAttributes();
}
};
final Host host = new Host(new TestProtocol());
final NullSession session = new NullSession(host) {
@Override
@SuppressWarnings("unchecked")
public <T> T _getFeature(final Class<T> type) {
if (type.equals(Move.class)) {
return (T) new Move() {
@Override
public Path move(final Path f, final Path renamed, TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) {
assertFalse(moved.get());
assertEquals(file, f);
moved.set(true);
return renamed;
}
@Override
public boolean isRecursive(final Path source, final Path target) {
return true;
}
};
}
if (type.equals(Write.class)) {
return (T) new Write<Void>() {
@Override
public StatusOutputStream write(final Path file, final TransferStatus status, final ConnectionCallback callback) {
fail();
return null;
}
@Override
public Append append(final Path file, final TransferStatus status) {
fail();
return new Append(false);
}
};
}
return null;
}
};
final RenameExistingFilter f = new RenameExistingFilter(new DisabledUploadSymlinkResolver(), session, new UploadFilterOptions(host).withTemporary(true));
f.withFinder(find).withAttributes(attributes);
final TransferStatus status = f.prepare(file, new NullLocal("/t") {
@Override
public boolean isDirectory() {
return true;
}
@Override
public boolean isFile() {
return false;
}
}, new TransferStatus().exists(true), new DisabledProgressListener());
assertTrue(found.get());
assertNull(status.getRename().remote);
assertNull(status.getRename().local);
assertFalse(moved.get());
f.apply(file, new NullLocal("/t") {
@Override
public boolean isDirectory() {
return true;
}
}, new TransferStatus().exists(true), new DisabledProgressListener());
assertTrue(moved.get());
}
use of ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver in project cyberduck by iterate-ch.
the class RenameFilterTest method testPrepare.
@Test
public void testPrepare() throws Exception {
RenameFilter f = new RenameFilter(new DisabledUploadSymlinkResolver(), new NullSession(new Host(new TestProtocol())));
final Path t = new Path("t", EnumSet.of(Path.Type.file));
f.prepare(t, new NullLocal("t"), new TransferStatus(), new DisabledProgressListener());
assertNotSame("t", t.getName());
}
Aggregations