Search in sources :

Example 1 with DisabledUploadSymlinkResolver

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());
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledUploadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver) TestProtocol(ch.cyberduck.core.TestProtocol) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) 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 2 with DisabledUploadSymlinkResolver

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()));
}
Also used : Path(ch.cyberduck.core.Path) 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 3 with DisabledUploadSymlinkResolver

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()));
}
Also used : Path(ch.cyberduck.core.Path) 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 4 with DisabledUploadSymlinkResolver

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());
}
Also used : Delete(ch.cyberduck.core.features.Delete) DisabledUploadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver) TestProtocol(ch.cyberduck.core.TestProtocol) AttributesFinder(ch.cyberduck.core.features.AttributesFinder) NullSession(ch.cyberduck.core.NullSession) Move(ch.cyberduck.core.features.Move) NullLocal(ch.cyberduck.core.NullLocal) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) ListProgressListener(ch.cyberduck.core.ListProgressListener) Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) StatusOutputStream(ch.cyberduck.core.io.StatusOutputStream) PathAttributes(ch.cyberduck.core.PathAttributes) Host(ch.cyberduck.core.Host) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Find(ch.cyberduck.core.features.Find) ConnectionCallback(ch.cyberduck.core.ConnectionCallback) Test(org.junit.Test)

Example 5 with DisabledUploadSymlinkResolver

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

Aggregations

Host (ch.cyberduck.core.Host)28 NullLocal (ch.cyberduck.core.NullLocal)28 Path (ch.cyberduck.core.Path)28 TestProtocol (ch.cyberduck.core.TestProtocol)28 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)28 DisabledUploadSymlinkResolver (ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver)28 Test (org.junit.Test)28 NullSession (ch.cyberduck.core.NullSession)27 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)18 ListProgressListener (ch.cyberduck.core.ListProgressListener)14 AttributedList (ch.cyberduck.core.AttributedList)8 PathAttributes (ch.cyberduck.core.PathAttributes)8 LocalAttributes (ch.cyberduck.core.LocalAttributes)7 Find (ch.cyberduck.core.features.Find)7 AttributesFinder (ch.cyberduck.core.features.AttributesFinder)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 ConnectionCallback (ch.cyberduck.core.ConnectionCallback)3 NullWriteFeature (ch.cyberduck.core.NullWriteFeature)3 Move (ch.cyberduck.core.features.Move)3 Local (ch.cyberduck.core.Local)2