@Test public void testSymlink() throws Exception { final LocalSession session = new LocalSession(new Host(new LocalProtocol(), new LocalProtocol().getDefaultHostname())); assumeTrue(session.isPosixFilesystem()); session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback()); session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback()); final Path workdir = new LocalHomeFinderFeature(session).find(); final Path target = new Path(workdir, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); new LocalTouchFeature(session).touch(target, new TransferStatus()); final Path link = new Path(workdir, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file, AbstractPath.Type.symboliclink)); new LocalSymlinkFeature(session).symlink(link, target.getName()); assertTrue(new LocalFindFeature(session).find(link)); assertEquals(EnumSet.of(Path.Type.file, AbstractPath.Type.symboliclink), new LocalListService(session).list(workdir, new DisabledListProgressListener()).get(link).getType()); new LocalDeleteFeature(session).delete(Collections.singletonList(link), new DisabledLoginCallback(), new Delete.DisabledCallback()); assertFalse(new LocalFindFeature(session).find(link)); assertTrue(new LocalFindFeature(session).find(target)); new LocalDeleteFeature(session).delete(Collections.singletonList(target), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
@Override public void symlink(final Path file, final String target) throws BackgroundException { try { Files.createSymbolicLink(session.toPath(file), session.toPath(target)); } catch(IOException e) { throw new LocalExceptionMappingService().map("Cannot create file {0}", e, file); } }
LocalSymlinkFeature implements Symlink { @Override public void symlink(final Path file, final String target) throws BackgroundException { try { Files.createSymbolicLink(session.toPath(file), session.toPath(target)); } catch(IOException e) { throw new LocalExceptionMappingService().map("Cannot create file {0}", e, file); } } }
LocalSymlinkFeature implements Symlink { @Override public void symlink(final Path file, final String target) throws BackgroundException { try { Files.createSymbolicLink(session.toPath(file), session.toPath(target)); } catch(IOException e) { throw new LocalExceptionMappingService().map("Cannot create file {0}", e, file); } } LocalSymlinkFeature(final LocalSession session); }
LocalSymlinkFeature implements Symlink { @Override public void symlink(final Path file, final String target) throws BackgroundException { try { Files.createSymbolicLink(session.toPath(file), session.toPath(target)); } catch(IOException e) { throw new LocalExceptionMappingService().map("Cannot create file {0}", e, file); } } LocalSymlinkFeature(final LocalSession session); @Override void symlink(final Path file, final String target); }
LocalSymlinkFeature implements Symlink { @Override public void symlink(final Path file, final String target) throws BackgroundException { try { Files.createSymbolicLink(session.toPath(file), session.toPath(target)); } catch(IOException e) { throw new LocalExceptionMappingService().map("Cannot create file {0}", e, file); } } LocalSymlinkFeature(final LocalSession session); @Override void symlink(final Path file, final String target);  }