|
@Testcontainers |
|
@SpringBootTest(classes = [FtpConfiguration::class]) |
|
@Disabled("some Permissions issue under Docker Desktop/Windows 10; also, mapping fixed ports could not possibly work in all situations") |
|
class FtpIntTest { |
|
@Autowired |
|
lateinit var ftpFilePublisher: FtpFilePublisher |
|
|
|
companion object { |
|
|
|
val logger = LoggerFactory.getLogger(FtpIntTest::class.java) |
|
|
|
@Container |
|
private val ftpContainer = GenericContainer<GenericContainer<*>>(DockerImageName.parse("panubo/vsftpd:latest")) |
|
.withEnv("FTP_USER", "guest") |
|
.withEnv("FTP_PASSWORD", "guest") |
|
.withFileSystemBind("C:\\temp", "/srv", BindMode.READ_WRITE) |
|
.withCreateContainerCmdModifier { |
|
it.withHostConfig( |
|
HostConfig.newHostConfig() |
|
.withPortBindings(Arrays.asList( |
|
PortBinding.parse("21:21"), |
|
PortBinding.parse("4559:4559"), |
|
PortBinding.parse("4560:4560"), |
|
PortBinding.parse("4561:4561"), |
|
PortBinding.parse("4562:4562"), |
|
PortBinding.parse("4563:4563"), |
|
PortBinding.parse("4564:4564"), |
|
)) |
|
) |
|
} |
|
|
|
val logConsumer = Slf4jLogConsumer(logger) |
|
|
|
@DynamicPropertySource |
|
@JvmStatic |
|
fun registerDynamicProperties(registry: DynamicPropertyRegistry) { |
|
registry.add("export.ftp.hostname", ftpContainer::getContainerIpAddress) |
|
registry.add("export.ftp.port") { ftpContainer.getMappedPort(21) } |
|
registry.add("export.ftp.username") { "guest" } |
|
registry.add("export.ftp.password") { "guest" } |
|
logger.info("hostname {} port {}", ftpContainer.getContainerIpAddress(), ftpContainer.getMappedPort(21)) |
|
ftpContainer.followOutput(logConsumer) |
|
} |
|
} |
|
|
|
@Test |
|
fun `can publish the file`() { |
|
val inputStream = ByteArrayInputStream("my-file".toByteArray()) |
|
ftpFilePublisher.publishFile("","test", inputStream) |
|
} |
|
|
|
} |