-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
236 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import no.maddin.niofs.testutil.BasicTestContainer; | ||
import no.maddin.niofs.testutil.FileUtils; | ||
import no.maddin.niofs.testutil.SftpgoContainer; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
import org.testcontainers.junit.jupiter.Testcontainers; | ||
|
||
import java.io.File; | ||
import java.net.URI; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import java.util.function.Supplier; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
/** | ||
* We prepare a file structure and use the various providers list the files. | ||
*/ | ||
@Testcontainers | ||
public class FilesListTest { | ||
|
||
private static final String TESTDATA_RESOURCE = "/sftpgo-data"; | ||
private static final File localDataFileRoot = FileUtils.classpathFile(FilesListTest.class, TESTDATA_RESOURCE); | ||
|
||
public static Stream<Arguments> data() { | ||
// anonymous class | ||
return Stream.of( | ||
Arguments.of( | ||
"sftp", | ||
(Supplier<BasicTestContainer>) () -> new SftpgoContainer(TESTDATA_RESOURCE) | ||
), | ||
Arguments.of( | ||
"webdav", | ||
(Supplier<BasicTestContainer>) () -> new SftpgoContainer(TESTDATA_RESOURCE) | ||
) | ||
); | ||
} | ||
|
||
@ParameterizedTest(name = "{index} {0}") | ||
@MethodSource("data") | ||
public void listFiles(String protocol, Supplier<BasicTestContainer> containerSupplier) throws Exception { | ||
|
||
String dataSubDir = UUID.randomUUID().toString(); | ||
List<String> createdFiles = FileUtils.createFilesInDir(localDataFileRoot, dataSubDir, 10); | ||
try (BasicTestContainer container = containerSupplier.get()) { | ||
container.start(); | ||
URI uri = container.getBaseUri(protocol); | ||
Path path = Paths.get(uri.resolve(dataSubDir)); | ||
try (Stream<Path> paths = Files.list(path)) { | ||
List<String> foundFiles = paths | ||
.map(Path::getFileName) | ||
.map(Path::toString) | ||
.collect(Collectors.toList()); | ||
|
||
assertThat(foundFiles, equalTo(createdFiles)); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Keep this directory. It is used by sftpgo to store the host keys. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
sftp/src/test/java/no/maddin/niofs/sftp/SshdContainer.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Keep this directory. It is used by sftpgo to store the host keys. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
test-util/src/main/java/no/maddin/niofs/testutil/BasicTestContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package no.maddin.niofs.testutil; | ||
|
||
import org.testcontainers.lifecycle.Startable; | ||
|
||
import java.net.URI; | ||
|
||
public interface BasicTestContainer extends Startable { | ||
URI getBaseUri(String protocol); | ||
} |
Oops, something went wrong.