issue 830: more LiveTests fixed on query, vapp, vapptemplate and vdc features

This commit is contained in:
Andrea Turli 2012-08-23 16:56:08 +02:00
parent 4cd8d17e82
commit 4e8149bfe8
6 changed files with 48 additions and 71 deletions

View File

@ -271,7 +271,6 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest {
assertNull(removed); assertNull(removed);
} }
private void removeMediaAttachedToCatalogItem(CatalogItem catalogItem) { private void removeMediaAttachedToCatalogItem(CatalogItem catalogItem) {
if (media != null) { if (media != null) {
if (catalogItem.getEntity().getHref().equals(media.getHref())) { if (catalogItem.getEntity().getHref().equals(media.getHref())) {

View File

@ -134,7 +134,6 @@ public class QueryApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "GET /vApps/query") @Test(description = "GET /vApps/query")
public void testQueryAllVApps() { public void testQueryAllVApps() {
vApp = instantiateVApp(); vApp = instantiateVApp();
QueryResultRecords queryResult = queryApi.vAppsQueryAll(); QueryResultRecords queryResult = queryApi.vAppsQueryAll();
Set<URI> hrefs = toHrefs(queryResult); Set<URI> hrefs = toHrefs(queryResult);

View File

@ -114,7 +114,7 @@ import com.google.common.collect.Sets;
* *
* @author grkvlt@apache.org * @author grkvlt@apache.org
*/ */
@Test(groups = { "live", "user" }, singleThreaded = true, testName = "VAppApiLiveTest") @Test(singleThreaded = true, testName = "VAppApiLiveTest")
public class VAppApiLiveTest extends AbstractVAppApiLiveTest { public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
private MetadataValue metadataValue; private MetadataValue metadataValue;
@ -146,7 +146,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
/** /**
* @see VAppApi#get(URI) * @see VAppApi#get(URI)
*/ */
@Test(description = "GET /vApp/{id}") @Test(groups = { "live", "user" }, description = "GET /vApp/{id}")
public void testGetVApp() { public void testGetVApp() {
// The method under test // The method under test
vApp = vAppApi.get(vAppUrn); vApp = vAppApi.get(vAppUrn);
@ -169,7 +169,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
assertVAppStatus(vAppUrn, Status.POWERED_OFF); assertVAppStatus(vAppUrn, Status.POWERED_OFF);
} }
@Test(description = "POST /vApp/{id}/action/recomposeVApp") @Test(groups = { "live", "user" }, description = "POST /vApp/{id}/action/recomposeVApp")
public void testRecomposeVApp() { public void testRecomposeVApp() {
VApp composedVApp = vdcApi.composeVApp(vdcUrn, ComposeVAppParams.builder() VApp composedVApp = vdcApi.composeVApp(vdcUrn, ComposeVAppParams.builder()
@ -227,7 +227,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
/** /**
* @see VAppApi#edit(URI, VApp) * @see VAppApi#edit(URI, VApp)
*/ */
@Test(description = "PUT /vApp/{id}", dependsOnMethods = { "testGetVApp" }) @Test(groups = { "live", "user" }, description = "PUT /vApp/{id}", dependsOnMethods = { "testGetVApp" })
public void testEditVApp() { public void testEditVApp() {
VApp newVApp = VApp.builder().name(name("new-name-")).description("New Description").build(); VApp newVApp = VApp.builder().name(name("new-name-")).description("New Description").build();
vAppNames.add(newVApp.getName()); vAppNames.add(newVApp.getName());
@ -246,7 +246,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
String.format(OBJ_FIELD_EQ, VAPP, "Description", newVApp.getDescription(), vApp.getDescription())); String.format(OBJ_FIELD_EQ, VAPP, "Description", newVApp.getDescription(), vApp.getDescription()));
} }
@Test(description = "POST /vApp/{id}/action/deploy", dependsOnMethods = { "testGetVApp" }) @Test(groups = { "live", "user" }, description = "POST /vApp/{id}/action/deploy", dependsOnMethods = { "testGetVApp" })
public void testDeployVApp() { public void testDeployVApp() {
DeployVAppParams params = DeployVAppParams.builder() DeployVAppParams params = DeployVAppParams.builder()
.deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS)).notForceCustomization() .deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS)).notForceCustomization()
@ -266,7 +266,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
assertVAppStatus(vAppUrn, Status.POWERED_OFF); assertVAppStatus(vAppUrn, Status.POWERED_OFF);
} }
@Test(description = "POST /vApp/{id}/power/action/powerOn", dependsOnMethods = { "testDeployVApp" }) @Test(groups = { "live", "user" }, description = "POST /vApp/{id}/power/action/powerOn", dependsOnMethods = { "testDeployVApp" })
public void testPowerOnVApp() { public void testPowerOnVApp() {
// Power off VApp // Power off VApp
vApp = powerOffVApp(vAppUrn); vApp = powerOffVApp(vAppUrn);
@ -282,7 +282,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
assertVAppStatus(vAppUrn, Status.POWERED_ON); assertVAppStatus(vAppUrn, Status.POWERED_ON);
} }
@Test(description = "POST /vApp/{id}/power/action/reboot", dependsOnMethods = { "testDeployVApp" }) @Test(groups = { "live", "user" }, description = "POST /vApp/{id}/power/action/reboot", dependsOnMethods = { "testDeployVApp" })
public void testReboot() { public void testReboot() {
// Power on VApp // Power on VApp
vApp = powerOnVApp(vAppUrn); vApp = powerOnVApp(vAppUrn);
@ -298,7 +298,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
assertVAppStatus(vAppUrn, Status.POWERED_OFF); assertVAppStatus(vAppUrn, Status.POWERED_OFF);
} }
@Test(description = "POST /vApp/{id}/power/action/shutdown", dependsOnMethods = { "testDeployVApp" }) @Test(groups = { "live", "user" }, description = "POST /vApp/{id}/power/action/shutdown", dependsOnMethods = { "testDeployVApp" })
public void testShutdown() { public void testShutdown() {
// Power on VApp // Power on VApp
vApp = powerOnVApp(vAppUrn); vApp = powerOnVApp(vAppUrn);
@ -319,7 +319,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
vApp = powerOnVApp(vAppUrn); vApp = powerOnVApp(vAppUrn);
} }
@Test(description = "POST /vApp/{id}/power/action/suspend", dependsOnMethods = { "testDeployVApp" }) @Test(groups = { "live", "user" }, description = "POST /vApp/{id}/power/action/suspend", dependsOnMethods = { "testDeployVApp" })
public void testSuspend() { public void testSuspend() {
// Power on VApp // Power on VApp
vApp = powerOnVApp(vAppUrn); vApp = powerOnVApp(vAppUrn);
@ -338,7 +338,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
vApp = powerOnVApp(vAppUrn); vApp = powerOnVApp(vAppUrn);
} }
@Test(description = "POST /vApp/{id}/power/action/reset", dependsOnMethods = { "testDeployVApp" }) @Test(groups = { "live", "user" }, description = "POST /vApp/{id}/power/action/reset", dependsOnMethods = { "testDeployVApp" })
public void testReset() { public void testReset() {
// Power on VApp // Power on VApp
vApp = powerOnVApp(vAppUrn); vApp = powerOnVApp(vAppUrn);
@ -354,7 +354,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
assertVAppStatus(vAppUrn, Status.POWERED_ON); assertVAppStatus(vAppUrn, Status.POWERED_ON);
} }
@Test(description = "POST /vApp/{id}/action/undeploy", dependsOnMethods = { "testDeployVApp" }) @Test(groups = { "live", "user" }, description = "POST /vApp/{id}/action/undeploy", dependsOnMethods = { "testDeployVApp" })
public void testUndeployVApp() { public void testUndeployVApp() {
// Power on VApp // Power on VApp
vApp = powerOnVApp(vAppUrn); vApp = powerOnVApp(vAppUrn);
@ -374,7 +374,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
assertVAppStatus(vAppUrn, Status.POWERED_OFF); assertVAppStatus(vAppUrn, Status.POWERED_OFF);
} }
@Test(description = "POST /vApp/{id}/power/action/powerOff", dependsOnMethods = { "testUndeployVApp" }) @Test(groups = { "live", "user" }, description = "POST /vApp/{id}/power/action/powerOff", dependsOnMethods = { "testUndeployVApp" })
public void testPowerOffVApp() { public void testPowerOffVApp() {
// Power on VApp // Power on VApp
vApp = powerOnVApp(vAppUrn); vApp = powerOnVApp(vAppUrn);
@ -390,7 +390,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
assertVAppStatus(vAppUrn, Status.POWERED_OFF); assertVAppStatus(vAppUrn, Status.POWERED_OFF);
} }
@Test(description = "POST /vApp/{id}/action/controlAccess", dependsOnMethods = { "testGetVApp" }) @Test(groups = { "live", "user" }, description = "POST /vApp/{id}/action/controlAccess", dependsOnMethods = { "testGetVApp" })
public void testControlAccessUser() { public void testControlAccessUser() {
ControlAccessParams params = ControlAccessParams ControlAccessParams params = ControlAccessParams
.builder() .builder()
@ -409,7 +409,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
assertEquals(modified, params, String.format(ENTITY_EQUAL, "ControlAccessParams")); assertEquals(modified, params, String.format(ENTITY_EQUAL, "ControlAccessParams"));
} }
@Test(description = "POST /vApp/{id}/action/controlAccess", dependsOnMethods = { "testControlAccessUser" }) @Test(groups = { "live", "user" }, description = "POST /vApp/{id}/action/controlAccess", dependsOnMethods = { "testControlAccessUser" })
public void testControlAccessEveryone() { public void testControlAccessEveryone() {
ControlAccessParams params = ControlAccessParams.builder().sharedToEveryone().everyoneAccessLevel("FullControl") ControlAccessParams params = ControlAccessParams.builder().sharedToEveryone().everyoneAccessLevel("FullControl")
@ -425,7 +425,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
assertEquals(modified, params, String.format(ENTITY_EQUAL, "ControlAccessParams")); assertEquals(modified, params, String.format(ENTITY_EQUAL, "ControlAccessParams"));
} }
@Test(description = "POST /vApp/{id}/action/discardSuspendedState", dependsOnMethods = { "testDeployVApp" }) @Test(groups = { "live", "user" }, description = "POST /vApp/{id}/action/discardSuspendedState", dependsOnMethods = { "testDeployVApp" })
public void testDiscardSuspendedState() { public void testDiscardSuspendedState() {
// Power on, then suspend the VApp // Power on, then suspend the VApp
vApp = powerOnVApp(vAppUrn); vApp = powerOnVApp(vAppUrn);
@ -488,7 +488,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
} }
} }
@Test(description = "GET /vApp/{id}/controlAccess", dependsOnMethods = { "testGetVApp" }) @Test(groups = { "live", "user" }, description = "GET /vApp/{id}/controlAccess", dependsOnMethods = { "testGetVApp" })
public void testGetControlAccess() { public void testGetControlAccess() {
// The method under test // The method under test
ControlAccessParams controlAccess = vAppApi.getAccessControl(vAppUrn); ControlAccessParams controlAccess = vAppApi.getAccessControl(vAppUrn);
@ -506,7 +506,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
checkLeaseSettingsSection(section); checkLeaseSettingsSection(section);
} }
@Test(description = "PUT /vApp/{id}/leaseSettingsSection", dependsOnMethods = { "testGetLeaseSettingsSection" }) @Test(groups = { "live", "user" }, description = "PUT /vApp/{id}/leaseSettingsSection", dependsOnMethods = { "testGetLeaseSettingsSection" })
public void testEditLeaseSettingsSection() { public void testEditLeaseSettingsSection() {
// Copy existing section // Copy existing section
LeaseSettingsSection oldSection = vAppApi.getLeaseSettingsSection(vAppUrn); LeaseSettingsSection oldSection = vAppApi.getLeaseSettingsSection(vAppUrn);
@ -551,7 +551,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
assertEquals(modified, newSection, String.format(ENTITY_EQUAL, "LeaseSettingsSection")); assertEquals(modified, newSection, String.format(ENTITY_EQUAL, "LeaseSettingsSection"));
} }
@Test(description = "GET /vApp/{id}/networkConfigSection", dependsOnMethods = { "testGetVApp" }) @Test(groups = { "live", "user" }, description = "GET /vApp/{id}/networkConfigSection", dependsOnMethods = { "testGetVApp" })
public void testGetNetworkConfigSection() { public void testGetNetworkConfigSection() {
// The method under test // The method under test
NetworkConfigSection section = vAppApi.getNetworkConfigSection(vAppUrn); NetworkConfigSection section = vAppApi.getNetworkConfigSection(vAppUrn);
@ -642,7 +642,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
.ipRanges(newIpRanges).build(); .ipRanges(newIpRanges).build();
} }
@Test(description = "GET /vApp/{id}/networkSection", dependsOnMethods = { "testGetVApp" }) @Test(groups = { "live", "user" }, description = "GET /vApp/{id}/networkSection", dependsOnMethods = { "testGetVApp" })
public void testGetNetworkSection() { public void testGetNetworkSection() {
// The method under test // The method under test
NetworkSection section = vAppApi.getNetworkSection(vAppUrn); NetworkSection section = vAppApi.getNetworkSection(vAppUrn);
@ -651,7 +651,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
checkNetworkSection(section); checkNetworkSection(section);
} }
@Test(description = "GET /vApp/{id}/owner", dependsOnMethods = { "testGetVApp" }) @Test(groups = { "live", "user" }, description = "GET /vApp/{id}/owner", dependsOnMethods = { "testGetVApp" })
public void testGetOwner() { public void testGetOwner() {
// The method under test // The method under test
Owner owner = vAppApi.getOwner(vAppUrn); Owner owner = vAppApi.getOwner(vAppUrn);
@ -660,7 +660,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
checkOwner(owner); checkOwner(owner);
} }
@Test(description = "PUT /vApp/{id}/owner", dependsOnMethods = { "testGetOwner" }) @Test(groups = { "live", "user" }, description = "PUT /vApp/{id}/owner", dependsOnMethods = { "testGetOwner" })
public void testEditOwner() { public void testEditOwner() {
Owner newOwner = Owner.builder().user(Reference.builder().href(user.getHref()).type(ADMIN_USER).build()).build(); Owner newOwner = Owner.builder().user(Reference.builder().href(user.getHref()).type(ADMIN_USER).build()).build();
@ -677,7 +677,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
assertEquals(modified.getUser().getHref(), newOwner.getUser().getHref()); assertEquals(modified.getUser().getHref(), newOwner.getUser().getHref());
} }
@Test(description = "GET /vApp/{id}/productSections", dependsOnMethods = { "testGetVApp" }) @Test(groups = { "live", "user" }, description = "GET /vApp/{id}/productSections", dependsOnMethods = { "testGetVApp" })
public void testGetProductSections() { public void testGetProductSections() {
// The method under test // The method under test
ProductSectionList sectionList = vAppApi.getProductSections(vAppUrn); ProductSectionList sectionList = vAppApi.getProductSections(vAppUrn);
@ -686,7 +686,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
checkProductSectionList(sectionList); checkProductSectionList(sectionList);
} }
@Test(description = "PUT /vApp/{id}/productSections", dependsOnMethods = { "testGetProductSections" }) @Test(groups = { "live", "user" }, description = "PUT /vApp/{id}/productSections", dependsOnMethods = { "testGetProductSections" })
public void testEditProductSections() { public void testEditProductSections() {
// Copy existing section and edit fields // Copy existing section and edit fields
ProductSectionList oldSections = vAppApi.getProductSections(vAppUrn); ProductSectionList oldSections = vAppApi.getProductSections(vAppUrn);
@ -718,7 +718,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
assertEquals(modified, newSections); assertEquals(modified, newSections);
} }
@Test(description = "GET /vApp/{id}/startupSection", dependsOnMethods = { "testGetVApp" }) @Test(groups = { "live", "user" }, description = "GET /vApp/{id}/startupSection", dependsOnMethods = { "testGetVApp" })
public void testGetStartupSection() { public void testGetStartupSection() {
// The method under test // The method under test
StartupSection section = vAppApi.getStartupSection(vAppUrn); StartupSection section = vAppApi.getStartupSection(vAppUrn);
@ -727,7 +727,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
checkStartupSection(section); checkStartupSection(section);
} }
@Test(description = "PUT /vApp/{id}/startupSection", dependsOnMethods = { "testGetStartupSection" }) @Test(groups = { "live", "user" }, description = "PUT /vApp/{id}/startupSection", dependsOnMethods = { "testGetStartupSection" })
public void testEditStartupSection() { public void testEditStartupSection() {
// Copy existing section and edit fields // Copy existing section and edit fields
StartupSection oldSection = vAppApi.getStartupSection(vAppUrn); StartupSection oldSection = vAppApi.getStartupSection(vAppUrn);
@ -747,7 +747,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
assertEquals(modified, newSection); assertEquals(modified, newSection);
} }
@Test(description = "PUT /vApp/{id}/metadata", dependsOnMethods = { "testGetVApp" }) @Test(groups = { "live", "user" }, description = "PUT /vApp/{id}/metadata", dependsOnMethods = { "testGetVApp" })
public void testSetMetadataValue() { public void testSetMetadataValue() {
key = name("key-"); key = name("key-");
String value = name("value-"); String value = name("value-");
@ -761,7 +761,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
checkMetadataValueFor(VAPP, newMetadataValue, value); checkMetadataValueFor(VAPP, newMetadataValue, value);
} }
@Test(description = "GET /vApp/{id}/metadata", dependsOnMethods = { "testSetMetadataValue" }) @Test(groups = { "live", "user" }, description = "GET /vApp/{id}/metadata", dependsOnMethods = { "testSetMetadataValue" })
public void testGetMetadata() { public void testGetMetadata() {
key = name("key-"); key = name("key-");
String value = name("value-"); String value = name("value-");
@ -778,7 +778,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
String.format(NOT_EMPTY_OBJECT_FMT, "MetadataEntry", "vApp")); String.format(NOT_EMPTY_OBJECT_FMT, "MetadataEntry", "vApp"));
} }
@Test(description = "GET /vApp/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" }) @Test(groups = { "live", "user" }, description = "GET /vApp/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" })
public void testGetOrgMetadataValue() { public void testGetOrgMetadataValue() {
key = name("key-"); key = name("key-");
@ -796,7 +796,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", expected, newValue.getValue())); String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", expected, newValue.getValue()));
} }
@Test(description = "DELETE /vApp/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" }) @Test(groups = { "live", "user" }, description = "DELETE /vApp/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" })
public void testRemoveMetadataEntry() { public void testRemoveMetadataEntry() {
// Delete the entry // Delete the entry
Task task = vAppApi.getMetadataApi(vAppUrn).removeEntry(key); Task task = vAppApi.getMetadataApi(vAppUrn).removeEntry(key);
@ -809,7 +809,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
checkMetadataKeyAbsentFor(VAPP, newMetadata, key); checkMetadataKeyAbsentFor(VAPP, newMetadata, key);
} }
@Test(description = "POST /vApp/{id}/metadata", dependsOnMethods = { "testGetMetadata" }) @Test(groups = { "live", "user" }, description = "POST /vApp/{id}/metadata", dependsOnMethods = { "testGetMetadata" })
public void testMergeMetadata() { public void testMergeMetadata() {
Metadata oldMetadata = vAppApi.getMetadataApi(vAppUrn).get(); Metadata oldMetadata = vAppApi.getMetadataApi(vAppUrn).get();
Map<String, String> oldMetadataMap = Checks.metadataToMap(oldMetadata); Map<String, String> oldMetadataMap = Checks.metadataToMap(oldMetadata);
@ -833,7 +833,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
/** /**
* @see VAppApi#remove(URI) * @see VAppApi#remove(URI)
*/ */
@Test(description = "DELETE /vApp/{id}") @Test(groups = { "live", "user" }, description = "DELETE /vApp/{id}")
public void testRemoveVApp() { public void testRemoveVApp() {
// Create a temporary VApp to remove // Create a temporary VApp to remove
VApp temp = instantiateVApp(); VApp temp = instantiateVApp();

View File

@ -136,20 +136,6 @@ public class VAppTemplateApiLiveTest extends AbstractVAppApiLiveTest {
checkProductSectionList(productSectionList); checkProductSectionList(productSectionList);
} }
@Test(description = "PUT /vAppTemplate/{id}/productSections")
public void testEditProductSections() {
// TODO make a real modification
ProductSectionList origSections = vAppTemplateApi.getProductSections(vApp.getId());
ProductSectionList newSections = origSections.toBuilder().build();
Task task = vAppTemplateApi.editProductSections(vApp.getId(), newSections);
assertTaskSucceeds(task);
ProductSectionList modified = vAppTemplateApi.getProductSections(vApp.getId());
checkProductSectionList(modified);
}
@Test(description = "GET /vAppTemplate/{id}/leaseSettingsSection") @Test(description = "GET /vAppTemplate/{id}/leaseSettingsSection")
public void testGetLeaseSettingsSection() { public void testGetLeaseSettingsSection() {
LeaseSettingsSection leaseSettingsSection = vAppTemplateApi.getLeaseSettingsSection(vAppTemplateUrn); LeaseSettingsSection leaseSettingsSection = vAppTemplateApi.getLeaseSettingsSection(vAppTemplateUrn);
@ -305,7 +291,7 @@ public class VAppTemplateApiLiveTest extends AbstractVAppApiLiveTest {
// First disable so that enable really has some work to do... // First disable so that enable really has some work to do...
vAppTemplateApi.disableDownload(vAppTemplateUrn); vAppTemplateApi.disableDownload(vAppTemplateUrn);
final Task task = vAppTemplateApi.enableDownload(vAppTemplateUrn); final Task task = vAppTemplateApi.enableDownload(vAppTemplateUrn);
assertTaskSucceeds(task); assertTaskSucceedsLong(task);
// TODO Check that it really is enabled. The only thing I can see for determining this // TODO Check that it really is enabled. The only thing I can see for determining this
// is the undocumented "download" link in the VAppTemplate. But that is brittle and we // is the undocumented "download" link in the VAppTemplate. But that is brittle and we

View File

@ -24,6 +24,7 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.O
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.URN_REQ_LIVE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.URN_REQ_LIVE;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.fail; import static org.testng.Assert.fail;
@ -32,6 +33,7 @@ import java.util.Set;
import org.jclouds.vcloud.director.v1_5.domain.Checks; import org.jclouds.vcloud.director.v1_5.domain.Checks;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity; import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity;
@ -188,7 +190,9 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "POST /vdc/{id}/action/cloneVAppTemplate") @Test(description = "POST /vdc/{id}/action/cloneVAppTemplate")
public void testCloneVAppTemplate() { public void testCloneVAppTemplate() {
clonedVAppTemplate = vdcApi.cloneVAppTemplate(vdcUrn, clonedVAppTemplate = vdcApi.cloneVAppTemplate(vdcUrn,
CloneVAppTemplateParams.builder().source(lazyGetVAppTemplate().getHref()).build()); CloneVAppTemplateParams.builder()
.source(lazyGetVAppTemplate().getHref())
.build());
Task task = Iterables.getFirst(clonedVAppTemplate.getTasks(), null); Task task = Iterables.getFirst(clonedVAppTemplate.getTasks(), null);
assertNotNull(task, "vdcApi.cloneVAppTemplate returned VAppTemplate that did not contain any tasks"); assertNotNull(task, "vdcApi.cloneVAppTemplate returned VAppTemplate that did not contain any tasks");
@ -299,22 +303,12 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
} }
private void setupMetadata() {
adminContext.getApi().getVdcApi().getMetadataApi(vdcUrn)
.putEntry("key", MetadataValue.builder().value("value").build());
metadataSet = true;
}
@Test(description = "GET /vdc/{id}/metadata", dependsOnMethods = { "testGetVdc" }) @Test(description = "GET /vdc/{id}/metadata", dependsOnMethods = { "testGetVdc" })
public void testGetMetadata() { public void testGetMetadata() {
if (adminContext != null) {
setupMetadata();
}
Metadata metadata = vdcApi.getMetadataApi(vdcUrn).get(); Metadata metadata = vdcApi.getMetadataApi(vdcUrn).get();
// required for testing // required for testing
assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), assertTrue(Iterables.isEmpty(metadata.getMetadataEntries()),
String.format(OBJ_FIELD_REQ_LIVE, VDC, "metadata.entries")); String.format(OBJ_FIELD_REQ_LIVE, VDC, "metadata.entries"));
Checks.checkMetadataFor(VDC, metadata); Checks.checkMetadataFor(VDC, metadata);
@ -322,6 +316,7 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "GET /vdc/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" }) @Test(description = "GET /vdc/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" })
public void testGetMetadataValue() { public void testGetMetadataValue() {
// setupMetadata();
// First find a key // First find a key
Metadata metadata = vdcApi.getMetadataApi(vdcUrn).get(); Metadata metadata = vdcApi.getMetadataApi(vdcUrn).get();
Map<String, String> metadataMap = Checks.metadataToMap(metadata); Map<String, String> metadataMap = Checks.metadataToMap(metadata);
@ -332,4 +327,9 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
Checks.checkMetadataValueFor(VDC, metadataValue, value); Checks.checkMetadataValueFor(VDC, metadataValue, value);
} }
private void setupMetadata() {
adminContext.getApi().getVdcApi().getMetadataApi(vdcUrn).putEntry("key", MetadataValue.builder().value("value").build());
metadataSet = true;
}
} }

