CamelTestSupport cannot be used with SwitchYard endpoints in FSW
Issue
- 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:
@Test
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(SampleServiceTest.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
...
- The Camel's
ProducerTemplateuses aCamelDefaultContextwhile producing message to SwitchYard endpoints obviously requires aSwitchYardCamelContextinstance. And theSwitchYardCamelContextcannot be casted to aCamelDefaultContextinstance. - How then is one supposed to use the Camel unit test framework with SwitchYard?
Environment
- Red Hat JBoss Fuse Service Works (FSW)
- 6.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.