Hi Damien,

In your test you need specify the configuration your Camel context is supposed 
to use. This is how we're setting it up:

@Override
protected AbstractApplicationContext createApplicationContext() {

                AbstractApplicationContext applicationContext = new  
AnnotationConfigApplicationContext(RestTestConfiguration.class, 
SomeRouteBuilder.class, RepoFactory4Test.class);
                return applicationContext;
        }

In your case the bean you're looking for - WorkflowRepository, also needs to be 
specified there. Whether you do it directly like SomeRouteBuilder above or via 
a @Configuration class like the above RestTestConfiguration and 
RepoFactory4Test classes is entirely up to you. The Spring's 
ContextConfiguration class might also work there if you specify the 
WorkflowRepository configuration on/in it.
We keep all the common beans that all tests need in the @Configuration classes 
and the test specific one's are then passed in directly in each test case.
While I'm not 100% certain it's the best or the most correct way of doing 
things it's been working very reliably so far for us.

Regards,
Valdis

-----Original Message-----
From: Damien Nicolas [mailto:dmn.nico...@gmail.com] 
Sent: 01 October 2018 10:20
To: users@camel.apache.org
Subject: Re: Integration tests with Spring annotations

Thanks for you reply!

Here its a sample of my test configuration: 
https://scanmail.trustwave.com/?c=6600&d=zvKx2wzOXtG5KKdFoKiUVWe72PAV8oVAvVCznBIPMw&s=33&u=https%3a%2f%2fpastebin%2ecom%2f7C82BLGT

but I always get the exception:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type
'com.camel.database.repositories.WorkflowRepository' available: expected at 
least 1 bean which qualifies as autowire candidate. Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true)}


Le lun. 1 oct. 2018 à 09:59, Valdis Andersons <valdis.anders...@vhi.ie> a écrit 
:

> Hi Damien,
>
> We use Spring annotations in our integrations quite a lot and it's 
> working rather well for us. In order to invoke the RouteBuilder 
> instance we just provide a class name for it in the ApplicationContext 
> of the test createApplicationContext method and then use a test 
> configuration file to specify the endpoints for it. Then we send 
> various messages to the endpoints and assert the results when consuming from 
> the output endpoints.
> What is you test setup, maybe you can provide a small sample to 
> illustrate the issue you're facing?
>
> Regards,
> Valdis
>
> -----Original Message-----
> From: Damien Nicolas [mailto:dmn.nico...@gmail.com]
> Sent: 30 September 2018 19:15
> To: users@camel.apache.org
> Subject: Integration tests with Spring annotations
>
> Hello,
>
> I am using CamelSpringTestSupport for an integration test with 
> Springboot, but I cannot use the annotation as mentionned here < 
> http://scanmail.trustwave.com/?c=6600&d=zvKx2wzOXtG5KKdFoKiUVWe72PAV8oVAvVO1yh9YZw&s=33&u=http%3a%2f%2fcamel%2eapache%2eorg%2fspring-testing%2ehtml>.
> I need to use "@Autowired"
> cause I am generating routes dynamically from a database.
> Is there a way to use Spring annotations but with the advantages of 
> CamelSpringTestSupport (by using createRouteBuilder())?
>
>
> --
> Damien NICOLAS
>
> Vhi Group DAC (Vhi) is a holding company for insurance and healthcare 
> services, which include Vhi Healthcare DAC, Vhi Insurance DAC, Vhi 
> Health Services DAC and Vhi Investments DAC. Vhi Healthcare DAC 
> trading as Vhi Healthcare and Vhi Insurance DAC trading as Vhi 
> Insurance are regulated by the Central Bank of Ireland. Vhi Healthcare 
> is tied to Vhi Insurance DAC for health insurance in Ireland which is 
> underwritten by Vhi Insurance DAC.
> Vhi Healthcare is tied to Zurich Life Assurance plc for Vhi Life Term 
> Insurance and Vhi Mortgage Protection which is underwritten by Zurich 
> Life Assurance plc. Vhi Healthcare is tied to Collinson Insurance 
> Services Limited for MultiTrip Travel Insurance, Backpacker Travel 
> Insurance and Vhi Dental Insurance which are underwritten by Great 
> Lakes Insurance SE, UK branch and for Vhi Canada Cover and Vhi 
> International Health Insurance which are underwritten by Astrenska 
> Insurance Limited. For more information about the Vhi Group please go 
> to: 
> https://scanmail.trustwave.com/?c=6600&d=zvKx2wzOXtG5KKdFoKiUVWe72PAV8
> oVAvVe0yRENYw&s=33&u=https%3a%2f%2fwww%2evhi%2eie%2fabout-vhi
>
>
> Tá Vhi Group DAC (Vhi) ina chuideachta sealbhaíochta le haghaidh 
> seirbhísí árachais agus seirbhísí cúram sláinte, lena n-áirítear Vhi 
> Healthcare DAC, Vhi Insurance DAC, Vhi Health Services DAC agus Vhi 
> Investments DAC.
> Déanann Banc Ceannais na hÉireann rialáil ar Vhi Healthcare DAC, ag 
> trádáil dó mar Vhi Healthcare, agus ar Vhi Insurance DAC, ag trádáil 
> dó mar Vhi Insurance. Tá Vhi Healthcare ceangailte le Vhi Insurance 
> DAC le haghaidh árachas sláinte in Éirinn, rud atá frithgheallta ag 
> Vhi Insurance DAC. Tá Vhi Healthcare ceangailte le Zurich Life 
> Assurance plc le haghaidh Árachais Saoil de chuid Vhi agus Árachas 
> Cosanta Morgáiste de chuid Vhi atá frithgheallta ag Zurich Life 
> Assurance plc. Tá Vhi Healthcare ceangailte le Collinson Insurance 
> Services Limited le haghaidh Árachas Taistil Ilturais agus Turasóirí 
> Mála Droma agus Árachas Fiaclóireachta de chuid Vhi atá frithgheallta 
> ag Great Lakes Insurance SE, UK branch agus le haghaidh Clúdach 
> Cheanada de chuid Vhi agus Árachas Sláinte Idirnáisiúnta de chuid Vhi 
> atá frithgheallta ag Astrenska Insurance Limited. Chun tuilleadh faisnéise a 
> fháil faoi Ghrúpa Vhi, tabhair cuairt ar:
> https://scanmail.trustwave.com/?c=6600&d=zvKx2wzOXtG5KKdFoKiUVWe72PAV8
> oVAvVe0yRENYw&s=33&u=https%3a%2f%2fwww%2evhi%2eie%2fabout-vhi
>
> This e-mail and any files transmitted with it contain information 
> which may be confidential and which may also be privileged and is 
> intended solely for the use of the individual or entity to whom it is 
> addressed. Unless you are the intended recipient you may not copy or 
> use it, or disclose it to anyone else. Any opinions expressed are that 
> of the individual and not necessarily that of the Vhi Group. If you 
> have received this e-mail in error please notify the sender by return.
>
>
>
>
>
>
>

--
Damien NICOLAS

Reply via email to