-
1. Re: Registering a MockHandler for a Camel Service
kcbabo Jun 4, 2013 1:17 PM (in response to luisdeltoro)Try using the replaceService method in SwitchYardTestKit. Here's an example:
-
2. Re: Registering a MockHandler for a Camel Service
luisdeltoro Jun 5, 2013 4:26 AM (in response to kcbabo)Hi Keith!
I've tried with the replaceService method and I'm still bumping into the same issue...
-
3. Re: Registering a MockHandler for a Camel Service
kcbabo Jun 5, 2013 8:34 AM (in response to luisdeltoro)Hmm ... works fine for me. To test, I took the camel-service quickstart and added a test method which replaces the JavaDSL service with a MockHandler:
@Test
public void testCamelRoute2() {
MockHandler handler = testKit.replaceService("JavaDSL");
// write file here so file binding picks it up after service provider is replaced
Assert.assertEquals(1, handler.waitForOKMessage().getMessages().size());
}
Can you provide the source for the test class and your switchyard.xml?
-
4. Re: Registering a MockHandler for a Camel Service
luisdeltoro Jun 6, 2013 10:21 AM (in response to kcbabo)Hi Keith,
after some investigation I was able to pinpoint the problem and reproduce it in the quickstart. Basically in seem to be due to the promoted service that holds the rest binding having a different name than the actual service:
This does not work:
<switchyard xmlns="urn:switchyard-config:switchyard:1.0"
xmlns:file="urn:switchyard-component-camel-file:config:1.0"
xmlns:swyd="urn:switchyard-config:switchyard:1.0"><composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="camel-service"
targetNamespace="urn:switchyard-quickstart:camel-service:0.1.0">
<service name="JavaDSLRest" promote="JavaDSLBuilder/JavaDSL">
<rest:binding.rest xmlns:rest="urn:switchyard-component-resteasy:config:1.0">
<rest:interfaces>org.switchyard.quickstarts.camel.service.JavaDSL</rest:interfaces>
<rest:contextPath>rest-binding</rest:contextPath>
</rest:binding.rest>
</service>
<component name="JavaDSLBuilder">
<implementation.camel xmlns="urn:switchyard-component-camel:config:1.0">
<java class="org.switchyard.quickstarts.camel.service.JavaDSLBuilder"/>
</implementation.camel>
<service name="JavaDSL">
<interface.java interface="org.switchyard.quickstarts.camel.service.JavaDSL"/>
</service>
<reference name="XMLService">
<swyd:interface.esb xmlns:swyd="urn:switchyard-config:switchyard:1.0" inputType="java:java.lang.String"/>
</reference>
</component>
<component name="XMLComponent">
<implementation.camel xmlns="urn:switchyard-component-camel:config:1.0">
<xml path="META-INF/route.xml"/>
</implementation.camel>
<service name="XMLService">
<swyd:interface.esb xmlns:swyd="urn:switchyard-config:switchyard:1.0" inputType="java:java.lang.String"/>
</service>
</component>
</composite>
</switchyard>Although this does work:
<switchyard xmlns="urn:switchyard-config:switchyard:1.0"
xmlns:file="urn:switchyard-component-camel-file:config:1.0"
xmlns:swyd="urn:switchyard-config:switchyard:1.0"><composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="camel-service"
targetNamespace="urn:switchyard-quickstart:camel-service:0.1.0">
<service name="JavaDSL" promote="JavaDSLBuilder/JavaDSL">
<rest:binding.rest xmlns:rest="urn:switchyard-component-resteasy:config:1.0">
<rest:interfaces>org.switchyard.quickstarts.camel.service.JavaDSL</rest:interfaces>
<rest:contextPath>rest-binding</rest:contextPath>
</rest:binding.rest>
</service>
<component name="JavaDSLBuilder">
<implementation.camel xmlns="urn:switchyard-component-camel:config:1.0">
<java class="org.switchyard.quickstarts.camel.service.JavaDSLBuilder"/>
</implementation.camel>
<service name="JavaDSL">
<interface.java interface="org.switchyard.quickstarts.camel.service.JavaDSL"/>
</service>
<reference name="XMLService">
<swyd:interface.esb xmlns:swyd="urn:switchyard-config:switchyard:1.0" inputType="java:java.lang.String"/>
</reference>
</component>
<component name="XMLComponent">
<implementation.camel xmlns="urn:switchyard-component-camel:config:1.0">
<xml path="META-INF/route.xml"/>
</implementation.camel>
<service name="XMLService">
<swyd:interface.esb xmlns:swyd="urn:switchyard-config:switchyard:1.0" inputType="java:java.lang.String"/>
</service>
</component>
</composite>
</switchyard>I noticed that when the promoted service and the service have the same name there is just one service in the service registry. When they have different names, there are two.
I still newbie in sca and switchyard matters so I would like to know if my approach is wrong and the promoted service should always have the same name as the service being promoted or if this is a bug.
PS: Please find attached a modified version of the camel service quickstart that reproduces this behaviour.
-
camel-service-qs.zip 13.1 KB
-
-
5. Re: Registering a MockHandler for a Camel Service
kcbabo Jun 6, 2013 10:17 AM (in response to luisdeltoro)I think this might be a skeleton in the deployment closet. Can you try to replace *both* names like this:
MockHandler handler = testKit.replaceService("JavaDSL"); MockHandler handler = testKit.replaceService("JavaDSLRest");
If that works, then just try this:
MockHandler handler = testKit.replaceService("JavaDSLRest");
thanks,
keith
-
6. Re: Registering a MockHandler for a Camel Service
luisdeltoro Jun 6, 2013 10:30 AM (in response to kcbabo)Hi Keith,
replacing the promoted service did trick!
It still not clear to me if this is the normal behaviour or we are using just a workaround here...
-
7. Re: Registering a MockHandler for a Camel Service
kcbabo Jun 6, 2013 10:39 AM (in response to luisdeltoro)It's a hack in deployer to handle services which are promoted with a different name:
We should really use reference wiring in that situation instead:
-
8. Re: Registering a MockHandler for a Camel Service
luisdeltoro Jun 6, 2013 10:41 AM (in response to kcbabo)I understand.
Thanks for the explanation Keith!
Regards,
Luis