Search in sources :

Example 61 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage 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 62 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage 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 63 with DefaultMessage

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

Example 64 with DefaultMessage

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

the class OpenstackIntegrationTest method reserveGlanceImage.

@Test
public void reserveGlanceImage() throws Exception {
    CamelContext camelContext = Mockito.mock(CamelContext.class);
    when(camelContext.getHeadersMapFactory()).thenReturn(new DefaultHeadersMapFactory());
    GlanceEndpoint endpoint = Mockito.mock(GlanceEndpoint.class);
    when(endpoint.getOperation()).thenReturn(GlanceConstants.RESERVE);
    Message msg = new DefaultMessage(camelContext);
    msg.setBody(dummyImage);
    Exchange exchange = Mockito.mock(Exchange.class);
    when(exchange.getIn()).thenReturn(msg);
    Producer producer = new GlanceProducer(endpoint, client);
    producer.process(exchange);
    ArgumentCaptor<Image> captor = ArgumentCaptor.forClass(Image.class);
    verify(imageService).reserve(captor.capture());
    assertEquals(dummyImage, captor.getValue());
    Image result = msg.getBody(Image.class);
    assertNotNull(result.getId());
    assertEqualsImages(dummyImage, result);
}
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) DefaultHeadersMapFactory(org.apache.camel.impl.DefaultHeadersMapFactory) GlanceProducer(org.apache.camel.component.openstack.glance.GlanceProducer) Image(org.openstack4j.model.image.Image) GlanceImage(org.openstack4j.openstack.image.domain.GlanceImage) GlanceEndpoint(org.apache.camel.component.openstack.glance.GlanceEndpoint) Test(org.junit.Test)

Example 65 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage in project atlasmap by atlasmap.

the class AtlasMapMultiDocsTest method test.

@Test
@DirtiesContext
public void test() throws Exception {
    result.setExpectedCount(1);
    Map<String, Message> sourceMap = new HashMap<>();
    SourceContact javaSource = new SourceContact();
    javaSource.setFirstName("JavaFirstName");
    javaSource.setLastName("JavaLastName");
    javaSource.setPhoneNumber("JavaPhoneNumber");
    javaSource.setZipCode("JavaZipCode");
    Message msg = new DefaultMessage(camelContext);
    msg.setBody(javaSource);
    msg.setHeader("testProp", "java-source-header");
    sourceMap.put("DOCID-JAVA-CONTACT-S", msg);
    msg = new DefaultMessage(camelContext);
    msg.setBody(JSON_SOURCE);
    msg.setHeader("testProp", "json-source-header");
    sourceMap.put("DOCID-JSON-CONTACT-S", msg);
    msg = new DefaultMessage(camelContext);
    msg.setBody(XML_SOURCE);
    msg.setHeader("testProp", "xml-source-header");
    sourceMap.put("DOCID-XML-CONTACT-S", msg);
    ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
    producerTemplate.sendBodyAndProperty("direct:start", null, "CAPTURED_OUT_MESSAGES_MAP", sourceMap);
    MockEndpoint.assertIsSatisfied(camelContext);
    Exchange exchange = result.getExchanges().get(0);
    Map<?, ?> targetMap = exchange.getProperty("TARGET_MESSAGES_MAP", Map.class);
    verifyTargetDocs(targetMap);
    assertEquals("java-source-header", exchange.getProperty("target-exchange"));
    assertEquals("json-source-header", exchange.getProperty("testProp"));
    assertEquals("xml-source-header", exchange.getIn().getHeader("testProp"));
    assertEquals("java-source-headerjson-source-headerxml-source-header", exchange.getIn().getHeader("testPropExpression"));
}
Also used : DefaultMessage(org.apache.camel.impl.DefaultMessage) Exchange(org.apache.camel.Exchange) ProducerTemplate(org.apache.camel.ProducerTemplate) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) HashMap(java.util.HashMap) SourceContact(io.atlasmap.java.test.SourceContact) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Aggregations

DefaultMessage (org.apache.camel.impl.DefaultMessage)66 Message (org.apache.camel.Message)59 Exchange (org.apache.camel.Exchange)32 Test (org.junit.Test)31 DefaultExchange (org.apache.camel.impl.DefaultExchange)24 HashMap (java.util.HashMap)19 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)11 CamelContext (org.apache.camel.CamelContext)7 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 DefaultHeadersMapFactory (org.apache.camel.impl.DefaultHeadersMapFactory)6 NotificationMessage (se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage)5 IOException (java.io.IOException)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 Method (java.lang.reflect.Method)3