My RouteBuilder classes have parametrised constructors, there is no default constructor. If I understand correctly, with CamelTestSupport I have to get away without all the Spring magic. I will keep this in mind in case I will reach dead end with the other solution.
Kind regards, Jan > -----Original Message----- > From: Steve Huston <shus...@riverace.com> > Sent: Monday, January 27, 2025 4:03 PM > To: users@camel.apache.org > Subject: RE: Testing with JUnit Spring Boot > > If you want to test a route(s) in isolation then, yes, you can avoid the > Spring tricks > and create the config yourself. Or load it in something like @TestProperty. > For > creating the route classes I do something like this: > > public class SteveRouteTest extends CamelTestSupport { > > @Override > protected RouteBuilder[] createRouteBuilders() { > return new RouteBuilder[] { > context.getInjector().newInstance(MyRoutes.class) > }; > } > > } > > > -----Original Message----- > > From: Jan Bares, WOOD & Co. <jan.ba...@wood.cz.INVALID> > > Sent: Monday, January 27, 2025 9:51 AM > > To: users@camel.apache.org > > Subject: RE: Testing with JUnit Spring Boot > > > > Thank you. But without @SpringBootTest how should I code my > > createRouteBuilder() method? I need to reuse my RouteXYBuilder class. This > > class is created by Spring DI. Or do I have to create all the configuration > > beans > > manually without Spring? > > > > Thanks, Jan > > > > > -----Original Message----- > > > From: Steve Huston <shus...@riverace.com> > > > Sent: Monday, January 27, 2025 3:32 PM > > > To: users@camel.apache.org > > > Subject: RE: Testing with JUnit Spring Boot > > > > > > Hi Jan, > > > > > > At a high level, take away the @CamelSpringBootTest and > > > @SpringBootTest; those are what is causing the whole test context and > > route set to load and start. > > > Change your RouteXYTest class to extend from CamelTestSupport > > > > > > > > https://url.emailprotection.link/?bi9ZSg2pX0C7Y504_kvP1Avxf9m9db8B8PE > > T > > > > > N6spbH9byAw6gEFbneE96szuWNaBUWY3ClQl_kVyr2Ask_5Mw5g_4APVDzn > > P0TwwYbVTXe > > > PAQJcm_B35_SHg3Lw-sDAnZ > > > > > > -Steve > > > > > > > -----Original Message----- > > > > From: Jan Bares, WOOD & Co. <jan.ba...@wood.cz.INVALID> > > > > Sent: Monday, January 27, 2025 9:18 AM > > > > To: users@camel.apache.org > > > > Subject: Testing with JUnit Spring Boot > > > > > > > > Hi, > > > > > > > > I need some help or at least pointer to samples on how to write > > > > JUnit tests for Camel 4.6 Spring Boot application. I don't know how > > > > to test single route in isolation without starting all the other > > > > (autostarted) > > routes. > > > > > > > > Our application has many routes that look like this > > > > > > > > @Configuration > > > > @Component > > > > @PropertySource("classpath:application.properties") > > > > @ConfigurationProperties(prefix = "xy-endpt") public class > > > > RouteXYConfig { .... > > > > } > > > > > > > > > > > > @Component > > > > public class RouteXYBuilder extends RouteBuilder { > > > > .... > > > > private final RouteXYConfig routeXYConfig; > > > > > > > > public RouteXYBuilder(RouteXYConfig routeXYConfig) { > > > > this. routeXYConfig = routeXYConfig; > > > > } > > > > > > > > @Override > > > > public void configure() { > > > > from(routeXYConfig.buildIncomingEndpoint())..... > > > > > > > > // add internal Direct routes > > > > } > > > > } > > > > > > > > I want to test each route in isolation, I have a test prototype like > > > > this: > > > > > > > > @CamelSpringBootTest > > > > @SpringBootTest(classes = Application.class) @DirtiesContext > > > > @UseAdviceWith public class RouteXYTest { > > > > @Test > > > > public void testRoute() throws Exception { > > > > // advice routeXY with mock > > > > > > > > camelConext.start(); > > > > > > > > ..... > > > > } > > > > } > > > > > > > > The prototype works but when I run camelContext.start() all the > > > > other routes are also started. I want to test single routeXY in > > > > isolation. I am not sure how can I achieve this. > > > > > > > > Kind regards, Jan > > > > > > > > > > > > > > > > > > > > > > > > ________________________________ > > > > DISCLAIMER > > > > WOOD & Company Financial Services, a.s. is authorized and regulated > > > > by the Czech National Bank as its Home State Regulator and by > > > > relevant local regulatory authorities in the jurisdictions where it > > > > operates. For further information about WOOD & Co., its investment > > > > services, financial instruments and associated risks, safeguard > > > > client assets (incl. compensation schemes) and contractual > > > > relationship please see our website at > > > > https://url.emailprotection.link/?bI6_Ebm9JZGGZD6fSwcual8JtOvB- > > AO5kT > > > > > > 8SRPcAvCyYgb1UYvmvpuUi36lfC56KiB7ToHYlrHOQNx4ZrGiqBbeNb4uu0MGz > > 6kRl6i > > > > kAUbu54eMBtBmo6zcu4qqCzF_Gbq8jwq3FOBS0DO94w84Fot_dzJ- > > VjXkwXNPPi_SVWJ > > > > 54~ > > > > OomE_slOtZrtEowu3qps62OL4qoWUIaV7_xQsWG3Fl- > > > > > > dCxO4nSA~~<https://url.emailprotection.link/?bI6_Ebm9JZGGZD6fSwcual8 > > > > JtOvB-AO5kT8SRPcAvCybi2XeqyGXTpmne_MxJ1VQe4L4H8J2R- > > DCCjowghArilWrkCR > > > > VD8Dy-Qu5BFctoOZf2tbIuMbeBedt5OXawahts > > > > R6V_lY6QtD_x6_bSzqWxSgygrxgD_JmDvaoagpMzsH98BA8KopHAux- > > > > ui7CIULQ~~>. Unless otherwise stated, this transmission is neither > > > > an offer nor the solicitation of an offer to sell or purchase any > > > > investment. All estimates, opinions and other information contained > > > > herein are subject to change without notice and are provided in good > > > > faith but without legal responsibility or liability. Opinion may be > > > > personal to the author and may not reflect the opinions of WOOD & > > > > Co. Communications from sales persons, sales traders or traders > > > > should not be regarded as investment research and may contain > > > > opinions or trading ideas which are different from WOOD & Co. > > > > investment research opinions. This e-mail and any attachments are > > > > confidential and may be privileged or otherwise protected from > > > > disclosure. If you are not a named addressee you must not use, > > > > disclose, distribute, copy, print or rely on this e- mail and any of > > > > its attachments. Please notify the sender that you have received > > > > this email by mistake by replying to the email, and then delete the > > > > email > > and any copies of it. Although WOOD & Co. routinely screens e-mails for > > viruses, addressees should scan this e-mail and any attachments for viruses. > > > > WOOD & Co. makes no representation or warranty as to the absence of > > > > viruses in this e-mail or any attachments. Please note that to > > > > ensure regulatory compliance and for the protection of our clients > > > > and business, we may monitor and read e-mails sent to and from our > > server(s). > > > > > > > > > > > > ________________________________ > > DISCLAIMER > > WOOD & Company Financial Services, a.s. is authorized and regulated by the > > Czech National Bank as its Home State Regulator and by relevant local > > regulatory authorities in the jurisdictions where it operates. For further > > information about WOOD & Co., its investment services, financial instruments > > and associated risks, safeguard client assets (incl. compensation schemes) > > and > > contractual relationship please see our website at > > https://url.emailprotection.link/?bLf6lI8IO4nr8mLy7La_SRm2gg78Z9wdK2VE > > OomE_slOtZrtEowu3qps62OL4qoWUIaV7_xQsWG3Fl- > > dCxO4nSA~~<https://url.emailprotection.link/?bvYo4x2HM_flZb8rRyDo6KRo > > R6V_lY6QtD_x6_bSzqWxSgygrxgD_JmDvaoagpMzsH98BA8KopHAux- > > ui7CIULQ~~>. Unless otherwise stated, this transmission is neither an offer > > nor > > the solicitation of an offer to sell or purchase any investment. All > > estimates, > > opinions and other information contained herein are subject to change > > without notice and are provided in good faith but without legal > > responsibility > > or liability. Opinion may be personal to the author and may not reflect the > > opinions of WOOD & Co. Communications from sales persons, sales traders or > > traders should not be regarded as investment research and may contain > > opinions or trading ideas which are different from WOOD & Co. investment > > research opinions. This e-mail and any attachments are confidential and may > > be privileged or otherwise protected from disclosure. If you are not a named > > addressee you must not use, disclose, distribute, copy, print or rely on > > this e- > > mail and any of its attachments. Please notify the sender that you have > > received this email by mistake by replying to the email, and then delete the > > email and any copies of it. Although WOOD & Co. routinely screens e-mails > > for > > viruses, addressees should scan this e-mail and any attachments for viruses. > > WOOD & Co. makes no representation or warranty as to the absence of > > viruses in this e-mail or any attachments. Please note that to ensure > > regulatory > > compliance and for the protection of our clients and business, we may > > monitor and read e-mails sent to and from our server(s). ________________________________ DISCLAIMER WOOD & Company Financial Services, a.s. is authorized and regulated by the Czech National Bank as its Home State Regulator and by relevant local regulatory authorities in the jurisdictions where it operates. For further information about WOOD & Co., its investment services, financial instruments and associated risks, safeguard client assets (incl. compensation schemes) and contractual relationship please see our website at www.wood.com<http://www.wood.com/>. Unless otherwise stated, this transmission is neither an offer nor the solicitation of an offer to sell or purchase any investment. All estimates, opinions and other information contained herein are subject to change without notice and are provided in good faith but without legal responsibility or liability. Opinion may be personal to the author and may not reflect the opinions of WOOD & Co. Communications from sales persons, sales traders or traders should not be regarded as investment research and may contain opinions or trading ideas which are different from WOOD & Co. investment research opinions. This e-mail and any attachments are confidential and may be privileged or otherwise protected from disclosure. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail and any of its attachments. Please notify the sender that you have received this email by mistake by replying to the email, and then delete the email and any copies of it. Although WOOD & Co. routinely screens e-mails for viruses, addressees should scan this e-mail and any attachments for viruses. WOOD & Co. makes no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our server(s).