Hi,

Have you got any further with this? I am suffering from the same problem.

________________________________________
From: Jeff Segal <jeffrey.se...@gmail.com>
Sent: 12 April 2016 16:46
To: users@camel.apache.org
Subject: camel-spring-boot + @UseAdviceWith

All,

I'm currently creating a camel-spring-boot project and would like to add
some tests using @UseAdviceWith but am hitting a few issues. I couldn't
find an example that fit that use case exactly, so I've played around with
different things to no avail.

Specifically, I found that when I use @ContextConfiguration to specify my
main Spring app config, my use of
@BootstrapWith(CamelTestContextBootstrapper.class) is honored (i.e. I can
step through it in a debugger during startup) and I can see @UseAdviceWith
being used in CamelSpringTestContextLoader.handleCamelContextStartup().
However, when I @Autowire my CamelContext into my test class, Spring
startup fails because it can't find my CamelContext Spring bean (even when
I explicitly include a @Configuration that extends CamelConfiguration,
which explicitly creates a CamelContext @Bean). I need a reference to my
CamelContext so that I can start it once I'm done setting up my routeWith
advice.

One last thing: when I use @SpringApplicationConfiguration instead of
@ContextConfiguration, Spring is able to find the CamelContext bean but it
ignores my @BootstrapWith(CamelTestContextBootstrapper.class) &
@UseAdviceWith and thus just starts up the CamelContext automatically
rather than waiting for me to start it manually (after my routeWith
advice).

Any pointers on what I might be doing wrong would be great. In summary:

Honoring @UseAdviceWith but no CamelContext Spring bean:

@ContextConfiguration(classes = {ApplicationConfig.class})
@RunWith(CamelSpringJUnit4ClassRunner.class)
@BootstrapWith(CamelTestContextBootstrapper.class)
@UseAdviceWith
@Slf4j
public class MyTest {

    @Autowired
    CamelContext camelContext;

    @Test
    public void test() throws InterruptedException {
        log.info("Starting test...");
        Thread.sleep(1000 * 60);
    }

}

Have a CamelContext Spring bean but NOT honoring @UseAdviceWith:

@SpringApplicationConfiguration(classes = {ApplicationConfig.class})
@RunWith(CamelSpringJUnit4ClassRunner.class)
@BootstrapWith(CamelTestContextBootstrapper.class)
@UseAdviceWith
@Slf4j
public class MyTest {

    @Autowired
    CamelContext camelContext;

    @Test
    public void test() throws InterruptedException {
        log.info("Starting test...");
        Thread.sleep(1000 * 60);
    }

}

Thanks!
Jeff
This email is confidential and may be privileged. If you are not the intended 
recipient, please notify the sender immediately and delete the email from your 
computer. You should not copy the email, use it for any purpose or disclose its 
contents to any other person. Please note that any views or opinions presented 
in this email may be personal to the author and do not necessarily represent 
the views or opinions of MetaPack. It is the responsibility of the recipient to 
check this email for the presence of viruses. MetaPack accepts no liability for 
any damage caused by any virus transmitted by this email. MetaPack Registered 
Office: 4th Floor, 200 Gray’s Inn Road London WC1X 8XZ. Registered in England 
No. 03870530. VAT No 945 7723 86.

Reply via email to