Search in sources :

Example 96 with TestProtocol

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

the class RenameExistingFilterTest method testApplyRename.

@Test
public void testApplyRename() throws Exception {
    RenameExistingFilter f = new RenameExistingFilter(new DisabledDownloadSymlinkResolver(), new NullTransferSession(new Host(new TestProtocol())));
    final String name = new AsciiRandomStringService().random();
    final Local local = LocalFactory.get(System.getProperty("java.io.tmpdir"), name);
    new DefaultLocalTouchFeature().touch(local);
    new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(RandomUtils.nextBytes(1)), local.getOutputStream(false));
    final Path p = new Path(name, EnumSet.of(Path.Type.file));
    final TransferStatus status = f.prepare(p, local, new TransferStatus().exists(true), new DisabledProgressListener());
    assertTrue(status.isExists());
    assertNull(status.getRename().local);
    f.apply(p, local, status, new DisabledProgressListener());
    assertEquals(name, local.getName());
    assertFalse(status.isExists());
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) AsciiRandomStringService(ch.cyberduck.core.AsciiRandomStringService) NullLocal(ch.cyberduck.core.NullLocal) Local(ch.cyberduck.core.Local) Host(ch.cyberduck.core.Host) DisabledDownloadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DisabledDownloadSymlinkResolver) NullTransferSession(ch.cyberduck.core.NullTransferSession) DefaultLocalTouchFeature(ch.cyberduck.core.local.DefaultLocalTouchFeature) ByteArrayInputStream(java.io.ByteArrayInputStream) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) StreamCopier(ch.cyberduck.core.io.StreamCopier) Test(org.junit.Test)

Example 97 with TestProtocol

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

the class RenameExistingFilterTest method testPrepare.

@Test
public void testPrepare() throws Exception {
    final Host host = new Host(new TestProtocol());
    final DownloadFilterOptions options = new DownloadFilterOptions(host);
    options.icon = false;
    RenameExistingFilter f = new RenameExistingFilter(new DisabledDownloadSymlinkResolver(), new NullTransferSession(host), options);
    final String name = new AsciiRandomStringService().random();
    final Local local = new NullLocal(System.getProperty("java.io.tmpdir"), name) {

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

        @Override
        public void rename(final Local renamed) {
            // Must not rename original file but copy
            fail();
        }
    };
    final Path p = new Path(name, EnumSet.of(Path.Type.file));
    final TransferStatus status = f.prepare(p, local, new TransferStatus(), new DisabledProgressListener());
    assertNull(status.getRename().local);
    assertFalse(status.isExists());
    f.apply(p, local, new TransferStatus(), new DisabledProgressListener());
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) AsciiRandomStringService(ch.cyberduck.core.AsciiRandomStringService) NullLocal(ch.cyberduck.core.NullLocal) Local(ch.cyberduck.core.Local) Host(ch.cyberduck.core.Host) DisabledDownloadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DisabledDownloadSymlinkResolver) NullTransferSession(ch.cyberduck.core.NullTransferSession) NullLocal(ch.cyberduck.core.NullLocal) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Test(org.junit.Test)

Example 98 with TestProtocol

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

the class RenameFilterTest method testDirectoryDownload.

@Test
public void testDirectoryDownload() throws Exception {
    RenameFilter f = new RenameFilter(new DisabledDownloadSymlinkResolver(), new NullTransferSession(new Host(new TestProtocol())));
    final String name = new AsciiRandomStringService().random();
    final NullLocal local = new NullLocal("/tmp", name) {

        @Override
        public boolean exists() {
            return name.equals(this.getName());
        }

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

        @Override
        public boolean isDirectory() {
            return true;
        }
    };
    final Path directory = new Path("t", EnumSet.of(Path.Type.directory));
    final Path file = new Path(directory, name, EnumSet.of(Path.Type.file));
    final TransferStatus directoryStatus = f.prepare(directory, local, new TransferStatus().exists(true), new DisabledProgressListener());
    final TransferStatus fileStatus = f.prepare(file, new NullLocal(local, "f"), directoryStatus, new DisabledProgressListener());
    assertNotNull(fileStatus.getRename().local);
    final String s = System.getProperty("file.separator");
    assertEquals(String.format("%stmp%st-1%s%s", s, s, s, name), fileStatus.getRename().local.getAbsolute());
}
Also used : DisabledDownloadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DisabledDownloadSymlinkResolver) NullTransferSession(ch.cyberduck.core.NullTransferSession) Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) AsciiRandomStringService(ch.cyberduck.core.AsciiRandomStringService) NullLocal(ch.cyberduck.core.NullLocal) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Host(ch.cyberduck.core.Host) Test(org.junit.Test)

