use of org.openstack4j.model.common.Payload in project camel by apache.
the class ObjectProducerTest method createTest.
@Test
public void createTest() throws Exception {
when(objectService.put(anyString(), anyString(), any(Payload.class))).thenReturn(ETAG);
msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.CREATE);
msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
msg.setHeader(SwiftConstants.OBJECT_NAME, OBJECT_NAME);
final Payload payload = getTmpPayload();
msg.setBody(payload);
producer.process(exchange);
ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<String> objectNameCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<Payload> payloadArgumentCaptor = ArgumentCaptor.forClass(Payload.class);
verify(objectService).put(containerNameCaptor.capture(), objectNameCaptor.capture(), payloadArgumentCaptor.capture());
assertEquals(CONTAINER_NAME, containerNameCaptor.getValue());
assertEquals(OBJECT_NAME, objectNameCaptor.getValue());
assertEquals(payload, payloadArgumentCaptor.getValue());
assertEquals(ETAG, msg.getBody(String.class));
}
use of org.openstack4j.model.common.Payload 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.common.Payload 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);
}
Aggregations