Search in sources :

Example 1 with JcloudsComponent

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();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) RouteBuilder(org.apache.camel.builder.RouteBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) ArrayList(java.util.ArrayList) StringPayload(org.jclouds.io.payloads.StringPayload) BlobStore(org.jclouds.blobstore.BlobStore) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) JcloudsComponent(org.apache.camel.component.jclouds.JcloudsComponent) Test(org.junit.Test)

Example 2 with JcloudsComponent

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();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) RouteBuilder(org.apache.camel.builder.RouteBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) ArrayList(java.util.ArrayList) StringPayload(org.jclouds.io.payloads.StringPayload) BlobStore(org.jclouds.blobstore.BlobStore) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) JcloudsComponent(org.apache.camel.component.jclouds.JcloudsComponent) Test(org.junit.Test)

Example 3 with JcloudsComponent

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();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) RouteBuilder(org.apache.camel.builder.RouteBuilder) ArrayList(java.util.ArrayList) BlobStore(org.jclouds.blobstore.BlobStore) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) JcloudsComponent(org.apache.camel.component.jclouds.JcloudsComponent) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)3 CamelContext (org.apache.camel.CamelContext)3 RouteBuilder (org.apache.camel.builder.RouteBuilder)3 JcloudsComponent (org.apache.camel.component.jclouds.JcloudsComponent)3 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)3 BlobStore (org.jclouds.blobstore.BlobStore)3 Test (org.junit.Test)3 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)2 StringPayload (org.jclouds.io.payloads.StringPayload)2 ProducerTemplate (org.apache.camel.ProducerTemplate)1