2

I am creating a Junit Test using CamelTestSupport. The Camel Route has few references to POJO Beans and OSGI references.The OSGI reference is an Interface.I had used SimpleRegistry to capture the POJO beans using Java DSL. However, I do not know how to add OSGI reference or OSGIServiceRegistry for the purpose.

How do I had OSGI reference and POJO Beans along with the OSGI references in the registry so that CamelTestSupport can trigger the test method?

For reference-

Camel version - 2.13.2

Junit version - 4.11

Kenster
  • 23,465
  • 21
  • 80
  • 106
enigma
  • 63
  • 6

1 Answers1

1

If you use blueprint, you can try to use CamelBlueprintTestSupport rather than CamelTestSupport. If it does not help, you can look at the code of CamelBlueprintTestSupport, specially the createBundleContext() method, wich registers some services at startup.

Alexandre Cartapanis
  • 1,513
  • 3
  • 15
  • 19
  • This answer reminded me of `@Override protected void addServicesOnStartup(Map> services) { services.put("myService", asService(myService, "beer", "Carlsberg")); }` which may help the OP too (it's in camel-test-blueprint too). This example and more documentation can be found here: http://camel.apache.org/blueprint-testing.html – fiw Feb 04 '16 at 16:59
  • I started using the CamelBlueprintTestSupport. After few initial error with the blueprint config, I was able to get started. However, the test method is now having trouble starting with bean exception. org.apache.camel.NoSuchBeanException: No bean could be found in the registry. How do we add the POJO bean reference to registry in case of BlueprintTestSupport ? – enigma Feb 04 '16 at 18:41
  • I used the CamelBlueprintTestSupport with Overridden addServicesOnStartup() & getBlueprintDescriptor() methods the Test was able to resolve the beans. Thank you for suggesting to use the CamelBlueprintTestSupport along w/ OSGI Blueprint. – enigma Feb 05 '16 at 23:01