Skip to content

CAMEL-22891: refactoring IT using JUnit#1677

Merged
Croway merged 1 commit intoapache:mainfrom
mcarlett:CAMEL-22891
Feb 25, 2026
Merged

CAMEL-22891: refactoring IT using JUnit#1677
Croway merged 1 commit intoapache:mainfrom
mcarlett:CAMEL-22891

Conversation

@mcarlett
Copy link
Contributor

Refactors completely the integration tests moving from arquillian to junit, instead of creating the application to test at runtime using shrinkwrap, it uses the maven archetype. Following a part of the included readme file, to overview the steps of each test

. Archetype generation -- The ArchetypeGenerationExtension JUnit 6 extension generates a minimal Spring Boot project from camel-archetype-spring-boot. The generated project is then customized: test-scoped dependencies and the demo camel-stream-starter are removed, the starter under test is added, and any extra dependencies or application.properties entries from the test config are applied.
. Compilation -- The generated project is compiled via mvn compile dependency:build-classpath, which also writes the full runtime classpath to a file for the next step.
. Classloader isolation -- A child URLClassLoader is created with the compiled classes and all resolved dependency JARs, parented by the test classloader. Only camel-api and spring-context live on the parent classloader so that assertion types (CamelContext, Component, DataFormat, Language, CamelClusterService) are shared.
. Spring Boot startup -- SpringApplication is loaded from the child classloader and started via reflection. A DefaultResourceLoader pointing at the child classloader ensures the generated project's application.properties is picked up. By default, the embedded web server is disabled (spring.main.web-application-type=none). When webRequired is set to true, the web stack is kept and the server binds to a random port (server.port=0) to avoid conflicts during parallel execution.

@Croway
Copy link
Contributor

Croway commented Feb 25, 2026

please move the non test classes under src/main like it was before


== Adding a new starter test

For most starters, create a class with no body:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there some automation that create ITs? I remember I saw something in the past, some .sh but I might be wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is not an automation currently, but this is useful to start implementing new tests, so I added a maven execution that is more portable than a bash script

mvn -Pgenerate -Dstarter=my-component -pl tests/camel-itest-spring-boot

@mcarlett
Copy link
Contributor Author

please move the non test classes under src/main like it was before

done

@Croway
Copy link
Contributor

Croway commented Feb 25, 2026

merging, let's check https://ci-builds.apache.org/job/Camel/job/Camel-Spring-Boot%20Daily%20JDK17/ tomorrow

@Croway Croway merged commit f32e3a2 into apache:main Feb 25, 2026
3 checks passed
@mcarlett mcarlett deleted the CAMEL-22891 branch February 26, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants