CamelBlueprintTestSupport cannot mock a service defined in a concrete class, rather than an interface
Issue
A Camel application for Fuse on Karaf uses Blueprint XML, and has unit tests based on CamelBlueprintTestSupport
. The Blueprint XML refers to services defined by interface and by class:
<reference id="foo" interface="org.test.classes.Foo" />
and
<reference id="bar" component-name="foobar" interface="org.test.classes.FooImpl" ext:proxy-method="classes">
Since the services referenced do not exist at test time, the test attempts to mock them, by overriding addServicesOnStartup()
and calling:
services.put (Foo.class.getName(), asService(new FooImpl(), null));
and
services.put (FooImpl.class.getName(), asService(new FooImpl(), null));
The first of these works, whilst the second does not – the test does not start because the service is not instantiated.
It is a characteristic of this problem that the Blueprint code does work correctly when the application is deployed on Karaf, despite the test failure.
Environment
- Red Hat Fuse
- 7.4
CamelBlueprintTestSupport
Other Fuse versions are probably affected
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.