mirror of https://github.com/apache/jclouds.git
Various minor changes to fix live tests
This commit is contained in:
parent
19c88aa1fe
commit
5de8e7bad6
|
@ -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";
|
||||
|
@ -89,6 +91,12 @@ public class VCloudDirectorLiveTestConstants {
|
|||
|
||||
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";
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Link> 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());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue