Hi,

I've got a pretty simple Blueprint Camel route, e.g.

<blueprint>
<Code omitted for brevity>
<camelContext id="blueprintContext"
xmlns="http://camel.apache.org/schema/blueprint";>
        <template id="producerTemplate" />
        
        <route id="myRoute">
                <from uri="fabric:key:queue" />
                <split parallelProcessing="true">
                        <simple>${body.getMyRequest}</simple>
                        <log message="Single My Request is ${body}"/>
                        <to uri="direct:processMyRequest" />
                </split>
        </route>
</camelContext>
</blueprint>

When deployed into a Fuse ESB Fabric messages route correctly. Like a good
developer, I've written a route test (which extends
CamelBlueprintTestSupport), e.g.

public class MyRouteTest extends CamelBlueprintTestSupport {
        private static final String MESSAGE = "Some message";

        @Produce
        protected ProducerTemplate producerTemplate;

        @Test
        public void messageSuccessfullyRouted() throws Exception {
                getMockEndpoint(MOCK_TO_QUEUE).expectedMessageCount(1);
                producerTemplate.requestBody("fabric:key:queue", MESSAGE);
                assertMockEndpointsSatisfied();
        }

        @Override
        protected String getBlueprintDescriptor() {
                return "/OSGI-INF/blueprint/blueprint.xml";
        }

        // Code omitted for brevity
}

Now, running the test (as part of my maven build) occasionally gives me a
NoSuchBeanException:

org.apache.camel.NoSuchBeanException: Found bean: producerTemplate in
BlueprintContainer:
org.apache.aries.blueprint.container.BlueprintContainerImpl@67ae0c6e of
type: org.apache.camel.impl.DefaultProducerTemplate expected type was:
interface org.apache.camel.Endpoint
        at java.lang.Class.cast(Class.java:3005)
        at
org.apache.camel.blueprint.BlueprintContainerRegistry.lookup(BlueprintContainerRegistry.java:58)
        at
org.apache.camel.impl.CompositeRegistry.lookup(CompositeRegistry.java:49)
        at
org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:62)
        at
org.apache.camel.util.CamelContextHelper.lookup(CamelContextHelper.java:108)
        at
org.apache.camel.util.CamelContextHelper.getEndpointInjection(CamelContextHelper.java:158)
        at
org.apache.camel.impl.CamelPostProcessorHelper.getEndpointInjection(CamelPostProcessorHelper.java:135)
        at
org.apache.camel.impl.CamelPostProcessorHelper.createInjectionProducerTemplate(CamelPostProcessorHelper.java:177)
        at
org.apache.camel.impl.CamelPostProcessorHelper.getInjectionValue(CamelPostProcessorHelper.java:144)
        at
org.apache.camel.impl.DefaultCamelBeanPostProcessor.injectField(DefaultCamelBeanPostProcessor.java:182)
        at
org.apache.camel.impl.DefaultCamelBeanPostProcessor$1.doWith(DefaultCamelBeanPostProcessor.java:175)
        at
org.apache.camel.util.ReflectionHelper.doWithFields(ReflectionHelper.java:73)
        at
org.apache.camel.impl.DefaultCamelBeanPostProcessor.injectFields(DefaultCamelBeanPostProcessor.java:166)
        at
org.apache.camel.impl.DefaultCamelBeanPostProcessor.postProcessBeforeInitialization(DefaultCamelBeanPostProcessor.java:80)
        at
org.apache.camel.test.junit4.CamelTestSupport.postProcessTest(CamelTestSupport.java:404)
        at
org.apache.camel.test.junit4.CamelTestSupport.doSetUp(CamelTestSupport.java:291)
        at
org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:217)
        at
org.apache.camel.test.blueprint.CamelBlueprintTestSupport.setUp(CamelBlueprintTestSupport.java:107)

Anyone got any ideas?

Many thanks



--
View this message in context: 
http://camel.465427.n5.nabble.com/Intermittent-NoSuchBeanException-in-a-Camel-Route-Test-tp5733405.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to