diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/binders/BindCaptureVAppTemplateToXmlPayloadTest.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/binders/BindCaptureVAppTemplateToXmlPayloadTest.java index 30c0a843e6..aeb9bd82b5 100644 --- a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/binders/BindCaptureVAppTemplateToXmlPayloadTest.java +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/binders/BindCaptureVAppTemplateToXmlPayloadTest.java @@ -37,7 +37,7 @@ public class BindCaptureVAppTemplateToXmlPayloadTest { public void test() throws IOException { String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/capture-vapp-template-default.xml")); - URI vAppURI = URI.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1001"); + URI vAppURI = URI.create("https://api.symphonyvpdc.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/vApp/1001"); String xml = new BindCaptureVAppTemplateToXmlPayload().generateXml(vAppURI); System.out.println(xml); diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/binders/BindCloneVAppToXmlPayloadTest.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/binders/BindCloneVAppToXmlPayloadTest.java index bf76ed2f9d..af4e4433f4 100644 --- a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/binders/BindCloneVAppToXmlPayloadTest.java +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/binders/BindCloneVAppToXmlPayloadTest.java @@ -36,7 +36,7 @@ public class BindCloneVAppToXmlPayloadTest { public void test() throws IOException { String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/cloneVApp-default.xml")); - URI vAppURI = URI.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1001"); + URI vAppURI = URI.create("https://api.symphonyvpdc.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/vApp/1001"); String xml = new BindCloneVMToXmlPayload().generateXml(vAppURI, "clonedvm", "VM Tier01"); System.out.println(xml); diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncClientTest.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncClientTest.java index 7542ef1801..ef040102bd 100644 --- a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncClientTest.java +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncClientTest.java @@ -21,6 +21,8 @@ package org.jclouds.savvis.vpdc.features; import java.io.IOException; import java.lang.reflect.Method; import java.net.URI; +import java.util.ArrayList; +import java.util.List; import java.util.Set; import org.jclouds.cim.OSType; @@ -30,8 +32,10 @@ import org.jclouds.http.functions.ParseSax; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.savvis.vpdc.domain.Network; import org.jclouds.savvis.vpdc.domain.VMSpec; import org.jclouds.savvis.vpdc.xml.TaskHandler; +import org.jclouds.savvis.vpdc.xml.TasksListHandler; import org.jclouds.util.Strings2; import org.testng.annotations.Test; @@ -108,13 +112,77 @@ public class VMAsyncClientTest extends BaseVPDCAsyncClientTest { checkFilters(request); } + + public void testAddMultipleVMsIntoVDC() throws SecurityException, NoSuchMethodException, IOException { + Method method = VMAsyncClient.class.getMethod("addMultipleVMsIntoVDC", URI.class, List.class); + CIMOperatingSystem os = Iterables.find(injector.getInstance(Key.get(new TypeLiteral>() { + })), new Predicate() { + + @Override + public boolean apply(CIMOperatingSystem arg0) { + return arg0.getOsType() == OSType.RHEL_64; + } + + }); + + Network network = Network.builder().name("VM Tier01").build(); + List vmSpecs = new ArrayList(); + vmSpecs.add(VMSpec.builder().name("Test VM").operatingSystem(os).network(network).build()); + + HttpRequest request = processor.createRequest(method, URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/11/vdc/22"), vmSpecs); + + assertRequestLineEquals(request, + "GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/ HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/vm-multiple-default.xml")), + "application/xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TasksListHandler.class); + assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class); + + checkFilters(request); + } + + public void testCaptureVApp() throws SecurityException, NoSuchMethodException, IOException { + Method method = VMAsyncClient.class.getMethod("captureVApp", String.class, String.class, URI.class); + HttpRequest request = processor.createRequest(method, "100000.0", "2736", URI.create("https://api.symphonyvpdc.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/vApp/1001")); + + assertRequestLineEquals(request, + "POST https://api.symphonyvpdc.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/action/captureVApp HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/capture-vapp-template-default.xml")), + "application/xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + + checkFilters(request); + } + + public void testCloneVApp() throws SecurityException, NoSuchMethodException, IOException { + Method method = VMAsyncClient.class.getMethod("cloneVApp", URI.class, String.class, String.class); + HttpRequest request = processor.createRequest(method, URI.create("https://api.symphonyvpdc.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/vApp/1001"), "clonedvm", "VM Tier01"); + + assertRequestLineEquals(request, + "POST https://api.symphonyvpdc.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/vApp/1001/action/cloneVApp HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/cloneVApp-default.xml")), + "application/xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + + checkFilters(request); + } + public void testRemoveVMFromVDC() throws SecurityException, NoSuchMethodException, IOException { Method method = VMAsyncClient.class.getMethod("removeVMFromVDC", String.class, String.class, String.class); HttpRequest request = processor.createRequest(method, "11", "22", "33"); assertRequestLineEquals(request, - "DELETE https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/33 HTTP/1.1"); + "DELETE https://api.symphonyvpdc.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, null, null, false); diff --git a/providers/savvis-symphonyvpdc/src/test/resources/capture-vapp-template-default.xml b/providers/savvis-symphonyvpdc/src/test/resources/capture-vapp-template-default.xml index 6d873ac2b6..28b5076d7c 100644 --- a/providers/savvis-symphonyvpdc/src/test/resources/capture-vapp-template-default.xml +++ b/providers/savvis-symphonyvpdc/src/test/resources/capture-vapp-template-default.xml @@ -1 +1 @@ -Save Template \ No newline at end of file +Save Template \ No newline at end of file diff --git a/providers/savvis-symphonyvpdc/src/test/resources/cloneVApp-default.xml b/providers/savvis-symphonyvpdc/src/test/resources/cloneVApp-default.xml index 2718f219f0..a60db84ebd 100644 --- a/providers/savvis-symphonyvpdc/src/test/resources/cloneVApp-default.xml +++ b/providers/savvis-symphonyvpdc/src/test/resources/cloneVApp-default.xml @@ -1 +1 @@ -VM Tier01 \ No newline at end of file +VM Tier01 \ No newline at end of file