use of org.apache.camel.component.openstack.nova.NovaEndpoint 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);
}
use of org.apache.camel.component.openstack.nova.NovaEndpoint 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());
}
Aggregations