From d069dce1e5cc18de64a41eda8938e0e5aca82fd5 Mon Sep 17 00:00:00 2001 From: danikov Date: Mon, 5 Mar 2012 15:15:50 +0000 Subject: [PATCH] add error strings to new tests --- .../v1_5/VCloudDirectorLiveTestConstants.java | 2 ++ .../v1_5/features/MediaClientLiveTest.java | 23 +++++++++++-------- 2 files changed, 16 insertions(+), 9 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 5420c9b670..aa83961055 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 @@ -70,5 +70,7 @@ public class VCloudDirectorLiveTestConstants { public static final String CONDITION_FMT = "ERR-121: The %s field must be %s: '%s'"; public static final String CORRECT_VALUE_OBJECT_FMT = "ERR-122: The %s field of the %s must be '%s': '%s'"; + + public static final String OBJ_FIELD_CLONE = "ERR-123: %s %s must be a clone of \"%s\" (%s)"; } 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 c807aa80c1..84ace497cf 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 @@ -108,17 +108,20 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkMediaFor(MEDIA, media); - assertNotNull(media.getFiles(), ""); - assertTrue(media.getFiles().getFiles().size() == 1, ""); + assertNotNull(media.getFiles(), String.format(OBJ_FIELD_REQ, MEDIA, "files")); + assertTrue(media.getFiles().getFiles().size() == 1, String.format(OBJ_FIELD_EQ, MEDIA, "files.size()", "1", + media.getFiles().getFiles().size())); File uploadFile = Iterables.getFirst(media.getFiles().getFiles(), null); - assertNotNull(uploadFile, ""); - assertTrue(equal(uploadFile.getSize(), sourceMedia.getSize()), ""); + assertNotNull(uploadFile, String.format(OBJ_FIELD_REQ, MEDIA, "files.first")); + assertTrue(equal(uploadFile.getSize(), sourceMedia.getSize()), String.format(OBJ_FIELD_EQ, MEDIA, "uploadFile.size()", + sourceMedia.getSize(), uploadFile.getSize())); Set links = uploadFile.getLinks(); - assertNotNull(links, ""); - assertTrue(links.size() == 1, ""); + 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 = Iterables.getFirst(links, null); - assertTrue(equal(uploadLink.getRel(), Link.Rel.UPLOAD_DEFAULT), ""); + assertTrue(equal(uploadLink.getRel(), Link.Rel.UPLOAD_DEFAULT), String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links.first")); fail(); //TODO upload file and assert it succeeds context.getApi().getUploadClient().uploadFile(uploadLink, sourceFile); @@ -173,7 +176,8 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { } Checks.checkMediaFor(MEDIA, media); - assertTrue(media.clone(oldMedia), ""); + assertTrue(media.clone(oldMedia), String.format(OBJ_FIELD_CLONE, MEDIA, "copied media", + media.toString(), oldMedia.toString())); mediaClient.getMetadataClient().setMetadata(media, "key", MetadataValue.builder().value("value").build()); @@ -196,7 +200,8 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { } Checks.checkMediaFor(MEDIA, media); - assertTrue(media.clone(oldMedia), ""); + assertTrue(media.clone(oldMedia), String.format(OBJ_FIELD_CLONE, MEDIA, "moved media", + media.toString(), oldMedia.toString())); } @Test(testName = "PUT /media/{id}",