package org.apache.sshd.fs.test;

import java.nio.file.Path;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import org.xbib.files.FileService;

import java.util.Map;
import java.util.logging.Logger;

public class FileServiceProviderTest {

    @Test
    public void testSFTP() throws Exception {
        Map<String, ?> env = Map.of("username", "joerg");
        FileService fs = FileService.newInstance("sftp://xbib.org:22", env);
        // close() is essential!
        try (Stream<Path> list = fs.list(".")) {
            list.forEach(p -> Logger.getAnonymousLogger().info(p.toString()));
        }
        // see if a second run still works
        try (Stream<Path> list = fs.list(".")) {
            list.forEach(p -> Logger.getAnonymousLogger().info(p.toString()));
        }
    }
}
