Issue 830: Initial setup for tests (both Live and Unit)

This commit is contained in:
Andrew Donald Kennedy 2012-03-08 20:19:54 +00:00
parent 7cfce5dd44
commit 7c80f7a989
11 changed files with 2377 additions and 46 deletions

View File

@ -23,9 +23,9 @@ package org.jclouds.vcloud.director.v1_5;
*/
public class VCloudDirectorLiveTestConstants {
/* Error codes from 100 to 199 reflect parsing and other errors in domain objects. */
public static final String OK = "ERR-200: ok";
public static final String OK = "ERR-100: ok";
/* Error codes from 100 to 199 reflect parsing and other errors in domain objects. */
public static final String REF_REQ_LIVE = "ERR-101: %s reference required to perform live tests";
@ -75,4 +75,10 @@ public class VCloudDirectorLiveTestConstants {
public static final String OBJ_FIELD_EMPTY_TO_DELETE = "ERR-124: %s must have no %s to be deleted (%s)";
/* Error codes from 300 to 399 reflect entities and their links and relationship errors. */
public static final String ENTITY_NON_NULL = "ERR-301: The %s entity must not be null";
public static final String ENTITY_EQUAL = "ERR-302: The two %s entities must be equal";
}

View File

@ -18,32 +18,29 @@
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.CONDITION_FMT;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.MUST_BE_WELL_FORMED_FMT;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.MUST_CONTAIN_FMT;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.NOT_NULL_OBJECT_FMT;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_ATTRB_REQ;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_GTE_0;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REQUIRED_VALUE_FMT;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REQUIRED_VALUE_OBJECT_FMT;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.*;
import static org.testng.Assert.*;
import java.net.URI;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.CustomOrgLdapSettings.AuthenticationMechanism;
import org.jclouds.vcloud.director.v1_5.domain.CustomOrgLdapSettings.ConnectorType;
import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings.LdapMode;
import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData;
import org.jclouds.vcloud.director.v1_5.domain.cim.VirtualSystemSettingData;
import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType;
import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.environment.EnvironmentType;
import org.testng.annotations.Test;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.google.common.net.InetAddresses;
/**
@ -516,13 +513,127 @@ public class Checks {
}
public static void checkVApp(VApp vApp) {
// TODO Auto-generated method stub
// Check optional fields
Owner owner = vApp.getOwner();
if (owner != null) checkOwner(owner);
// NOTE inMaintenanceMode cannot be checked
VAppChildren children = vApp.getChildren();
if (children != null) checkVAppChildren(children);
// NOTE ovfDescriptorUploaded cannot be checked
// Check parent type
checkAbstractVAppType(vApp);
}
public static void checkVAppChildren(VAppChildren vAppChildren) {
// Check optional fields
for (VApp vApp : vAppChildren.getVApps()) {
checkVApp(vApp);
}
for (Vm vm : vAppChildren.getVms()) {
checkVm(vm);
}
}
public static void checkAbstractVAppType(AbstractVAppType<?> abstractVAppType) {
// Check optional fields
Reference vAppParent = abstractVAppType.getVAppParent();
if (vAppParent != null) checkReferenceType(vAppParent);
// NOTE deployed cannot be checked
for (SectionType<?> section : abstractVAppType.getSections()) {
checkSectionType(section);
}
// Check parent type
checkResourceEntityType(abstractVAppType);
}
public static void checkVAppTemplate(VAppTemplate template) {
// TODO Auto-generated method stub
// Check optional fields
Owner owner = template.getOwner();
if (owner != null) checkOwner(owner);
for (VAppTemplate child : template.getChildren()) {
checkVAppTemplate(child);
}
for (SectionType<?> section : template.getSections()) {
checkSectionType(section);
}
// NOTE vAppScopedLocalId cannot be checked
// NOTE ovfDescriptorUploaded cannot be checked
// NOTE goldMaster cannot be checked
// Check parent type
checkResourceEntityType(template);
}
public static void checkVm(Vm vm) {
// Check optional fields
EnvironmentType environment = vm.getEnvironment();
if (environment != null) checkEnvironmentType(environment);
// NOTE vAppScopedLocalId cannot be checked
// NOTE needsCustomization cannot be checked
// Check parent type
checkAbstractVAppType(vm);
}
public static void checkControlAccessParams(ControlAccessParams params) {
// Check required fields
assertNotNull(params.isSharedToEveryone(), String.format(OBJ_FIELD_REQ, "ControlAccessParams", "IsSharedToEveryone"));
// Check optional fields
if (params.isSharedToEveryone()) {
assertNotNull(params.getEveryoneAccessLevel(), String.format(OBJ_FIELD_REQ, "ControlAccessParams", "EveryoneAccessLevel"));
} else {
assertNotNull(params.getAccessSettings(), String.format(OBJ_FIELD_REQ, "ControlAccessParams", "AccessSettings"));
checkAccessSettings(params.getAccessSettings());
}
}
public static void checkAccessSettings(AccessSettings accessSettings) {
for (AccessSetting setting : accessSettings.getAccessSettings()) {
checkAccessSetting(setting);
}
}
public static void checkAccessSetting(AccessSetting setting) {
// Check required fields
assertNotNull(setting.getSubject(), String.format(OBJ_FIELD_REQ, "AccessSetting", "Subject"));
checkReferenceType(setting.getSubject());
assertNotNull(setting.getAccessLevel(), String.format(OBJ_FIELD_REQ, "AccessSetting", "AccessLevel"));
}
public static void checkEnvironmentType(EnvironmentType environment) {
// TODO
}
public static void checkSectionType(SectionType<?> section) {
// Check optional fields
// NOTE info cannot be checked
// NOTE required cannot be checked
}
public static void checkVirtualHardwareSection(VirtualHardwareSection hardware) {
// Check optional fields
VirtualSystemSettingData virtualSystem = hardware.getSystem();
if (virtualSystem != null) checkVirtualSystemSettingData(virtualSystem);
for (String transport : hardware.getTransports()) {
// NOTE transport cannot be checked
}
for (ResourceAllocationSettingData item : hardware.getItems()) {
checkResourceAllocationSettingData(item);
}
// Check parent type
checkSectionType(hardware);
}
public static void checkVirtualSystemSettingData(VirtualSystemSettingData virtualSystem) {
// TODO
}
public static void checkResourceAllocationSettingData(ResourceAllocationSettingData item) {
// TODO
}
public static void checkMediaFor(String client, Media media) {

View File

@ -229,7 +229,6 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
Task setCatalogItemMetadataValue = catalogClient.getMetadataClient().setMetadata(catalogItemRef.getHref(), "KEY", newMetadataValue);
checkTask(setCatalogItemMetadataValue);
Checks.checkTask(setCatalogItemMetadataValue);
assertTrue(retryTaskSuccess.apply(setCatalogItemMetadataValue),
String.format(TASK_COMPLETE_TIMELY, "setCatalogItemMetadataValue"));
@ -243,7 +242,6 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
public void testDeleteCatalogItemMetadataValue() {
Task deleteCatalogItemMetadataValue = catalogClient.getMetadataClient().deleteMetadataEntry(catalogItemRef.getHref(), "KEY");
checkTask(deleteCatalogItemMetadataValue);
Checks.checkTask(deleteCatalogItemMetadataValue);
assertTrue(retryTaskSuccess.apply(deleteCatalogItemMetadataValue),
String.format(TASK_COMPLETE_TIMELY, "deleteCatalogItemMetadataValue"));
try {
@ -271,7 +269,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
deleteAllCatalogItemMetadata(catalogItemURI);
Metadata newMetadata = Metadata.builder().entry(MetadataEntry.builder().entry("KEY", "VALUE").build()).build();
Task mergeCatalogItemMetadata = catalogClient.getMetadataClient().mergeMetadata(catalogItemURI, newMetadata);
Checks.checkTask(mergeCatalogItemMetadata);
checkTask(mergeCatalogItemMetadata);
assertTrue(retryTaskSuccess.apply(mergeCatalogItemMetadata),
String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata"));
}

View File

@ -0,0 +1,730 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
*(Link.builder().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(Link.builder().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.vcloud.director.v1_5.features;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.*;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.*;
import static org.testng.Assert.*;
import java.net.URI;
import java.util.concurrent.TimeUnit;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants;
import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams;
import org.jclouds.vcloud.director.v1_5.domain.DeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppTemplateParams;
import org.jclouds.vcloud.director.v1_5.domain.InstantiationParams;
import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection;
import org.jclouds.vcloud.director.v1_5.domain.MediaInsertOrEjectParams;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection;
import org.jclouds.vcloud.director.v1_5.domain.Owner;
import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList;
import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList;
import org.jclouds.vcloud.director.v1_5.domain.RecomposeVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.RelocateParams;
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status;
import org.jclouds.vcloud.director.v1_5.domain.RuntimeInfoSection;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.VApp;
import org.jclouds.vcloud.director.v1_5.domain.VAppNetworkConfiguration;
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion;
import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer;
import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.OperatingSystemSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.RASD;
import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
/**
* Tests behavior of {@code VAppClient}
*
* @author grkvlt@apache.org
*/
@Test(groups = { "live", "user", "vapp" }, testName = "VAppClientLiveTest")
public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
public static final String VAPP = "vApp";
public static final String VAPP_TEMPLATE = "vAppTemplate";
public static final String VDC = "vdc";
/*
* Convenience reference to API clients.
*/
protected CatalogClient catalogClient;
protected OrgClient orgClient;
protected VAppClient vAppClient;
protected VAppTemplateClient vAppTemplateClient;
protected VdcClient vdcClient;
protected MetadataClient metadataClient;
/*
* Objects shared between tests.
*/
VApp vApp;
@BeforeClass(inheritGroups = true)
@Override
public void setupRequiredClients() {
catalogClient = context.getApi().getCatalogClient();
orgClient = context.getApi().getOrgClient();
vAppClient = context.getApi().getVAppClient();
vAppTemplateClient = context.getApi().getVAppTemplateClient();
vdcClient = context.getApi().getVdcClient();
metadataClient = vAppClient.getMetadataClient();
}
/**
* @see VAppClient#getVApp(URI)
*/
@Test(testName = "GET /vApp/{id}")
public void testGetVApp() {
VApp vAppInstantiated = instantiateVApp();
// The method under test
vApp = vAppClient.getVApp(vAppInstantiated.getHref());
// Check the retrieved object is well formed
checkVApp(vApp);
assertEquals(vApp, vAppInstantiated, String.format(ENTITY_EQUAL, VAPP));
}
/**
* @see VAppClient#modifyVApp(URI, VApp)
*/
@Test(testName = "PUT /vApp/{id}", dependsOnMethods = { "testGetVApp" })
public void testModifyVApp() {
vApp.setName("new-name");
vApp.setDescription("New Description");
// The method under test
Task modifyVApp = vAppClient.modifyVApp(vApp.getHref(), vApp);
assertTrue(retryTaskSuccess.apply(modifyVApp), String.format(TASK_COMPLETE_TIMELY, "modifyVApp"));
vApp = vAppClient.getVApp(vApp.getHref());
assertEquals(vApp.getName(), "new-name", String.format(OBJ_FIELD_EQ, VAPP, "name", "new-name", "modified"));
assertEquals(vApp.getDescription(), "New Description", String.format(OBJ_FIELD_EQ, VAPP, "description", "New Description", "modified"));
}
@Test(testName = "POST /vApp/{id}/action/deploy", dependsOnMethods = { "testGetVApp" })
public void testDeployVApp() {
DeployVAppParams params = DeployVAppParams.builder()
.deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS))
.forceCustomization()
.notPowerOn()
.build();
// The method under test
Task deployVApp = vAppClient.deploy(vApp.getHref(), params);
assertTrue(retryTaskSuccess.apply(deployVApp), String.format(TASK_COMPLETE_TIMELY, "deployVApp"));
vApp = vAppClient.getVApp(vApp.getHref());
Integer deployedStatus = Status.DEPLOYED.getValue();
assertEquals(vApp.getStatus(), deployedStatus, String.format(OBJ_FIELD_EQ, VAPP, "status", deployedStatus, "deployed"));
}
@Test(testName = "POST /vApp/{id}/power/action/powerOn", dependsOnMethods = { "testDeployVApp" })
public void testPowerOnVApp() {
// The method under test
Task powerOnVApp = vAppClient.powerOn(vApp.getHref());
assertTrue(retryTaskSuccess.apply(powerOnVApp), String.format(TASK_COMPLETE_TIMELY, "powerOnVApp"));
vApp = vAppClient.getVApp(vApp.getHref());
Integer poweredOnStatus = Status.POWERED_ON.getValue();
assertEquals(vApp.getStatus(), poweredOnStatus, String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOnStatus, "powered on"));
}
@Test(testName = "POST /vApp/{id}/power/action/powerOff", dependsOnMethods = { "testPowerOnVApp" })
public void testPowerOffVApp() {
// The method under test
Task powerOffVApp = vAppClient.powerOff(vApp.getHref());
assertTrue(retryTaskSuccess.apply(powerOffVApp), String.format(TASK_COMPLETE_TIMELY, "powerOffVApp"));
vApp = vAppClient.getVApp(vApp.getHref());
Integer poweredOffStatus = Status.POWERED_OFF.getValue();
assertEquals(vApp.getStatus(), poweredOffStatus, String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOffStatus, "powered off"));
}
@Test(enabled = false, testName = "POST /vApp/{id}/action/consolidate", dependsOnMethods = { "testGetVApp" })
public void testConsolidateVApp(URI vAppURI) {
// The method under test
Task consolidateVApp = vAppClient.consolidateVApp(vApp.getHref());
assertTrue(retryTaskSuccess.apply(consolidateVApp), String.format(TASK_COMPLETE_TIMELY, "consolidateVApp"));
}
@Test(enabled = false, testName = "POST /vApp/{id}/action/controlAccess", dependsOnMethods = { "testGetVApp" })
public void testControlAccess() {
ControlAccessParams params = ControlAccessParams.builder()
.sharedToEveryone()
.build();
// The method under test
ControlAccessParams modified = vAppClient.controlAccess(vApp.getHref(), params);
checkControlAccessParams(modified);
// TODO check individual fields
assertEquals(modified, params, String.format(ENTITY_EQUAL, "ControlAccessParams"));
}
@Test(enabled = false, testName = "POST /vApp/{id}/action/discardSuspendedState", dependsOnMethods = { "testGetVApp" })
public void testDiscardSuspendedState() {
// The method under test
Task discardSuspendedState = vAppClient.discardSuspendedState(vApp.getHref());
assertTrue(retryTaskSuccess.apply(discardSuspendedState), String.format(TASK_COMPLETE_TIMELY, "discardSuspendedState"));
}
@Test(testName = "POST /vApp/{id}/action/enterMaintenanceMode", dependsOnMethods = { "testGetVApp" })
public void testEnterMaintenanceMode() {
// The method under test
vAppClient.enterMaintenanceMode(vApp.getHref());
vApp = vAppClient.getVApp(vApp.getHref());
assertTrue(vApp.isInMaintenanceMode(), String.format(CONDITION_FMT, "InMaintenanceMode", "TRUE", vApp.isInMaintenanceMode()));
}
@Test(testName = "POST /vApp/{id}/action/exitMaintenanceMode", dependsOnMethods = { "testEnterMaintenanceMode" })
public void testExitMaintenanceMode() {
// The method under test
vAppClient.exitMaintenanceMode(vApp.getHref());
vApp = vAppClient.getVApp(vApp.getHref());
assertFalse(vApp.isInMaintenanceMode(), String.format(CONDITION_FMT, "InMaintenanceMode", "FALSE", vApp.isInMaintenanceMode()));
}
@Test(enabled = false, testName = "POST /vApp/{id}/action/installVMwareTools", dependsOnMethods = { "testGetVApp" })
public void testInstallVMwareTools() {
// The method under test
Task installVMwareTools = vAppClient.installVMwareTools(vApp.getHref());
assertTrue(retryTaskSuccess.apply(installVMwareTools), String.format(TASK_COMPLETE_TIMELY, "installVMwareTools"));
}
@Test(enabled = false, testName = "POST /vApp/{id}/action/recomposeVApp", dependsOnMethods = { "testGetVApp" })
public void testRecomposeVApp() {
RecomposeVAppParams params = RecomposeVAppParams.builder()
.build();
// The method under test
Task recomposeVApp = vAppClient.recomposeVApp(vApp.getHref(), params);
assertTrue(retryTaskSuccess.apply(recomposeVApp), String.format(TASK_COMPLETE_TIMELY, "recomposeVApp"));
}
@Test(enabled = false, testName = "POST /vApp/{id}/action/relocate", dependsOnMethods = { "testGetVApp" })
public void testRelocate() {
RelocateParams params = RelocateParams.builder()
.build();
// The method under test
Task relocate = vAppClient.relocate(vApp.getHref(), params);
assertTrue(retryTaskSuccess.apply(relocate), String.format(TASK_COMPLETE_TIMELY, "relocate"));
}
@Test(enabled = false, testName = "POST /vApp/{id}/action/undeploy", dependsOnMethods = { "testGetVApp" })
public void testUndeploy() {
UndeployVAppParams params = UndeployVAppParams.builder()
.build();
// The method under test
Task undeploy = vAppClient.undeploy(vApp.getHref(), params);
assertTrue(retryTaskSuccess.apply(undeploy), String.format(TASK_COMPLETE_TIMELY, "undeploy"));
}
@Test(enabled = false, testName = "POST /vApp/{id}/action/upgradeHardwareVersion", dependsOnMethods = { "testGetVApp" })
public void testUpgradeHardwareVersion() {
// The method under test
Task upgradeHardwareVersion = vAppClient.upgradeHardwareVersion(vApp.getHref());
assertTrue(retryTaskSuccess.apply(upgradeHardwareVersion), String.format(TASK_COMPLETE_TIMELY, "upgradeHardwareVersion"));
}
@Test(enabled = false, testName = "POST /vApp/{id}/power/action/reboot", dependsOnMethods = { "testGetVApp" })
public void testReboot() {
// The method under test
Task powerOffVApp = vAppClient.reboot(vApp.getHref());
assertTrue(retryTaskSuccess.apply(powerOffVApp), String.format(TASK_COMPLETE_TIMELY, "powerOffVApp"));
vApp = vAppClient.getVApp(vApp.getHref());
Integer poweredOnStatus = Status.POWERED_ON.getValue();
assertEquals(vApp.getStatus(), poweredOnStatus, String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOnStatus, "powered off"));
}
@Test(enabled = false, testName = "POST /vApp/{id}/power/action/reset", dependsOnMethods = { "testGetVApp" })
public void testReset() {
// The method under test
Task powerOffVApp = vAppClient.reset(vApp.getHref());
assertTrue(retryTaskSuccess.apply(powerOffVApp), String.format(TASK_COMPLETE_TIMELY, "powerOffVApp"));
vApp = vAppClient.getVApp(vApp.getHref());
Integer poweredOffStatus = Status.POWERED_ON.getValue();
assertEquals(vApp.getStatus(), poweredOffStatus, String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOffStatus, "powered off"));
}
@Test(enabled = false, testName = "POST /vApp/{id}/power/action/shutdown", dependsOnMethods = { "testGetVApp" })
public void testShutdown() {
// The method under test
Task powerOffVApp = vAppClient.shutdown(vApp.getHref());
assertTrue(retryTaskSuccess.apply(powerOffVApp), String.format(TASK_COMPLETE_TIMELY, "powerOffVApp"));
vApp = vAppClient.getVApp(vApp.getHref());
Integer poweredOffStatus = Status.POWERED_OFF.getValue();
assertEquals(vApp.getStatus(), poweredOffStatus, String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOffStatus, "powered off"));
}
@Test(enabled = false, testName = "POST /vApp/{id}/power/action/suspend", dependsOnMethods = { "testGetVApp" })
public void testSuspend() {
// The method under test
Task powerOffVApp = vAppClient.suspend(vApp.getHref());
assertTrue(retryTaskSuccess.apply(powerOffVApp), String.format(TASK_COMPLETE_TIMELY, "powerOffVApp"));
vApp = vAppClient.getVApp(vApp.getHref());
Integer poweredOffStatus = Status.POWERED_OFF.getValue();
assertEquals(vApp.getStatus(), poweredOffStatus, String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOffStatus, "powered off"));
}
@Test(enabled = false, testName = "GET /vApp/{id}/controlAccess", dependsOnMethods = { "testGetVApp" })
public void testGetControlAccess() {
// The method under test
ControlAccessParams controlAccess = vAppClient.getControlAccess(vApp.getHref());
// checkControlAccessParams(controlAccess);
}
@Test(enabled = false, testName = "GET /vApp/{id}/guestCustomizationSection", dependsOnMethods = { "testGetVApp" })
public void testGetGuestCustomizationSection() {
// The method under test
GuestCustomizationSection section = vAppClient.getGuestCustomizationSection(vApp.getHref());
// checkGuestCustomizationSection(section);
}
@Test(enabled = false, testName = "PUT /vApp/{id}/guestCustomizationSection", dependsOnMethods = { "testGetGuestCustomizationSection" })
public void testModifyGuestCustomizationSection() {
GuestCustomizationSection section = vAppClient.getGuestCustomizationSection(vApp.getHref());
// section.setX()
// The method under test
Task modifyGuestCustomizationSection = vAppClient.modifyGuestCustomizationSection(vApp.getHref(), section);
assertTrue(retryTaskSuccess.apply(modifyGuestCustomizationSection), String.format(TASK_COMPLETE_TIMELY, "modifyGuestCustomizationSection"));
GuestCustomizationSection modified = vAppClient.getGuestCustomizationSection(vApp.getHref());
// assertEquals(modified.getX, "");
}
@Test(enabled = false, testName = "GET /vApp/{id}/leaseSettingsSection", dependsOnMethods = { "testGetVApp" })
public void testGetLeaseSettingsSection() {
// The method under test
LeaseSettingsSection section = vAppClient.getLeaseSettingsSection(vApp.getHref());
// checkLeaseSettingsSection(section);
}
@Test(enabled = false, testName = "PUT /vApp/{id}/leaseSettingsSection", dependsOnMethods = { "testGetLeaseSettingsSection" })
public void testModifyLeaseSettingsSection() {
LeaseSettingsSection section = vAppClient.getLeaseSettingsSection(vApp.getHref());
// section.setX()
// The method under test
Task modifyLeaseSettingsSection = vAppClient.modifyLeaseSettingsSection(vApp.getHref(), section);
assertTrue(retryTaskSuccess.apply(modifyLeaseSettingsSection), String.format(TASK_COMPLETE_TIMELY, "modifyLeaseSettingsSection"));
LeaseSettingsSection modified = vAppClient.getLeaseSettingsSection(vApp.getHref());
// assertEquals(modified.getX, "");
}
@Test(enabled = false, testName = "PUT /vApp/{id}/media/action/insertMedia", dependsOnMethods = { "testGetVApp" })
public void testInsertMedia() {
MediaInsertOrEjectParams params = MediaInsertOrEjectParams.builder()
.build();
// The method under test
Task insertMedia = vAppClient.insertMedia(vApp.getHref(), params);
assertTrue(retryTaskSuccess.apply(insertMedia), String.format(TASK_COMPLETE_TIMELY, "insertMedia"));
}
@Test(enabled = false, testName = "PUT /vApp/{id}/media/action/ejectMedia", dependsOnMethods = { "testInsertMedia" })
public void testEjectMedia() {
MediaInsertOrEjectParams params = MediaInsertOrEjectParams.builder()
.build();
// The method under test
Task ejectMedia = vAppClient.ejectMedia(vApp.getHref(), params);
assertTrue(retryTaskSuccess.apply(ejectMedia), String.format(TASK_COMPLETE_TIMELY, "ejectMedia"));
}
@Test(enabled = false, testName = "GET /vApp/{id}/networkConfigSection", dependsOnMethods = { "testGetVApp" })
public void testGetNetworkConfigSection() {
// The method under test
NetworkConfigSection section = vAppClient.getNetworkConfigSection(vApp.getHref());
// checkNetworkConfigSection(section);
}
@Test(enabled = false, testName = "PUT /vApp/{id}/networkConfigSection", dependsOnMethods = { "testGetNetworkConfigSection" })
public void testModifyNetworkConfigSection() {
NetworkConfigSection section = vAppClient.getNetworkConfigSection(vApp.getHref());
// section.setX()
// The method under test
Task modifyNetworkConfigSection = vAppClient.modifyNetworkConfigSection(vApp.getHref(), section);
assertTrue(retryTaskSuccess.apply(modifyNetworkConfigSection), String.format(TASK_COMPLETE_TIMELY, "modifyNetworkConfigSection"));
NetworkConfigSection modified = vAppClient.getNetworkConfigSection(vApp.getHref());
// assertEquals(modified.getX, "");
}
@Test(enabled = false, testName = "GET /vApp/{id}/networkConnectionSection", dependsOnMethods = { "testGetVApp" })
public void testGetNetworkConnectionSection() {
// The method under test
NetworkConnectionSection section = vAppClient.getNetworkConnectionSection(vApp.getHref());
// checkNetworkConnectionSection(section);
}
@Test(enabled = false, testName = "PUT /vApp/{id}/networkConnectionSection", dependsOnMethods = { "testGetNetworkConnectionSection" })
public void testModifyNetworkConnectionSection() {
NetworkConnectionSection section = vAppClient.getNetworkConnectionSection(vApp.getHref());
// section.setX()
// The method under test
Task modifyNetworkConnectionSection = vAppClient.modifyNetworkConnectionSection(vApp.getHref(), section);
assertTrue(retryTaskSuccess.apply(modifyNetworkConnectionSection), String.format(TASK_COMPLETE_TIMELY, "modifyNetworkConnectionSection"));
NetworkConnectionSection modified = vAppClient.getNetworkConnectionSection(vApp.getHref());
// assertEquals(modified.getX, "");
}
@Test(enabled = false, testName = "GET /vApp/{id}/networkSection", dependsOnMethods = { "testGetVApp" })
public void testGetNetworkSection() {
// The method under test
NetworkSection section = vAppClient.getNetworkSection(vApp.getHref());
// checkNetworkSection(section);
}
@Test(enabled = false, testName = "GET /vApp/{id}/operatingSystemSection", dependsOnMethods = { "testGetVApp" })
public void testGetOperatingSystemSection() {
// The method under test
OperatingSystemSection section = vAppClient.getOperatingSystemSection(vApp.getHref());
// checkOperatingSystemSection(section);
}
@Test(enabled = false, testName = "PUT /vApp/{id}/operatingSystemSection", dependsOnMethods = { "testGetOperatingSystemSection" })
public void testModifyOperatingSystemSection() {
OperatingSystemSection section = vAppClient.getOperatingSystemSection(vApp.getHref());
// section.setX()
// The method under test
Task modifySection = vAppClient.modifyOperatingSystemSection(vApp.getHref(), section);
assertTrue(retryTaskSuccess.apply(modifySection), String.format(TASK_COMPLETE_TIMELY, "modifySection"));
OperatingSystemSection modified = vAppClient.getOperatingSystemSection(vApp.getHref());
// assertEquals(modified.getX, "");
}
@Test(enabled = false, testName = "GET /vApp/{id}/owner", dependsOnMethods = { "testGetVApp" })
public void testGetOwner() {
// The method under test
Owner owner = vAppClient.getOwner(vApp.getHref());
checkOwner(owner);
}
@Test(enabled = false, testName = "PUT /vApp/{id}/owner", dependsOnMethods = { "testGetOwner" })
public void testModifyOwner() {
Owner newOwner = Owner.builder()
.build();
// The method under test
Task modifyOwner = vAppClient.modifyOwner(vApp.getHref(), newOwner);
assertTrue(retryTaskSuccess.apply(modifyOwner), String.format(TASK_COMPLETE_TIMELY, "modifyOwner"));
Owner modified = vAppClient.getOwner(vApp.getHref());
assertEquals(modified, newOwner);
}
@Test(enabled = false, testName = "GET /vApp/{id}/productSections", dependsOnMethods = { "testGetVApp" })
public void testGetProductSections() {
// The method under test
ProductSectionList sectionList = vAppClient.getProductSections(vApp.getHref());
// checkProductSectionList(sectionList);
}
@Test(enabled = false, testName = "PUT /vApp/{id}/productSections", dependsOnMethods = { "testGetProductSections" })
public void testModifyProductSections() {
ProductSectionList sectionList = vAppClient.getProductSections(vApp.getHref());
// sectionList.setX()
// The method under test
Task modifyProductSections = vAppClient.modifyProductSections(vApp.getHref(), sectionList);
assertTrue(retryTaskSuccess.apply(modifyProductSections), String.format(TASK_COMPLETE_TIMELY, "modifyProductSections"));
ProductSectionList modifiedList = vAppClient.getProductSections(vApp.getHref());
// assertEquals(modified.getX, "");
}
@Test(enabled = false, testName = "GET /vApp/{id}/question", dependsOnMethods = { "testGetVApp" })
public void testGetPendingQuestion() {
// TODO how to test?
// The method under test
VmPendingQuestion question = vAppClient.getPendingQuestion(vApp.getHref());
// checkQuestion(question);
}
@Test(enabled = false, testName = "PUT /vApp/{id}/question/action/answer", dependsOnMethods = { "testGetPendingQuestion" })
public void testAnswerQuestion() {
// TODO add builder
// VmQuestionAnswer answer = VmQuestionAnswer.builer()
// .build();
// The method under test
// vAppClient.answerQuestion(vApp.getHref(), answer);
// TODO how to test?
}
@Test(enabled = false, testName = "GET /vApp/{id}/runtimeInfoSection", dependsOnMethods = { "testGetVApp" })
public void testGetRuntimeInfoSection() {
// The method under test
RuntimeInfoSection section = vAppClient.getRuntimeInfoSection(vApp.getHref());
// checkRuntimeInfoSection(section);
}
@Test(enabled = false, testName = "GET /vApp/{id}/screen", dependsOnMethods = { "testGetVApp" })
public void testGetScreenImage() {
// The method under test
byte[] image = vAppClient.getScreenImage(vApp.getHref());
// TODO how to check?
}
@Test(enabled = false, testName = "GET /vApp/{id}/screen/action/acquireTicket", dependsOnMethods = { "testGetVApp" })
public void testGetScreenTicket() {
// The method under test
byte[] image = vAppClient.getScreenImage(vApp.getHref());
// TODO how to check?
}
@Test(enabled = false, testName = "GET /vApp/{id}/startupSection", dependsOnMethods = { "testGetVApp" })
public void testGetStartupSection() {
// The method under test
StartupSection section = vAppClient.getStartupSection(vApp.getHref());
// checkStartupSection(section);
}
@Test(enabled = false, testName = "PUT /vApp/{id}/startupSection", dependsOnMethods = { "testGetStartupSection" })
public void testModifyStartupSection() {
StartupSection section = vAppClient.getStartupSection(vApp.getHref());
// section.setX()
// The method under test
Task modifyStartupSection = vAppClient.modifyStartupSection(vApp.getHref(), section);
assertTrue(retryTaskSuccess.apply(modifyStartupSection), String.format(TASK_COMPLETE_TIMELY, "modifyStartupSection"));
StartupSection modified = vAppClient.getStartupSection(vApp.getHref());
// assertEquals(modified.getX, "");
}
@Test(enabled = false, testName = "GET /vApp/{id}/virtualHardwareSection", dependsOnMethods = { "testGetVApp" })
public void testGetVirtualHardwareSection() {
// Method under test
VirtualHardwareSection hardware = vAppClient.getVirtualHardwareSection(vApp.getHref());
checkVirtualHardwareSection(hardware);
}
@Test(enabled = false, testName = "PUT /vApp/{id}/virtualHardwareSection", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testModifyVirtualHardwareSection() {
VirtualHardwareSection hardware = vAppClient.getVirtualHardwareSection(vApp.getHref());
hardware.setInfo("New Info");
// Method under test
Task modifyVirtualHardwareSection = vAppClient.modifyVirtualHardwareSection(vApp.getHref(), hardware);
assertTrue(retryTaskSuccess.apply(modifyVirtualHardwareSection), String.format(TASK_COMPLETE_TIMELY, "modifyVirtualHardwareSection"));
VirtualHardwareSection modified = vAppClient.getVirtualHardwareSection(vApp.getHref());
assertEquals(modified.getInfo(), "New Info");
}
@Test(enabled = false, testName = "GET /vApp/{id}/virtualHardwareSection/cpu", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionCpu() {
RASD rasd = vAppClient.getVirtualHardwareSectionCpu(vApp.getHref());
// checkRASD(rasd);
}
@Test(enabled = false, testName = "PUT /vApp/{id}/virtualHardwareSection/cpu", dependsOnMethods = { "testGetVirtualHardwareSectionCpu" })
public void testModifyVirtualHardwareSectionCpu() {
RASD rasd = vAppClient.getVirtualHardwareSectionCpu(vApp.getHref());
// rasd.setX("New Info");
// Method under test
Task modifyVirtualHardwareSectionCpu = vAppClient.modifyVirtualHardwareSectionCpu(vApp.getHref(), rasd);
assertTrue(retryTaskSuccess.apply(modifyVirtualHardwareSectionCpu), String.format(TASK_COMPLETE_TIMELY, "modifyVirtualHardwareSectionCpu"));
RASD modified = vAppClient.getVirtualHardwareSectionCpu(vApp.getHref());
// assertEquals(modified.getInfo(), "New Info");
}
@Test(enabled = false, testName = "GET /vApp/{id}/virtualHardwareSection/disks", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionDisks() {
RasdItemsList rasdItems = vAppClient.getVirtualHardwareSectionDisks(vApp.getHref());
// checkRasdItemsList(rasdItems);
}
@Test(enabled = false, testName = "PUT /vApp/{id}/virtualHardwareSection/disks", dependsOnMethods = { "testGetVirtualHardwareSectionDisks" })
public void testModifyVirtualHardwareSectionDisks() {
RasdItemsList rasdItems = vAppClient.getVirtualHardwareSectionDisks(vApp.getHref());
// rasd.setX("New Info");
// Method under test
Task modifyVirtualHardwareSectionDisks = vAppClient.modifyVirtualHardwareSectionDisks(vApp.getHref(), rasdItems);
assertTrue(retryTaskSuccess.apply(modifyVirtualHardwareSectionDisks), String.format(TASK_COMPLETE_TIMELY, "modifyVirtualHardwareSectionDisks"));
RasdItemsList modified = vAppClient.getVirtualHardwareSectionDisks(vApp.getHref());
// assertEquals(modified.getInfo(), "New Info");
}
@Test(enabled = false, testName = "GET /vApp/{id}/virtualHardwareSection/media", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionMedia() {
RasdItemsList rasdItems = vAppClient.getVirtualHardwareSectionMedia(vApp.getHref());
// checkRasdItemsList(rasdItems);
}
@Test(enabled = false, testName = "GET /vApp/{id}/virtualHardwareSection/memory", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionMemory() {
RASD rasd = vAppClient.getVirtualHardwareSectionCpu(vApp.getHref());
// checkRASD(rasd);
}
@Test(enabled = false, testName = "PUT /vApp/{id}/virtualHardwareSection/memory", dependsOnMethods = { "testGetVirtualHardwareSectionMemory" })
public void testModifyVirtualHardwareSectionMemory() {
RASD rasd = vAppClient.getVirtualHardwareSectionMemory(vApp.getHref());
// rasd.setX("New Info");
// Method under test
Task modifyVirtualHardwareSectionMemory = vAppClient.modifyVirtualHardwareSectionMemory(vApp.getHref(), rasd);
assertTrue(retryTaskSuccess.apply(modifyVirtualHardwareSectionMemory), String.format(TASK_COMPLETE_TIMELY, "modifyVirtualHardwareSectionMemory"));
RASD modified = vAppClient.getVirtualHardwareSectionMemory(vApp.getHref());
// assertEquals(modified.getInfo(), "New Info");
}
@Test(enabled = false, testName = "GET /vApp/{id}/virtualHardwareSection/networkCards", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionNetworkCards() {
RasdItemsList rasdItems = vAppClient.getVirtualHardwareSectionNetworkCards(vApp.getHref());
// checkRasdItemsList(rasdItems);
}
@Test(enabled = false, testName = "PUT /vApp/{id}/virtualHardwareSection/networkCards", dependsOnMethods = { "testGetVirtualHardwareSectionNetworkCards" })
public void testModifyVirtualHardwareSectionNetworkCards() {
RasdItemsList rasdItems = vAppClient.getVirtualHardwareSectionNetworkCards(vApp.getHref());
// rasd.setX("New Info");
// Method under test
Task modifyVirtualHardwareSectionNetworkCards = vAppClient.modifyVirtualHardwareSectionNetworkCards(vApp.getHref(), rasdItems);
assertTrue(retryTaskSuccess.apply(modifyVirtualHardwareSectionNetworkCards), String.format(TASK_COMPLETE_TIMELY, "modifyVirtualHardwareSectionNetworkCards"));
RasdItemsList modified = vAppClient.getVirtualHardwareSectionNetworkCards(vApp.getHref());
// assertEquals(modified.getInfo(), "New Info");
}
@Test(enabled = false, testName = "GET /vApp/{id}/virtualHardwareSection/serialPorts", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionSerialPorts() {
RasdItemsList rasdItems = vAppClient.getVirtualHardwareSectionSerialPorts(vApp.getHref());
// checkRasdItemsList(rasdItems);
}
@Test(enabled = false, testName = "PUT /vApp/{id}/virtualHardwareSection/serialPorts", dependsOnMethods = { "testGetVirtualHardwareSectionSerialPorts" })
public void testModifyVirtualHardwareSectionSerialPorts() {
RasdItemsList rasdItems = vAppClient.getVirtualHardwareSectionSerialPorts(vApp.getHref());
// rasd.setX("New Info");
// Method under test
Task modifyVirtualHardwareSectionSerialPorts = vAppClient.modifyVirtualHardwareSectionSerialPorts(vApp.getHref(), rasdItems);
assertTrue(retryTaskSuccess.apply(modifyVirtualHardwareSectionSerialPorts), String.format(TASK_COMPLETE_TIMELY, "modifyVirtualHardwareSectionSerialPorts"));
RasdItemsList modified = vAppClient.getVirtualHardwareSectionSerialPorts(vApp.getHref());
// assertEquals(modified.getInfo(), "New Info");
}
/**
* @see VAppClient#deleteVApp(URI)
*/
@Test(testName = "DELETE /vApp/{id}", dependsOnMethods = { "testPowerOffVApp" })
public void testDeleteVApp() {
// The method under test
Task deleteVApp = vAppClient.deleteVApp(vApp.getHref());
assertTrue(retryTaskSuccess.apply(deleteVApp), String.format(TASK_COMPLETE_TIMELY, "deleteVApp"));
try {
vApp = vAppClient.getVApp(vApp.getHref());
fail("The VApp should have been deleted");
} catch (VCloudDirectorException vcde) {
assertEquals(vcde.getError().getMajorErrorCode(), Integer.valueOf(403), "The error code should have been 'Forbidden' (403)");
vApp = null;
}
}
@AfterClass(groups = { "live" })
public void cleanUp() {
if (vApp != null) {
Task deleteVApp = vAppClient.deleteVApp(vApp.getHref());
retryTaskSuccess.apply(deleteVApp);
}
}
private VApp instantiateVApp() {
Vdc vdc = vdcClient.getVdc(vdcURI);
assertNotNull(vdc, String.format(OBJ_REQ_LIVE, VDC));
VAppTemplate vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI);
assertNotNull(vAppTemplate, String.format(OBJ_REQ_LIVE, VAPP_TEMPLATE));
InstantiateVAppTemplateParams instantiate = InstantiateVAppTemplateParams.builder().name("test-vapp").notDeploy().notPowerOn().description("Test VApp").instantiationParams(
InstantiationParams.builder().sections(
ImmutableSet.of(NetworkConfigSection.builder().info("Configuration parameters for logical networks").networkConfigs(
ImmutableSet.of(VAppNetworkConfiguration.builder().networkName("vAppNetwork").configuration(
NetworkConfiguration.builder().parentNetwork(Iterables.find(vdc.getAvailableNetworks().getNetworks(), new Predicate<Reference>() {
@Override
public boolean apply(Reference reference) {
return reference.getHref().equals(networkURI);
}
})).fenceMode("bridged").build()).build())).build())).build()).source(Reference.builder().href(vAppTemplateURI).build()).build();
VApp vAppInstantiated = vdcClient.instantiateVApp(vdcURI, instantiate);
assertNotNull(vAppInstantiated, String.format(VCloudDirectorLiveTestConstants.NOT_NULL_OBJECT_FMT, VAPP));
return vAppInstantiated;
}
}

View File

@ -18,8 +18,7 @@
*/
package org.jclouds.vcloud.director.v1_5.features;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import static org.testng.Assert.*;
import java.net.URI;
@ -189,11 +188,11 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneVAppTemplate")
.xmlFilePayload("/vdc/params/cloneVApp.xml", VCloudDirectorMediaType.CLONE_V_APP_PARAMS)
.xmlFilePayload("/vdc/params/cloneVApp.xml", VCloudDirectorMediaType.CLONE_VAPP_PARAMS)
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vdc/cloneVApp.xml", VCloudDirectorMediaType.V_APP)
.xmlFilePayload("/vdc/cloneVApp.xml", VCloudDirectorMediaType.VAPP)
.httpResponseBuilder().build());
VApp expected = cloneVApp();
@ -211,11 +210,11 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneVAppTemplate")
.xmlFilePayload("/vdc/params/cloneVAppTemplate.xml", VCloudDirectorMediaType.CLONE_V_APP_TEMPLATE_PARAMS)
.xmlFilePayload("/vdc/params/cloneVAppTemplate.xml", VCloudDirectorMediaType.CLONE_VAPP_TEMPLATE_PARAMS)
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vdc/cloneVAppTemplate.xml", VCloudDirectorMediaType.V_APP_TEMPLATE)
.xmlFilePayload("/vdc/cloneVAppTemplate.xml", VCloudDirectorMediaType.VAPP_TEMPLATE)
.httpResponseBuilder().build());
VAppTemplate expected = cloneVAppTemplate();
@ -237,7 +236,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vdc/composeVApp.xml", VCloudDirectorMediaType.V_APP)
.xmlFilePayload("/vdc/composeVApp.xml", VCloudDirectorMediaType.VAPP)
.httpResponseBuilder().build());
VApp expected = composeVApp();
@ -259,7 +258,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vdc/instantiateVAppTemplate.xml", VCloudDirectorMediaType.V_APP)
.xmlFilePayload("/vdc/instantiateVAppTemplate.xml", VCloudDirectorMediaType.VAPP)
.httpResponseBuilder().build());
VApp expected = instantiateVAppTemplate();
@ -281,7 +280,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vdc/uploadVAppTemplate.xml", VCloudDirectorMediaType.V_APP_TEMPLATE)
.xmlFilePayload("/vdc/uploadVAppTemplate.xml", VCloudDirectorMediaType.VAPP_TEMPLATE)
.httpResponseBuilder().build());
VAppTemplate expected = uploadVAppTemplate();

