Hi You should test the route in the XML file and therefore not add routes in Java DSL as well.
Just use the producer template from the unit test method to send a message to the CXFRS service. And then assert the reply is as expected. On Fri, Feb 25, 2011 at 2:36 PM, bdusauso <bdusau...@yp5.be> wrote: > > Hi, > > I'd like to do some basic test for a route. > I have a REST service, configured as : > > <beans xmlns="http://www.springframework.org/schema/beans" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:cxf="http://camel.apache.org/schema/cxf" > xmlns:jaxrs="http://cxf.apache.org/jaxrs" > xsi:schemaLocation="http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans.xsd > http://camel.apache.org/schema/cxf > http://camel.apache.org/schema/cxf/camel-cxf.xsd > http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd > http://camel.apache.org/schema/spring > http://camel.apache.org/schema/spring/camel-spring.xsd"> > > <cxf:rsServer id="restServer" > address="http://localhost:9000/service" > serviceClass="com.example.ServiceImpl"/> > > <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> > <route> > <from > uri="cxfrs://bean:restServer?serviceClass=com.example.ServiceImpl"/> > <log message="OK"/> > </route> > </camelContext> > </beans> > > When I try this test > > > public class RestComputationServiceTest extends CamelSpringTestSupport { > > @Override > protected AbstractApplicationContext createApplicationContext() { > return new > ClassPathXmlApplicationContext("/META-INF/spring/rest-webservice-application-context.xml"); > } > > @Override > protected RouteBuilder createRouteBuilder() throws Exception { > return new RouteBuilder() { > @Override > public void configure() throws Exception { > from("bean:restServer").to("mock:recipient"); > } > }; > } > > @Test > public void testRestInput() throws IOException, InterruptedException { > Resource xmlFile = new > ClassPathResource("/xml/webservice-request-example.xml"); > InputStream stream = xmlFile.getInputStream(); > String body = IOUtils.toString(stream); > template.sendBody("bean:restServer", body); > > MockEndpoint recipient = getMockEndpoint("mock:recipient"); > recipient.expectedMessageCount(1); > recipient.assertIsSatisfied(); > } > } > > I get this message : > [...] // No errors in here > Feb 25, 2011 2:09:48 PM org.apache.cxf.jaxrs.utils.ResourceUtils > getResourceStream > WARNING: No file resource <ns:request > xmlns:ns="http://ademe.fr/ademedb/schema/webservice/request/1.0"> > <ns:id>3</ns:id> > <ns:version>1.0-full</ns:version> > <ns:parameters> > <ns:parameter key="foo"> > <ns:integerValue>3</ns:integerValue> > </ns:parameter> > </ns:parameters> > </ns:request> is available on local disk > Feb 25, 2011 2:09:48 PM org.apache.camel.component.mock.MockEndpoint > assertIsSatisfied > INFO: Asserting: Endpoint[mock://recipient] is satisfied > Feb 25, 2011 2:09:49 PM org.apache.camel.processor.Logger log > SEVERE: Failed delivery for exchangeId: ID-mig-36230-1298639385923-0-3. > Exhausted after delivery attempt: 1 caught: > org.apache.camel.component.bean.AmbiguousMethodCallException: Ambiguous > method invocations possible: [public void > org.apache.cxf.jaxrs.JAXRSServerFactoryBean.setResourceProvider(java.lang.Class,org.apache.cxf.jaxrs.lifecycle.ResourceProvider), > public void > org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean.setModelBeansWithServiceClass(java.util.List,java.lang.Class[]), > public void > org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean.setModelRefWithServiceClass(java.lang.String,java.lang.Class[])]. > Exchange[Message: [Body is null]] > org.apache.camel.component.bean.AmbiguousMethodCallException: Ambiguous > method invocations possible: [public void > org.apache.cxf.jaxrs.JAXRSServerFactoryBean.setResourceProvider(java.lang.Class,org.apache.cxf.jaxrs.lifecycle.ResourceProvider), > public void > org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean.setModelBeansWithServiceClass(java.util.List,java.lang.Class[]), > public void > org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean.setModelRefWithServiceClass(java.lang.String,java.lang.Class[])]. > Exchange[Message: [Body is null]] > at > org.apache.camel.component.bean.BeanInfo.chooseMethod(BeanInfo.java:398) > at > org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:158) > at > org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:150) > at > org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:91) > at > org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:74) > at > org.apache.camel.impl.ProcessorPollingConsumer.receive(ProcessorPollingConsumer.java:51) > at > org.apache.camel.impl.ProcessorPollingConsumer.receiveNoWait(ProcessorPollingConsumer.java:59) > at > org.apache.camel.impl.DefaultScheduledPollConsumer.poll(DefaultScheduledPollConsumer.java:48) > at > org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:97) > at > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) > at > java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317) > at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) > at > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98) > at > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180) > at > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204) > at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) > at java.lang.Thread.run(Thread.java:662) > Feb 25, 2011 2:09:49 PM org.apache.camel.processor.Logger log > > I know what AmbiguousMethodCallException means, but I can't tell why it is > raised. > What am I doing wrong ? > > Regards. > -- > View this message in context: > http://camel.465427.n5.nabble.com/CXF-component-testing-tp3400123p3400123.html > Sent from the Camel - Users mailing list archive at Nabble.com. > -- Claus Ibsen ----------------- FuseSource Email: cib...@fusesource.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/