Search in sources :

Example 1 with DefaultHeadersMapFactory

use of org.apache.camel.impl.DefaultHeadersMapFactory 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)

Example 2 with DefaultHeadersMapFactory

use of org.apache.camel.impl.DefaultHeadersMapFactory in project wildfly-camel by wildfly-extras.

the class OpenstackIntegrationTest method createNeutronNetwork.

@Test
public void createNeutronNetwork() 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);
    msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.CREATE);
    msg.setHeader(OpenstackConstants.NAME, dummyNetwork.getName());
    msg.setHeader(NeutronConstants.NETWORK_TYPE, dummyNetwork.getNetworkType());
    msg.setHeader(NeutronConstants.TENANT_ID, dummyNetwork.getTenantId());
    NeutronEndpoint endpoint = Mockito.mock(NeutronEndpoint.class);
    Producer producer = new NetworkProducer(endpoint, client);
    producer.process(exchange);
    ArgumentCaptor<Network> captor = ArgumentCaptor.forClass(Network.class);
    verify(networkService).create(captor.capture());
    assertEqualsNetwork(dummyNetwork, captor.getValue());
    assertNotNull(msg.getBody(Network.class).getId());
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CamelContext(org.apache.camel.CamelContext) DefaultMessage(org.apache.camel.impl.DefaultMessage) Exchange(org.apache.camel.Exchange) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) NeutronEndpoint(org.apache.camel.component.openstack.neutron.NeutronEndpoint) 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) Network(org.openstack4j.model.network.Network) DefaultHeadersMapFactory(org.apache.camel.impl.DefaultHeadersMapFactory) NetworkProducer(org.apache.camel.component.openstack.neutron.producer.NetworkProducer) Test(org.junit.Test)

Example 3 with DefaultHeadersMapFactory

use of org.apache.camel.impl.DefaultHeadersMapFactory in project wildfly-camel by wildfly-extras.

the class OpenstackIntegrationTest method testNovaKeypair.

@Test
public void testNovaKeypair() throws Exception {
    when(osTestKeypair.getName()).thenReturn(KEYPAIR_NAME);
    when(osTestKeypair.getPublicKey()).thenReturn(dummyKeypair.getPublicKey());
    when(osTestKeypair.getFingerprint()).thenReturn("fp");
    when(osTestKeypair.getPrivateKey()).thenReturn("prk");
    CamelContext camelContext = Mockito.mock(CamelContext.class);
    when(camelContext.getHeadersMapFactory()).thenReturn(new DefaultHeadersMapFactory());
    Message msg = new DefaultMessage(camelContext);
    msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.CREATE);
    msg.setHeader(OpenstackConstants.NAME, KEYPAIR_NAME);
    Exchange exchange = Mockito.mock(Exchange.class);
    when(exchange.getIn()).thenReturn(msg);
    NovaEndpoint endpoint = Mockito.mock(NovaEndpoint.class);
    Producer producer = new KeypairProducer(endpoint, client);
    producer.process(exchange);
    ArgumentCaptor<String> nameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> keypairCaptor = ArgumentCaptor.forClass(String.class);
    verify(keypairService).create(nameCaptor.capture(), keypairCaptor.capture());
    assertEquals(KEYPAIR_NAME, nameCaptor.getValue());
    assertNull(keypairCaptor.getValue());
    Keypair result = msg.getBody(Keypair.class);
    assertEquals("fp", result.getFingerprint());
    assertEquals("prk", result.getPrivateKey());
    assertEquals(dummyKeypair.getName(), result.getName());
    assertEquals(dummyKeypair.getPublicKey(), result.getPublicKey());
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CamelContext(org.apache.camel.CamelContext) DefaultMessage(org.apache.camel.impl.DefaultMessage) Exchange(org.apache.camel.Exchange) NovaEndpoint(org.apache.camel.component.openstack.nova.NovaEndpoint) NovaKeypair(org.openstack4j.openstack.compute.domain.NovaKeypair) Keypair(org.openstack4j.model.compute.Keypair) 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) DefaultHeadersMapFactory(org.apache.camel.impl.DefaultHeadersMapFactory) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) KeypairProducer(org.apache.camel.component.openstack.nova.producer.KeypairProducer) Test(org.junit.Test)

Example 4 with DefaultHeadersMapFactory

