-
1. Re: unit testing camel-web projects
njiang Nov 28, 2011 9:16 PM (in response to julianc)If you just want to test the camel route, you can use the support classes in camel-test module. It will be more easy to run and test.
When you finished the test , you can put the camel route inside the camel-web.
Willem
-
2. Re: unit testing camel-web projects
julianc Nov 29, 2011 5:11 PM (in response to njiang)Hi Willem,
thats a good idea to get me going. I'd like the tests to run as part of mvn package but I'm trying your idea first.
I've done this:
mvn archetype:generate -DarchetypeGroupId=org.apache.camel.archetypes -DarchetypeArtifactId=camel-archetype-activemq -DarchetypeVersion=2.9.0-RC1
add
to the pom.xml
add the attached java class to
src/test/java/wsinteg/unittest/FirstTest.java
run
mvn camel:run and all is well
run
mvn test
get the following error:
main] BrokerService ERROR Failed to start ActiveMQ JMS Message Broker. Reason: javax.management.InstanceAlreadyExistsException: org.apache.activemq:BrokerName=localhost,Type=Broker
javax.management.InstanceAlreadyExistsException: org.apache.activemq:BrokerName=localhost,Type=Broker
Any ideas ?
Julian
-
FirstTest.java 1.4 KB
-
-
3. Re: unit testing camel-web projects
njiang Nov 30, 2011 8:44 AM (in response to julianc)Can you disable the JMX server in you spring configuration ?
It looks like the JMS broker try to register to the JMX server before running the test.
-
4. Re: unit testing camel-web projects
julianc Dec 3, 2011 7:06 AM (in response to njiang)Tried that, it wasn't the answer, but it helped me find it, thanks.
Now, if I have only one test it works. But the second test fails because it tried to create the broker again but the broker is still running from the first test.
Any ideas?
Julian
-
5. Re: unit testing camel-web projects
davsclaus Dec 5, 2011 9:25 AM (in response to julianc)You should possible stop the broker in the tearDown method, so its properly shutdown between tests.
-
6. Re: unit testing camel-web projects
julianc Dec 5, 2011 12:38 PM (in response to davsclaus)Hi Claus,
I've got everything working. The most recent problem is with testNG. The attached patch modifies an instance of the standard spring archetype to use a test class. I've also now got it working the way I wanted with a webconsole archetype.
All the problems were detail ones. I do think it would be great to have sample tests in the sample archetypes.
Thanks to Willem for really helpful ideas that got me going in the right direction
Julian
Edited by: julianc on Dec 5, 2011 5:36 PM
-
jc.patch 6.7 KB
-