View File

@ -248,13 +248,6 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
userUrn = emptyToNull(System.getProperty("test." + provider + ".user-id")); userUrn = emptyToNull(System.getProperty("test." + provider + ".user-id"));
// QueryResultRecords queryResult = adminContext.getApi().getQueryApi().usersQueryAll();
// for (QueryResultRecordType recordType : queryResult.getRecords()) {
// User user = adminContext.getApi().getUserApi().get(recordType.getHref());
// System.out.println(user.getName());
// System.out.println(user.getId());
// }
org = context org = context
.getApi() .getApi()
.getOrgApi() .getOrgApi()
@ -366,7 +359,7 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
}); });
if (optionalVm.isPresent()) { if (optionalVm.isPresent()) {
Logger.CONSOLE.info("found vAppTemplate: %s", prettyVm.apply(optionalVm.get())); Logger.CONSOLE.info("found vm: %s", prettyVm.apply(optionalVm.get()));
} else { } else {
Logger.CONSOLE.warn("%s doesn't have any vm in org %s; vms: %s", context.getApi() Logger.CONSOLE.warn("%s doesn't have any vm in org %s; vms: %s", context.getApi()
.getCurrentSession().getUser(), org.getName(), Iterables.transform(vms, prettyVm)); .getCurrentSession().getUser(), org.getName(), Iterables.transform(vms, prettyVm));
@ -684,10 +677,10 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
} }
} }
// Shutdown and power off the VApp if necessary // power off the VApp if necessary
if (vApp.getStatus() == Status.POWERED_ON) { if (vApp.getStatus() == Status.POWERED_ON) {
try { try {
Task shutdownTask = vAppApi.shutdown(vAppUrn); Task shutdownTask = vAppApi.powerOff(vAppUrn);
taskDoneEventually(shutdownTask); taskDoneEventually(shutdownTask);
} catch (Exception e) { } catch (Exception e) {
// keep going; cleanup as much as possible // keep going; cleanup as much as possible