Thanks for sharing it with us.
If you are using camel-http4 component, you don't need to start a real Jetty server for it. You can find more information about it by checking out the unites of the camel-http4[1].

[1]https://svn.apache.org/repos/asf/camel/trunk/components/camel-http4/src/test

On Fri Nov 25 15:46:23 2011, Xenofon Papadopoulos wrote:
In Camel 2.7 I need to make an HTTP request to a remote web server from
inside a bean. The route looks like:

<route id="billing.commit">
<from
uri="activemq:queue:billing.outbound?concurrentConsumers=50&amp;maxConcurrentConsumers=70"
/>
<to uri="bean:billingBean?method=process"/>
<inOnly uri="activemq:queue:myService" />
<inOnly uri="activemq:queue:smsGateway" />
<onException>
<exception>java.lang.Exception</exception>
<handled><constant>true</constant></handled>
<setHeader headerName="STATUS"><simple>1</simple></setHeader>
...
</onException>
</route>


billingBean is a Spring bean that is injected with a ProducerTemplate and
after some processing it makes the request, parses the response and
continues with the exchange.
I need to write an automated test for this, so I created a simulator for
the server and a tried the following route:

public class BillingServiceTest extends CamelSpringTestSupport {


@Override
public void setUp() throws Exception {
super.setUp();
erviceTestUri = context.resolvePropertyPlaceholders( "{{mcss.uri}}" );
final String jettyEndpoint = "jetty:" + mcssServiceTestUri;
logger.info( "Setting up jetty endpoint at: " + jettyEndpoint );
context.addRoutes( new RouteBuilder() {
@Override
public void configure() throws Exception {
from( jettyEndpoint )
.beanRef( "billingServiceSimulator", "processRequest" );
}
} );
}




--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
        http://jnn.javaeye.com (Chinese)
Twitter: willemjiang Weibo: willemjiang

Reply via email to