camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: trying to unit test JMS example
Date Mon, 03 Aug 2009 01:55:34 GMT
Hi,

Can you show me the camel-client.xml ?
Since you didn't use the Spring JUnit test helper to load the spring 
configuration file, so these class member will not be injected.

	@EndpointInject(uri = "mock:result")
	protected MockEndpoint resultEndpoint;
	@Produce(uri = "direct:start")
	protected ProducerTemplate template;

Willem

Mick Knutson wrote:
> I am trying to go through:
> 
> http://camel.apache.org/tutorial-jmsremoting.html
> 
> I have downloaded the source, and have been able to run the server with an
> installed version of AMQ. then I tried to create a JUnit test in stead of
> the CamelClientRemoting.class
> 
> What I need some help with, is to understand how I can properly Unit Test
> the server itself during my Maven build?
> 
> I also would prefer to use an embedded AMQ instead of the full blown AMQ
> server for these unit tests.
> 
> Here is the JUnit test I created so far:
> 
> *public class MultiplierTest extends CamelTestSupport {
>     @EndpointInject(uri = "mock:result")
>     protected MockEndpoint resultEndpoint;
>     @Produce(uri = "direct:start")
>     protected ProducerTemplate template;
> 
>     @Test
>     public void testSendMultiplierMessage() throws Exception {
> 
> System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
>         System.out.println("Notice this client requires that the CamelServer
> is already running!");
> 
>         ApplicationContext context = new
> ClassPathXmlApplicationContext("camel-client.xml");
> 
>         // get the camel template for Spring template style sending of
> messages (= producer)
>         ProducerTemplate camelTemplate = (ProducerTemplate)
> context.getBean("camelTemplate");
> 
>         System.out.println("Invoking the multiply with 22");
>         // as opposed to the CamelClientRemoting example we need to define
> the service URI in this java code
>         int response = (Integer)camelTemplate.sendBody("jms:queue:numbers",
> ExchangePattern.InOut, 22);
>         System.out.println("... the result is: " + response);
> assertEquals(66, response);
>     }
> *
> 
> 
> 
> ---
> Thank You…
> 
> Mick Knutson, President
> 
> BASE Logic, Inc.
> Enterprise Architecture, Design, Mentoring & Agile Consulting
> p. (866) BLiNC-411: (254-6241-1)
> f. (415) 685-4233
> 
> Website: http://baselogic.com
> Linked IN: http://linkedin.com/in/mickknutson
> Vacation Rental: http://tahoe.baselogic.com
> ---
> 


Mime
View raw message