@Test public void testParse() throws Exception { final CommandLineParser parser = new PosixParser(); final CommandLine input = parser.parse(new Options(), new String[]{}); final ProtocolFactory factory = new ProtocolFactory(new HashSet<>(Arrays.asList(new FTPTLSProtocol(), new S3Protocol()))); factory.register(new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/FTP.cyberduckprofile"))); factory.register(new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/FTPS.cyberduckprofile"))); factory.register(new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/S3 (HTTPS).cyberduckprofile"))); assertEquals(new Path("/", EnumSet.of(Path.Type.directory)), new CommandLinePathParser(input, factory).parse("ftps: assertEquals(new Path("/d", EnumSet.of(Path.Type.directory)), new CommandLinePathParser(input, factory).parse("ftps: assertEquals(new Path("/d", EnumSet.of(Path.Type.file)), new CommandLinePathParser(input, factory).parse("ftps: assertEquals(new Path("/", EnumSet.of(Path.Type.directory)), new CommandLinePathParser(input, factory).parse("ftps: assertEquals(new Path("/", EnumSet.of(Path.Type.directory)), new CommandLinePathParser(input, factory).parse("ftps: assertEquals(new Path("/test.cyberduck.ch", EnumSet.of(Path.Type.directory)), new CommandLinePathParser(input, factory).parse("s3:u@test.cyberduck.ch/")); assertEquals(new Path("/test.cyberduck.ch", EnumSet.of(Path.Type.directory)), new CommandLinePathParser(input, factory).parse("s3:u@test.cyberduck.ch/")); assertEquals(new Path("/test.cyberduck.ch/d", EnumSet.of(Path.Type.directory)), new CommandLinePathParser(input, factory).parse("s3:u@test.cyberduck.ch/d/")); assertEquals(new Path("/test.cyberduck.ch/d", EnumSet.of(Path.Type.directory)), new CommandLinePathParser(input, factory).parse("s3: assertEquals(new Path("/test.cyberduck.ch/d", EnumSet.of(Path.Type.file)), new CommandLinePathParser(input, factory).parse("s3: assertEquals(new Path("/test.cyberduck.ch/d", EnumSet.of(Path.Type.file)), new CommandLinePathParser(input, factory).parse("s3: }
public Path parse(final String uri) throws HostParserException { final Host host = new HostParser(factory).get(uri); if(StringUtils.isBlank(host.getDefaultPath())) { return new Path(String.valueOf(Path.DELIMITER), EnumSet.of((Path.Type.directory))); } return new Path(PathNormalizer.normalize(host.getDefaultPath()), EnumSet.of(detector.detect(host.getDefaultPath()))); }
CommandLinePathParser { public Path parse(final String uri) throws HostParserException { final Host host = new HostParser(factory).get(uri); if(StringUtils.isBlank(host.getDefaultPath())) { return new Path(String.valueOf(Path.DELIMITER), EnumSet.of((Path.Type.directory))); } return new Path(PathNormalizer.normalize(host.getDefaultPath()), EnumSet.of(detector.detect(host.getDefaultPath()))); } }
CommandLinePathParser { public Path parse(final String uri) throws HostParserException { final Host host = new HostParser(factory).get(uri); if(StringUtils.isBlank(host.getDefaultPath())) { return new Path(String.valueOf(Path.DELIMITER), EnumSet.of((Path.Type.directory))); } return new Path(PathNormalizer.normalize(host.getDefaultPath()), EnumSet.of(detector.detect(host.getDefaultPath()))); } CommandLinePathParser(final CommandLine input);  CommandLinePathParser(final CommandLine input, final ProtocolFactory factory); }
CommandLinePathParser { public Path parse(final String uri) throws HostParserException { final Host host = new HostParser(factory).get(uri); if(StringUtils.isBlank(host.getDefaultPath())) { return new Path(String.valueOf(Path.DELIMITER), EnumSet.of((Path.Type.directory))); } return new Path(PathNormalizer.normalize(host.getDefaultPath()), EnumSet.of(detector.detect(host.getDefaultPath()))); } CommandLinePathParser(final CommandLine input);  CommandLinePathParser(final CommandLine input, final ProtocolFactory factory); Path parse(final String uri); }
CommandLinePathParser { public Path parse(final String uri) throws HostParserException { final Host host = new HostParser(factory).get(uri); if(StringUtils.isBlank(host.getDefaultPath())) { return new Path(String.valueOf(Path.DELIMITER), EnumSet.of((Path.Type.directory))); } return new Path(PathNormalizer.normalize(host.getDefaultPath()), EnumSet.of(detector.detect(host.getDefaultPath()))); } CommandLinePathParser(final CommandLine input);  CommandLinePathParser(final CommandLine input, final ProtocolFactory factory); Path parse(final String uri);  }