use of org.apache.camel.component.jclouds.JcloudsComponent in project wildfly-camel by wildfly-extras.
the class JCloudsBlobStoreIntegrationTest method testBlobStoreConsumerWithDirectory.
@Test
public void testBlobStoreConsumerWithDirectory() throws Exception {
BlobStore blobStore = getBlobStore();
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
fromF("jclouds:blobstore:transient?container=%s&directory=dir", CONTAINER_NAME_WITH_DIR).convertBodyTo(String.class).to("mock:result");
}
});
List<BlobStore> blobStores = new ArrayList<>();
blobStores.add(blobStore);
JcloudsComponent jclouds = camelctx.getComponent("jclouds", JcloudsComponent.class);
jclouds.setBlobStores(blobStores);
MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class);
mockEndpoint.expectedBodiesReceived("Hello Kermit");
camelctx.start();
try {
JcloudsBlobStoreHelper.writeBlob(blobStore, CONTAINER_NAME_WITH_DIR, BLOB_NAME_WITH_DIR, new StringPayload("Hello Kermit"));
mockEndpoint.assertIsSatisfied();
} finally {
camelctx.stop();
}
}
use of org.apache.camel.component.jclouds.JcloudsComponent in project wildfly-camel by wildfly-extras.
the class JCloudsBlobStoreIntegrationTest method testBlobStoreConsumer.
@Test
public void testBlobStoreConsumer() throws Exception {
BlobStore blobStore = getBlobStore();
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
fromF("jclouds:blobstore:transient?container=%s", CONTAINER_NAME).convertBodyTo(String.class).to("mock:result");
}
});
List<BlobStore> blobStores = new ArrayList<>();
blobStores.add(blobStore);
JcloudsComponent jclouds = camelctx.getComponent("jclouds", JcloudsComponent.class);
jclouds.setBlobStores(blobStores);
MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class);
mockEndpoint.expectedBodiesReceived("Hello Kermit");
camelctx.start();
try {
JcloudsBlobStoreHelper.writeBlob(blobStore, CONTAINER_NAME, BLOB_NAME, new StringPayload("Hello Kermit"));
mockEndpoint.assertIsSatisfied();
} finally {
camelctx.stop();
}
}
use of org.apache.camel.component.jclouds.JcloudsComponent in project wildfly-camel by wildfly-extras.
the class JCloudsBlobStoreIntegrationTest method testBlobStoreProducer.
@Test
public void testBlobStoreProducer() throws Exception {
BlobStore blobStore = getBlobStore();
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").setHeader(JcloudsConstants.BLOB_NAME, constant(BLOB_NAME_WITH_DIR)).setHeader(JcloudsConstants.CONTAINER_NAME, constant(CONTAINER_NAME_WITH_DIR)).to("jclouds:blobstore:transient");
}
});
List<BlobStore> blobStores = new ArrayList<>();
blobStores.add(blobStore);
JcloudsComponent jclouds = camelctx.getComponent("jclouds", JcloudsComponent.class);
jclouds.setBlobStores(blobStores);
camelctx.start();
try {
ProducerTemplate template = camelctx.createProducerTemplate();
String result = template.requestBody("direct:start", "Hello Kermit", String.class);
Assert.assertEquals("Hello Kermit", result);
} finally {
camelctx.stop();
}
}
Aggregations