activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mick Knutson" <mknut...@baselogic.com>
Subject Re: testNG test harness for Camel, sending and receiving messages
Date Thu, 18 Sep 2008 00:47:01 GMT
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
org.apache.camel.component.file.FileComponent@407374]
FileConsumer.pollFileOrDirectory(81) | Polling directory src/data
[myproject] DEBUG [Thread: 1
org.apache.camel.component.file.FileComponent@407374]
FileConsumer.isChanged(231) | file:src/data/message1.xml isChanged:false
sizeCheck:false(0) lastModifiedCheck:false(0)
[myproject] DEBUG [Thread: 1
org.apache.camel.component.file.FileComponent@407374]
FileConsumer.isChanged(231) | file:src/data/message2.xml isChanged:false
sizeCheck:false(0) lastModifiedCheck:false(0)
[myproject] DEBUG [Thread: 1
org.apache.camel.component.file.FileComponent@407374]
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
org.apache.camel.component.file.FileComponent@698f02]
ScheduledPollConsumer.run(62) | Starting to poll:
Endpoint[file:src/data?noop=true]
[myproject] DEBUG [Thread: 1
org.apache.camel.component.file.FileComponent@698f02]
FileConsumer.pollFileOrDirectory(81)
| Polling directory src/data
[myproject] DEBUG [Thread: 1
org.apache.camel.component.file.FileComponent@698f02]
FileConsumer.isChanged(231) | file:src/data/message1.xml isChanged:true
sizeCheck:false(0) lastModifiedCheck:true(0)
[myproject] DEBUG [Thread: 1
org.apache.camel.component.file.FileComponent@698f02]
FileEndpoint.getFileStrategy(158) | Using file process strategy:
org.apache.camel.component.file.strategy.NoOpFileProcessStrategy@43095f
[myproject] DEBUG [Thread: 1
org.apache.camel.component.file.FileComponent@698f02]
FileConsumer.pollFile(122) | About to process file: src/data/message1.xml
using exchange: Exchange[FileMessage: src/data/message1.xml]
[myproject] DEBUG [Thread: 1
org.apache.camel.component.file.FileComponent@698f02]
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
org.apache.camel.component.file.FileComponent@698f02]
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
<james.strachan@gmail.com>wrote:

> 2008/9/16 Mick Knutson <mknutson@baselogic.com>:
> > 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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message