mirror of https://github.com/apache/jclouds.git
move and complete media tests
This commit is contained in:
parent
f2f2233db0
commit
526dee9bf7
|
@ -26,7 +26,10 @@ import java.net.URI;
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
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.Error;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.File;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.FilesList;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Media;
|
import org.jclouds.vcloud.director.v1_5.domain.Media;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
||||||
|
@ -35,6 +38,7 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Owner;
|
import org.jclouds.vcloud.director.v1_5.domain.Owner;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
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.Task;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.TasksInProgress;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -43,10 +47,70 @@ import org.testng.annotations.Test;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "NetworkClientExpectTest")
|
@Test(groups = { "unit", "media" }, singleThreaded = true, testName = "MediaClientExpectTest")
|
||||||
public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test
|
||||||
|
public void testCreateMedia() {
|
||||||
|
URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f");
|
||||||
|
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
new VcloudHttpRequestPrimer()
|
||||||
|
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/media")
|
||||||
|
.acceptMedia(VCloudDirectorMediaType.MEDIA)
|
||||||
|
.xmlFilePayload("/media/createMediaSource.xml", VCloudDirectorMediaType.MEDIA)
|
||||||
|
.httpRequestBuilder().build(),
|
||||||
|
new VcloudHttpResponsePrimer()
|
||||||
|
.xmlFilePayload("/media/createMedia.xml", VCloudDirectorMediaType.MEDIA)
|
||||||
|
.httpResponseBuilder().statusCode(201).build());
|
||||||
|
|
||||||
|
Media source = Media.builder()
|
||||||
|
.size(0)
|
||||||
|
.imageType("iso")
|
||||||
|
.name("Test media 1")
|
||||||
|
.type("application/vnd.vmware.vcloud.media+xml")
|
||||||
|
.description("Test media generated by testCreateMedia()")
|
||||||
|
.build();
|
||||||
|
Media expected = createMedia();
|
||||||
|
|
||||||
|
Reference vdcRef = Reference.builder().href(vdcUri).build();
|
||||||
|
|
||||||
|
assertEquals(client.getVdcClient().createMedia(vdcRef, source), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCloneMedia() {
|
||||||
|
URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f");
|
||||||
|
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
new VcloudHttpRequestPrimer()
|
||||||
|
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneMedia")
|
||||||
|
.acceptMedia(VCloudDirectorMediaType.MEDIA)
|
||||||
|
.xmlFilePayload("/media/cloneMediaParams.xml", VCloudDirectorMediaType.CLONE_MEDIA_PARAMS)
|
||||||
|
.httpRequestBuilder().build(),
|
||||||
|
new VcloudHttpResponsePrimer()
|
||||||
|
.xmlFilePayload("/media/cloneMedia.xml", VCloudDirectorMediaType.MEDIA)
|
||||||
|
.httpResponseBuilder().statusCode(201).build());
|
||||||
|
|
||||||
|
CloneMediaParams params = CloneMediaParams.builder()
|
||||||
|
.name("moved test media")
|
||||||
|
.description("moved by testCloneMedia()")
|
||||||
|
.source(Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.media+xml")
|
||||||
|
.name("copied test media")
|
||||||
|
.id("urn:vcloud:media:da8361af-cccd-4103-a71c-493513c49094")
|
||||||
|
.href(URI.create("https://mycloud.greenhousedata.com/api/media/da8361af-cccd-4103-a71c-493513c49094"))
|
||||||
|
.build())
|
||||||
|
.isSourceDelete(false)
|
||||||
|
.build();
|
||||||
|
Media expected = cloneMedia();
|
||||||
|
|
||||||
|
Reference vdcRef = Reference.builder().href(vdcUri).build();
|
||||||
|
|
||||||
|
assertEquals(client.getVdcClient().cloneMedia(vdcRef, params), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGetMedia() {
|
public void testGetMedia() {
|
||||||
URI mediaUri = URI.create(endpoint + "/media/794eb334-754e-4917-b5a0-5df85cbd61d1");
|
URI mediaUri = URI.create(endpoint + "/media/794eb334-754e-4917-b5a0-5df85cbd61d1");
|
||||||
|
|
||||||
|
@ -59,13 +123,14 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
|
||||||
.xmlFilePayload("/media/media.xml", VCloudDirectorMediaType.MEDIA)
|
.xmlFilePayload("/media/media.xml", VCloudDirectorMediaType.MEDIA)
|
||||||
.httpResponseBuilder().build());
|
.httpResponseBuilder().build());
|
||||||
|
|
||||||
Media expected = media();
|
Media expected = getMedia();
|
||||||
|
|
||||||
Reference mediaRef = Reference.builder().href(mediaUri).build();
|
Reference mediaRef = Reference.builder().href(mediaUri).build();
|
||||||
|
|
||||||
assertEquals(client.getMediaClient().getMedia(mediaRef), expected);
|
assertEquals(client.getMediaClient().getMedia(mediaRef), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testResponse400ForInvalidMedia() {
|
public void testResponse400ForInvalidMedia() {
|
||||||
URI mediaUri = URI.create(endpoint + "/media/NOTAUUID");
|
URI mediaUri = URI.create(endpoint + "/media/NOTAUUID");
|
||||||
|
|
||||||
|
@ -319,7 +384,96 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
|
||||||
assertEquals(client.getMediaClient().getOwner(mediaRef), expected);
|
assertEquals(client.getMediaClient().getOwner(mediaRef), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Media media() {
|
private static Media createMedia() {
|
||||||
|
return Media.builder()
|
||||||
|
.size(0)
|
||||||
|
.imageType("iso")
|
||||||
|
.status(0)
|
||||||
|
.name("Test media 1")
|
||||||
|
.id("urn:vcloud:media:d51b0b9d-099c-499f-97f8-4fbe40ba06d7")
|
||||||
|
.type("application/vnd.vmware.vcloud.media+xml")
|
||||||
|
.href(URI.create("https://mycloud.greenhousedata.com/api/media/d51b0b9d-099c-499f-97f8-4fbe40ba06d7"))
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("up")
|
||||||
|
.type("application/vnd.vmware.vcloud.vdc+xml")
|
||||||
|
.href(URI.create("https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"))
|
||||||
|
.build())
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("remove")
|
||||||
|
.href(URI.create("https://mycloud.greenhousedata.com/api/media/d51b0b9d-099c-499f-97f8-4fbe40ba06d7"))
|
||||||
|
.build())
|
||||||
|
.description("Test media generated by testCreateMedia()")
|
||||||
|
.files(FilesList.builder()
|
||||||
|
.file(File.builder()
|
||||||
|
.size(0l)
|
||||||
|
.bytesTransferred(0l)
|
||||||
|
.name("file")
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("upload:default")
|
||||||
|
.href(URI.create("https://mycloud.greenhousedata.com:443/transfer/b1fdf2d0-feff-4414-a8d1-3a8d86c4ccc5/file"))
|
||||||
|
.build())
|
||||||
|
.build())
|
||||||
|
.build())
|
||||||
|
.owner(owner())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Media cloneMedia() {
|
||||||
|
return Media.builder()
|
||||||
|
.size(175163392)
|
||||||
|
.imageType("iso")
|
||||||
|
.status(0)
|
||||||
|
.name("copied test media-copy-671136ae-b8f0-4389-bca6-50e9c42268f2")
|
||||||
|
.id("urn:vcloud:media:a6b023f2-7f90-4e89-a24d-56e0eba83a5a")
|
||||||
|
.type("application/vnd.vmware.vcloud.media+xml")
|
||||||
|
.href(URI.create("https://mycloud.greenhousedata.com/api/media/a6b023f2-7f90-4e89-a24d-56e0eba83a5a"))
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("up")
|
||||||
|
.type("application/vnd.vmware.vcloud.vdc+xml")
|
||||||
|
.href(URI.create("https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"))
|
||||||
|
.build())
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("remove")
|
||||||
|
.href(URI.create("https://mycloud.greenhousedata.com/api/media/a6b023f2-7f90-4e89-a24d-56e0eba83a5a"))
|
||||||
|
.build())
|
||||||
|
.description("copied by testCloneMedia()")
|
||||||
|
.tasksInProgress(TasksInProgress.builder()
|
||||||
|
.task(Task.builder()
|
||||||
|
.status("running")
|
||||||
|
.startTime(dateService.iso8601DateParse("2012-03-02T04:58:48.754-07:00"))
|
||||||
|
.operationName("vdcCopyMedia")
|
||||||
|
.operation("Copying Media File copied test media-copy-671136ae-b8f0-4389-bca6-50e9c42268f2(a6b023f2-7f90-4e89-a24d-56e0eba83a5a)")
|
||||||
|
.expiryTime(dateService.iso8601DateParse("2012-05-31T04:58:48.754-06:00"))
|
||||||
|
.name("task")
|
||||||
|
.id("urn:vcloud:task:7e4f6baf-7ef0-43ea-93cc-62cc329afb5d")
|
||||||
|
.type("application/vnd.vmware.vcloud.task+xml")
|
||||||
|
.href(URI.create("https://mycloud.greenhousedata.com/api/task/7e4f6baf-7ef0-43ea-93cc-62cc329afb5d"))
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("task:cancel")
|
||||||
|
.href(URI.create("https://mycloud.greenhousedata.com/api/task/7e4f6baf-7ef0-43ea-93cc-62cc329afb5d/action/cancel"))
|
||||||
|
.build())
|
||||||
|
.owner(Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.media+xml")
|
||||||
|
.name("copied test media-copy-671136ae-b8f0-4389-bca6-50e9c42268f2")
|
||||||
|
.href(URI.create("https://mycloud.greenhousedata.com/api/media/a6b023f2-7f90-4e89-a24d-56e0eba83a5a"))
|
||||||
|
.build())
|
||||||
|
.user(Reference.builder()
|
||||||
|
.type("application/vnd.vmware.admin.user+xml")
|
||||||
|
.name("acole")
|
||||||
|
.href(URI.create("https://mycloud.greenhousedata.com/api/admin/user/c090335b-708c-4c1c-9e3d-89560d002120"))
|
||||||
|
.build())
|
||||||
|
.org(Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.org+xml")
|
||||||
|
.name("cloudsoft")
|
||||||
|
.href(URI.create("https://mycloud.greenhousedata.com/api/org/c076f90a-397a-49fa-89b8-b294c1599cd0"))
|
||||||
|
.build())
|
||||||
|
.build())
|
||||||
|
.build())
|
||||||
|
.owner(owner())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Media getMedia() {
|
||||||
return Media.builder()
|
return Media.builder()
|
||||||
.size(175163392)
|
.size(175163392)
|
||||||
.imageType("iso")
|
.imageType("iso")
|
||||||
|
@ -356,7 +510,8 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
|
||||||
.type("application/vnd.vmware.vcloud.metadata+xml")
|
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||||
.href(URI.create("https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata"))
|
.href(URI.create("https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata"))
|
||||||
.build())
|
.build())
|
||||||
.description("Windows 2003 R2 Disk2 Standard 32bit & 64bit")
|
.type("application/vnd.vmware.vcloud.media+xml")
|
||||||
|
.description("Windows 2003 R2 Disk2 Standard 32bit & 64bit")
|
||||||
.owner(owner())
|
.owner(owner())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,28 +193,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test
|
||||||
public void testCloneMedia() {
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
|
||||||
new VcloudHttpRequestPrimer()
|
|
||||||
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneMedia")
|
|
||||||
.xmlFilePayload("/vdc/params/cloneMedia.xml", VCloudDirectorMediaType.CLONE_MEDIA_PARAMS)
|
|
||||||
.acceptAnyMedia()
|
|
||||||
.httpRequestBuilder().build(),
|
|
||||||
new VcloudHttpResponsePrimer()
|
|
||||||
.xmlFilePayload("/vdc/cloneMedia.xml", VCloudDirectorMediaType.MEDIA)
|
|
||||||
.httpResponseBuilder().build());
|
|
||||||
|
|
||||||
Media expected = cloneMedia();
|
|
||||||
|
|
||||||
// TODO: configure params
|
|
||||||
CloneMediaParams params = CloneMediaParams.builder()
|
|
||||||
|
|
||||||
.build();
|
|
||||||
|
|
||||||
assertEquals(client.getVdcClient().cloneMedia(vdcRef, params), expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testCloneVApp() {
|
public void testCloneVApp() {
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
|
Loading…
Reference in New Issue