[CONF] Apache Camel Articles

2011-03-15 Thread confluence







Articles
Page edited by Claus Ibsen


 Changes (1)
 




...
* [Smooks OSGI: Camel, UN/EDIFACT, ServiceMix|http://www.dzone.com/links/r/smooks_osgi_camel_unedifact_servicemix.html] shows how to use Smooks with Camel running in the Apache ServieMix OSGi container. * [Transparent Asynchronous Remoting via JMS|http://hwellmann.blogspot.com/2011/03/transparent-asynchronous-remoting-via.html] by Harald Wellman, who blogs how to use Camel for asynchronous remoting over [JMS], having the middleware hidden, so the client is unaware of this fact, its just using a interface. 
* [LEGO Java: Apache Camel Context and Route Basics|http://www.canoo.com/blog/2011/03/14/lego-java-apache-camel-context-and-route-basics/] shows how to build integration applications using [EIP]s LEGO style. Building an application to parse HTML pages from web sites. 
  
...


Full Content

See alsoSee also Camel User Stories.

Articles on Apache Camel

	Wanna try our Apache Camel developer tools for Enterprise Integration Patterns?  by James Strachan
	A bit more meat: Camel applied : JMS to File by Mike McLean
	Matteo wrote a blog entry about using Camel with iBatis
	Knowledge Tree integration using Apache Camel
	Integrating Apache Camel with JBoss ESB by Edgar Ankiewsky
	Simple DSL OSGi bundle example by Andrej Koelewijn
	Realization of EAI Patterns with Apache Camel by Pascal Kolb at the Universität Stuttgart
	Spring Remoting with JMS Example on Amin Abbaspour's Weblog
	Implementing Fuji integration scenario using Camel SE by Louis Polycarpou on using Camel with Open ESB
	Using the Camel aggregator correctly by Torsten Mielke, a great blog entry how to use the Camel aggregator.
	Camel routes and HL7 by Roger Searjeant on using Camel and its HL7 support in the health care space.
	Combining ApacheCamel+BSF to make JBoss ESB polyglot by Edgard Ankiewsky Silva, a JBoss employeer.
	Groovy and Grape - easiest way to send gtalk message with Apache Camel by Andrej Koelewijn how easy it is to use Groovy and Grape to quickly try out new frameworks such as Apache Camel.
	Domain-Specific Languages (DSLs) in Apache Camel (Spanish) by Gema Perdiguero, Tecsisa.
	Apache Camel integration in ServiceMix (Spanish) by Sebastián Gómez, Tecsisa.
	Apache Camel: Integration Nirvana by Jonathan Anstey Great for learning what Camel is and what it can do
	Leverage EIP with Apache Camel and Twitter by Bruno Borges
	Apache Camel Reference Card at DZone (the first card out of two) by Claus Ibsen
	Using RSS with Apache Camel by Jeroen Reijn
	Using Groovy and Camel to pool Google Analyst email reports by Mr. Haki
	Using grails-camel plugin to work with Camel in Grails land by Mr. Haki
	Send mail with Apache Camel from Gails by Mr. Haki
	Navigating the Integration Landscape - Claus Ibsen on Apache Camel Claus Ibsen was interviewed at DZone discussing the integration landscape
	Apache Camel: Enterprise Integration met scripttalen en DSLs (Dutch) by Peter Maas, Finalist IT Group.
	Axis 2 ride with Camel how to use Axis 2 with the Camel report incident tutorial by Sagara
	Introduction to the Open eHealth Integration Platform (based on top of Apache Camel) Excellent DZone article by Martin Krasser
	An IRC alerter written using Apache Camel and Java how to easily integrate IRC with Camel to monitor and do alerts.
	Entreprise Integration Pattern with Apache Camel 2.0 by Julien Dechmann, how to use Camel to split and transform CSV files to POJO and XML and sending to a JMS destination
	A Camel based XML payload HTTP polling provider by Christopher Hunt to use Camel with AJAX. Interesting read.
	Camel vs. JBI by Adrian Trenaman.
	Things to consider when selecting between Apache Camel and Apache Servicemix by Ashwin Karpe
	Groovy and Camel for monitoring ActiveMQ by Eric Hauser how to monitor AMQ Advisory queues from a single groovy file.
	Camellos - Discovering Apache Camel by Gunnar Hillert. A very nice and short blog series about Camel showing its powers in a simple and intuitive way. Highly recommended for new users
	Apache Camel alternatives by Gunnar Hillert. He presents a brief overview of other projects in the integration space.
	First steps with Apache Camel on Google App Engine by Martin Krasser posts his findings to get Camel running on the GAE.
	A jira notification system for irc using Camel by Guillaume Nodet - all code is in a single XML hot deployed in Apache Karaf.
	Camel, CXF and JMS by Example by Silvester van der Bijl. Good blog entry how to use CXF and Camel together.
	A simple file monitoring console with camel, cometd and jquery by Andrej Koelewijn. Shows how to use Camel to monitor log files and push lines changed using cometd to a webpage. All in a few files using Groovy.
	A Groovy ride on Camel by Jack 

[CONF] Apache Camel Camel Test

2011-03-15 Thread confluence







Camel Test
Page edited by Christian Mueller


 Changes (3)
 




...
{code}  
You might also want to add commons-logging slf4j and log4j to ensure nice logging messages (and maybe adding a [log4j.properties|http://svn.apache.org/repos/asf/camel/trunk/components/camel-test/src/test/resources/log4j.properties] file into your src/test/resources directory). 
 {code:xml} dependency 
groupIdcommons-logging/groupId groupIdorg.slf4j/groupId 
artifactIdcommons-logging/artifactId artifactIdslf4j-log4j12/artifactId 
  scopetest/scope /dependency 
...


Full Content

Camel Test

As a simple alternative to using Spring Testing or Guice the camel-test module was introduced into the Camel 2.0 trunk so you can perform powerful Testing of your Enterprise Integration Patterns easily.

Adding to your pom.xml

To get started using Camel Test you will need to add an entry to your pom.xml



dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-test/artifactId
  version${camel-version}/version
  scopetest/scope
/dependency



You might also want to add slf4j and log4j to ensure nice logging messages (and maybe adding a log4j.properties file into your src/test/resources directory).



dependency
  groupIdorg.slf4j/groupId
  artifactIdslf4j-log4j12/artifactId
  scopetest/scope
/dependency
dependency
  groupIdlog4j/groupId
  artifactIdlog4j/artifactId
  scopetest/scope
/dependency



Writing your test

You firstly need to derive from the class CamelTestSupport and typically you will need to override the createRouteBuilder() method to create routes to be tested.

Here is an example. 


public class FilterTest extends CamelTestSupport {

@EndpointInject(uri = "mock:result")
protected MockEndpoint resultEndpoint;

@Produce(uri = "direct:start")
protected ProducerTemplate template;

public void testSendMatchingMessage() throws Exception {
String expectedBody = "matched/";

resultEndpoint.expectedBodiesReceived(expectedBody);

template.sendBodyAndHeader(expectedBody, "foo", "bar");

resultEndpoint.assertIsSatisfied();
}

public void testSendNotMatchingMessage() throws Exception {
resultEndpoint.expectedMessageCount(0);

template.sendBodyAndHeader("notMatched/", "foo", "notMatchedHeaderValue");

resultEndpoint.assertIsSatisfied();
}

@Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
}
};
}
}



Notice how you can use the various Camel binding and injection annotations to inject individual Endpoint objects - particularly the Mock endpoints which are very useful for Testing. Also you can inject producer objects such as ProducerTemplate or some application code interface for sending messages or invoking services.


JNDI

Camel uses a Registry to allow you to configure Component or Endpoint instances or Beans used in your routes. If you are not using Spring or OSGi then JNDI is used as the default registry implementation.

So you will also need to create a jndi.properties file in your src/test/resources directory so that there is a default registry available to initialise the CamelContext.

Here is an example jndi.properties file



java.naming.factory.initial = org.apache.camel.util.jndi.CamelInitialContextFactory



Dynamically assigning ports
Available as of Camel 2.7

Tests that use port numbers will fail if that port is already on use. AvailablePortFinder provides methods for finding unused port numbers at runtime. 



// Get the next available port number starting from the default starting port of 1024
int port1 = AvailablePortFinder.getNextAvailable();
/* 
 * Get another port. Note that just getting a port number does not reserve it so
 * we look starting one past the last port number we got.
 */
int port2 = AvailablePortFinder.getNextAvailable(port1 + 1);






See Also


	Testing
	Mock







Change Notification Preferences

View Online
|
View Changes
|
Add Comment