use of org.apache.camel.impl.DefaultHeadersMapFactory in project wildfly-camel by wildfly-extras.

the class OpenstackIntegrationTest method createCinderVolume.

@Test
public void createCinderVolume() 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);
    CinderEndpoint endpoint = Mockito.mock(CinderEndpoint.class);
    when(endpoint.getOperation()).thenReturn(OpenstackConstants.CREATE);
    msg.setBody(dummyVolume);
    Producer producer = new VolumeProducer(endpoint, client);
    producer.process(exchange);
    assertEqualVolumes(dummyVolume, msg.getBody(Volume.class));
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CamelContext(org.apache.camel.CamelContext) DefaultMessage(org.apache.camel.impl.DefaultMessage) Exchange(org.apache.camel.Exchange) 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) Volume(org.openstack4j.model.storage.block.Volume) CinderEndpoint(org.apache.camel.component.openstack.cinder.CinderEndpoint) VolumeProducer(org.apache.camel.component.openstack.cinder.producer.VolumeProducer) DefaultHeadersMapFactory(org.apache.camel.impl.DefaultHeadersMapFactory) Test(org.junit.Test)

Example 5 with DefaultHeadersMapFactory

use of org.apache.camel.impl.DefaultHeadersMapFactory in project wildfly-camel by wildfly-extras.

the class OpenstackIntegrationTest method createKeystoneProject.

@Test
public void createKeystoneProject() 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);
    msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.CREATE);
    msg.setHeader(OpenstackConstants.NAME, dummyProject.getName());
    msg.setHeader(KeystoneConstants.DESCRIPTION, dummyProject.getDescription());
    msg.setHeader(KeystoneConstants.DOMAIN_ID, dummyProject.getDomainId());
    msg.setHeader(KeystoneConstants.PARENT_ID, dummyProject.getParentId());
    KeystoneEndpoint endpoint = Mockito.mock(KeystoneEndpoint.class);
    Producer producer = new ProjectProducer(endpoint, client);
    producer.process(exchange);
    ArgumentCaptor<Project> captor = ArgumentCaptor.forClass(Project.class);
    verify(projectService).create(captor.capture());
    assertEqualsProject(dummyProject, captor.getValue());
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CamelContext(org.apache.camel.CamelContext) DefaultMessage(org.apache.camel.impl.DefaultMessage) Exchange(org.apache.camel.Exchange) Project(org.openstack4j.model.identity.v3.Project) 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) ProjectProducer(org.apache.camel.component.openstack.keystone.producer.ProjectProducer) DefaultHeadersMapFactory(org.apache.camel.impl.DefaultHeadersMapFactory) KeystoneEndpoint(org.apache.camel.component.openstack.keystone.KeystoneEndpoint) Test(org.junit.Test)

Aggregations

CamelContext (org.apache.camel.CamelContext)6 Exchange (org.apache.camel.Exchange)6 Message (org.apache.camel.Message)6 Producer (org.apache.camel.Producer)6 VolumeProducer (org.apache.camel.component.openstack.cinder.producer.VolumeProducer)6 GlanceProducer (org.apache.camel.component.openstack.glance.GlanceProducer)6 ProjectProducer (org.apache.camel.component.openstack.keystone.producer.ProjectProducer)6 NetworkProducer (org.apache.camel.component.openstack.neutron.producer.NetworkProducer)6 KeypairProducer (org.apache.camel.component.openstack.nova.producer.KeypairProducer)6 ContainerProducer (org.apache.camel.component.openstack.swift.producer.ContainerProducer)6 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)6 DefaultHeadersMapFactory (org.apache.camel.impl.DefaultHeadersMapFactory)6 DefaultMessage (org.apache.camel.impl.DefaultMessage)6 Test (org.junit.Test)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 CinderEndpoint (org.apache.camel.component.openstack.cinder.CinderEndpoint)1 GlanceEndpoint (org.apache.camel.component.openstack.glance.GlanceEndpoint)1 KeystoneEndpoint (org.apache.camel.component.openstack.keystone.KeystoneEndpoint)1 NeutronEndpoint (org.apache.camel.component.openstack.neutron.NeutronEndpoint)1 NovaEndpoint (org.apache.camel.component.openstack.nova.NovaEndpoint)1