use of org.wildfly.extension.camel.WildFlyCamelContext in project wildfly-camel by wildfly-extras.
the class DynamoDBIntegrationTest method testKeyValueOperations.
@Test
public void testKeyValueOperations() throws Exception {
AmazonDynamoDBClient client = provider.getClient();
Assume.assumeNotNull("AWS client not null", client);
DynamoDBUtils.assertNoStaleTables(client, "before");
try {
try {
TableDescription description = DynamoDBUtils.createTable(client, tableName);
Assert.assertEquals("ACTIVE", description.getTableStatus());
WildFlyCamelContext camelctx = new WildFlyCamelContext();
camelctx.getNamingContext().bind("ddbClientA", client);
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("aws-ddb://" + tableName + "?amazonDDBClient=#ddbClientA");
}
});
camelctx.start();
try {
DynamoDBUtils.putItem(camelctx, "Book 103 Title");
String result = ((AttributeValue) DynamoDBUtils.getItem(camelctx).get("Title")).getS();
Assert.assertEquals("Book 103 Title", result);
DynamoDBUtils.updItem(camelctx, "Book 103 Update");
result = ((AttributeValue) DynamoDBUtils.getItem(camelctx).get("Title")).getS();
Assert.assertEquals("Book 103 Update", result);
} finally {
camelctx.stop();
}
} finally {
DynamoDBUtils.deleteTable(client, tableName);
}
} finally {
DynamoDBUtils.assertNoStaleTables(client, "after");
}
}
use of org.wildfly.extension.camel.WildFlyCamelContext in project wildfly-camel by wildfly-extras.
the class EC2IntegrationTest method testCreateInstance.
@Test
public void testCreateInstance() throws Exception {
AmazonEC2Client ec2Client = provider.getClient();
Assume.assumeNotNull("AWS client not null", ec2Client);
assertNoStaleInstances(ec2Client, "before");
try {
WildFlyCamelContext camelctx = new WildFlyCamelContext();
camelctx.getNamingContext().bind("ec2Client", ec2Client);
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:createAndRun").to("aws-ec2://TestDomain?amazonEc2Client=#ec2Client&operation=createAndRunInstances");
from("direct:terminate").to("aws-ec2://TestDomain?amazonEc2Client=#ec2Client&operation=terminateInstances");
}
});
camelctx.start();
try {
// Create and run an instance
Map<String, Object> headers = new HashMap<>();
headers.put(EC2Constants.IMAGE_ID, "ami-02ace471");
headers.put(EC2Constants.INSTANCE_TYPE, InstanceType.T2Micro);
headers.put(EC2Constants.SUBNET_ID, EC2Utils.getSubnetId(ec2Client));
headers.put(EC2Constants.INSTANCE_MIN_COUNT, 1);
headers.put(EC2Constants.INSTANCE_MAX_COUNT, 1);
headers.put(EC2Constants.INSTANCES_TAGS, Arrays.asList(new Tag("Name", "wildfly-camel")));
ProducerTemplate template = camelctx.createProducerTemplate();
RunInstancesResult result1 = template.requestBodyAndHeaders("direct:createAndRun", null, headers, RunInstancesResult.class);
String instanceId = result1.getReservation().getInstances().get(0).getInstanceId();
System.out.println("InstanceId: " + instanceId);
// Terminate the instance
headers = new HashMap<>();
headers.put(EC2Constants.INSTANCES_IDS, Collections.singleton(instanceId));
TerminateInstancesResult result2 = template.requestBodyAndHeaders("direct:terminate", null, headers, TerminateInstancesResult.class);
Assert.assertEquals(instanceId, result2.getTerminatingInstances().get(0).getInstanceId());
} finally {
camelctx.stop();
}
} finally {
assertNoStaleInstances(ec2Client, "after");
}
}
use of org.wildfly.extension.camel.WildFlyCamelContext in project wildfly-camel by wildfly-extras.
the class SESIntegrationTest method sendSimpleMessage.
@Test
public void sendSimpleMessage() throws Exception {
AmazonSimpleEmailServiceClient sesClient = provider.getClient();
Assume.assumeNotNull("AWS client not null", sesClient);
WildFlyCamelContext camelctx = new WildFlyCamelContext();
camelctx.getNamingContext().bind("sesClient", sesClient);
camelctx.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:start").to("aws-ses://" + SESUtils.FROM + "?amazonSESClient=#sesClient");
}
});
camelctx.start();
try {
Exchange exchange = ExchangeBuilder.anExchange(camelctx).withHeader(SesConstants.SUBJECT, SESUtils.SUBJECT).withHeader(SesConstants.TO, Collections.singletonList(SESUtils.TO)).withBody("Hello world!").build();
ProducerTemplate producer = camelctx.createProducerTemplate();
Exchange result = producer.send("direct:start", exchange);
String messageId = result.getIn().getHeader(SesConstants.MESSAGE_ID, String.class);
Assert.assertNotNull("MessageId not null", messageId);
} finally {
camelctx.stop();
}
}
use of org.wildfly.extension.camel.WildFlyCamelContext in project wildfly-camel by wildfly-extras.
the class ReactorIntegrationTest method createWildFlyCamelContext.
private CamelContext createWildFlyCamelContext() throws Exception {
WildFlyCamelContext camelctx = new WildFlyCamelContext();
if (boundAlready.compareAndSet(false, true)) {
Context jndictx = camelctx.getNamingContext();
jndictx.bind("hello", new SampleBean());
}
return camelctx;
}
use of org.wildfly.extension.camel.WildFlyCamelContext in project wildfly-camel by wildfly-extras.
the class SNSIntegrationTest method sendInOnly.
@Test
public void sendInOnly() 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("snsClientA", snsClient);
camelctx.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:start").to("aws-sns://" + topicName + "?amazonSNSClient=#snsClientA");
}
});
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(SnsConstants.SUBJECT, "This is my subject");
exchange.getIn().setBody("This is my message text.");
}
});
Assert.assertNotNull(exchange.getIn().getHeader(SnsConstants.MESSAGE_ID));
} finally {
camelctx.stop();
}
} finally {
snsClient.deleteTopic(arn);
}
} finally {
assertNoStaleTopic(snsClient, "after");
}
}
Aggregations