title: Using Citrus to mock SFTP and Kafka for Integration Testing Spring-Boot apache-camel xml based routes?
body: <p>I am working with a Spring Boot application that was written using Apache Camel spring-xml routes. There is very little java based application logic, and it is nearly entirely written in xml and based on the various camel routes. </p>
  
  <p>The routes are configured to connect to the different environments and systems through property files, using a property such as <code>KAFKA_URL and KAFKA_PORT</code>. Inside one of the implemented routes, the application connects with the following and consumes/produces messages to it:</p>
  
  <pre><code>&lt;to id="route_id_replaced_for_question" uri="kafka:{{env:KAFKA_URL:{{KAFKA_URL}}}}:{{env:KAFKA_PORT:{{KAFKA_PORT}}}}?topic={{env:KAFKA_TOPIC:{{topic_to_connect_to}}}}&amp;amp;kerberosRenewJitter=1&amp;amp;kerberosRenewWindowFactor=1&amp;amp;{{kafka.ssl.props}}&amp;amp;{{kafka.encryption.props}}"/&gt;
  </code></pre>
  
  <p>Additionally, we connect to an SFTP server, which I am also trying to mock using Citrus. That follows a similar pattern where: </p>
  
  <pre><code>&lt;from id="_requestFile" uri="{{env:FTP_URL:{{FTP_URL}}}}:{{env:FTP_PORT:{{FTP_PORT}}}}/{{env:FTP_FILE_DIR:{{FTP_FILE_DIR}}}}/?delete=true&amp;amp;fileExist=Append&amp;amp;password={{env:FTP_PASSWORD:{{FTP_PASSWORD}}}}&amp;amp;delay={{env:FTP_POLL_DELAY:{{FTP_POLL_DELAY}}}}&amp;amp;username={{env:FTP_USER:{{FTP_USER}}}}"/&gt;
  </code></pre>
  
  <p>Inside of my integration test, I have configured a Citrus' EmbeddedKafkaServer class with the following:</p>
  
  <pre><code> @Bean
      public EmbeddedKafkaServer embeddedKafkaServer() {
          return new EmbeddedKafkaServerBuilder()
                  .kafkaServerPort(9092)
                  .topics("topic_to_connect_to")
                  .build();
      }
  </code></pre>
  
  <p>and a Citrus FTP server with:</p>
  
  <pre><code>    @Bean
      public SftpServer sftpServer() {
          return CitrusEndpoints.sftp()
                  .server()
                  .port(2222)
                  .autoStart(true)
                  .user("username")
                  .password("passwordtoconnectwith")
                  .userHomePath("filedirectory/filestoreadfrom")
                  .build();
      }
  </code></pre>
  
  <p>Ideally, my test will connect to the mock sftp server, and I will push a file to the appropriate directory using Citrus, which my application will then read in, process, and publish to a topic on the embedded kafka cluster and verify in the test. </p>
  
  <p>I was under the impression that I would set <code>KAFKA_PORT</code> to 9092 and <code>KAFKA_URL</code> to localhost, as well as <code>FTP_URL</code> to localhost and <code>FTP_PORT</code> to 2222 (amongst the other properties needed) inside of my properties file, but that does not seem to connect me to the embedded cluster or sftp servers..</p>
  
  <p>What piece of the puzzle am I missing to have my spring boot application connect to both of these mocked instances and run its' business logic processing from there? </p>