From 98a89aa68d5d55b0780c027855c2a03abf02d2f4 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Wed, 11 Apr 2012 12:11:36 +0100 Subject: [PATCH 1/6] Fix DMTF section types --- .../java/org/jclouds/dmtf/ovf/OperatingSystemSection.java | 2 -- .../java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java | 2 -- .../vcloud/director/v1_5/domain/OperatingSystemSection.java | 2 ++ .../vcloud/director/v1_5/domain/VirtualHardwareSection.java | 4 +++- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java index 724eb9fa21..b51014cbf2 100644 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java @@ -23,7 +23,6 @@ import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; @@ -33,7 +32,6 @@ import com.google.common.base.Objects; * @author Adrian Cole * @author Adam Lowe */ -@XmlType(name = "OperatingSystemSection_Type") public class OperatingSystemSection extends SectionType { public static Builder builder() { diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java index 3b5dbadeec..8d6db5eb47 100644 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java @@ -25,7 +25,6 @@ import java.util.Set; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; import org.jclouds.dmtf.cim.ResourceAllocationSettingData; import org.jclouds.dmtf.cim.VirtualSystemSettingData; @@ -46,7 +45,6 @@ import com.google.common.collect.Sets; * @author Adam Lowe * @author grkvlt@apache.org */ -@XmlType(name = "VirtualHardwareSection_Type") public class VirtualHardwareSection extends SectionType { public static Builder builder() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java index 50fab311ce..2fe2a5649e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java @@ -30,6 +30,7 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -44,6 +45,7 @@ import com.google.common.collect.Sets; * @author grkvlt@apache.org */ @XmlRootElement(name = "OperatingSystemSection") +@XmlType(name = "OperatingSystemSection_Type") @XmlSeeAlso({ org.jclouds.dmtf.ovf.OperatingSystemSection.class }) public class OperatingSystemSection extends org.jclouds.dmtf.ovf.OperatingSystemSection { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java index a5c216a7df..340e333caf 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java @@ -30,6 +30,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -41,7 +42,8 @@ import com.google.common.collect.Sets; * * @author grkvlt@apache.org */ -@XmlRootElement(name = "VirtualHardwareSection", namespace = VCLOUD_1_5_NS) +@XmlRootElement(name = "VirtualHardwareSection") +@XmlType(name = "VirtualHardwareSection_Type") @XmlSeeAlso({ org.jclouds.dmtf.ovf.VirtualHardwareSection.class }) public class VirtualHardwareSection extends org.jclouds.dmtf.ovf.VirtualHardwareSection { From b786178a909bf5d471def602ca86ed4888359b44 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Wed, 11 Apr 2012 12:12:01 +0100 Subject: [PATCH 2/6] Better error checking and logging in test tear down/clean up methods --- .../v1_5/predicates/TaskStatusEquals.java | 5 +- .../director/v1_5/predicates/TaskSuccess.java | 20 +++-- .../vcloud/director/v1_5/domain/Checks.java | 2 + .../v1_5/features/CatalogClientLiveTest.java | 36 ++++---- .../v1_5/features/MediaClientLiveTest.java | 17 ++-- .../v1_5/features/NetworkClientLiveTest.java | 11 ++- .../v1_5/features/OrgClientLiveTest.java | 17 ++-- .../v1_5/features/QueryClientLiveTest.java | 4 +- .../v1_5/features/VAppClientLiveTest.java | 84 +++++++++++-------- .../features/VAppTemplateClientLiveTest.java | 7 +- .../v1_5/features/VdcClientLiveTest.java | 8 +- .../admin/AdminCatalogClientLiveTest.java | 11 +-- .../admin/AdminVdcClientLiveTest.java | 2 +- .../features/admin/UserClientLiveTest.java | 15 ++-- .../BaseVCloudDirectorClientLiveTest.java | 41 ++++++--- 15 files changed, 172 insertions(+), 108 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java index 4ba0faca7e..73a505d891 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java @@ -18,6 +18,8 @@ */ package org.jclouds.vcloud.director.v1_5.predicates; +import static com.google.common.base.Preconditions.checkNotNull; + import java.util.Collection; import java.util.Collections; import java.util.Set; @@ -34,7 +36,7 @@ import com.google.common.base.Predicate; import com.google.common.collect.Iterables; /** - * Test a {@link Task} to see if it has succeeded. + * Test a {@link Task} status is in a particular set of {@link Task.Status statuses}. * * @author grkvlt@apache.org */ @@ -61,6 +63,7 @@ public class TaskStatusEquals implements Predicate { /** @see Predicate#apply(Object) */ @Override public boolean apply(Task task) { + checkNotNull(task, "task"); logger.trace("looking for status on task %s", task); // TODO shouldn't we see if it's already done before getting it from API server? diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskSuccess.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskSuccess.java index 0380138d08..82d278a55f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskSuccess.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskSuccess.java @@ -18,6 +18,10 @@ */ package org.jclouds.vcloud.director.v1_5.predicates; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.EnumSet; + import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Singleton; @@ -30,7 +34,7 @@ import org.jclouds.vcloud.director.v1_5.features.TaskClient; import com.google.common.base.Predicate; /** - * Test a {@link Task} to see if it has succeeded. + * Test a {@link Task} to see if it has {@link Task.Status#SUCCESS succeeded}. * * @author grkvlt@apache.org */ @@ -50,21 +54,19 @@ public class TaskSuccess implements Predicate { /** @see Predicate#apply(Object) */ @Override public boolean apply(Task task) { - logger.trace("looking for status on task %s", task); + checkNotNull(task, "task"); + logger.trace("looking for status on task %s", task.getOperationName()); // TODO shouldn't we see if it's already done before getting it from API server? task = taskClient.getTask(task.getHref()); // perhaps task isn't available, yet if (task == null) return false; - logger.trace("%s: looking for status %s: currently: %s", task, Task.Status.SUCCESS, task.getStatus()); - if (task.getStatus().equals(Task.Status.ERROR)) + + logger.trace("%s: looking for status %s: currently: %s", task.getOperationName(), Task.Status.SUCCESS, task.getStatus()); + if (EnumSet.of(Task.Status.ERROR, Task.Status.CANCELED, Task.Status.ABORTED).contains(task.getStatus())) { throw new VCloudDirectorException(task); - if (task.getStatus().equals(Task.Status.CANCELED)) - throw new VCloudDirectorException(task); - if (task.getStatus().equals(Task.Status.ABORTED)) - throw new VCloudDirectorException(task); - return task.getStatus().equals(Task.Status.SUCCESS); + } else return task.getStatus().equals(Task.Status.SUCCESS); } @Override diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java index 512173b720..8c95489a10 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java @@ -582,6 +582,8 @@ public class Checks { } public static void checkVmPendingQuestion(VmPendingQuestion question) { + assertNotNull(question, String.format(NOT_NULL_OBJ_FMT, "VmPendingQuestion")); + // Check required fields assertNotNull(question.getQuestion(), String.format(OBJ_FIELD_REQ, "VmPendingQuestion", "Question")); assertNotNull(question.getQuestionId(), String.format(OBJ_FIELD_REQ, "VmPendingQuestion", "QuestionId")); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java index bf0284a2fc..9ee89bc11b 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java @@ -25,7 +25,6 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.O import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkCatalogItem; -import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkError; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadata; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadataValue; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkTask; @@ -35,9 +34,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog; import org.jclouds.vcloud.director.v1_5.domain.CatalogItem; @@ -112,22 +109,29 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { @AfterClass(alwaysRun = true) public void tearDown() { - if (catalogItem != null) - catalogClient.deleteCatalogItem(catalogItem.getHref()); - - if (media != null) - context.getApi().getMediaClient().deleteMedia(media.getHref()); - - if (adminCatalog != null) { - adminContext.getApi().getCatalogClient().deleteCatalog(adminCatalog.getHref()); + if (catalogItem != null) { try { - catalogClient.getCatalog(catalogRef.getHref()); - fail("The Catalog should have been deleted"); - } catch (VCloudDirectorException vcde) { - checkError(vcde.getError()); - assertEquals(vcde.getError().getMajorErrorCode(), Integer.valueOf(403), "The majorErrorCode should be 403 since the item has been deleted"); + catalogClient.deleteCatalogItem(catalogItem.getHref()); + } catch (Exception e) { + logger.warn(e, "Error when deleting catalog item '%s'", catalogItem.getName()); } } + if (media != null) { + try { + Task delete = context.getApi().getMediaClient().deleteMedia(media.getHref()); + taskDoneEventually(delete); + } catch (Exception e) { + logger.warn(e, "Error when deleting media '%s'", media.getName()); + } + } + if (adminContext != null && adminCatalog != null) { + try { + adminContext.getApi().getCatalogClient().deleteCatalog(adminCatalog.getHref()); + } catch (Exception e) { + logger.warn(e, "Error when deleting catalog '%s'", adminCatalog.getName()); + } + } + // TODO wait for tasks } @Test(description = "GET /catalog/{id}") diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java index 1759f04f94..de8bab0473 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java @@ -42,18 +42,15 @@ import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; import java.net.URISyntaxException; import java.util.Collections; import java.util.Set; import org.jclouds.io.Payloads; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.Checks; import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; -import org.jclouds.vcloud.director.v1_5.domain.Error; import org.jclouds.vcloud.director.v1_5.domain.File; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Media; @@ -108,10 +105,20 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { @AfterClass(alwaysRun = true) protected void tidyUp() { if (media != null) { - assertTaskSucceeds(mediaClient.deleteMedia(media.getHref())); + try { + Task delete = mediaClient.deleteMedia(media.getHref()); + taskDoneEventually(delete); + } catch (Exception e) { + logger.warn(e, "Error when deleting media '%s': %s", media.getName()); + } } if (oldMedia != null) { - assertTaskSucceeds(mediaClient.deleteMedia(oldMedia.getHref())); + try { + Task delete = mediaClient.deleteMedia(oldMedia.getHref()); + taskDoneEventually(delete); + } catch (Exception e) { + logger.warn(e, "Error when deleting media '%s': %s", oldMedia.getName()); + } } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java index 3b39a37493..2a4375bffd 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java @@ -36,6 +36,7 @@ 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.Network; import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; +import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -67,10 +68,14 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest { } @AfterClass(alwaysRun = true) - public void cleanUp() throws Exception { + public void cleanUp() { if (metadataSet) { - adminContext.getApi().getNetworkClient().getMetadataClient() - .deleteMetadataEntry(toAdminUri(networkURI), "key"); + try { + Task delete = adminContext.getApi().getNetworkClient().getMetadataClient().deleteMetadataEntry(toAdminUri(networkURI), "key"); + taskDoneEventually(delete); + } catch (Exception e) { + logger.warn(e, "Error when deleting metadata"); + } } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java index b40961672f..9f18039da7 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java @@ -40,6 +40,7 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -73,11 +74,17 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { @AfterClass(alwaysRun = true) public void cleanUp() throws Exception { if (adminMembersSet) { - adminContext.getApi().getOrgClient().getMetadataClient() - .deleteMetadataEntry(toAdminUri(orgURI), "KEY"); - - adminContext.getApi().getCatalogClient() - .deleteCatalog(catalogRef); + try { + Task delete = adminContext.getApi().getOrgClient().getMetadataClient().deleteMetadataEntry(toAdminUri(orgURI), "KEY"); + taskDoneEventually(delete); + } catch (Exception e) { + logger.warn(e, "Error when deleting metadata entry"); + } + try { + adminContext.getApi().getCatalogClient().deleteCatalog(catalogRef); + } catch (Exception e) { + logger.warn(e, "Error when deleting catalog'%s': %s", catalogRef); + } } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java index fb8b0c7894..d0bb44abff 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java @@ -76,9 +76,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest { @AfterClass(alwaysRun = true) public void cleanUp() throws Exception { - if (vApp != null) { - cleanUpVApp(vApp); - } + if (vApp != null) cleanUpVApp(vApp); } @Override 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 773d292aac..8b82c17a63 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 @@ -134,46 +134,46 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest { private MetadataValue metadataValue; private String key; - private URI mediaURI; private URI testUserURI; + private boolean mediaCreated = false; + private boolean testUserCreated = false; - @Override - @BeforeClass(alwaysRun = true) - protected void setupRequiredClients() { - super.setupRequiredClients(); - + @BeforeClass(alwaysRun = true, dependsOnMethods = { "setupRequiredClients" }) + protected void setupRequiredEntities() { Set links = vdcClient.getVdc(vdcURI).getLinks(); - Predicate addMediaLink = and(relEquals("add"), typeEquals(VCloudDirectorMediaType.MEDIA)); - - if (contains(links, addMediaLink)) { - Link addMedia = find(links, addMediaLink); - byte[] iso = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + + if (mediaURI == null) { + Predicate addMediaLink = and(relEquals(Link.Rel.ADD), typeEquals(VCloudDirectorMediaType.MEDIA)); - Media sourceMedia = Media.builder() - .type(VCloudDirectorMediaType.MEDIA) - .name("Test media "+random.nextInt()) - .size(iso.length) - .imageType(Media.ImageType.ISO) - .description("Test media generated by vAppClientLiveTest") - .build(); - Media media = context.getApi().getMediaClient().createMedia(addMedia.getHref(), sourceMedia); - - Link uploadLink = getFirst(getFirst(media.getFiles(), null).getLinks(), null); - context.getApi().getUploadClient().upload(uploadLink.getHref(), Payloads.newByteArrayPayload(iso)); - - media = context.getApi().getMediaClient().getMedia(media.getHref()); - - if (media.getTasks().size() == 1) { - Task uploadTask = Iterables.getOnlyElement(media.getTasks()); - Checks.checkTask(uploadTask); - assertEquals(uploadTask.getStatus(), Task.Status.RUNNING); - assertTrue(retryTaskSuccess.apply(uploadTask), String.format(TASK_COMPLETE_TIMELY, "uploadTask")); + if (contains(links, addMediaLink)) { + Link addMedia = find(links, addMediaLink); + byte[] iso = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + + Media sourceMedia = Media.builder() + .type(VCloudDirectorMediaType.MEDIA) + .name("Test media "+random.nextInt()) + .size(iso.length) + .imageType(Media.ImageType.ISO) + .description("Test media generated by vAppClientLiveTest") + .build(); + Media media = context.getApi().getMediaClient().createMedia(addMedia.getHref(), sourceMedia); + + Link uploadLink = getFirst(getFirst(media.getFiles(), null).getLinks(), null); + context.getApi().getUploadClient().upload(uploadLink.getHref(), Payloads.newByteArrayPayload(iso)); + media = context.getApi().getMediaClient().getMedia(media.getHref()); + + if (media.getTasks().size() == 1) { + Task uploadTask = Iterables.getOnlyElement(media.getTasks()); + Checks.checkTask(uploadTask); + assertEquals(uploadTask.getStatus(), Task.Status.RUNNING); + assertTrue(retryTaskSuccess.apply(uploadTask), String.format(TASK_COMPLETE_TIMELY, "uploadTask")); + media = context.getApi().getMediaClient().getMedia(media.getHref()); + } + + mediaURI = media.getHref(); + mediaCreated = true; } - - mediaURI = media.getHref(); - } else { - mediaURI = super.mediaURI; } if (adminContext != null) { @@ -187,8 +187,20 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest { @Override @AfterClass(alwaysRun = true) public void cleanUp() { - if (adminContext != null && mediaURI != null) { - assertTaskDoneEventually(context.getApi().getMediaClient().deleteMedia(mediaURI)); + if (adminContext != null && mediaCreated && mediaURI != null) { + try { + Task delete = context.getApi().getMediaClient().deleteMedia(mediaURI); + taskDoneEventually(delete); + } catch (Exception e) { + logger.warn("Error when deleting media: %s", e.getMessage()); + } + } + if (adminContext != null && testUserCreated && testUserURI != null) { + try { + adminContext.getApi().getUserClient().deleteUser(testUserURI); + } catch (Exception e) { + logger.warn("Error when deleting user: %s", e.getMessage()); + } } } 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 15d43555de..5a3da1cdbe 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 @@ -93,7 +93,12 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { @AfterClass(alwaysRun = true) protected void tidyUp() { if (key != null) { - assertTaskSucceeds(vAppTemplateClient.getMetadataClient().deleteMetadataEntry(vAppTemplateURI, key)); + try { + Task delete = vAppTemplateClient.getMetadataClient().deleteMetadataEntry(vAppTemplateURI, key); + taskDoneEventually(delete); + } catch (Exception e) { + logger.warn(e, "Error when deleting metadata entry '%s'", key); + } } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java index 7ae512dc31..bf1a1cd3b7 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java @@ -118,8 +118,12 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { } if (metadataSet) { - adminContext.getApi().getVdcClient().getMetadataClient() - .deleteMetadataEntry(toAdminUri(vdcURI), "key"); + try { + Task delete = adminContext.getApi().getVdcClient().getMetadataClient().deleteMetadataEntry(toAdminUri(vdcURI), "key"); + taskDoneEventually(delete); + } catch (Exception e) { + logger.warn(e, "Error deleting metadata entry"); + } } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java index e8c73cc02a..c6c2d68751 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java @@ -83,13 +83,10 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest @AfterClass(alwaysRun = true) protected void tidyUp() { if (catalog != null) { - catalogClient.deleteCatalog(catalog.getHref()); - try { //TODO: predicate to retry for a short while? - catalogClient.getCatalog(catalog.getHref()); - fail("The Catalog should have been deleted"); - } catch (VCloudDirectorException vcde) { - checkError(vcde.getError()); - assertEquals(vcde.getError().getMajorErrorCode(), Integer.valueOf(403), "The majorErrorCode should be 403 since the item has been deleted"); + try { + catalogClient.deleteCatalog(catalog.getHref()); + } catch (Exception e) { + logger.warn(e, "Error deleting admin catalog '%s'", catalog.getName()); } } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java index 6ef70f5087..205d470c85 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java @@ -75,7 +75,7 @@ public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { if (metadataKey != null) { try { Task task = metadataClient.deleteMetadataEntry(adminVdcUri, metadataKey); - assertTaskSucceeds(task); + taskDoneEventually(task); } catch (VCloudDirectorException e) { logger.warn(e, "Error deleting metadata-value (perhaps it doesn't exist?); continuing..."); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java index 9ca09a523f..80bd1c94e0 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java @@ -30,7 +30,6 @@ import static org.testng.AssertJUnit.assertFalse; import java.net.URI; import org.jclouds.rest.AuthorizationException; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles; @@ -77,8 +76,8 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest { if (user != null) { try { userClient.deleteUser(user.getHref()); - } catch (VCloudDirectorException e) { - // ignore; user probably already deleted + } catch (Exception e) { + logger.warn(e, "Error deleting user '%s'", user.getName()); } } } @@ -177,11 +176,13 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest { assertTrue(settings.isAccountLockoutEnabled()); - for (int i=0; i immutableSet) { + protected boolean taskStatusEventually(Task task, Task.Status running, ImmutableSet immutableSet) { TaskClient taskClient = context.getApi().getTaskClient(); TaskStatusEquals predicate = new TaskStatusEquals(taskClient, running, immutableSet); RetryablePredicate retryablePredicate = new RetryablePredicate(predicate, TASK_TIMEOUT_SECONDS * 1000L); - assertTrue(retryablePredicate.apply(task), "Task must enter status "+running); + return retryablePredicate.apply(task); } - protected void assertTaskDoneEventually(Task task) { + protected void assertTaskStatusEventually(Task task, Task.Status running, ImmutableSet immutableSet) { + assertTrue(taskStatusEventually(task, running, immutableSet), + String.format("Task '%s' must reach status %s", task.getOperationName(), running)); + } + + protected boolean taskDoneEventually(Task task) { TaskClient taskClient = context.getApi().getTaskClient(); TaskStatusEquals predicate = new TaskStatusEquals( taskClient, ImmutableSet.of(Task.Status.ABORTED, Task.Status.CANCELED, Task.Status.ERROR, Task.Status.SUCCESS), Collections.emptySet()); RetryablePredicate retryablePredicate = new RetryablePredicate(predicate, LONG_TASK_TIMEOUT_SECONDS * 1000L); - assertTrue(retryablePredicate.apply(task), "Task must be done"); + return retryablePredicate.apply(task); + } + + protected void assertTaskDoneEventually(Task task) { + assertTrue(taskDoneEventually(task), + String.format("Task '%s' must complete", task.getOperationName())); } /** @@ -407,10 +417,13 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ protected void cleanUpVAppTemplate(VAppTemplate vAppTemplate) { VAppTemplateClient vappTemplateClient = context.getApi().getVAppTemplateClient(); - - Task task = vappTemplateClient.deleteVappTemplate(vAppTemplate.getHref()); - assertTaskSucceeds(task); - } + try { + Task task = vappTemplateClient.deleteVappTemplate(vAppTemplate.getHref()); + taskDoneEventually(task); + } catch (Exception e) { + logger.warn(e, "Error deleting template '%s'", vAppTemplate.getName()); + } + } protected void cleanUpVApp(VApp vApp) { cleanUpVApp(vApp.getHref()); @@ -434,7 +447,9 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ // Otherwise, get error on delete "entity is busy completing an operation. if (vApp.getTasks() != null) { for (Task task : vApp.getTasks()) { - assertTaskDoneEventually(task); + if (!taskDoneEventually(task)) { + logger.warn("Task '%s' did not complete", task.getOperationName()); + } } } @@ -442,7 +457,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ if (vApp.getStatus().equals(Status.POWERED_ON.getValue())) { try { Task shutdownTask = vAppClient.shutdown(vAppURI); - retryTaskSuccess.apply(shutdownTask); + taskDoneEventually(shutdownTask); } catch (Exception e) { // keep going; cleanup as much as possible logger.warn(e, "Continuing cleanup after error shutting down VApp %s", vApp.getName()); @@ -454,7 +469,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ try { UndeployVAppParams params = UndeployVAppParams.builder().build(); Task undeployTask = vAppClient.undeploy(vAppURI, params); - retryTaskSuccess.apply(undeployTask); + taskDoneEventually(undeployTask); } catch (Exception e) { // keep going; cleanup as much as possible logger.warn(e, "Continuing cleanup after error undeploying VApp %s", vApp.getName()); @@ -463,7 +478,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ try { Task task = vAppClient.deleteVApp(vAppURI); - assertTaskSucceeds(task); + taskDoneEventually(task); vAppNames.remove(vApp.getName()); logger.info("Deleted VApp %s", vApp.getName()); } catch (Exception e) { @@ -480,4 +495,4 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ public static String name(String prefix) { return prefix + Integer.toString(random.nextInt(Integer.MAX_VALUE)); } -} +} \ No newline at end of file From fd616ddbed040e55e02804375b229a9ff10b3839 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Wed, 11 Apr 2012 13:05:04 +0100 Subject: [PATCH 3/6] Error handler check for empty payload --- .../director/v1_5/handlers/VCloudDirectorErrorHandler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/handlers/VCloudDirectorErrorHandler.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/handlers/VCloudDirectorErrorHandler.java index 5d209865c7..49c936c914 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/handlers/VCloudDirectorErrorHandler.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/handlers/VCloudDirectorErrorHandler.java @@ -55,11 +55,12 @@ public class VCloudDirectorErrorHandler implements HttpErrorHandler { : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine()); Exception exception = new HttpResponseException(command, response, message); - // Try to create a VCloudDirectorException from XML payload - if (response.getPayload().getContentMetadata().getContentType().startsWith(VCloudDirectorMediaType.ERROR)) { + // Try to create a VCloudDirectorException from XML payload, if it exists + if (response.getPayload() != null && response.getPayload().getContentMetadata().getContentType().startsWith(VCloudDirectorMediaType.ERROR)) { try { Error error = JAXB.unmarshal(InputSuppliers.of(data).getInput(), Error.class); exception = new VCloudDirectorException(error); + message = error.getMessage(); } catch (Exception e) { Throwables.propagate(e); } From 2e67af207557eb3dea0d275c379967f3c45bd627 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Wed, 11 Apr 2012 14:03:34 +0100 Subject: [PATCH 4/6] Minor fixups --- .../java/org/jclouds/vcloud/director/v1_5/domain/Link.java | 3 ++- .../vcloud/director/v1_5/domain/OperatingSystemSection.java | 3 ++- .../vcloud/director/v1_5/domain/VirtualHardwareSection.java | 3 ++- .../vcloud/director/v1_5/features/VAppTemplateAsyncClient.java | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java index 6aad1d69ae..447ea1f7b3 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java @@ -95,6 +95,7 @@ public class Link extends Reference { @XmlEnumValue("remove") REMOVE("remove"), @XmlEnumValue("screen:acquireTicket") SCREEN_ACQUIRE_TICKET("screen:acquireTicket"), @XmlEnumValue("screen:thumbnail") SCREEN_THUMBNAIL("screen:thumbnail"), + @XmlEnumValue("syncSyslogSettings") SYNC_SYSLOG_SETTINGS("syncSyslogSettings"), @XmlEnumValue("task:cancel") TASK_CANCEL("task:cancel"), @XmlEnumValue("blockingTask") BLOCKING_TASK("blockingTask"), @XmlEnumValue("taskOwner") TASK_OWNER("taskOwner"), @@ -121,7 +122,7 @@ public class Link extends Reference { NEXT_PAGE, OVA, OVF, POWER_OFF, POWER_ON, REBOOT, RESET, SHUTDOWN, SUSPEND, PREVIOUS_PAGE, PUBLISH, RECOMPOSE, RECONNECT, REGISTER, REJECT, RELOCATE, REMOVE, REPAIR, SCREEN_ACQUIRE_TICKET, - SCREEN_THUMBNAIL, TASK_CANCEL, BLOCKING_TASK, TASK_OWNER, + SCREEN_THUMBNAIL, SYNC_SYSLOG_SETTINGS, TASK_CANCEL, BLOCKING_TASK, TASK_OWNER, TASK_PARAMS, TASK_REQUEST, UNDEPLOY, UNLOCK, UNREGISTER, UP, UPDATE_PROGRESS, UPGRADE, UPLOAD_ALTERNATE, UPLOAD_DEFAULT, UPLOAD_DEFAULT); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java index 2fe2a5649e..654fc6d0fe 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java @@ -20,6 +20,7 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_VMW_NS; @@ -44,7 +45,7 @@ import com.google.common.collect.Sets; * @author Adam Lowe * @author grkvlt@apache.org */ -@XmlRootElement(name = "OperatingSystemSection") +@XmlRootElement(name = "OperatingSystemSection", namespace = OVF_NS) @XmlType(name = "OperatingSystemSection_Type") @XmlSeeAlso({ org.jclouds.dmtf.ovf.OperatingSystemSection.class }) public class OperatingSystemSection extends org.jclouds.dmtf.ovf.OperatingSystemSection { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java index 340e333caf..34961da6c0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java @@ -20,6 +20,7 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.net.URI; @@ -42,7 +43,7 @@ import com.google.common.collect.Sets; * * @author grkvlt@apache.org */ -@XmlRootElement(name = "VirtualHardwareSection") +@XmlRootElement(name = "VirtualHardwareSection", namespace = OVF_NS) @XmlType(name = "VirtualHardwareSection_Type") @XmlSeeAlso({ org.jclouds.dmtf.ovf.VirtualHardwareSection.class }) public class VirtualHardwareSection extends org.jclouds.dmtf.ovf.VirtualHardwareSection { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncClient.java index e49e85d604..1a60ee16b8 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncClient.java @@ -204,7 +204,7 @@ public interface VAppTemplateAsyncClient { * @see VAppTemplateClient#getNetworkConnectionSection(URI) */ @GET - @Consumes(NETWORK_CONFIG_SECTION) + @Consumes(NETWORK_CONNECTION_SECTION) @Path("/networkConnectionSection") @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) From 19c88aa1fe90f69829f5a9000f273fa79a1be2c4 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Wed, 11 Apr 2012 22:48:48 +0100 Subject: [PATCH 5/6] Updated test annotations for command-line test tool --- .../director/v1_5/HttpClientLiveTest.java | 114 +++++++++++++++ .../v1_5/NonClientOperationsLiveTest.java | 136 ------------------ .../features/CatalogClientExpectTest.java | 2 +- .../v1_5/features/CatalogClientLiveTest.java | 2 +- .../v1_5/features/MediaClientExpectTest.java | 2 +- .../v1_5/features/MediaClientLiveTest.java | 2 +- .../features/NetworkClientExpectTest.java | 2 +- .../v1_5/features/NetworkClientLiveTest.java | 2 +- .../v1_5/features/OrgClientExpectTest.java | 2 +- .../v1_5/features/OrgClientLiveTest.java | 2 +- .../v1_5/features/QueryClientExpectTest.java | 2 +- .../v1_5/features/QueryClientLiveTest.java | 2 +- .../v1_5/features/TaskClientExpectTest.java | 2 +- .../v1_5/features/TaskClientLiveTest.java | 2 +- .../v1_5/features/UploadClientLiveTest.java | 2 +- .../v1_5/features/VAppClientExpectTest.java | 2 +- .../v1_5/features/VAppClientLiveTest.java | 2 +- .../VAppTemplateClientExpectTest.java | 2 +- .../features/VAppTemplateClientLiveTest.java | 2 +- .../v1_5/features/VdcClientExpectTest.java | 2 +- .../v1_5/features/VdcClientLiveTest.java | 2 +- .../admin/AdminCatalogClientExpectTest.java | 2 +- .../admin/AdminCatalogClientLiveTest.java | 2 +- .../admin/AdminNetworkClientExpectTest.java | 2 +- .../admin/AdminNetworkClientLiveTest.java | 2 +- .../admin/AdminOrgClientExpectTest.java | 2 +- .../admin/AdminOrgClientLiveTest.java | 2 +- .../admin/AdminQueryClientExpectTest.java | 2 +- .../admin/AdminQueryClientLiveTest.java | 2 +- .../admin/AdminVdcClientExpectTest.java | 2 +- .../admin/AdminVdcClientLiveTest.java | 2 +- .../features/admin/GroupClientExpectTest.java | 2 +- .../features/admin/GroupClientLiveTest.java | 2 +- .../features/admin/UserClientExpectTest.java | 2 +- .../features/admin/UserClientLiveTest.java | 8 +- .../v1_5/login/SessionClientExpectTest.java | 2 +- .../v1_5/login/SessionClientLiveTest.java | 8 +- 37 files changed, 154 insertions(+), 178 deletions(-) create mode 100644 labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java delete mode 100644 labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/NonClientOperationsLiveTest.java diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java new file mode 100644 index 0000000000..550c337e72 --- /dev/null +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java @@ -0,0 +1,114 @@ +/* + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.io.IOException; +import java.net.URI; + +import org.jclouds.crypto.CryptoStreams; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.jclouds.util.Strings2; +import org.jclouds.vcloud.director.v1_5.domain.OrgList; +import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; +import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; +import org.jclouds.xml.internal.JAXBParser; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.Iterables; + +/** + * Tests live behavior of {@link AdminCatalogClient}. + * + * @author danikov + */ +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "HttpClientLiveTest") +public class HttpClientLiveTest extends BaseVCloudDirectorClientLiveTest { + + private JAXBParser parser = new JAXBParser("true"); + private SessionWithToken sessionWithToken; + + @Override + protected void setupRequiredClients() throws Exception { + setupCredentials(); + } + + @Test(description = "POST /login") + public void testPostLogin() throws IOException { + testLoginWithMethod("POST"); + } + + @Test(description = "GET /login") + public void testGetLogin() throws IOException { + testLoginWithMethod("GET"); + } + + private void testLoginWithMethod(final String method) throws IOException { + String user = identity.substring(0, identity.lastIndexOf('@')); + String org = identity.substring(identity.lastIndexOf('@') + 1); + String password = credential; + + String authHeader = "Basic " + CryptoStreams.base64(String.format("%s@%s:%s", checkNotNull(user), checkNotNull(org), checkNotNull(password)).getBytes("UTF-8")); + + HttpResponse response = context.getUtils().getHttpClient().invoke(HttpRequest.builder() + .method(method) + .endpoint(URI.create(endpoint + "/login")) + .headers(ImmutableMultimap.builder() + .put("Authorization", authHeader) + .put("Accept", "*/*") + .build()) + .build()); + + sessionWithToken = SessionWithToken.builder().session(session).token(response.getFirstHeaderOrNull("x-vcloud-authorization")).build(); + + assertEquals(sessionWithToken.getSession().getUser(), user); + assertEquals(sessionWithToken.getSession().getOrg(), org); + assertTrue(sessionWithToken.getSession().getLinks().size() > 0); + assertNotNull(sessionWithToken.getToken()); + + OrgList orgList = parser.fromXML(Strings2.toStringAndClose(response.getPayload().getInput()), OrgList.class); + + assertTrue(orgList.getOrgs().size() > 0, "must have orgs"); + + context.getApi().getOrgClient().getOrg(Iterables.getLast(orgList.getOrgs()).getHref()); + } + + @Test(description = "GET /schema/{schemaFileName}", dependsOnMethods = { "testPostLogin", "testGetLogin" }) + public void testGetSchema() throws IOException { + String schemafileName = "master.xsd"; + HttpResponse response = context.getUtils().getHttpClient().invoke(HttpRequest.builder() + .method("GET") + .endpoint(URI.create(endpoint + "/v1.5/schema/" + schemafileName)) + .headers(ImmutableMultimap.builder() + .put("x-vcloud-authorization", sessionWithToken.getToken()) + .put("Accept", "*/*") + .build()) + .build()); + + String schema = Strings2.toStringAndClose(response.getPayload().getInput()); + + // TODO: asserting something about the schema + } +} diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/NonClientOperationsLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/NonClientOperationsLiveTest.java deleted file mode 100644 index 65f4aa31e5..0000000000 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/NonClientOperationsLiveTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.vcloud.director.v1_5; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.crypto.CryptoStreams; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.util.Strings2; -import org.jclouds.vcloud.director.v1_5.domain.OrgList; -import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; -import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; -import org.jclouds.xml.internal.JAXBParser; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Iterables; - -/** - * Tests live behavior of {@link AdminCatalogClient}. - * - * @author danikov - */ -@Test(groups = {"live", "user", "nonClient"}, singleThreaded = true, testName = "NonClientOperationsLiveTest") -public class NonClientOperationsLiveTest extends BaseVCloudDirectorClientLiveTest -{ - - private JAXBParser parser = new JAXBParser("true"); - - private SessionWithToken sessionWithToken; - - @Override - protected void setupRequiredClients() throws Exception - { - setupCredentials(); - } - - @Test(testName = "POST /login") - public void testPostLogin() throws IOException - { - testLoginWithMethod("POST"); - } - - @Test(testName = "GET /login") - public void testGetLogin() throws IOException - { - testLoginWithMethod("GET"); - } - - private void testLoginWithMethod(final String method) throws IOException - { - String user = identity.substring(0, identity.lastIndexOf('@')); - String org = identity.substring(identity.lastIndexOf('@') + 1); - String password = credential; - - String authHeader = - "Basic " - + CryptoStreams.base64(String.format("%s@%s:%s", checkNotNull(user), - checkNotNull(org), checkNotNull(password)).getBytes("UTF-8")); - - HttpResponse response = - context - .getUtils() - .getHttpClient() - .invoke( - HttpRequest - .builder() - .method(method) - .endpoint(URI.create(endpoint + "/login")) - .headers(ImmutableMultimap.of("Authorization", authHeader, "Accept", "*/*")) - .build()); - - sessionWithToken = - SessionWithToken.builder().session(session) - .token(response.getFirstHeaderOrNull("x-vcloud-authorization")).build(); - - assertEquals(sessionWithToken.getSession().getUser(), user); - assertEquals(sessionWithToken.getSession().getOrg(), org); - assertTrue(sessionWithToken.getSession().getLinks().size() > 0); - assertNotNull(sessionWithToken.getToken()); - - OrgList orgList = - parser.fromXML(Strings2.toStringAndClose(response.getPayload().getInput()), - OrgList.class); - - assertTrue(orgList.getOrgs().size() > 0, "must have orgs"); - - context.getApi().getOrgClient().getOrg(Iterables.getLast(orgList.getOrgs()).getHref()); - } - - @Test(testName = "GET /schema/{schemaFileName}", dependsOnMethods = {"testPostLogin", - "testGetLogin"}) - public void testGetSchema() throws IOException - { - String schemafileName = "master.xsd"; - HttpResponse response = - context - .getUtils() - .getHttpClient() - .invoke( - HttpRequest - .builder() - .method("GET") - .endpoint(URI.create(endpoint + "/v1.5/schema/" + schemafileName)) - .headers( - ImmutableMultimap.of("x-vcloud-authorization", - sessionWithToken.getToken(), "Accept", "*/*")).build()); - - String schema = Strings2.toStringAndClose(response.getPayload().getInput()); - - // TODO: asserting something about the schema - } -} diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java index 0c5a194843..0335daf5ad 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java @@ -45,7 +45,7 @@ import com.google.common.collect.ImmutableSet; * * @author grkvlt@apache.org */ -@Test(groups = { "unit", "user", "catalog" }, singleThreaded = true, testName = "CatalogClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "CatalogClientExpectTest") public class CatalogClientExpectTest extends VCloudDirectorClientExpectTest { @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java index 9ee89bc11b..81c6df43e3 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java @@ -61,7 +61,7 @@ import com.google.common.collect.Iterables; * * @author grkvlt@apache.org */ -@Test(groups = { "live", "user", "catalog" }, singleThreaded = true, testName = "CatalogClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CatalogClientLiveTest") public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { /* diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java index 1350c0d714..be405a174c 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java @@ -49,7 +49,7 @@ import com.google.common.collect.ImmutableSet; * * @author danikov */ -@Test(groups = { "unit", "user", "media" }, singleThreaded = true, testName = "MediaClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "MediaClientExpectTest") public class MediaClientExpectTest extends VCloudDirectorAdminClientExpectTest { @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java index de8bab0473..d9c461b206 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java @@ -74,7 +74,7 @@ import com.google.common.collect.Iterables; * * @author danikov */ -@Test(groups = { "live", "user", "media" }, singleThreaded = true, testName = "MediaClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "MediaClientLiveTest") public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String MEDIA = "media"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java index 4fdb7fd8cb..64842221e4 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java @@ -53,7 +53,7 @@ import com.google.common.collect.ImmutableSet; * * @author danikov */ -@Test(groups = { "unit", "user", "network" }, singleThreaded = true, testName = "NetworkClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "NetworkClientExpectTest") public class NetworkClientExpectTest extends VCloudDirectorAdminClientExpectTest { @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java index 2a4375bffd..7f98d5df26 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java @@ -49,7 +49,7 @@ import com.google.common.collect.Iterables; * * @author danikov */ -@Test(groups = { "live", "user", "network" }, singleThreaded = true, testName = "NetworkClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "NetworkClientLiveTest") public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String NETWORK = "network"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java index 2c5ddd9c24..2bcf6eb09e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java @@ -46,7 +46,7 @@ import com.google.common.collect.Iterables; * * @author Adrian Cole */ -@Test(groups = { "unit", "user", "org" }, singleThreaded = true, testName = "OrgClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "OrgClientExpectTest") public class OrgClientExpectTest extends VCloudDirectorAdminClientExpectTest { @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java index 9f18039da7..6630bd1cdd 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java @@ -53,7 +53,7 @@ import com.google.common.collect.Iterables; * * @author grkvlt@apache.org */ -@Test(groups = { "live", "user", "org" }, singleThreaded = true, testName = "OrgClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "OrgClientLiveTest") public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { /* diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientExpectTest.java index 287598d308..3aa66882be 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientExpectTest.java @@ -41,7 +41,7 @@ import com.google.common.collect.ImmutableMultimap; * * @author grkvlt@apache.org */ -@Test(groups = { "unit", "user", "query" }, singleThreaded = true, testName = "QueryClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "QueryClientExpectTest") public class QueryClientExpectTest extends VCloudDirectorAdminClientExpectTest { @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java index d0bb44abff..ceff2b4b55 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java @@ -61,7 +61,7 @@ import com.google.common.collect.Iterables; * * @author grkvlt@apache.org */ -@Test(groups = { "live", "user", "query" }, singleThreaded = true, testName = "QueryClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "QueryClientLiveTest") public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest { /* diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientExpectTest.java index f62745bf1e..43c5cd0ad9 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientExpectTest.java @@ -43,7 +43,7 @@ import com.google.common.collect.ImmutableMultimap; * * @author grkvlt@apache.org */ -@Test(groups = { "unit", "user", "task" }, singleThreaded = true, testName = "TaskClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "TaskClientExpectTest") public class TaskClientExpectTest extends VCloudDirectorAdminClientExpectTest { @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java index 9b1bac8b03..3db51c5ee8 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java @@ -43,7 +43,7 @@ import com.google.common.collect.Iterables; * * @author grkvlt@apache.org */ -@Test(groups = { "live", "user", "task" }, singleThreaded = true, testName = "TaskClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "TaskClientLiveTest") public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest { /* diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java index 0d9e8b9050..bc05002fc0 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java @@ -27,7 +27,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "live", "user", "upload" }, singleThreaded = true, testName = "UploadClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "UploadClientLiveTest") public class UploadClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String UPLOAD = "upload"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientExpectTest.java index ebf622b700..b54e0626cb 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientExpectTest.java @@ -64,7 +64,7 @@ import com.google.common.collect.Multimaps; * * @author grkvlt@apache.org */ -@Test(groups = { "unit", "user", "vapp" }, singleThreaded = true, testName = "VAppClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "VAppClientExpectTest") public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest { private String vAppId = "vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be"; 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 8b82c17a63..e5051647ba 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 @@ -129,7 +129,7 @@ import com.google.common.collect.Sets; * * @author grkvlt@apache.org */ -@Test(groups = { "live", "user", "vapp" }, singleThreaded = true, testName = "VAppClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "VAppClientLiveTest") public class VAppClientLiveTest extends AbstractVAppClientLiveTest { private MetadataValue metadataValue; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java index 21a63f50d6..e42ea30c9e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java @@ -77,7 +77,7 @@ import com.google.common.collect.ImmutableSet; * * @author Adam Lowe */ -@Test(groups = { "unit", "user", "vapptemplate" }, testName = "VAppTemplateClientExpectTest") +@Test(groups = { "unit", "user" }, testName = "VAppTemplateClientExpectTest") public class VAppTemplateClientExpectTest extends VCloudDirectorAdminClientExpectTest { public VAppTemplateClientExpectTest() { 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 5a3da1cdbe..674084686f 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 @@ -84,7 +84,7 @@ import com.google.common.collect.Iterables; * * @author Aled Sage */ -@Test(groups = { "live", "user", "vapptemplate" }, singleThreaded = true, testName = "VAppTemplateClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "VAppTemplateClientLiveTest") public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { private String key; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java index 69a9aff4db..37872d3518 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java @@ -56,7 +56,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "unit", "user", "vdc" }, singleThreaded = true, testName = "VdcClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "VdcClientExpectTest") public class VdcClientExpectTest extends VCloudDirectorAdminClientExpectTest { private URI vdcURI; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java index bf1a1cd3b7..4db5a17c49 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java @@ -66,7 +66,7 @@ import com.google.common.collect.Iterables; * * @author danikov */ -@Test(groups = { "live", "user", "vdc" }, singleThreaded = true, testName = "VdcClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "VdcClientLiveTest") public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String VDC = "vdc"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientExpectTest.java index 5f2c3a71ff..4d2b5433a0 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientExpectTest.java @@ -40,7 +40,7 @@ import com.google.common.collect.ImmutableSet; * * @author grkvlt@apache.org */ -@Test(groups = { "unit", "admin", "catalog" }, singleThreaded = true, testName = "CatalogClientExpectTest") +@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "CatalogClientExpectTest") public class AdminCatalogClientExpectTest extends VCloudDirectorAdminClientExpectTest { private Reference catalogRef = Reference.builder() diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java index c6c2d68751..957f6b331d 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java @@ -54,7 +54,7 @@ import com.google.common.collect.Iterables; * * @author danikov */ -@Test(groups = { "live", "admin", "catalog" }, singleThreaded = true, testName = "CatalogClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "CatalogClientLiveTest") public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String CATALOG = "admin catalog"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientExpectTest.java index 380f14c061..7ff0c808d3 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientExpectTest.java @@ -39,7 +39,7 @@ import com.google.common.collect.ImmutableSet; * * @author danikov */ -@Test(groups = { "unit", "admin", "network"}, singleThreaded = true, testName = "AdminNetworkClientExpectTest") +@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "AdminNetworkClientExpectTest") public class AdminNetworkClientExpectTest extends VCloudDirectorAdminClientExpectTest { Reference networkRef = Reference.builder() diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientLiveTest.java index 8534ade8e1..0ecbd05541 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientLiveTest.java @@ -51,7 +51,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "live", "admin", "network" }, singleThreaded = true, testName = "AdminNetworkLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "AdminNetworkLiveTest") public class AdminNetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String NETWORK = "AdminNetwork"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientExpectTest.java index 2539fce13d..4c57f0fb25 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientExpectTest.java @@ -43,7 +43,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "unit", "user", "org"}, singleThreaded = true, testName = "AdminOrgClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "AdminOrgClientExpectTest") public class AdminOrgClientExpectTest extends VCloudDirectorAdminClientExpectTest { private Reference orgRef = Reference.builder() diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientLiveTest.java index 9224390c6b..cb8ee41e50 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientLiveTest.java @@ -47,7 +47,7 @@ import com.google.common.collect.Iterables; * * @author danikov */ -@Test(groups = { "live", "admin", "org" }, singleThreaded = true, testName = "AdminOrgClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "AdminOrgClientLiveTest") public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String ORG = "admin org"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientExpectTest.java index aac0747ce1..d75ac6291a 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientExpectTest.java @@ -39,7 +39,7 @@ import com.google.common.collect.ImmutableMultimap; * * @author Aled Sage */ -@Test(groups = { "unit", "admin", "query" }, singleThreaded = true, testName = "AdminQueryClientExpectTest") +@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "AdminQueryClientExpectTest") public class AdminQueryClientExpectTest extends VCloudDirectorAdminClientExpectTest { // TODO Write expect tests for all other admin-query operations diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientLiveTest.java index f6f85594bb..4813a72132 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientLiveTest.java @@ -40,7 +40,7 @@ import org.testng.annotations.Test; * * @author Aled Sage */ -@Test(groups = { "live", "admin", "query" }, singleThreaded = true, testName = "AdminQueryClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "AdminQueryClientLiveTest") public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest { /* diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientExpectTest.java index b34dad2d43..fa19328b73 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientExpectTest.java @@ -35,7 +35,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "unit", "admin", "vdc" }, singleThreaded = true, testName = "AdminVdcClientExpectTest") +@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "AdminVdcClientExpectTest") public class AdminVdcClientExpectTest extends VCloudDirectorAdminClientExpectTest { private Reference vdcRef = Reference.builder() diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java index 205d470c85..577a7b0f21 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java @@ -45,7 +45,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "live", "admin", "vdc" }, singleThreaded = true, testName = "AdminVdcClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "AdminVdcClientLiveTest") public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String VDC = "admin vdc"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientExpectTest.java index 96e49a777b..ec8c6cdc4d 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientExpectTest.java @@ -34,7 +34,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "unit", "admin", "group"}, singleThreaded = true, testName = "GroupClientExpectTest") +@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "GroupClientExpectTest") public class GroupClientExpectTest extends VCloudDirectorAdminClientExpectTest { private Reference groupRef = Reference.builder() diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientLiveTest.java index 8617396c83..3490762c10 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientLiveTest.java @@ -38,7 +38,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "live", "admin", "group" }, singleThreaded = true, testName = "GroupClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "GroupClientLiveTest") public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String GROUP = "admin group"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientExpectTest.java index 6fae492e4c..2e56895584 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientExpectTest.java @@ -37,7 +37,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "unit", "admin", "adminUser"}, singleThreaded = true, testName = "UserClientExpectTest") +@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "UserClientExpectTest") public class UserClientExpectTest extends VCloudDirectorAdminClientExpectTest { private Reference orgRef = Reference.builder() diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java index 80bd1c94e0..81ac32bcb0 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java @@ -48,7 +48,7 @@ import com.google.common.collect.Iterables; * * @author danikov */ -@Test(groups = { "live", "admin", "adminUser" }, singleThreaded = true, testName = "UserClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "UserClientLiveTest") public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String USER = "admin user"; @@ -89,16 +89,14 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest { checkUser(newUser); } - @Test(description = "GET /admin/user/{id}", - dependsOnMethods = { "testCreateUser" }) + @Test(description = "GET /admin/user/{id}", dependsOnMethods = { "testCreateUser" }) public void testGetUser() { user = userClient.getUser(user.getHref()); checkUser(user); } - @Test(description = "PUT /admin/user/{id}", - dependsOnMethods = { "testGetUser" }) + @Test(description = "PUT /admin/user/{id}", dependsOnMethods = { "testGetUser" }) public void testUpdateUser() { User oldUser = user.toBuilder().build(); User newUser = user.toBuilder() diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java index 0c31ba2885..d905f77b5b 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java @@ -40,7 +40,7 @@ import com.google.common.collect.ImmutableMultimap; * * @author Adrian Cole */ -@Test(groups = "unit", testName = "SessionClientExpectTest") +@Test(groups = { "unit", "user" }, testName = "SessionClientExpectTest") // only needed as SessionClient is not registered in rest.properties @RegisterContext(sync = SessionClient.class, async = SessionAsyncClient.class) public class SessionClientExpectTest extends BaseRestClientExpectTest { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java index 31662c7269..c4c5c7f2ee 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java @@ -48,7 +48,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Listeners(FormatApiResultsListener.class) -@Test(groups = { "live", "user", "login" }, testName = "SessionClientLiveTest") +@Test(groups = { "live", "user" }, testName = "SessionClientLiveTest") public class SessionClientLiveTest extends BaseVersionedServiceLiveTest { public SessionClientLiveTest() { provider = "vcloud-director"; @@ -73,7 +73,7 @@ public class SessionClientLiveTest extends BaseVersionedServiceLiveTest { private SessionClient client; private SessionWithToken sessionWithToken; - @Test(testName = "POST /sessions") + @Test(description = "POST /sessions") public void testLogin() { String user = identity.substring(0, identity.lastIndexOf('@')); String org = identity.substring(identity.lastIndexOf('@') + 1); @@ -86,13 +86,13 @@ public class SessionClientLiveTest extends BaseVersionedServiceLiveTest { assertNotNull(sessionWithToken.getToken()); } - @Test(testName = "GET /session", dependsOnMethods = "testLogin") + @Test(description = "GET /session", dependsOnMethods = "testLogin") public void testGetSession() { assertEquals(client.getSessionWithToken(sessionWithToken.getSession().getHref(), sessionWithToken.getToken()), sessionWithToken.getSession()); } - @Test(testName = "DELETE /session", dependsOnMethods = "testGetSession") + @Test(description = "DELETE /session", dependsOnMethods = "testGetSession") public void testLogout() { client.logoutSessionWithToken(sessionWithToken.getSession().getHref(), sessionWithToken.getToken()); } From 5de8e7bad6222a3fe93d276900a3d191a05ac249 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Wed, 11 Apr 2012 22:49:16 +0100 Subject: [PATCH 6/6] Various minor changes to fix live tests --- .../v1_5/VCloudDirectorLiveTestConstants.java | 8 +++++++ .../vcloud/director/v1_5/domain/Checks.java | 4 ++-- .../v1_5/features/MediaClientLiveTest.java | 22 ++++++++++--------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java index a7e7236134..c1ee58df0e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java @@ -51,6 +51,8 @@ public class VCloudDirectorLiveTestConstants { public static final String OBJ_FIELD_GTE_1 = "ERR-108: %s field %s must be greater than to equal to 0 (%d)"; + public static final String OBJ_FIELD_GTE = "ERR-108: %s field %s must be greater than to equal to %d (%d)"; + public static final String GETTER_RETURNS_SAME_OBJ = "ERR-109: %s should return the same %s as %s (%s, %s)"; public static final String OBJ_FIELD_UPDATABLE = "ERR-110: %s field %s should be updatable"; @@ -88,7 +90,13 @@ public class VCloudDirectorLiveTestConstants { public static final String NOT_EMPTY_STRING_FMT = "ERR-126: The %s field must not be an empty string"; public static final String MATCHES_STRING_FMT = "ERR-127: The %s field must match the pattern \"%s\" (%s)"; + + public static final String OBJ_FIELD_LIST_EMPTY = "ERR-128: %s %s must be empty (%d members)"; + public static final String OBJ_FIELD_LIST_SIZE_EQ = "ERR-129: %s %s must have %d members (%d members)"; + + public static final String OBJ_FIELD_LIST_SIZE_GE = "ERR-130: %s %s must have at least %d members (%d members)"; + /* 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"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java index 8c95489a10..b637c229ef 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java @@ -729,7 +729,7 @@ public class Checks { // NOTE transport cannot be checked if (hardware.getItems() != null) { for (ResourceAllocationSettingData item : hardware.getItems()) { - checkResourceAllocationSettingData((RasdItem) item); + checkResourceAllocationSettingData(item); } } @@ -760,7 +760,7 @@ public class Checks { // assertNotNull(virtualSystem.getVirtualSystemType(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "virtualSystemType")); } - public static void checkResourceAllocationSettingData(RasdItem item) { + public static void checkResourceAllocationSettingData(ResourceAllocationSettingData item) { // TODO } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java index d9c461b206..4776eb7557 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java @@ -32,6 +32,8 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.O 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_FIELD_UPDATABLE; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_LIST_SIZE_EQ; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_LIST_SIZE_GE; 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.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY; @@ -62,10 +64,12 @@ import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; +import org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; @@ -144,29 +148,27 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkMediaFor(MEDIA, media); assertNotNull(media.getFiles(), String.format(OBJ_FIELD_REQ, MEDIA, "files")); - assertTrue(media.getFiles().size() == 1, String.format(OBJ_FIELD_EQ, MEDIA, "files.size()", "1", - media.getFiles().size())); + assertTrue(media.getFiles().size() == 1, String.format(OBJ_FIELD_LIST_SIZE_EQ, MEDIA, "files", 1, media.getFiles().size())); File uploadFile = getFirst(media.getFiles(), null); assertNotNull(uploadFile, String.format(OBJ_FIELD_REQ, MEDIA, "files.first")); assertEquals(uploadFile.getSize(), new Long(iso.length)); - assertTrue(equal(uploadFile.getSize(), sourceMedia.getSize()), String.format(OBJ_FIELD_EQ, MEDIA, "uploadFile.size()", - sourceMedia.getSize(), uploadFile.getSize())); + assertEquals(uploadFile.getSize().longValue(), sourceMedia.getSize(), + String.format(OBJ_FIELD_EQ, MEDIA, "uploadFile.size()", sourceMedia.getSize(), uploadFile.getSize())); Set links = uploadFile.getLinks(); assertNotNull(links, String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links")); - assertTrue(links.size() == 1, String.format(OBJ_FIELD_EQ, MEDIA, "uploadfile.links.size()", "1", - links.size())); - Link uploadLink = getFirst(links, null); - assertTrue(equal(uploadLink.getRel(), Link.Rel.UPLOAD_DEFAULT), String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links.first")); + assertTrue(links.size() >= 1, String.format(OBJ_FIELD_LIST_SIZE_GE, MEDIA, "uploadfile.links", 1, links.size())); + assertTrue(Iterables.all(links, Predicates.or(LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT), LinkPredicates.relEquals(Link.Rel.UPLOAD_ALTERNATE))), + String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links.first")); + Link uploadLink = Iterables.find(links, LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT)); context.getApi().getUploadClient().upload(uploadLink.getHref(), Payloads.newByteArrayPayload(iso)); media = mediaClient.getMedia(media.getHref()); - if (media.getTasks().size() == 1) { Task uploadTask = Iterables.getOnlyElement(media.getTasks()); Checks.checkTask(uploadTask); - assertEquals(uploadTask.getStatus(), "running"); + assertEquals(uploadTask.getStatus(), Task.Status.RUNNING); assertTrue(retryTaskSuccess.apply(uploadTask), String.format(TASK_COMPLETE_TIMELY, "uploadTask")); media = mediaClient.getMedia(media.getHref()); }