Example 99 with TestProtocol

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

the class ResumeFilterTest method testPrepareDirectoryExistsFalse.

@Test
public void testPrepareDirectoryExistsFalse() throws Exception {
    final Host host = new Host(new TestProtocol());
    final NullSession session = new NullTransferSession(host);
    ResumeFilter f = new ResumeFilter(new DisabledDownloadSymlinkResolver(), session, new DownloadFilterOptions(host), new DefaultDownloadFeature(session.getFeature(Read.class)) {

        @Override
        public boolean offset(final Path file) {
            return true;
        }
    });
    Path p = new Path("a", EnumSet.of(Path.Type.directory));
    final NullLocal local = new NullLocal("a") {

        @Override
        public boolean exists() {
            return false;
        }
    };
    final TransferStatus status = f.prepare(p, local, new TransferStatus(), new DisabledProgressListener());
    assertFalse(status.isAppend());
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) NullTransferSession(ch.cyberduck.core.NullTransferSession) DisabledDownloadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DisabledDownloadSymlinkResolver) DefaultDownloadFeature(ch.cyberduck.core.shared.DefaultDownloadFeature) NullLocal(ch.cyberduck.core.NullLocal) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Test(org.junit.Test)

Example 100 with TestProtocol

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

the class ResumeFilterTest method testPrepareDirectoryExists.

@Test
public void testPrepareDirectoryExists() throws Exception {
    final Host host = new Host(new TestProtocol());
    final NullSession session = new NullTransferSession(host);
    ResumeFilter f = new ResumeFilter(new DisabledDownloadSymlinkResolver(), session, new DownloadFilterOptions(host), new DefaultDownloadFeature(session.getFeature(Read.class)) {

        @Override
        public boolean offset(final Path file) {
            return true;
        }
    });
    Path p = new Path("a", EnumSet.of(Path.Type.directory));
    final NullLocal local = new NullLocal("a") {

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

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

        @Override
        public boolean isDirectory() {
            return true;
        }
    };
    final TransferStatus status = f.prepare(p, local, new TransferStatus().exists(true), new DisabledProgressListener());
    assertTrue(status.isExists());
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) NullTransferSession(ch.cyberduck.core.NullTransferSession) DisabledDownloadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DisabledDownloadSymlinkResolver) DefaultDownloadFeature(ch.cyberduck.core.shared.DefaultDownloadFeature) NullLocal(ch.cyberduck.core.NullLocal) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Test(org.junit.Test)

Aggregations

TestProtocol (ch.cyberduck.core.TestProtocol)253 Test (org.junit.Test)251 Host (ch.cyberduck.core.Host)230 Path (ch.cyberduck.core.Path)173 NullSession (ch.cyberduck.core.NullSession)131 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)107 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)96 Local (ch.cyberduck.core.Local)79 NullLocal (ch.cyberduck.core.NullLocal)76 ListProgressListener (ch.cyberduck.core.ListProgressListener)44 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)35 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)34 AttributedList (ch.cyberduck.core.AttributedList)33 ProtocolFactory (ch.cyberduck.core.ProtocolFactory)29 Transfer (ch.cyberduck.core.transfer.Transfer)28 DisabledUploadSymlinkResolver (ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver)28 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)27 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)27 VaultCredentials (ch.cyberduck.core.vault.VaultCredentials)27 UploadTransfer (ch.cyberduck.core.transfer.UploadTransfer)25