Issue 830: Randomize name of instantiated VApps (implemented by @aledsage) and Metadata

This commit is contained in:
Andrew Donald Kennedy 2012-03-16 16:44:47 +00:00
parent 86f249d0d8
commit 22a718c07e
4 changed files with 18 additions and 11 deletions

View File

@ -24,6 +24,7 @@ import java.net.URI;
import java.util.Map;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
@ -44,8 +45,10 @@ import com.google.common.base.Objects.ToStringHelper;
* @author grkvlt@apache.org
*/
@XmlSeeAlso({
VAppReference.class,
CatalogReference.class
})
@XmlRootElement(name = "Reference")
@XmlType(name = "ReferenceType")
public class Reference {

View File

@ -199,8 +199,8 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien
// If we found any references, delete the VApp they point to
if (vApps != null && !Iterables.isEmpty(vApps)) {
for (Reference each : vApps) {
VApp found = vAppClient.getVApp(each.getHref());
for (Reference ref : vApps) {
VApp found = vAppClient.getVApp(ref.getHref());
// debug(found);
// Shutdown and power off the VApp if necessary

View File

@ -22,6 +22,7 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.C
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.ENTITY_EQUAL;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.*;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ADMIN_USER;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.MEDIA;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkControlAccessParams;
@ -106,7 +107,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
*/
@Test(testName = "GET /vApp/{id}")
public void testGetVApp() {
VApp vAppInstantiated = instantiateVApp("test-vapp");
VApp vAppInstantiated = instantiateVApp();
// Wait for the task to complete
Task instantiateTask = Iterables.getOnlyElement(vAppInstantiated.getTasks());
@ -120,7 +121,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
// Check the required fields are set
assertEquals(vApp.isDeployed(), Boolean.FALSE, String.format(OBJ_FIELD_EQ, VAPP, "deployed", "FALSE", vApp.isDeployed().toString()));
assertEquals(vApp.getName(), "test-vapp", String.format(OBJ_FIELD_EQ, VAPP, "name", "test-vapp", vApp.getName()));
assertTrue(vApp.getName().startsWith("test-vapp-"), String.format(MATCHES_STRING_FMT, "name", "test-vapp-*", vApp.getName()));
assertEquals(vApp.getDescription(), "Test VApp", String.format(OBJ_FIELD_EQ, VAPP, "Description", "Test VApp", vApp.getDescription()));
// TODO instantiationParams instantiationParams()
@ -136,7 +137,10 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
*/
@Test(testName = "PUT /vApp/{id}", dependsOnMethods = { "testGetVApp" })
public void testModifyVApp() {
VApp newVApp = VApp.builder().name("new-name").description("New Description").build();
VApp newVApp = VApp.builder()
.name("new-name-" + Integer.toString(random.nextInt(Integer.MAX_VALUE)))
.description("New Description")
.build();
// The method under test
Task modifyVApp = vAppClient.modifyVApp(vApp.getHref(), newVApp);
@ -1023,8 +1027,8 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
@Test(testName = "PUT & GET /vApp/{id}/metadata", dependsOnMethods = { "testGetMetadata" })
public void testSetAndGetMetadataValue() {
// Store a value
String key = Integer.toString(random.nextInt());
String value = Integer.toString(random.nextInt());
String key = Integer.toString(random.nextInt(Integer.MAX_VALUE));
String value = Integer.toString(random.nextInt(Integer.MAX_VALUE));
MetadataValue metadataValue = MetadataValue.builder().value(value).build();
vAppClient.getMetadataClient().setMetadata(vApp.getHref(), key, metadataValue);
@ -1038,7 +1042,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
@Test(testName = "DELETE /vApp/{id}/metadata/{key}", dependsOnMethods = { "testSetAndGetMetadataValue" })
public void testDeleteMetadataEntry() {
// Store a value, to be deleted
String key = Integer.toString(random.nextInt());
String key = Integer.toString(random.nextInt(Integer.MAX_VALUE));
MetadataValue metadataValue = MetadataValue.builder().value("myval").build();
vAppClient.getMetadataClient().setMetadata(vApp.getHref(), key, metadataValue);
@ -1059,8 +1063,8 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
Map<String, String> oldMetadataMap = Checks.metadataToMap(oldMetadata);
// Store a value, to be deleted
String key = Integer.toString(random.nextInt());
String value = Integer.toString(random.nextInt());
String key = Integer.toString(random.nextInt(Integer.MAX_VALUE));
String value = Integer.toString(random.nextInt(Integer.MAX_VALUE));
Metadata addedMetadata = Metadata.builder()
.entry(MetadataEntry.builder().key(key).value(value).build())
.build();

View File

@ -251,7 +251,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
* @return the VApp that is being instantiated
*/
protected VApp instantiateVApp() {
return instantiateVApp("test-vapp-"+random.nextInt(Integer.MAX_VALUE));
return instantiateVApp("test-vapp-" + random.nextInt(Integer.MAX_VALUE));
}
protected VApp instantiateVApp(String name) {