CamelTestSupport cannot be used with SwitchYard endpoints in FSW

Solution Verified - Updated -


  • In FSW 6, I deployed a service having a Camel interface and a Camel URI binding. In order to invoke the service I'm using a Camel unit test (CamelTestSupport) like the following:
  public void testStartService() throws Exception {
    template.sendBody("switchyard://SampleService", "Test message");
  • However, running this unit test using "mvn test" raises the following error:
java.lang.ClassCastException: org.apache.camel.impl.DefaultCamelContext cannot be cast to org.switchyard.common.camel.SwitchYardCamelContext
    at com.example.switchyard.SampleServiceTest.testStartService(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
  • The Camel's ProducerTemplate uses a CamelDefaultContext while producing message to SwitchYard endpoints obviously requires a SwitchYardCamelContext instance. And the SwitchYardCamelContext cannot be casted to a CamelDefaultContext instance.
  • How then is one supposed to use the Camel unit test framework with SwitchYard?


  • Red Hat JBoss Fuse Service Works (FSW)
    • 6.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In