Hi, Did you import in your pom.xml *camel-test-infra-ftp *with type* test-jar? *The test jar contains both main and test classes https://github.com/apache/camel-spring-boot/blob/main/components-starter/camel-ftp-starter/pom.xml#L54-L60
Moreover, in *camel-spring-boot* repository there are some tests that use *camel-test-infra-ftp* https://github.com/apache/camel-spring-boot/tree/main/components-starter/camel-ftp-starter/src/test. Maybe you can find something interesting there. Regards, Federico Il giorno mar 3 giu 2025 alle ore 12:24 <med...@volny.cz> ha scritto: > Hello, > > I would like to use Camel Infrastructure for my Spring Boot Camel > End-to-End tests. > > II have spent quite some time investigating how it works. Unfortunately > the documentation is very limited and I was not able to find any examples > either. > > I started with a very simple scenario -> one route from FTP to file. After > couple of hours I was able to come to following test that works. > > @SpringBootTest > @Import({ FtpServiceTestConfig.class, Process1TestRoutes.class}) > @TestPropertySource("classpath:application-e2e.yaml") > @TestInstance(TestInstance.Lifecycle.PER_CLASS) > @ActiveProfiles("e2e") > public class Process1E2ETest { > @Autowired > CamelContext camelContext; > > @RegisterExtension > static FtpService ftpService = > FtpServiceFactory.createEmbeddedService(); > > @Test > void shouldTransferFileFromInputToOutput() throws Exception { > > // Create the route after FTP server is initialized > camelContext.addRoutes(new RouteBuilder() { > @Override > public void configure() { > from("ftp://" + ftpService.hostname() + ":" + > ftpService.port() + "/" + ftpService.directoryName() > + "?username=" + ftpService.username() > + "&password=" + ftpService.password() > + "&delete=true&delay=1000") > .to("file:target/out") > .log("Received: ${file:name}"); > } > }); > > // Ensure target directory exists > Files.createDirectories(Path.of("target/out")); > > // Create input file in the correct FTP directory > Path ftpRootDir = ftpService.getFtpRootDir(); > Path ftpInputDir = ftpRootDir.resolve(ftpService.directoryName()); > Files.createDirectories(ftpInputDir); > Path inputFile = ftpInputDir.resolve("test.txt"); > Files.writeString(inputFile, "Hello from test", > StandardOpenOption.CREATE); > > System.out.println("Created file at: " + > inputFile.toAbsolutePath()); > > // Wait longer for Camel route to process the file > Thread.sleep(5000); > > Path outputFile = Path.of("target/out/test.txt"); > assertTrue(Files.exists(outputFile), "Output file should exist at > " + outputFile.toAbsolutePath()); > String content = Files.readString(outputFile); > assertEquals("Hello from test", content); > } > } > > I had to copy FtpService and FtpServiceFactory with their dependencies > from Camel Github Repository ( > https://github.com/apache/camel/tree/camel-4.12.x/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services) > as they are not included in maven dependency jar. I am using Apache Camel > 4.12.0 > > I do not like the solution much as it creates the route only inside the > test that is kind of ugly. If I try to create it in @TestConfiguration or > even @BeforeAll the troube is that the FTP server is not initalized yet and > ftpService.port() is 0 at that time. > > Can anyone explain me how it is meant to be used and/or provide some > example? > > Regards > > Jiří >