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());
}
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));
}
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());
}
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);
}
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"));
}
Aggregations