camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Karlsen <davidkarl...@gmail.com>
Subject Re: Use @RunWith(CamelSpringJUnit4ClassRunner.class) & @UseAdviceWith + find Mocks after starting camel context
Date Tue, 30 Oct 2012 16:33:32 GMT
Yes. This is possible and how we test in my shop. You can also disable jmx
for the test with @disableJmx which also adds value.
Have a nice Camel ride.
Den 30. okt. 2012 16:12 skrev "Cyril Lakech" <cyril.lakech@adeoservices.com>
følgende:

> Hi,
>
> I would like to use 3 excellent camel features together in my test:
>
> @RunWith(CamelSpringJUnit4ClassRunner.class) to use my spring config
>
> @UseAdviceWith to be able to change the behavior of a few endpoints dealing
> with remote http APIs
>
> And we would be able to retrieve mocks of other endpoints to test of
> course.
>
> Here is a sample :
>
> @RunWith(CamelSpringJUnit4ClassRunner.class)
> @UseAdviceWith
> public class PriceRouteBuilderTest {
>
>         //given
>
>
>
> camelContext.getRouteDefinition("direct:in/prices").adviceWith(camelContext,
> new AdviceWithRouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 mockEndpoints();
>                 includeRoutes(new MyExtraRoute());
>
> weaveById("direct:pointsOfSale").replace().to("direct:posTest");
>             }
>         });
>         // we must manually start when we are done with all the advice with
>         camelContext.start();
>
>         //pointsOfSale.expectedBodiesReceived("TEST");
>
>         //when
>         inPrice.sendBody("TEST");
>
>         //then
>         MockEndpoint.assertIsSatisfied(camelContext);
>
> }
>
> Is it possible or not ?
>
> If not, what are your advice to do it ?
>
> Regards,
>
> Cyril Lakech
>
> --
> Ce message et toutes les pièces jointes sont établis à l'attention
> exclusive de leurs destinataires et sont confidentiels. Si vous recevez ce
> message par erreur, merci de le détruire et d'en avertir immédiatement
> l'expéditeur. L'internet ne permettant pas d'assurer l'intégrité de ce
> message, le contenu de ce message ne représente en aucun cas un engagement
> de la part de GROUPE ADEO.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message