Hi The purpose with mock endpoint is for unit testing. You can only send message to a mock endpoint, not consume (read) from them. http://activemq.apache.org/camel/mock.html
So you aggregator start need to be something NOT mock <from uri="mock:aggreg-start" Should be eg: a direct queue http://activemq.apache.org/camel/direct.html <from uri="direct:aggreg-start" Med venlig hilsen Claus Ibsen ...................................... Silverbullet Skovsgårdsvænget 21 8362 Hørning Tlf. +45 2962 7576 Web: www.silverbullet.dk -----Original Message----- From: mta38 [mailto:[EMAIL PROTECTED] Sent: 14. oktober 2008 14:01 To: [email protected] Subject: MockEndpoint - "You cannot consume from this endpoint" Hi all, I have the following route implemented in xml spring file. <bean id="myAggregatorStrategy" class="aggregator.MyAggregationStrategy"/> <camelContext id="myCamelContext" xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="file:src/data/creerMarche1.xml?noop=true" /> <to uri="mock:client1" /> </route> <route> <from uri="file:src/data/creerMarche2.xml?noop=true" /> <to uri="mock:client2" /> </route> <!-- route for Aggregator --> <route> <from uri="mock:aggreg-start" /> <convertBodyTo type="java.lang.String"/> <aggregator strategyRef="myAggregatorStrategy"> <xpath>//soapenv:Body/g1:creerMarche</xpath> <completedPredicate> <simple>header.aggregated = 2</simple> </completedPredicate> </aggregator> <to uri="mock:aggreg-end" /> </route> </camelContext> My test class is: @ContextConfiguration(locations={"/aggregator/camel-context-springtest.xml"}) public class BusLogicRouteTestSpring extends AbstractJUnit38SpringContextTests { private static final transient Log LOG = LogFactory.getLog(BusLogicRouteTestSpring.class); @Autowired protected CamelContext myCamelContext; @EndpointInject(uri="mock:client1") protected MockEndpoint client1; @EndpointInject(uri="mock:client2") protected MockEndpoint client2; @EndpointInject(uri="mock:aggreg-start") ProducerTemplate producer; public BusLogicRouteTestSpring() { super(); } public BusLogicRouteTestSpring(String name) { super(name); } public void testConfigure() throws Exception{ List<Exchange> exchangesCli1 = client1.getReceivedExchanges(); List<Exchange> exchangesCli2 = client2.getReceivedExchanges(); for (Exchange exch : exchangesCli1) { producer.send(exch); } for (Exchange exch : exchangesCli1) { producer.send(exch); } } } When I test these routes I have the following errors: [ main] DefaultCamelContext INFO JMX enabled. Using InstrumentationLifecycleStrategy. [ main] ResolverUtil WARN Could not find class 'org/apache/activemq/camel/converter/InvokeJmsMessageListenerTest.class' in any classloaders: [EMAIL PROTECTED] [ main] ResolverUtil WARN Could not find class 'org/apache/activemq/camel/converter/InvokeMessageListenerTest.class' in any classloaders: [EMAIL PROTECTED] [ main] TestContextManager ERROR Caught exception while allowing TestExecutionListener [EMAIL PROTECTED] to prepare test instance [testConfigure(aggregator.BusLogicRouteTestSpring)] java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:203) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:255) at org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests.runBare(AbstractJUnit38SpringContextTests.java:183) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: java.lang.UnsupportedOperationException: You cannot consume from this endpoint at org.apache.camel.component.mock.MockEndpoint.createConsumer(MockEndpoint.java:164) at org.apache.camel.impl.EventDrivenPollingConsumer.doStart(EventDrivenPollingConsumer.java:98) at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:42) at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:53) at org.apache.camel.processor.BatchProcessor.doStart(BatchProcessor.java:166) at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47) at org.apache.camel.impl.DefaultCamelContext.addService(DefaultCamelContext.java:359) at org.apache.camel.impl.DefaultCamelContext.startRoutes(DefaultCamelContext.java:557) at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:530) at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:149) at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47) at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:103) at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78) at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:275) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:737) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:384) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:42) at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:173) at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:199) ... 14 more I suppose the problem is due to the line <from uri="mock:aggreg-start" /> but I don't know why. In camel documentation on MockEndpoint, the createConsumer() method exist... Is someone can have some explanation? Thanks in advance Mta38 -- View this message in context: http://www.nabble.com/MockEndpoint---%22You-cannot-consume-from-this-endpoint%22-tp19972046s22882p19972046.html Sent from the Camel - Users mailing list archive at Nabble.com.
