mardi 11 juin 2019

Using the citrus-framework FTP support with Scala

I'm playing around with the citrus-framework in Scala. My first goal is to define a basic test that uses the FTP client. The test class that uses this FTP client is:

@ExtendWith(value = Array(classOf[CitrusExtension]))
class CitrusFtpExample extends Matchers {

  @BeanProperty
  @Autowired
  val ftpClient : FtpClient = null

  @Test
  @CitrusTest
  def runFtpConnectionTest(@CitrusResource runner: TestRunner): Unit = {
    runner.send(SendMessageBuilder => SendMessageBuilder
      .endpoint(ftpClient)
      .message(FtpMessage.command(FTPCmd.MKD).arguments("todo")))
  }

The class used to configure the required FTP client is:

@Configuration
class EndpointConfig {

  @Bean
  def getFtpClient: FtpClient = {
    CitrusEndpoints.ftp()
      .client()
      .port(22222)
      .username("anonymous")
      .timeout(10000L)
      .build()
  }
}

During execution, the used runner fails in sending the defined message because the defined FtpClient endpoint is not set properly:

com.consol.citrus.exceptions.TestCaseFailedException: Neither endpoint nor endpoint uri is set properly!

I think there is a problem with properly injecting the required FtpClient. However I cannot figure out the exact problem.

Aucun commentaire:

Enregistrer un commentaire