use of org.wildfly.extension.camel.WildFlyCamelContext in project wildfly-camel by wildfly-extras.
the class SpringRedisIntegrationTest method testRedisRoute.
@Test
@SuppressWarnings("rawtypes")
public void testRedisRoute() throws Exception {
Assume.assumeFalse("[#1701] Cannot start Redis server on Windows", EnvironmentUtils.isWindows());
JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
connectionFactory.afterPropertiesSet();
RedisTemplate redisTemplate = new RedisTemplate();
redisTemplate.setConnectionFactory(connectionFactory);
redisTemplate.afterPropertiesSet();
CamelContextFactory contextFactory = ServiceLocator.getRequiredService(CamelContextFactory.class);
WildFlyCamelContext camelctx = contextFactory.createCamelContext(getClass().getClassLoader());
Context jndictx = camelctx.getNamingContext();
jndictx.bind("redisTemplate", redisTemplate);
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
int port = Integer.parseInt(AvailablePortFinder.readServerData("redis-port"));
from("direct:start").to("spring-redis://localhost:" + port + "?redisTemplate=#redisTemplate");
}
});
camelctx.start();
try {
Object[] headers = new Object[] { RedisConstants.COMMAND, "SET", RedisConstants.KEY, "key1", RedisConstants.VALUE, "value" };
ProducerTemplate producer = camelctx.createProducerTemplate();
producer.send("direct:start", new Processor() {
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
for (int i = 0; i < headers.length; i = i + 2) {
in.setHeader(headers[i].toString(), headers[i + 1]);
}
}
});
Assert.assertEquals("value", redisTemplate.opsForValue().get("key1"));
} finally {
camelctx.stop();
}
}
use of org.wildfly.extension.camel.WildFlyCamelContext in project wildfly-camel by wildfly-extras.
the class S3IntegrationTest method testBucketOperations.
@Test
public void testBucketOperations() throws Exception {
AmazonS3Client s3Client = provider.getClient();
Assume.assumeNotNull("AWS client not null", s3Client);
assertNoStaleBuckets(s3Client, "before");
try {
try {
S3Utils.createBucket(s3Client, bucketName);
WildFlyCamelContext camelctx = new WildFlyCamelContext();
camelctx.getNamingContext().bind("s3Client", s3Client);
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
String clientref = "amazonS3Client=#s3Client";
from("direct:upload").to("aws-s3://" + bucketName + "?" + clientref);
from("aws-s3://" + bucketName + "?" + clientref).to("seda:read");
}
});
try {
camelctx.start();
try {
// Put object
Map<String, Object> headers = new HashMap<>();
headers.put(S3Constants.KEY, OBJECT_KEY);
ProducerTemplate producer = camelctx.createProducerTemplate();
String content = "My bucket content";
String result1 = producer.requestBodyAndHeaders("direct:upload", content, headers, String.class);
Assert.assertEquals(content, result1);
ConsumerTemplate consumer = camelctx.createConsumerTemplate();
String result2 = consumer.receiveBody("seda:read", String.class);
Assert.assertEquals(content, result2);
} finally {
camelctx.stop();
}
} finally {
s3Client.deleteObject(bucketName, OBJECT_KEY);
}
} finally {
S3Utils.deleteBucket(s3Client, bucketName);
}
} finally {
assertNoStaleBuckets(s3Client, "after");
}
}
use of org.wildfly.extension.camel.WildFlyCamelContext in project wildfly-camel by wildfly-extras.
the class InfinispanIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
camelctx = new WildFlyCamelContext();
cacheContainer = (CacheContainer) camelctx.getNamingContext().lookup(CONTAINER_NAME);
cacheName = cacheContainer.getCache().getName();
}
use of org.wildfly.extension.camel.WildFlyCamelContext in project wildfly-camel by wildfly-extras.
the class AzureIntegrationTest method createCamelContext.
private CamelContext createCamelContext(StorageCredentials creds) throws Exception {
WildFlyCamelContext camelctx = new WildFlyCamelContext();
Context jndictx = camelctx.getNamingContext();
jndictx.rebind("creds", creds);
return camelctx;
}
use of org.wildfly.extension.camel.WildFlyCamelContext in project wildfly-camel by wildfly-extras.
the class CaffeineLoadCacheIntegrationTest method before.
@Before
public void before() throws Exception {
CacheLoader<Integer, Integer> cl = new CacheLoader<Integer, Integer>() {
public Integer load(Integer key) throws Exception {
return key + 1;
}
};
cache = Caffeine.newBuilder().build(cl);
camelctx = new WildFlyCamelContext();
Context jndi = camelctx.getNamingContext();
jndi.rebind("cache", cache);
}
Aggregations