concept Arquillian in category camel

appears as: Arquilli
Camel in Action

This is an excerpt from Manning's book Camel in Action.

Listing 9.12 Testing Camel using Arquillian on WildFly Swarm
@RunWith(Arquillian.class)     #1 @DefaultDeployment(type = DefaultDeployment.Type.JAR)     #2 public class WildFlySwarmCamelTest { @Inject     #3 private CamelContext camelContext;     #3 @Inject @Uri("seda:inbox")     #4 private ProducerTemplate template;     #4 @Test public void testSeda() throws Exception { template.sendBody("Hello Swarm"); ConsumerTemplate consumer = camelContext.createConsumerTemplate(); Object body = consumer.receiveBody("seda:outbox", 5000);     #5 assertEquals("Hello Swarm", body); } } #1 Sets up unit test to run with Arquillian #2 Uses the default deployment #3 Injects CamelContext #4 Injects ProducerTemplate to send to seda:inbox #5 Receives message from seda:outbox

The class WildFlySwarmCamelTest has been annotated with JUnit @RunWith(Arquillian) ❶ to set up and run the unit test using Arquillian. Because your Camel application is running inside WildFly Swarm, you’ve annotated the class with @DefaultDeployment ❷, which instructs Arquillian to include your entire application together with WildFly Swarm. Notice that you specify type = DefaultDeployment.Type.JAR, which is required when using WildFly Swarm in JAR packaging mode, instead of the default WAR packaging mode. You’ll do this most often with WildFly Swarm because it’s intended for microservices, where you deploy and run only one application in the server. But Arquillian is capable of deploying only what you’ve instructed when you run in traditional application servers, which you’ll try in the following section.