From 7d5dbbef59c80a6f19ddca848991c0e01d1966d8 Mon Sep 17 00:00:00 2001 From: danikov Date: Thu, 23 Feb 2012 11:04:01 +0000 Subject: [PATCH] flesh out/first pass live tests --- .../v1_5/features/VdcClientLiveTest.java | 188 ++++++++++++++++-- 1 file changed, 170 insertions(+), 18 deletions(-) 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 634dc7e49a..4b049d4dd6 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 @@ -29,13 +29,23 @@ import static org.testng.Assert.assertTrue; import java.net.URI; +import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; 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.CloneVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParams; +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.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.VApp; +import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.collect.Iterables; @@ -49,26 +59,26 @@ import com.google.common.collect.Iterables; public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String VDC = "vdc"; - + /* * Convenience reference to API client. */ protected VdcClient vdcClient; - + private Reference vdcRef; - @BeforeGroups(groups = { "live" }, dependsOnMethods = { "setupClient" }) - public void before() { - String vdcId = ""; // TODO: inject + @BeforeClass(inheritGroups = true) + @Override + public void setupRequiredClients() { vdcRef = Reference.builder() .type("application/vnd.vmware.vcloud.vdc+xml") .name("") - .href(URI.create(endpoint+"/vdc/"+vdcId)) - .id(vdcId) + .href(URI.create(endpoint+"/vdc/"+vDCId)) + .id(vDCId) .build(); vdcClient = context.getApi().getVdcClient(); } - + @Test(testName = "GET /vdc/{id}") public void testGetVdc() { // required for testing @@ -116,14 +126,157 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { } } -// POST /vdc/{id}/action/captureVApp -// POST /vdc/{id}/action/cloneMedia -// POST /vdc/{id}/action/cloneVApp -// POST /vdc/{id}/action/cloneVAppTemplate -// POST /vdc/{id}/action/composeVApp -// POST /vdc/{id}/action/instantiateVAppTemplate -// POST /vdc/{id}/action/uploadVAppTemplate -// POST /vdc/{id}/media + @Test(testName = "POST /vdc/{id}/action/captureVApp", enabled = false) + public void testCaptureVApp() { + Reference templateSource = null; // TODO: vApp reference + VAppTemplate template = vdcClient.captureVApp(vdcRef, CaptureVAppParams.builder() + .source(templateSource) + // TODO: test optional params + //.name("") + //.description("") + //.sections(sections) // TODO: ovf sections + .build()); + + Checks.checkVAppTemplate(template); + + // TODO: await task to complete + // TODO: make assertions that the task was successful + } + + @Test(testName = "POST /vdc/{id}/action/cloneMedia") + public void testCloneMedia() { + Reference mediaSource = null; // TODO: media reference + Media media = vdcClient.cloneMedia(vdcRef, CloneMediaParams.builder() + .source(mediaSource) + // TODO: test optional params + //.name("") + //.description("") + //.isSourceDelete(true) + .build()); + + Checks.checkMediaFor(VDC, media); + + // TODO: await task to complete + // TODO: make assertions that the task was successful + } + + @Test(testName = "POST /vdc/{id}/action/cloneVApp", enabled = false) + public void testCloneVApp() { + Reference vAppSource = null; // TODO: vApp reference + VApp vApp = vdcClient.cloneVApp(vdcRef, CloneVAppParams.builder() + .source(vAppSource) + // TODO: test optional params + //.name("") + //.description("") + //.deploy(true) + //.isSourceDelete(true) + //.powerOn(true) + //.instantiationParams(InstantiationParams.builder() + // .sections(sections) // TODO: ovf sections? various tests? + // .build()) + + // Reserved. Unimplemented params; may test eventually when implemented + //.vAppParent(vAppParentRef) + //.linkedClone(true) + .build()); + + Checks.checkVApp(vApp); + + // TODO: await task to complete + // TODO: make assertions that the task was successful + } + + @Test(testName = "POST /vdc/{id}/action/cloneVAppTemplate", enabled = false) + public void testCloneVAppTemplate() { + Reference templateSource = null; // TODO: vAppTemplate reference + VAppTemplate template = vdcClient.cloneVAppTemplate(vdcRef, CloneVAppTemplateParams.builder() + .source(templateSource) + // TODO: test optional params + //.name("") + //.description("") + //.isSourceDelete(true) + //.sections(sections) // TODO: ovf sections + .build()); + + Checks.checkVAppTemplate(template); + + // TODO: await task to complete + // TODO: make assertions that the task was successful + } + + @Test(testName = "POST /vdc/{id}/action/composeVApp", enabled = false) + public void testComposeVApp() { + VApp vApp = vdcClient.composeVApp(vdcRef, ComposeVAppParams.builder() + // TODO: test optional params + //.name("") + //.description("") + //.deploy(true) + //.isSourceDelete(true) + //.powerOn(true) + //.instantiationParams(InstantiationParams.builder() + // .sections(sections) // TODO: ovf sections? various tests? + // .build()) + + // Reserved. Unimplemented params; may test eventually when implemented + //.linkedClone() + .build()); + + Checks.checkVApp(vApp); + + // TODO: await task to complete + // TODO: make assertions that the task was successful + } + + @Test(testName = "POST /vdc/{id}/action/instantiateVAppTemplate", enabled = false) + public void testInstantiateVAppTemplate() { + Reference templateSource = null; // TODO: vApp or vAppTemplate reference + VApp vApp = vdcClient.instantiateVApp(vdcRef, InstantiateVAppParams.builder() + .source(templateSource) + // TODO: test optional params + //.name("") + //.description("") + //.isSourceDelete(true) + .build()); + + Checks.checkVApp(vApp); + + // TODO: await task to complete + // TODO: make assertions that the task was successful + } + + @Test(testName = "POST /vdc/{id}/action/uploadVAppTemplate", enabled = false) + public void testUploadVAppTemplate() { + VAppTemplate template = vdcClient.uploadVAppTemplate(vdcRef, UploadVAppTemplateParams.builder() + // TODO: test optional params + //.name("") + //.description("") + //.transferFormat("") + //.manifestRequired(true) + .build()); + + Checks.checkVAppTemplate(template); + + // TODO: await task to complete + // TODO: make assertions that the task was successful + } + + @Test(testName = "POST /vdc/{id}/media") + public void testCreateMedia() { + Media media = vdcClient.createMedia(vdcRef, Media.builder() + .name("") + .imageType(Media.ImageType.ISO) + .size(0) + // TODO: test optional params + //.name("") + //.description("") + //.isSourceDelete(true) + .build()); + + Checks.checkMediaFor(VDC, media); + + // TODO: await task to complete + // TODO: make assertions that the task was successful + } @Test(testName = "GET /network/{id}/metadata") public void testGetMetadata() { @@ -141,5 +294,4 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkMetadataValueFor(VDC, metadataValue); } - }