I'd not noticed you'd used junit4; all the Camel examples still use JUnit3.
To run a test case in JUnit4 the name of the method is irrelevant - you have to use @Test to make it a test 2009/1/13 cmoulliard <cmoulli...@gmail.com>: > > Using the following syntax, the test is executed : > > package org.apache.camel.bindy.csv; > > import org.apache.camel.EndpointInject; > import org.apache.camel.Produce; > import org.apache.camel.ProducerTemplate; > import org.apache.camel.builder.RouteBuilder; > import org.apache.camel.component.mock.MockEndpoint; > import org.apache.camel.spring.javaconfig.SingleRouteCamelConfiguration; > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > import org.junit.Test; > import org.springframework.config.java.annotation.Bean; > import org.springframework.config.java.annotation.Configuration; > import org.springframework.config.java.test.JavaConfigContextLoader; > import org.springframework.test.annotation.DirtiesContext; > import org.springframework.test.context.ContextConfiguration; > import > org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; > > @ContextConfiguration(locations = > "org.apache.camel.bindy.csv.BindyCSVUnmarshallTest$ContextConfig", > loader = JavaConfigContextLoader.class) > public class BindyCSVUnmarshallTest extends AbstractJUnit4SpringContextTests > { > > private static final transient Log LOG = LogFactory > .getLog(BindyCSVUnmarshallTest.class); > > String record = "01,A,Albert,Cartier,BE12345678,Belgacom Ventage > 10/10,1500,EUR,08-01-2009"; > > @EndpointInject(uri = "mock:result") > protected MockEndpoint resultEndpoint; > > @Produce(uri = "direct:start") > protected ProducerTemplate template; > > @Test > public void testMarshallMessage() throws Exception { > > resultEndpoint.expectedBodiesReceived(record); > template.sendBody(record); > > resultEndpoint.assertIsSatisfied(); > > } > > > @Configuration > public static class ContextConfig extends > SingleRouteCamelConfiguration { > > CamelDataFormat camelDataFormat = new > CamelDataFormat("org.apache.camel.bindy.model"); > > @Bean > public RouteBuilder route() { > return new RouteBuilder() { > public void configure() { > from("direct:start") > //from("file://src/test/data/") > .unmarshal(camelDataFormat) > .to("mock:result"); > } > }; > } > } > > } > > > BUT junit reports the following error : > > main INFO > [org.springframework.beans.factory.support.DefaultListableBeanFactory] - > Destroying singletons in > org.springframework.beans.factory.support.defaultlistablebeanfact...@1e78c96: > defining beans > [org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,camelBeanPostProcessor]; > parent: > org.springframework.beans.factory.support.defaultlistablebeanfact...@105d88a > org.apache.maven.surefire.booter.SurefireExecutionException: > org/junit/Assume$AssumptionViolatedException; nested exception is > java.lang.NoClassDefFoundError: org/junit/Assume$AssumptionViolatedException > java.lang.NoClassDefFoundError: org/junit/Assume$AssumptionViolatedException > at > org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:240) > at > org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333) > at > org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217) > at > org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197) > at > org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143) > at > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:160) > at > org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:59) > at > org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:52) > at > org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34) > at > org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44) > at > org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:50) > at > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97) > at > org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62) > at > org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140) > at > org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127) > at org.apache.maven.surefire.Surefire.run(Surefire.java:177) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:585) > at > org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338) > at > org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997) > [ERROR] > > James.Strachan wrote: >> >> Ah... >> >> >> 2009/1/13 cmoulliard <cmoulli...@gmail.com>: >> [snip] >> >> >>> @ContextConfiguration(locations = >>> "org.apache.camel.spring.javaconfig.patterns.FilterTest$ContextConfig", >> >> The above annotation is the name of the class to create for your >> ApplicationContext - not the one inside BindyCSVUnmarshallTest. >> >> Currently JavaConfig and Spring Test don't work that nicely together >> so you have to use a fully qualified class name unfortunatley >> >> -- >> James >> ------- >> http://macstrac.blogspot.com/ >> >> Open Source Integration >> http://fusesource.com/ >> >> > > > ----- > Charles Moulliard > SOA Architect > > My Blog : http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/ > -- > View this message in context: > http://www.nabble.com/only-testMocksAreValid-is-executed-by-Camel-Spring-unit-test-%21%21-tp21436628s22882p21437293.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > -- James ------- http://macstrac.blogspot.com/ Open Source Integration http://fusesource.com/