I am making some headway. I have create a startup method: [EMAIL PROTECTED](groups = {"init"}) public void startCamel() { try { log.debug("Start Camel Context"); // create the camel context: camelContext = new DefaultCamelContext();
// add the routes to the camel Context camelContext.addRoutes(new ChangeRequestRouteBuilder()); // start Camel Context // create a camel template for sending messages: camelTemplate = new CamelTemplate(camelContext); // I added this as the recommendation to the deprecated // camelTemplate above... //producerTemplate = new ProducerTemplate(); // start the camel context camelContext.start(); } catch (Exception e) { // this is an example -> don't handle exceptions: e.printStackTrace(); } }// * But I have an issue. *CamelTemplate is deprecated, and **ProducerTemplate is abstract*. How how do I start using the *ProducerTemplate instead? *Also, in my SpringTestNG base, I start up my test context:* [EMAIL PROTECTED](* * locations = {"classpath:applicationContext-test.xml"}* *)* That includes:* **<import resource="classpath:META-INF/spring/camel-context.xml" />* and I am using the embedded broker: *<!-- lets configure the default ActiveMQ broker URL -->* * <bean id="activemq" class="org.apache.camel.component.jms.JmsComponent">* * <property name="connectionFactory">* * <bean class="org.apache.activemq.ActiveMQConnectionFactory">* * <property name="brokerURL" value="vm://localhost?broker.persistent=false&broker.useJmx=false"/>* * </bean>* * </property>* * </bean>* so why do i keep getting the full default broker being searched for: *[myproject] DEBUG [ActiveMQ Task] FailoverTransport.doReconnect(671) | Attempting connect to: tcp://localhost:61616 [myproject] DEBUG [ActiveMQ Task] FailoverTransport.doReconnect(699) | Connect fail to: tcp://localhost:61616, reason: java.net.ConnectException: Connection refused [myproject] DEBUG [ActiveMQ Task] FailoverTransport.doReconnect(732) | Waiting 30000 ms before attempting connection. * On Wed, Sep 17, 2008 at 10:49 PM, James Strachan <[EMAIL PROTECTED]>wrote: > I agree with everything Claus just said :) But another thing you can > do is run the TestNG test case directly in your IDE as well without > using Maven at all. > > > 2008/9/18 Mick Knutson <[EMAIL PROTECTED]>: > > I have created a base class extending AbstractTestNGSpringContextTests as > > you mentioned. I actually did the same to support bdunit. > > > > But there are a few things, related to camel that I am just not getting > yet. > > > > > > > > * What does the camel-maven-plugin doing that my base class will not by > > initializing the camel-context.xml? > > > > I tried to run my mvn install without the camel-maven-plugin. I get the > > camel-context initialized, but does not run the same as when I run mvn > > camel:run. > > > > *There is:* > > *public class CRRouteBuilder extends RouteBuilder { > > .... > > public static void main(String[] args) { > > new Main().run(args); > > } > > * > > > > in my RouteBuilder and I guess I am not sure if this is started by the > > plugin to run or not. > > > > I tried mvn camel:run and keep getting a poll loop: > > > > *[myproject] DEBUG [Thread: 1 > > [EMAIL PROTECTED] > > FileConsumer.pollFileOrDirectory(81) | Polling directory src/data > > [myproject] DEBUG [Thread: 1 > > [EMAIL PROTECTED] > > FileConsumer.isChanged(231) | file:src/data/message1.xml isChanged:false > > sizeCheck:false(0) lastModifiedCheck:false(0) > > [myproject] DEBUG [Thread: 1 > > [EMAIL PROTECTED] > > FileConsumer.isChanged(231) | file:src/data/message2.xml isChanged:false > > sizeCheck:false(0) lastModifiedCheck:false(0) > > [myproject] DEBUG [Thread: 1 > > [EMAIL PROTECTED] > > FileConsumer.isChanged(231) | file:src/data/message3.xml isChanged:false > > sizeCheck:false(0) lastModifiedCheck:false(0) > > * > > > > so should I not use the plugin at all? And just start the camelContext by > > itself? > > > > Do I just need to have my testNG send a message to initiate the process? > > > > > > It seems that the process is initiated: > > > > *[myproject] DEBUG [VMTransport] > ActiveMQConnection.onAsyncException(1695) | > > Async exception with no exception listener: > > org.apache.activemq.transport.TransportDisposedIOException: Peer > > (vm://localhost#1) disposed. > > org.apache.activemq.transport.TransportDisposedIOException: Peer > > (vm://localhost#1) disposed. > > at > > > org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:203) > > at > > > org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:122) > > at > > > org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:43) > > at > > > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650) > > at > > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675) > > at java.lang.Thread.run(Thread.java:613) > > [myproject] DEBUG [ActiveMQ Transport Stopper: vm://localhost#0] > > TransportConnection.doStop(994) | Connection Stopped: vm://localhost#0 > > [myproject] INFO [ActiveMQ ShutdownHook] TransportConnector.stop(273) | > > Connector vm://localhost Stopped > > [myproject] DEBUG [Thread-2] DefaultListableBeanFactory.destroyBean(447) > | > > Retrieved dependent beans for bean > > 'org.apache.activemq.ActiveMQConnectionFactory#3dc0f4': [activemq] > > [myproject] DEBUG [Thread-2] DefaultListableBeanFactory.destroyBean(447) > | > > Retrieved dependent beans for bean 'camel:beanPostProcessor': [camel] > > [myproject] DEBUG [Thread-2] DefaultListableBeanFactory.destroyBean(447) > | > > Retrieved dependent beans for bean 'camel': [camel:beanPostProcessor, > > org.apache.camel.component.file.FileComponent, > > com.servepath.ChangeRequestTest] > > myproject] DEBUG [Thread-2] DisposableBeanAdapter.destroy(148) | Invoking > > destroy() on bean with name 'camel' > > [myproject] INFO [ActiveMQ ShutdownHook] BrokerService.stop(512) | > ActiveMQ > > JMS Message Broker (localhost, > > ID:mick-knutsons-macbook.local-50355-1221698401973-0:0) stopped > > [myproject] DEBUG [Thread: 1 > > [EMAIL PROTECTED] > > ScheduledPollConsumer.run(62) | Starting to poll: > > Endpoint[file:src/data?noop=true] > > [myproject] DEBUG [Thread: 1 > > [EMAIL PROTECTED] > > FileConsumer.pollFileOrDirectory(81) > > | Polling directory src/data > > [myproject] DEBUG [Thread: 1 > > [EMAIL PROTECTED] > > FileConsumer.isChanged(231) | file:src/data/message1.xml isChanged:true > > sizeCheck:false(0) lastModifiedCheck:true(0) > > [myproject] DEBUG [Thread: 1 > > [EMAIL PROTECTED] > > FileEndpoint.getFileStrategy(158) | Using file process strategy: > > [EMAIL PROTECTED] > > [myproject] DEBUG [Thread: 1 > > [EMAIL PROTECTED] > > FileConsumer.pollFile(122) | About to process file: src/data/message1.xml > > using exchange: Exchange[FileMessage: src/data/message1.xml] > > [myproject] DEBUG [Thread: 1 > > [EMAIL PROTECTED] > > FileProcessStrategySupport.begin(62) | Locking the file: > > src/data/message1.xml using the lock file name: > > > /opt/projects/changerequest/camel-example-spring/src/data/message1.xml.cameLock > > [myproject] ERROR [Thread: 1 > > [EMAIL PROTECTED] > > BrokerService.start(466) | Failed to start ActiveMQ JMS Message Broker. > > Reason: java.lang.IllegalStateException: Shutdown in progress > > > > * > > > > But there is an error in bold above. > > > > > > > > > > > > On Tue, Sep 16, 2008 at 11:14 PM, James Strachan > > <[EMAIL PROTECTED]>wrote: > > > >> 2008/9/16 Mick Knutson <[EMAIL PROTECTED]>: > >> > I am trying to setup camel within Maven to start my camel context via > the > >> > <plugin> > >> > <groupId>org.apache.camel</groupId> > >> > <artifactId>camel-maven-plugin</artifactId> > >> > <version>1.4.0</version> > >> > </plugin> > >> > > >> > Now I was hoping that someone has already created a baseCamelTestNG > class > >> to > >> > start/stop camel, then helper class to send and receive messages. > >> > > >> > Then after the tests have run, the plugin can shutdown. > >> > >> BTW there's a Camel user list, I've CC'd so other camel users can listen > >> too... > >> http://activemq.apache.org/camel/discussion-forums.html > >> > >> The best approach for unit testing and sending & receiving messages is > >> to use the Spring Testing mechanism which works with JUnit 3.x, 4.x or > >> TestNG > >> http://activemq.apache.org/camel/spring-testing.html > >> > >> for TestNG you might want to derive from > AbstractTestNGSpringContextTests > >> see > >> > >> > http://static.springframework.org/spring/docs/2.5.x/reference/testing.html#testcontext-fixture-di > >> > >> this then does the dependency injection with Spring and runs your test > >> case. > >> > >> To send messages you can inject a ProducerTemplate; then to receive > >> messages you can then use the @MessageDriven annotation on a method - > >> see the examples here > >> http://activemq.apache.org/camel/bean-integration.html > >> > >> plus you can then inject mock endpoints for testing as well as described > >> here > >> http://activemq.apache.org/camel/spring-testing.html > >> http://activemq.apache.org/camel/mock.html > >> > >> -- > >> James > >> ------- > >> http://macstrac.blogspot.com/ > >> > >> Open Source Integration > >> http://open.iona.com > >> > > > > > > > > -- > > --- > > Thank You… > > > > Mick Knutson > > BASE Logic, inc. > > (415) 354-4215 > > > > Website: http://baselogic.com > > Blog: http://baselogic.com/blog > > BLiNC Magazine: http://blincmagazine.com > > Linked IN: http://linkedin.com/in/mickknutson > > DJ Mick: http://djmick.com > > MySpace: http://myspace.com/mickknutson > > Vacation Rental: http://tahoe.baselogic.com > > > > > > -- > James > ------- > http://macstrac.blogspot.com/ > > Open Source Integration > http://open.iona.com > -- --- Thank You… Mick Knutson BASE Logic, inc. (415) 354-4215 Website: http://baselogic.com Blog: http://baselogic.com/blog BLiNC Magazine: http://blincmagazine.com Linked IN: http://linkedin.com/in/mickknutson DJ Mick: http://djmick.com MySpace: http://myspace.com/mickknutson Vacation Rental: http://tahoe.baselogic.com