use of org.wildfly.extension.camel.WildFlyCamelContext in project wildfly-camel by wildfly-extras.
the class SNSIntegrationTest method sendInOut.
@Test
public void sendInOut() throws Exception {
AmazonSNSClient snsClient = provider.getClient();
Assume.assumeNotNull("AWS client not null", snsClient);
assertNoStaleTopic(snsClient, "before");
try {
final String arn = snsClient.createTopic(topicName).getTopicArn();
try {
WildFlyCamelContext camelctx = new WildFlyCamelContext();
camelctx.getNamingContext().bind("snsClientB", snsClient);
camelctx.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:start").to("aws-sns://" + topicName + "?amazonSNSClient=#snsClientB");
}
});
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
Exchange exchange = producer.send("direct:start", ExchangePattern.InOut, new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(SnsConstants.SUBJECT, "This is my subject");
exchange.getIn().setBody("This is my message text.");
}
});
Assert.assertNotNull(exchange.getOut().getHeader(SnsConstants.MESSAGE_ID));
} finally {
camelctx.stop();
}
} finally {
snsClient.deleteTopic(arn);
}
} finally {
assertNoStaleTopic(snsClient, "after");
}
}
use of org.wildfly.extension.camel.WildFlyCamelContext in project wildfly-camel by wildfly-extras.
the class SQSIntegrationTest method sendInOnly.
@Test
public void sendInOnly() throws Exception {
AmazonSQSClient sqsClient = provider.getClient();
Assume.assumeNotNull("AWS client not null", sqsClient);
assertNoStaleQueue(sqsClient, "before");
try {
final String url = sqsClient.createQueue(queueName).getQueueUrl();
try {
WildFlyCamelContext camelctx = new WildFlyCamelContext();
camelctx.getNamingContext().bind("sqsClient", sqsClient);
camelctx.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:start").to("aws-sqs://" + queueName + "?amazonSQSClient=#sqsClient");
from("aws-sqs://" + queueName + "?amazonSQSClient=#sqsClient").to("mock:result");
}
});
MockEndpoint mockep = camelctx.getEndpoint("mock:result", MockEndpoint.class);
mockep.expectedMessageCount(1);
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
producer.send("direct:start", ExchangePattern.InOnly, new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody("This is my message text.");
}
});
mockep.assertIsSatisfied();
Exchange exchange = mockep.getExchanges().get(0);
Assert.assertEquals("This is my message text.", exchange.getIn().getBody());
Assert.assertNotNull(exchange.getIn().getHeader(SqsConstants.MESSAGE_ID));
Assert.assertNotNull(exchange.getIn().getHeader(SqsConstants.RECEIPT_HANDLE));
Assert.assertEquals("6a1559560f67c5e7a7d5d838bf0272ee", exchange.getIn().getHeader(SqsConstants.MD5_OF_BODY));
Assert.assertNotNull(exchange.getIn().getHeader(SqsConstants.ATTRIBUTES));
Assert.assertNotNull(exchange.getIn().getHeader(SqsConstants.MESSAGE_ATTRIBUTES));
} finally {
camelctx.stop();
}
} finally {
sqsClient.deleteQueue(url);
}
} finally {
assertNoStaleQueue(sqsClient, "after");
}
}
use of org.wildfly.extension.camel.WildFlyCamelContext in project wildfly-camel by wildfly-extras.
the class KinesisIntegrationTest method send.
@Test
public void send() throws Exception {
AmazonKinesisClient kinClient = provider.getClient();
Assume.assumeNotNull("AWS client not null", kinClient);
assertNoStaleStreams(kinClient, "before");
try {
KinesisUtils.createStream(kinClient, streamName);
try {
WildFlyCamelContext camelctx = new WildFlyCamelContext();
camelctx.getNamingContext().bind("kinClient", kinClient);
camelctx.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:start").to("aws-kinesis://" + streamName + "?amazonKinesisClient=#kinClient");
from("aws-kinesis://" + streamName + "?amazonKinesisClient=#kinClient").to("mock:result");
}
});
MockEndpoint mockep = camelctx.getEndpoint("mock:result", MockEndpoint.class);
mockep.expectedMessageCount(2);
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
Exchange exchange = producer.send("direct:start", ExchangePattern.InOnly, new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KinesisConstants.PARTITION_KEY, "partition-1");
exchange.getIn().setBody("Kinesis Event 1.");
}
});
Assert.assertNull(exchange.getException());
exchange = producer.send("direct:start", ExchangePattern.InOut, new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KinesisConstants.PARTITION_KEY, "partition-1");
exchange.getIn().setBody("Kinesis Event 2.");
}
});
Assert.assertNull(exchange.getException());
mockep.assertIsSatisfied();
assertResultExchange(mockep.getExchanges().get(0), "Kinesis Event 1.", "partition-1");
assertResultExchange(mockep.getExchanges().get(1), "Kinesis Event 2.", "partition-1");
} finally {
camelctx.stop();
}
} finally {
kinClient.deleteStream(streamName);
}
} finally {
assertNoStaleStreams(kinClient, "after");
}
}
use of org.wildfly.extension.camel.WildFlyCamelContext in project wildfly-camel by wildfly-extras.
the class GuavaEventIntegrationTest method shouldReceiveMessageFromCamel.
@Test
public void shouldReceiveMessageFromCamel() throws Exception {
WildFlyCamelContext camelctx = new WildFlyCamelContext();
camelctx.getNamingContext().bind("eventBusB", eventBus);
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("guava-eventbus:eventBusB");
}
});
camelctx.start();
try {
String message = "message";
eventBus.register(this);
ProducerTemplate producer = camelctx.createProducerTemplate();
producer.sendBody("direct:start", message);
Assert.assertEquals(message, receivedEvent);
} finally {
camelctx.stop();
}
}
use of org.wildfly.extension.camel.WildFlyCamelContext in project wildfly-camel by wildfly-extras.
the class CaffeineCacheIntegrationTest method before.
@Before
public void before() throws NamingException {
camelctx = new WildFlyCamelContext();
Context jndi = camelctx.getNamingContext();
jndi.rebind("cache", cache);
jndi.rebind("cacheRl", cacheRl);
jndi.rebind("cacheSc", cacheSc);
}
Aggregations