use of org.openstack4j.model.image.Image in project camel by apache.
the class GlanceProducerTest method reserveWithHeadersTest.
@Test
public void reserveWithHeadersTest() throws Exception {
when(endpoint.getOperation()).thenReturn(GlanceConstants.RESERVE);
msg.setHeader(OpenstackConstants.NAME, dummyImage.getName());
msg.setHeader(GlanceConstants.CONTAINER_FORMAT, dummyImage.getContainerFormat());
msg.setHeader(GlanceConstants.DISK_FORMAT, dummyImage.getDiskFormat());
msg.setHeader(GlanceConstants.CHECKSUM, dummyImage.getChecksum());
msg.setHeader(GlanceConstants.MIN_DISK, dummyImage.getMinDisk());
msg.setHeader(GlanceConstants.MIN_RAM, dummyImage.getMinRam());
msg.setHeader(GlanceConstants.OWNER, dummyImage.getOwner());
producer.process(exchange);
final ArgumentCaptor<Image> captor = ArgumentCaptor.forClass(Image.class);
verify(imageService).reserve(captor.capture());
assertEqualsImages(dummyImage, captor.getValue());
final Image result = msg.getBody(Image.class);
assertNotNull(result.getId());
assertEqualsImages(dummyImage, result);
}
use of org.openstack4j.model.image.Image in project camel by apache.
the class GlanceProducer method doReserve.
private void doReserve(Exchange exchange) {
final Image in = messageToImage(exchange.getIn());
final Image out = os.images().reserve(in);
exchange.getIn().setBody(out);
}
use of org.openstack4j.model.image.Image in project camel by apache.
the class GlanceProducerTest method createTest.
@Test
public void createTest() throws Exception {
msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.CREATE);
msg.setHeader(OpenstackConstants.NAME, dummyImage.getName());
msg.setHeader(GlanceConstants.OWNER, dummyImage.getOwner());
msg.setHeader(GlanceConstants.MIN_DISK, dummyImage.getMinDisk());
msg.setHeader(GlanceConstants.MIN_RAM, dummyImage.getMinRam());
msg.setHeader(GlanceConstants.CHECKSUM, dummyImage.getChecksum());
msg.setHeader(GlanceConstants.DISK_FORMAT, dummyImage.getDiskFormat());
msg.setHeader(GlanceConstants.CONTAINER_FORMAT, dummyImage.getContainerFormat());
final InputStream is = new FileInputStream(File.createTempFile("image", ".iso"));
msg.setBody(is);
producer.process(exchange);
final ArgumentCaptor<Payload> payloadCaptor = ArgumentCaptor.forClass(Payload.class);
final ArgumentCaptor<org.openstack4j.model.image.Image> imageCaptor = ArgumentCaptor.forClass(org.openstack4j.model.image.Image.class);
verify(imageService).create(imageCaptor.capture(), payloadCaptor.capture());
assertEquals(is, payloadCaptor.getValue().open());
final Image result = msg.getBody(Image.class);
assertNotNull(result.getId());
assertEqualsImages(dummyImage, result);
}
use of org.openstack4j.model.image.Image in project camel by apache.
the class GlanceProducerTest method uploadWithoutUpdatingTest.
@Test
public void uploadWithoutUpdatingTest() throws Exception {
msg.setHeader(OpenstackConstants.OPERATION, GlanceConstants.UPLOAD);
final String id = "id";
msg.setHeader(OpenstackConstants.ID, id);
final File file = File.createTempFile("image", ".iso");
msg.setBody(file);
producer.process(exchange);
final ArgumentCaptor<Payload> payloadCaptor = ArgumentCaptor.forClass(Payload.class);
final ArgumentCaptor<String> imageIdCaptor = ArgumentCaptor.forClass(String.class);
final ArgumentCaptor<org.openstack4j.model.image.Image> imageCaptor = ArgumentCaptor.forClass(org.openstack4j.model.image.Image.class);
verify(imageService).upload(imageIdCaptor.capture(), payloadCaptor.capture(), imageCaptor.capture());
assertEquals(file, payloadCaptor.getValue().getRaw());
assertEquals(id, imageIdCaptor.getValue());
assertNull(imageCaptor.getValue());
final Image result = msg.getBody(Image.class);
assertNotNull(result.getId());
assertEqualsImages(dummyImage, result);
}
use of org.openstack4j.model.image.Image in project camel by apache.
the class GlanceProducerTest method reserveTest.
@Test
public void reserveTest() throws Exception {
when(endpoint.getOperation()).thenReturn(GlanceConstants.RESERVE);
msg.setBody(dummyImage);
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);
}
Aggregations