camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Willem Jiang (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (CAMEL-5494) Camel's JavaConfigContextLoader class lacks support for Camel's testing annotations
Date Thu, 30 Aug 2012 03:36:08 GMT

     [ https://issues.apache.org/jira/browse/CAMEL-5494?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Willem Jiang resolved CAMEL-5494.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 2.11.0

Applied the patch into trunk with thanks to Joshua.
                
> Camel's JavaConfigContextLoader class lacks support for Camel's testing annotations
> -----------------------------------------------------------------------------------
>
>                 Key: CAMEL-5494
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5494
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-spring
>    Affects Versions: 2.10.0
>            Reporter: Joshua Ecklund
>            Assignee: Willem Jiang
>              Labels: annotations, javaconfig, mocks, spring, test
>             Fix For: 2.11.0
>
>         Attachments: CamelSpringDelegatingTestContextLoader.java, TestCamelSpringDelegatingTestContextLoader.java
>
>
> While implementing a Camel route in a new project which uses Spring's JavaConfig I ran
into some issues with tests I had written.
> Originally I implemented the tests using the old XML-based appContext, then once I had
everything working I started converting it all to JavaConfig.  After some research, I found
that to do this I had to use
> {code:java}
> @ContextConfiguration(
>         locations = {"blah.EsbConfig", ... },
>         loader = JavaConfigContextLoader.class
> )
> {code}
> Which was fine, except it completely broke the functionality of the @MockEndpoints annotation
on my tests.  I tried adding a org.apache.camel.impl.InterceptSendToMockEndpointStrategy bean
to my JavaConfig context, but that didn't change anything.  To fix it I ended up making a
new (Smart)ContextLoader called CamelSpringDelegatingTestContextLoader, which extends Spring's
DelegatingSmartContextLoader and is based on CamelSpringTestContextLoader.  It handles both
XML and JavaConfig style Spring configuration, and so far seems to have fixed everything.
 
> You must use CamelSpringJUnit4ClassRunner for this to work, and change @ContextConfiguration's
"locations" to "classes" (and specify them as Class instances). See example below.
> {code:java}
> @RunWith(CamelSpringJUnit4ClassRunner.class)
> @ContextConfiguration(
>         classes = {TestCamelSpringDelegatingTestContextLoader.TestConfig.class},
>         loader = CamelSpringDelegatingTestContextLoader.class
> )
> @MockEndpoints
> public class TestSomethingWithCamel { ... }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message