Search in sources :

Example 1 with SwiftEndpoint

use of org.apache.camel.component.openstack.swift.SwiftEndpoint in project wildfly-camel by wildfly-extras.

the class OpenstackIntegrationTest method testEndpoints.

@Test
public void testEndpoints() throws Exception {
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {

        public void configure() throws Exception {
            from("direct:start").to("openstack-swift:localhost");
            from("direct:start").to("openstack-nova:localhost");
            from("direct:start").to("openstack-neutron:localhost");
            from("direct:start").to("openstack-keystone:localhost");
            from("direct:start").to("openstack-glance:localhost");
            from("direct:start").to("openstack-cinder:localhost");
        }
    });
    SwiftEndpoint swiftEndpoint = camelctx.getEndpoint("openstack-swift:localhost", SwiftEndpoint.class);
    Assert.assertNotNull("SwiftEndpoint not null", swiftEndpoint);
    NovaEndpoint novaEndpoint = camelctx.getEndpoint("openstack-nova:localhost", NovaEndpoint.class);
    Assert.assertNotNull("NovaEndpoint not null", novaEndpoint);
    NeutronEndpoint neutronEndpoint = camelctx.getEndpoint("openstack-neutron:localhost", NeutronEndpoint.class);
    Assert.assertNotNull("NeutronEndpoint not null", neutronEndpoint);
    KeystoneEndpoint keystoneEndpoint = camelctx.getEndpoint("openstack-keystone:localhost", KeystoneEndpoint.class);
    Assert.assertNotNull("KeystoneEndpoint not null", keystoneEndpoint);
    GlanceEndpoint glanceEndpoint = camelctx.getEndpoint("openstack-glance:localhost", GlanceEndpoint.class);
    Assert.assertNotNull("GlanceEndpoint not null", glanceEndpoint);
    CinderEndpoint cinderEndpoint = camelctx.getEndpoint("openstack-cinder:localhost", CinderEndpoint.class);
    Assert.assertNotNull("cinderEndpoint not null", cinderEndpoint);
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CamelContext(org.apache.camel.CamelContext) NovaEndpoint(org.apache.camel.component.openstack.nova.NovaEndpoint) RouteBuilder(org.apache.camel.builder.RouteBuilder) NeutronEndpoint(org.apache.camel.component.openstack.neutron.NeutronEndpoint) CinderEndpoint(org.apache.camel.component.openstack.cinder.CinderEndpoint) SwiftEndpoint(org.apache.camel.component.openstack.swift.SwiftEndpoint) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) IOException(java.io.IOException) KeystoneEndpoint(org.apache.camel.component.openstack.keystone.KeystoneEndpoint) GlanceEndpoint(org.apache.camel.component.openstack.glance.GlanceEndpoint) Test(org.junit.Test)

Example 2 with SwiftEndpoint

use of org.apache.camel.component.openstack.swift.SwiftEndpoint in project wildfly-camel by wildfly-extras.

the class OpenstackIntegrationTest method createSwiftContainer.

@Test
public void createSwiftContainer() throws Exception {
    CamelContext camelContext = Mockito.mock(CamelContext.class);
    when(camelContext.getHeadersMapFactory()).thenReturn(new DefaultHeadersMapFactory());
    Message msg = new DefaultMessage(camelContext);
    Exchange exchange = Mockito.mock(Exchange.class);
    when(exchange.getIn()).thenReturn(msg);
    when(containerService.create(anyString(), nullable(CreateUpdateContainerOptions.class))).thenReturn(actionResponse);
    when(actionResponse.isSuccess()).thenReturn(true);
    SwiftEndpoint endpoint = Mockito.mock(SwiftEndpoint.class);
    Producer producer = new ContainerProducer(endpoint, client);
    msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.CREATE);
    msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
    producer.process(exchange);
    ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<CreateUpdateContainerOptions> optionsCaptor = ArgumentCaptor.forClass(CreateUpdateContainerOptions.class);
    verify(containerService).create(containerNameCaptor.capture(), optionsCaptor.capture());
    assertEquals(CONTAINER_NAME, containerNameCaptor.getValue());
    assertNull(optionsCaptor.getValue());
    assertFalse(msg.isFault());
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CamelContext(org.apache.camel.CamelContext) DefaultMessage(org.apache.camel.impl.DefaultMessage) Exchange(org.apache.camel.Exchange) CreateUpdateContainerOptions(org.openstack4j.model.storage.object.options.CreateUpdateContainerOptions) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) VolumeProducer(org.apache.camel.component.openstack.cinder.producer.VolumeProducer) ProjectProducer(org.apache.camel.component.openstack.keystone.producer.ProjectProducer) ContainerProducer(org.apache.camel.component.openstack.swift.producer.ContainerProducer) GlanceProducer(org.apache.camel.component.openstack.glance.GlanceProducer) KeypairProducer(org.apache.camel.component.openstack.nova.producer.KeypairProducer) Producer(org.apache.camel.Producer) NetworkProducer(org.apache.camel.component.openstack.neutron.producer.NetworkProducer) ContainerProducer(org.apache.camel.component.openstack.swift.producer.ContainerProducer) DefaultHeadersMapFactory(org.apache.camel.impl.DefaultHeadersMapFactory) SwiftEndpoint(org.apache.camel.component.openstack.swift.SwiftEndpoint) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

CamelContext (org.apache.camel.CamelContext)2 SwiftEndpoint (org.apache.camel.component.openstack.swift.SwiftEndpoint)2 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 Exchange (org.apache.camel.Exchange)1 Message (org.apache.camel.Message)1 Producer (org.apache.camel.Producer)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 CinderEndpoint (org.apache.camel.component.openstack.cinder.CinderEndpoint)1 VolumeProducer (org.apache.camel.component.openstack.cinder.producer.VolumeProducer)1 GlanceEndpoint (org.apache.camel.component.openstack.glance.GlanceEndpoint)1 GlanceProducer (org.apache.camel.component.openstack.glance.GlanceProducer)1 KeystoneEndpoint (org.apache.camel.component.openstack.keystone.KeystoneEndpoint)1 ProjectProducer (org.apache.camel.component.openstack.keystone.producer.ProjectProducer)1 NeutronEndpoint (org.apache.camel.component.openstack.neutron.NeutronEndpoint)1 NetworkProducer (org.apache.camel.component.openstack.neutron.producer.NetworkProducer)1 NovaEndpoint (org.apache.camel.component.openstack.nova.NovaEndpoint)1 KeypairProducer (org.apache.camel.component.openstack.nova.producer.KeypairProducer)1 ContainerProducer (org.apache.camel.component.openstack.swift.producer.ContainerProducer)1