@Test
public void testCreateUpdateAndDeleteImage() {
StringPayload imageData = new StringPayload("This isn't really an image!");
for (String zoneId : api.getConfiguredZones()) {
ImageApi imageApi = api.getImageApiForZone(zoneId);
ImageDetails details = imageApi.create("jclouds-live-test", imageData, diskFormat(DiskFormat.RAW), containerFormat(ContainerFormat.BARE));
assertEquals(details.getName(), "jclouds-live-test");
assertEquals(details.getSize().get().longValue(), imageData.getRawContent().length());
details = imageApi.update(details.getId(), UpdateImageOptions.Builder.name("jclouds-live-test2"), UpdateImageOptions.Builder.minDisk(10));
assertEquals(details.getName(), "jclouds-live-test2");
assertEquals(details.getMinDisk(), 10);
Image fromListing = imageApi.list(
ListImageOptions.Builder.containerFormat(ContainerFormat.BARE).name("jclouds-live-test2").limit(2))
.get(0);
assertEquals(fromListing.getId(), details.getId());
assertEquals(fromListing.getSize(), details.getSize());
assertEquals(Iterables.getOnlyElement(imageApi.listInDetail(ListImageOptions.Builder.name("jclouds-live-test2"))), details);
assertTrue(imageApi.delete(details.getId()));
assertTrue(imageApi.list(ListImageOptions.Builder.name("jclouds-live-test2")).isEmpty());
}
}