View File

@ -18,14 +18,9 @@
*/
package org.jclouds.vcloud.director.v1_5.features;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_GTE_0;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ_LIVE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_REQ_LIVE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.*;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.*;
import static org.testng.Assert.*;
import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.Checks;
@ -125,7 +120,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
//.sections(sections) // TODO: ovf sections
.build());
Checks.checkVAppTemplate(template);
checkVAppTemplate(template);
// TODO: await task to complete
// TODO: make assertions that the task was successful

View File

@ -94,26 +94,28 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
}
protected String catalogName;
// TODO: change to URI, not id
protected String vAppTemplateId;
protected URI vAppTemplateURI;
protected URI networkURI;
protected URI vdcURI;
// TODO change properties to URI, not id
@SuppressWarnings("unchecked")
protected void initTestParametersFromPropertiesOrLazyDiscover() {
vAppTemplateId = Strings.emptyToNull(System.getProperty("test." + provider + ".vapptemplate-id"));
catalogName = Strings.emptyToNull(System.getProperty("test." + provider + ".catalog-name"));
String vAppTemplateId = Strings.emptyToNull(System.getProperty("test." + provider + ".vapptemplate-id"));
if (vAppTemplateId != null)
vAppTemplateURI = URI.create(endpoint + "/vAppTemplate/" + vAppTemplateId);
// TODO: change properties to URI, not id
String vdcId = Strings.emptyToNull(System.getProperty("test." + provider + ".vdc-id"));
if (vdcId != null)
vdcURI = URI.create(endpoint + "/vdc/" + vdcId);
String networkId = Strings.emptyToNull(System.getProperty("test." + provider + ".network-id"));
if (networkId != null)
networkURI = URI.create(endpoint + "/network/" + networkId);
if (Iterables.any(Lists.newArrayList(vAppTemplateId, catalogName, networkURI, vdcURI), Predicates.isNull())) {
if (Iterables.any(Lists.newArrayList(catalogName, vAppTemplateURI, networkURI, vdcURI), Predicates.isNull())) {
Org thisOrg = context.getApi().getOrgClient().getOrg(
Iterables.find(context.getApi().getOrgClient().getOrgList().getOrgs(),
ReferenceTypePredicates.<Reference> nameEquals(session.getOrg())).getHref());

View File

@ -184,7 +184,6 @@ public class BaseVCloudDirectorRestClientExpectTest extends BaseRestClientExpect
* Provides convenience methods for priming a HttpRequest.Builder for vCloud testing
*
* @author danikov
*
*/
protected class VcloudHttpRequestPrimer {
private Multimap<String, String> headers = LinkedListMultimap.create();

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<VApp xmlns="http://www.vmware.com/vcloud/v1.5" deployed="false" status="0" name="test-vapp" id="urn:vcloud:vapp:d0e2b6b9-4381-4ddc-9572-cdfae54059be" type="application/vnd.vmware.vcloud.vApp+xml" href="https://mycloud.greenhousedata.com/api/vApp/vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://mycloud.greenhousedata.com/api/v1.5/schema/master.xsd">
<Link rel="down" type="application/vnd.vmware.vcloud.vAppNetwork+xml" name="orgNet-cloudsoft-External" href="https://mycloud.greenhousedata.com/api/network/2a2e2da4-446a-4ebc-a086-06df7c9570f0"/>
<Link rel="down" type="application/vnd.vmware.vcloud.controlAccess+xml" href="https://mycloud.greenhousedata.com/api/vApp/vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be/controlAccess/"/>
<Link rel="up" type="application/vnd.vmware.vcloud.vdc+xml" href="https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"/>
<Link rel="down" type="application/vnd.vmware.vcloud.owner+xml" href="https://mycloud.greenhousedata.com/api/vApp/vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be/owner"/>
<Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://mycloud.greenhousedata.com/api/vApp/vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be/metadata"/>
<Description>Test VApp</Description>
<Tasks>
<Task status="running" startTime="2012-03-12T10:41:22.060-06:00" operationName="vdcInstantiateVapp" operation="Creating Virtual Application test-vapp(d0e2b6b9-4381-4ddc-9572-cdfae54059be)" expiryTime="2012-06-10T10:41:22.060-06:00" name="task" id="urn:vcloud:task:2e458266-e70a-4860-bcb7-302fac12b6a3" type="application/vnd.vmware.vcloud.task+xml" href="https://mycloud.greenhousedata.com/api/task/2e458266-e70a-4860-bcb7-302fac12b6a3">
<Link rel="task:cancel" href="https://mycloud.greenhousedata.com/api/task/2e458266-e70a-4860-bcb7-302fac12b6a3/action/cancel"/>
<Owner type="application/vnd.vmware.vcloud.vApp+xml" name="test-vapp" href="https://mycloud.greenhousedata.com/api/vApp/vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be"/>
<User type="application/vnd.vmware.admin.user+xml" name="acole" href="https://mycloud.greenhousedata.com/api/admin/user/c090335b-708c-4c1c-9e3d-89560d002120"/>
<Organization type="application/vnd.vmware.vcloud.org+xml" name="cloudsoft" href="https://mycloud.greenhousedata.com/api/org/c076f90a-397a-49fa-89b8-b294c1599cd0"/>
<Progress>1</Progress>
</Task>
</Tasks>
<Owner type="application/vnd.vmware.vcloud.owner+xml">
<User type="application/vnd.vmware.admin.user+xml" name="acole" href="https://mycloud.greenhousedata.com/api/admin/user/c090335b-708c-4c1c-9e3d-89560d002120"/>
</Owner>
<InMaintenanceMode>false</InMaintenanceMode>
</VApp>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<InstantiateVAppTemplateParams
xmlns="http://www.vmware.com/vcloud/v1.5"
name="test-vapp"
deploy="false"
powerOn="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
<Description>Test VApp</Description>
<InstantiationParams>
<NetworkConfigSection>
<ovf:Info>Configuration parameters for logical networks</ovf:Info>
<NetworkConfig networkName="vAppNetwork">
<Configuration>
<ParentNetwork href="https://vcloud.example.com/api/network/b466c0c5-8a5c-4335-b703-a2e2e6b5f3e1" />
<FenceMode>bridged</FenceMode>
</Configuration>
</NetworkConfig>
</NetworkConfigSection>
</InstantiationParams>
<Source href="https://vcloud.example.com/api/vAppTemplate/vappTemplate-33578b29-1437-4b30-9f9a-4d4a3393b913" />
<AllEULAsAccepted>true</AllEULAsAccepted>
</InstantiateVAppTemplateParams>