| /** |
| * Licensed to jclouds, Inc. (jclouds) under one or more |
| * contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. jclouds licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| package org.jclouds.openstack.nova.v2_0.features; |
| |
| import static org.testng.Assert.assertEquals; |
| import static org.testng.Assert.assertFalse; |
| import static org.testng.Assert.assertNotNull; |
| import static org.testng.Assert.assertTrue; |
| |
| import java.util.Set; |
| |
| import org.jclouds.openstack.nova.v2_0.domain.Image; |
| import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest; |
| import org.jclouds.openstack.v2_0.domain.Resource; |
| import org.testng.annotations.Test; |
| |
| /** |
| * Tests behavior of {@link ImageApi} |
| * |
| * @author Michael Arnold |
| */ |
| @Test(groups = "live", testName = "ImageApiLiveTest") |
| public class ImageApiLiveTest extends BaseNovaApiLiveTest { |
| |
| @Test(description = "GET /v${apiVersion}/{tenantId}/images") |
| public void testListImages() throws Exception { |
| for (String zoneId : zones) { |
| ImageApi api = novaContext.getApi().getImageApiForZone(zoneId); |
| Set<? extends Resource> response = api.listImages(); |
| assertNotNull(response); |
| assertFalse(response.isEmpty()); |
| for (Resource image : response) { |
| assertNotNull(image.getId()); |
| assertNotNull(image.getName()); |
| assertNotNull(image.getLinks()); |
| } |
| } |
| } |
| |
| @Test(description = "GET /v${apiVersion}/{tenantId}/images/detail") |
| public void testListImagesInDetail() throws Exception { |
| for (String zoneId : novaContext.getApi().getConfiguredZones()) { |
| ImageApi api = novaContext.getApi().getImageApiForZone(zoneId); |
| Set<? extends Image> response = api.listImagesInDetail(); |
| assertNotNull(response); |
| assertFalse(response.isEmpty()); |
| for (Image image : response) { |
| assertNotNull(image.getId()); |
| assertNotNull(image.getName()); |
| assertNotNull(image.getLinks()); |
| assertNotNull(image.getCreated()); |
| assertTrue(image.getMinDisk() > 0); |
| assertTrue(image.getMinRam() > 0); |
| assertTrue(image.getProgress() >= 0 && image.getProgress() <= 100); |
| assertNotNull(image.getStatus()); |
| assertNotNull(image.getServer()); |
| assertNotNull(image.getTenantId()); |
| assertNotNull(image.getUpdated()); |
| assertNotNull(image.getUserId()); |
| } |
| } |
| } |
| |
| @Test(description = "GET /v${apiVersion}/{tenantId}/images/{id}", dependsOnMethods = { "testListImagesInDetail" }) |
| public void testGetImageById() throws Exception { |
| for (String zoneId : novaContext.getApi().getConfiguredZones()) { |
| ImageApi api = novaContext.getApi().getImageApiForZone(zoneId); |
| Set<? extends Image> response = api.listImagesInDetail(); |
| for (Image image : response) { |
| Image details = api.getImage(image.getId()); |
| assertNotNull(details); |
| assertEquals(details.getId(), image.getId()); |
| assertEquals(details.getName(), image.getName()); |
| assertEquals(details.getLinks(), image.getLinks()); |
| assertEquals(details.getCreated(), image.getCreated()); |
| assertEquals(details.getMinDisk(), image.getMinDisk()); |
| assertEquals(details.getMinRam(), image.getMinRam()); |
| assertEquals(details.getProgress(), image.getProgress()); |
| assertEquals(details.getStatus(), image.getStatus()); |
| assertEquals(details.getServer(), image.getServer()); |
| assertEquals(details.getTenantId(), image.getTenantId()); |
| assertEquals(details.getUpdated(), image.getUpdated()); |
| assertEquals(details.getUserId(), image.getUserId()); |
| } |
| } |
| } |
| } |