fixed tests based on new endpoint

This commit is contained in:
Kedar Dave 2011-05-18 00:12:27 -05:00
parent e3b7d6d91c
commit a364a43b56
5 changed files with 73 additions and 5 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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;
@ -109,12 +113,76 @@ public class VMAsyncClientTest extends BaseVPDCAsyncClientTest<VMAsyncClient> {
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<Set<CIMOperatingSystem>>() {
})), new Predicate<CIMOperatingSystem>() {
@Override
public boolean apply(CIMOperatingSystem arg0) {
return arg0.getOsType() == OSType.RHEL_64;
}
});
Network network = Network.builder().name("VM Tier01").build();
List<VMSpec> vmSpecs = new ArrayList<VMSpec>();
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);

View File

@ -1 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><CaptureVAppParams xmlns="http://schemas.api.sandbox.symphonyVPDC.savvis.net/vpdci" name="CaptureTemplate"><Description>Save Template</Description><Source href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1001"/></CaptureVAppParams>
<?xml version="1.0" encoding="UTF-8" standalone="no"?><CaptureVAppParams xmlns="http://schemas.api.sandbox.symphonyVPDC.savvis.net/vpdci" name="CaptureTemplate"><Description>Save Template</Description><Source href="https://api.symphonyvpdc.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/vApp/1001"/></CaptureVAppParams>

View File

@ -1 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><CloneVAppParams xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" deploy="true" name="clonedvm" powerOn="true" xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8 https://api.symphonyvpdc.savvis.net/ns/vcloud.xsd"><Description>VM Tier01</Description><VApp href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/" type="application/vnd.vmware.vcloud.vApp+xml"/></CloneVAppParams>
<?xml version="1.0" encoding="UTF-8" standalone="no"?><CloneVAppParams xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" deploy="true" name="clonedvm" powerOn="true" xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8 https://api.symphonyvpdc.savvis.net/ns/vcloud.xsd"><Description>VM Tier01</Description><VApp href="https://api.symphonyvpdc.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/vApp/" type="application/vnd.vmware.vcloud.vApp+xml"/></CloneVAppParams>