diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java
index 7eaa5aaced..f602e2f89e 100644
--- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java
+++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java
@@ -39,8 +39,8 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
/**
- * Represents a media.
- *
+ * Represents removable media, such as a CD-ROM, DVD or Floppy disk.
+ *
*
* <complexType name="Media" />
*
@@ -53,7 +53,7 @@ public class Media extends ResourceEntity {
public static enum ImageType {
@XmlEnumValue("iso") ISO("iso"),
@XmlEnumValue("floppy") FLOPPY("floppy"),
- UNRECOGNIZED("unrecognized");
+ @XmlEnumValue("") UNRECOGNIZED("unrecognized");
public static final List ALL = ImmutableList.of(ISO, FLOPPY);
diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java
index 8461649e28..6dc1020a79 100644
--- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java
+++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java
@@ -189,8 +189,9 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien
}
@AfterClass(alwaysRun = true, description = "Cleans up the environment by deleting created VApps")
- protected void cleanUp() {
+ protected void cleanUpEnvironment() {
vdc = vdcClient.getVdc(vdcURI); // Refresh
+
// Find references in the Vdc with the VApp type and in the list of instantiated VApp names
Iterable vApps = Iterables.filter(vdc.getResourceEntities(),
Predicates.and(ReferencePredicates. typeEquals(VCloudDirectorMediaType.VAPP), ReferencePredicates. nameIn(vAppNames)));
diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java
index abb2fa6c51..c5ec6a0b17 100644
--- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java
+++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java
@@ -116,10 +116,10 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
Media sourceMedia = Media.builder()
.type(VCloudDirectorMediaType.MEDIA)
- .name("Test media "+random.nextInt())
+ .name(name("media"))
.size(iso.length)
.imageType(Media.ImageType.ISO)
- .description("Test media generated by vAppClientLiveTest")
+ .description("Test media generated by VAppClientLiveTest")
.build();
Media media = context.getApi().getMediaClient().createMedia(addMedia.getHref(), sourceMedia);
@@ -149,22 +149,21 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
}
}
- @Override
- @AfterClass(alwaysRun = true)
+ @AfterClass(alwaysRun = true, dependsOnMethods = { "cleanUpEnvironment" })
public void cleanUp() {
if (adminContext != null && mediaCreated && mediaURI != null) {
try {
- Task delete = context.getApi().getMediaClient().deleteMedia(mediaURI);
- taskDoneEventually(delete);
+ Task delete = context.getApi().getMediaClient().deleteMedia(mediaURI);
+ taskDoneEventually(delete);
} catch (Exception e) {
- logger.warn("Error when deleting media: %s", e.getMessage());
+ logger.warn(e, "Error when deleting media");
}
}
if (adminContext != null && testUserCreated && testUserURI != null) {
try {
- adminContext.getApi().getUserClient().deleteUser(testUserURI);
+ adminContext.getApi().getUserClient().deleteUser(testUserURI);
} catch (Exception e) {
- logger.warn("Error when deleting user: %s", e.getMessage());
+ logger.warn(e, "Error when deleting user");
}
}
}
@@ -218,7 +217,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
@Test(description = "POST /vApp/{id}/action/deploy", dependsOnMethods = { "testGetVApp" })
public void testDeployVApp() {
DeployVAppParams params = DeployVAppParams.builder()
- .deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS))
+ .deploymentLeaseSeconds((int)TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS))
.notForceCustomization()
.notPowerOn()
.build();
diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java
index ccf16cd99c..faf4c07531 100644
--- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java
+++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java
@@ -90,7 +90,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
private String key;
private String val;
- @AfterClass(alwaysRun = true)
+ @AfterClass(alwaysRun = true, dependsOnMethods = { "cleanUpEnvironment" })
protected void tidyUp() {
if (key != null) {
try {
diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VmClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VmClientExpectTest.java
index 66c50af7c8..79ba42fee1 100644
--- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VmClientExpectTest.java
+++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VmClientExpectTest.java
@@ -33,7 +33,6 @@ import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket;
import org.jclouds.vcloud.director.v1_5.domain.Task;
-import org.jclouds.vcloud.director.v1_5.domain.VApp;
import org.jclouds.vcloud.director.v1_5.domain.Vm;
import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion;
import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer;
@@ -41,7 +40,6 @@ import org.jclouds.vcloud.director.v1_5.domain.dmtf.RasdItem;
import org.jclouds.vcloud.director.v1_5.domain.params.ControlAccessParams;
import org.jclouds.vcloud.director.v1_5.domain.params.DeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.params.MediaInsertOrEjectParams;
-import org.jclouds.vcloud.director.v1_5.domain.params.RecomposeVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams;
import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection;
diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VmClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VmClientLiveTest.java
index 19b8da7a04..bcb4f09413 100644
--- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VmClientLiveTest.java
+++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VmClientLiveTest.java
@@ -134,10 +134,10 @@ public class VmClientLiveTest extends AbstractVAppClientLiveTest {
Media sourceMedia = Media.builder()
.type(VCloudDirectorMediaType.MEDIA)
- .name("Test media "+random.nextInt())
+ .name(name("media"))
.size(iso.length)
.imageType(Media.ImageType.ISO)
- .description("Test media generated by vmClient.iveTest")
+ .description("Test media generated by VmClientLiveTest")
.build();
Media media = context.getApi().getMediaClient().createMedia(addMedia.getHref(), sourceMedia);
@@ -167,8 +167,7 @@ public class VmClientLiveTest extends AbstractVAppClientLiveTest {
}
}
- @Override
- @AfterClass(alwaysRun = true)
+ @AfterClass(alwaysRun = true, dependsOnMethods = { "cleanUpEnvironment" })
public void cleanUp() {
if (adminContext != null && mediaCreated && mediaURI != null) {
try {
diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java
index 29148e5ff0..7cc8233b5e 100644
--- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java
+++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java
@@ -43,12 +43,13 @@ import org.jclouds.rest.RestContext;
import org.jclouds.vcloud.director.testng.FormatApiResultsListener;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext;
-import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminAsyncClient;
import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient;
import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
+import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status;
+import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles;
import org.jclouds.vcloud.director.v1_5.domain.RoleReferences;
import org.jclouds.vcloud.director.v1_5.domain.Session;
import org.jclouds.vcloud.director.v1_5.domain.Task;
@@ -56,8 +57,6 @@ import org.jclouds.vcloud.director.v1_5.domain.User;
import org.jclouds.vcloud.director.v1_5.domain.VApp;
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.ResourceEntity.Status;
-import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles;
import org.jclouds.vcloud.director.v1_5.domain.network.Network;
import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConfiguration;
import org.jclouds.vcloud.director.v1_5.domain.network.VAppNetworkConfiguration;
@@ -104,7 +103,7 @@ import com.google.inject.Guice;
public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTest {
@Resource
- protected Logger logger = Logger.CONSOLE;
+ protected Logger logger = Logger.NULL;
protected static final long TASK_TIMEOUT_SECONDS = 100L;
protected static final long LONG_TASK_TIMEOUT_SECONDS = 300L;
@@ -429,15 +428,12 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe
protected void cleanUpVApp(URI vAppURI) {
VAppClient vAppClient = context.getApi().getVAppClient();
- VApp vApp;
- try {
- vApp = vAppClient.getVApp(vAppURI); // Refresh
- logger.debug("Deleting VApp %s (%s)", vApp.getName(), vAppURI.getPath());
- } catch (VCloudDirectorException e) {
- // Presumably vApp has already been deleted. Ignore.
+ VApp vApp = vAppClient.getVApp(vAppURI); // Refresh
+ if (vApp == null) {
logger.info("Cannot find VApp at %s", vAppURI.getPath());
- return;
+ return; // Presumably vApp has already been deleted. Ignore.
}
+ logger.debug("Deleting VApp %s (%s)", vApp.getName(), vAppURI.getPath());
// Wait for busy tasks to complete (don't care if it's failed or successful)
// Otherwise, get error on delete "entity is busy completing an operation.
@@ -463,7 +459,9 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe
// Undeploy the VApp if necessary
if (vApp.isDeployed()) {
try {
- UndeployVAppParams params = UndeployVAppParams.builder().build();
+ UndeployVAppParams params = UndeployVAppParams.builder()
+ .undeployPowerAction(UndeployVAppParams.PowerAction.SHUTDOWN)
+ .build();
Task undeployTask = vAppClient.undeploy(vAppURI, params);
taskDoneEventually(undeployTask);
} catch (Exception e) {
@@ -478,12 +476,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe
vAppNames.remove(vApp.getName());
logger.info("Deleted VApp %s", vApp.getName());
} catch (Exception e) {
- try {
- vApp = vAppClient.getVApp(vAppURI); // Refresh
- } catch (Exception e2) {
- // Ignore
- }
-
+ vApp = vAppClient.getVApp(vAppURI); // Refresh
logger.warn(e, "Deleting VApp %s failed (%s)", vApp.getName(), vAppURI.getPath());
}
}