diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java index 26753f1571..07052ec444 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java @@ -18,35 +18,9 @@ */ package org.jclouds.openstack.nova; -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withFile; -import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withMetadata; -import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withSharedIpGroup; -import static org.jclouds.openstack.nova.options.CreateSharedIpGroupOptions.Builder.withServer; -import static org.jclouds.openstack.nova.options.ListOptions.Builder.changesSince; -import static org.jclouds.openstack.nova.options.ListOptions.Builder.withDetails; -import static org.jclouds.openstack.nova.options.RebuildServerOptions.Builder.withImage; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.lang.reflect.Method; -import java.net.URI; -import java.net.UnknownHostException; -import java.util.Date; -import java.util.Properties; - -import javax.ws.rs.core.MediaType; - -import org.jclouds.openstack.nova.config.NovaRestClientModule; -import org.jclouds.openstack.nova.domain.BackupSchedule; -import org.jclouds.openstack.nova.domain.DailyBackup; -import org.jclouds.openstack.nova.domain.RebootType; -import org.jclouds.openstack.nova.domain.WeeklyBackup; -import org.jclouds.openstack.nova.options.CreateServerOptions; -import org.jclouds.openstack.nova.options.CreateSharedIpGroupOptions; -import org.jclouds.openstack.nova.options.ListOptions; -import org.jclouds.openstack.nova.options.RebuildServerOptions; +import com.google.common.collect.ImmutableMap; +import com.google.inject.Module; +import com.google.inject.TypeLiteral; import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ReleasePayloadAndReturn; @@ -57,848 +31,877 @@ import org.jclouds.openstack.OpenStackAuthAsyncClient.AuthenticationResponse; import org.jclouds.openstack.TestOpenStackAuthenticationModule; import org.jclouds.openstack.filters.AddTimestampQuery; import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.nova.config.NovaRestClientModule; +import org.jclouds.openstack.nova.domain.BackupSchedule; +import org.jclouds.openstack.nova.domain.DailyBackup; +import org.jclouds.openstack.nova.domain.RebootType; +import org.jclouds.openstack.nova.domain.WeeklyBackup; +import org.jclouds.openstack.nova.options.CreateServerOptions; +import org.jclouds.openstack.nova.options.CreateSharedIpGroupOptions; +import org.jclouds.openstack.nova.options.ListOptions; +import org.jclouds.openstack.nova.options.RebuildServerOptions; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextSpec; -import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; +import org.jclouds.rest.functions.*; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableMap; -import com.google.inject.Module; -import com.google.inject.TypeLiteral; +import javax.ws.rs.core.MediaType; +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URI; +import java.net.UnknownHostException; +import java.util.Date; +import java.util.Properties; + +import static org.jclouds.Constants.PROPERTY_API_VERSION; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; +import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.*; +import static org.jclouds.openstack.nova.options.CreateSharedIpGroupOptions.Builder.withServer; +import static org.jclouds.openstack.nova.options.ListOptions.Builder.changesSince; +import static org.jclouds.openstack.nova.options.ListOptions.Builder.withDetails; +import static org.jclouds.openstack.nova.options.RebuildServerOptions.Builder.withImage; +import static org.testng.Assert.assertEquals; /** * Tests behavior of {@code NovaAsyncClient} - * + * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "NovaAsyncClientTest") public class NovaAsyncClientTest extends RestClientTest { - private static final Class listOptionsVarargsClass = new ListOptions[] {}.getClass(); - private static final Class createServerOptionsVarargsClass = new CreateServerOptions[] {} - .getClass(); - - public void testCreateServer() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, - createServerOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, "ralphie", 2, 1); - - assertRequestLineEquals(request, "POST http://serverManagementUrl/servers?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1}}", - "application/json", false); - - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - - } - - public void testCreateServerWithIpGroup() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, - createServerOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, "ralphie", 2, 1, withSharedIpGroup(2)); - - assertRequestLineEquals(request, "POST http://serverManagementUrl/servers?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, - "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"sharedIpGroupId\":2}}", - "application/json", false); - - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testCreateServerWithFile() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, - createServerOptionsVarargsClass); - HttpRequest request = processor - .createRequest(method, "ralphie", 2, 1, withFile("/etc/jclouds", "foo".getBytes())); - - assertRequestLineEquals(request, "POST http://serverManagementUrl/servers?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals( - request, - "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"personality\":[{\"path\":\"/etc/jclouds\",\"contents\":\"Zm9v\"}]}}", - "application/json", false); - - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); + private static final Class listOptionsVarargsClass = new ListOptions[]{}.getClass(); + private static final Class createServerOptionsVarargsClass = new CreateServerOptions[]{} + .getClass(); + + @Test + public void testCreateServer() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, + createServerOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, "ralphie", 2, 1); + + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1}}", + "application/json", false); + + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + + } + + @Test + public void testCreateServerWithIpGroup() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, + createServerOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, "ralphie", 2, 1, withSharedIpGroup(2)); + + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, + "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"sharedIpGroupId\":2}}", + "application/json", false); + + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + @Test + public void testCreateServerWithFile() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, + createServerOptionsVarargsClass); + HttpRequest request = processor + .createRequest(method, "ralphie", 2, 1, withFile("/etc/jclouds", "foo".getBytes())); + + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals( + request, + "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"personality\":[{\"path\":\"/etc/jclouds\",\"contents\":\"Zm9v\"}]}}", + "application/json", false); + + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + + } + + @Test + public void testCreateServerWithMetadata() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, + createServerOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, "ralphie", 2, 1, + withMetadata(ImmutableMap.of("foo", "bar"))); + + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, + "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"metadata\":{\"foo\":\"bar\"}}}", + "application/json", false); + + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + + } + + public void testCreateServerWithIpGroupAndSharedIp() throws IOException, SecurityException, NoSuchMethodException, + UnknownHostException { + Method method = NovaAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, + createServerOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, "ralphie", 2, 1, + withSharedIpGroup(2).withSharedIp("127.0.0.1")); + + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals( + request, + "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"sharedIpGroupId\":2,\"addresses\":{\"public\":[\"127.0.0.1\"]}}}", + "application/json", false); - } - - public void testCreateServerWithMetadata() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, - createServerOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, "ralphie", 2, 1, - withMetadata(ImmutableMap.of("foo", "bar"))); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - assertRequestLineEquals(request, "POST http://serverManagementUrl/servers?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, - "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"metadata\":{\"foo\":\"bar\"}}}", - "application/json", false); + checkFilters(request); + } + + public void testDeleteImage() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("deleteImage", int.class); + HttpRequest request = processor.createRequest(method, 2); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertRequestLineEquals(request, "DELETE http://endpoint/vapiversion/images/2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - checkFilters(request); + assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class); - } + checkFilters(request); + } - public void testCreateServerWithIpGroupAndSharedIp() throws IOException, SecurityException, NoSuchMethodException, - UnknownHostException { - Method method = NovaAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, - createServerOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, "ralphie", 2, 1, - withSharedIpGroup(2).withSharedIp("127.0.0.1")); + public void testListServers() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listServers", listOptionsVarargsClass); + HttpRequest request = processor.createRequest(method); + + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/servers?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, "POST http://serverManagementUrl/servers?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals( - request, - "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"sharedIpGroupId\":2,\"addresses\":{\"public\":[\"127.0.0.1\"]}}}", - "application/json", false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + checkFilters(request); + } - checkFilters(request); - } + Date now = new Date(10000000l); - public void testDeleteImage() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("deleteImage", int.class); - HttpRequest request = processor.createRequest(method, 2); + public void testListServersOptions() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listServers", listOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, changesSince(now).maxResults(1).startAt(2)); - assertRequestLineEquals(request, "DELETE http://serverManagementUrl/images/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, + "GET http://endpoint/vapiversion/servers?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testListServers() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listServers", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method); + public void testListServersDetail() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listServers", listOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, withDetails()); - assertRequestLineEquals(request, "GET http://serverManagementUrl/servers?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/servers/detail?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - Date now = new Date(10000000l); + public void testGetServer() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("getServer", int.class); + HttpRequest request = processor.createRequest(method, 2); - public void testListServersOptions() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listServers", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, changesSince(now).maxResults(1).startAt(2)); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/servers/2?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, - "GET http://serverManagementUrl/servers?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + checkFilters(request); + } - checkFilters(request); - } + public void testListFlavors() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); + HttpRequest request = processor.createRequest(method); - public void testListServersDetail() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listServers", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, withDetails()); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/flavors?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, "GET http://serverManagementUrl/servers/detail?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + checkFilters(request); + } - checkFilters(request); - } + public void testListFlavorsOptions() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, changesSince(now).maxResults(1).startAt(2)); - public void testGetServer() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("getServer", int.class); - HttpRequest request = processor.createRequest(method, 2); + assertRequestLineEquals(request, + "GET http://endpoint/vapiversion/flavors?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, "GET http://serverManagementUrl/servers/2?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + checkFilters(request); + } - checkFilters(request); - } + public void testListFlavorsDetail() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, withDetails()); - public void testListFlavors() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/flavors/detail?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, "GET http://serverManagementUrl/flavors?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + checkFilters(request); + } - checkFilters(request); - } + public void testListFlavorsDetailOptions() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, withDetails().changesSince(now).maxResults(1).startAt(2)); - public void testListFlavorsOptions() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, changesSince(now).maxResults(1).startAt(2)); + assertRequestLineEquals(request, + "GET http://endpoint/vapiversion/flavors/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, - "GET http://serverManagementUrl/flavors?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + checkFilters(request); + } - checkFilters(request); - } + public void testGetFlavor() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("getFlavor", int.class); + HttpRequest request = processor.createRequest(method, 2); - public void testListFlavorsDetail() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, withDetails()); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/flavors/2?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, "GET http://serverManagementUrl/flavors/detail?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + checkFilters(request); + } - checkFilters(request); - } + public void testListImages() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listImages", listOptionsVarargsClass); + HttpRequest request = processor.createRequest(method); - public void testListFlavorsDetailOptions() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, withDetails().changesSince(now).maxResults(1).startAt(2)); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/images?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, - "GET http://serverManagementUrl/flavors/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + checkFilters(request); + } - checkFilters(request); - } + public void testListImagesDetail() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listImages", listOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, withDetails()); - public void testGetFlavor() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("getFlavor", int.class); - HttpRequest request = processor.createRequest(method, 2); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/images/detail?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, "GET http://serverManagementUrl/flavors/2?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + checkFilters(request); + } - checkFilters(request); - } + public void testListImagesOptions() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listImages", listOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, changesSince(now).maxResults(1).startAt(2)); - public void testListImages() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listImages", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method); + assertRequestLineEquals(request, + "GET http://endpoint/vapiversion/images?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, "GET http://serverManagementUrl/images?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + checkFilters(request); + } - checkFilters(request); - } + public void testListImagesDetailOptions() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listImages", listOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, withDetails().changesSince(now).maxResults(1).startAt(2)); - public void testListImagesDetail() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listImages", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, withDetails()); + assertRequestLineEquals(request, + "GET http://endpoint/vapiversion/images/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, "GET http://serverManagementUrl/images/detail?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + checkFilters(request); + } - checkFilters(request); - } + public void testGetImage() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("getImage", int.class); + HttpRequest request = processor.createRequest(method, 2); - public void testListImagesOptions() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listImages", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, changesSince(now).maxResults(1).startAt(2)); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/images/2?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, - "GET http://serverManagementUrl/images?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + checkFilters(request); + } - checkFilters(request); - } + public void testDeleteServer() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("deleteServer", int.class); + HttpRequest request = processor.createRequest(method, 2); - public void testListImagesDetailOptions() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listImages", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, withDetails().changesSince(now).maxResults(1).startAt(2)); + assertRequestLineEquals(request, "DELETE http://endpoint/vapiversion/servers/2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, - "GET http://serverManagementUrl/images/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + checkFilters(request); + } - checkFilters(request); - } + public void testShareIpNoConfig() throws IOException, SecurityException, NoSuchMethodException, UnknownHostException { + Method method = NovaAsyncClient.class.getMethod("shareIp", String.class, int.class, int.class, + boolean.class); + HttpRequest request = processor.createRequest(method, "127.0.0.1", 2, 3, false); - public void testGetImage() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("getImage", int.class); - HttpRequest request = processor.createRequest(method, 2); + assertRequestLineEquals(request, "PUT http://endpoint/vapiversion/servers/2/ips/public/127.0.0.1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, "{\"shareIp\":{\"sharedIpGroupId\":3,\"configureServer\":false}}", + MediaType.APPLICATION_JSON, false); - assertRequestLineEquals(request, "GET http://serverManagementUrl/images/2?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + checkFilters(request); - checkFilters(request); - } + } - public void testDeleteServer() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("deleteServer", int.class); - HttpRequest request = processor.createRequest(method, 2); + public void testShareIpConfig() throws IOException, SecurityException, NoSuchMethodException, UnknownHostException { + Method method = NovaAsyncClient.class.getMethod("shareIp", String.class, int.class, int.class, + boolean.class); + HttpRequest request = processor.createRequest(method, "127.0.0.1", 2, 3, true); - assertRequestLineEquals(request, "DELETE http://serverManagementUrl/servers/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "PUT http://endpoint/vapiversion/servers/2/ips/public/127.0.0.1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, "{\"shareIp\":{\"sharedIpGroupId\":3,\"configureServer\":true}}", + MediaType.APPLICATION_JSON, false); - assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); - public void testShareIpNoConfig() throws IOException, SecurityException, NoSuchMethodException, UnknownHostException { - Method method = NovaAsyncClient.class.getMethod("shareIp", String.class, int.class, int.class, - boolean.class); - HttpRequest request = processor.createRequest(method, "127.0.0.1", 2, 3, false); + } - assertRequestLineEquals(request, "PUT http://serverManagementUrl/servers/2/ips/public/127.0.0.1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, "{\"shareIp\":{\"sharedIpGroupId\":3,\"configureServer\":false}}", - MediaType.APPLICATION_JSON, false); + public void testUnshareIpNoConfig() throws IOException, SecurityException, NoSuchMethodException, + UnknownHostException { + Method method = NovaAsyncClient.class.getMethod("unshareIp", String.class, int.class); + HttpRequest request = processor.createRequest(method, "127.0.0.1", 2, 3, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertRequestLineEquals(request, "DELETE http://endpoint/vapiversion/servers/2/ips/public/127.0.0.1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - checkFilters(request); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class); - } + checkFilters(request); - public void testShareIpConfig() throws IOException, SecurityException, NoSuchMethodException, UnknownHostException { - Method method = NovaAsyncClient.class.getMethod("shareIp", String.class, int.class, int.class, - boolean.class); - HttpRequest request = processor.createRequest(method, "127.0.0.1", 2, 3, true); + } - assertRequestLineEquals(request, "PUT http://serverManagementUrl/servers/2/ips/public/127.0.0.1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, "{\"shareIp\":{\"sharedIpGroupId\":3,\"configureServer\":true}}", - MediaType.APPLICATION_JSON, false); + public void testReplaceBackupSchedule() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("replaceBackupSchedule", int.class, BackupSchedule.class); + HttpRequest request = processor.createRequest(method, 2, new BackupSchedule(WeeklyBackup.MONDAY, + DailyBackup.H_0800_1000, true)); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/backup_schedule HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, + "{\"backupSchedule\":{\"daily\":\"H_0800_1000\",\"enabled\":true,\"weekly\":\"MONDAY\"}}", + MediaType.APPLICATION_JSON, false); - checkFilters(request); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnFalseOn404.class); - } + checkFilters(request); - public void testUnshareIpNoConfig() throws IOException, SecurityException, NoSuchMethodException, - UnknownHostException { - Method method = NovaAsyncClient.class.getMethod("unshareIp", String.class, int.class); - HttpRequest request = processor.createRequest(method, "127.0.0.1", 2, 3, false); + } - assertRequestLineEquals(request, "DELETE http://serverManagementUrl/servers/2/ips/public/127.0.0.1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + public void testDeleteBackupSchedule() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("deleteBackupSchedule", int.class); + HttpRequest request = processor.createRequest(method, 2); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class); + assertRequestLineEquals(request, "DELETE http://endpoint/vapiversion/servers/2/backup_schedule HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, MediaType.APPLICATION_JSON, false); - checkFilters(request); + assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class); - } + checkFilters(request); - public void testReplaceBackupSchedule() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("replaceBackupSchedule", int.class, BackupSchedule.class); - HttpRequest request = processor.createRequest(method, 2, new BackupSchedule(WeeklyBackup.MONDAY, - DailyBackup.H_0800_1000, true)); + } - assertRequestLineEquals(request, "POST http://serverManagementUrl/servers/2/backup_schedule HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, - "{\"backupSchedule\":{\"daily\":\"H_0800_1000\",\"enabled\":true,\"weekly\":\"MONDAY\"}}", - MediaType.APPLICATION_JSON, false); + public void testChangeAdminPass() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("changeAdminPass", int.class, String.class); + HttpRequest request = processor.createRequest(method, 2, "foo"); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnFalseOn404.class); + assertRequestLineEquals(request, "PUT http://endpoint/vapiversion/servers/2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, "{\"server\":{\"adminPass\":\"foo\"}}", MediaType.APPLICATION_JSON, false); - checkFilters(request); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - } + checkFilters(request); - public void testDeleteBackupSchedule() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("deleteBackupSchedule", int.class); - HttpRequest request = processor.createRequest(method, 2); + } - assertRequestLineEquals(request, "DELETE http://serverManagementUrl/servers/2/backup_schedule HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, MediaType.APPLICATION_JSON, false); + public void testChangeServerName() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("renameServer", int.class, String.class); + HttpRequest request = processor.createRequest(method, 2, "foo"); - assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class); + assertRequestLineEquals(request, "PUT http://endpoint/vapiversion/servers/2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, "{\"server\":{\"name\":\"foo\"}}", MediaType.APPLICATION_JSON, false); - checkFilters(request); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - } + checkFilters(request); - public void testChangeAdminPass() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("changeAdminPass", int.class, String.class); - HttpRequest request = processor.createRequest(method, 2, "foo"); + } - assertRequestLineEquals(request, "PUT http://serverManagementUrl/servers/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, "{\"server\":{\"adminPass\":\"foo\"}}", MediaType.APPLICATION_JSON, false); + public void testListSharedIpGroups() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listSharedIpGroups", listOptionsVarargsClass); + HttpRequest request = processor.createRequest(method); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/shared_ip_groups?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - checkFilters(request); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); - } + checkFilters(request); + } - public void testChangeServerName() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("renameServer", int.class, String.class); - HttpRequest request = processor.createRequest(method, 2, "foo"); + public void testListSharedIpGroupsOptions() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listSharedIpGroups", listOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, changesSince(now).maxResults(1).startAt(2)); - assertRequestLineEquals(request, "PUT http://serverManagementUrl/servers/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, "{\"server\":{\"name\":\"foo\"}}", MediaType.APPLICATION_JSON, false); + assertRequestLineEquals(request, + "GET http://endpoint/vapiversion/shared_ip_groups?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); - checkFilters(request); + checkFilters(request); + } - } + public void testListSharedIpGroupsDetail() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listSharedIpGroups", listOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, withDetails()); - public void testListSharedIpGroups() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listSharedIpGroups", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/shared_ip_groups/detail?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, "GET http://serverManagementUrl/shared_ip_groups?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + checkFilters(request); + } - checkFilters(request); - } + public void testListSharedIpGroupsDetailOptions() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listSharedIpGroups", listOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, withDetails().changesSince(now).maxResults(1).startAt(2)); - public void testListSharedIpGroupsOptions() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listSharedIpGroups", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, changesSince(now).maxResults(1).startAt(2)); + assertRequestLineEquals(request, + "GET http://endpoint/vapiversion/shared_ip_groups/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, - "GET http://serverManagementUrl/shared_ip_groups?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + checkFilters(request); + } - checkFilters(request); - } + public void testGetSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("getSharedIpGroup", int.class); + HttpRequest request = processor.createRequest(method, 2); - public void testListSharedIpGroupsDetail() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listSharedIpGroups", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, withDetails()); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/shared_ip_groups/2?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, "GET http://serverManagementUrl/shared_ip_groups/detail?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + checkFilters(request); + } - checkFilters(request); - } + private static final Class createSharedIpGroupOptionsVarargsClass = new CreateSharedIpGroupOptions[]{} + .getClass(); - public void testListSharedIpGroupsDetailOptions() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listSharedIpGroups", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, withDetails().changesSince(now).maxResults(1).startAt(2)); + public void testCreateSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("createSharedIpGroup", String.class, + createSharedIpGroupOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, "ralphie"); - assertRequestLineEquals(request, - "GET http://serverManagementUrl/shared_ip_groups/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/shared_ip_groups?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, "{\"sharedIpGroup\":{\"name\":\"ralphie\"}}", MediaType.APPLICATION_JSON, false); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); - public void testGetSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("getSharedIpGroup", int.class); - HttpRequest request = processor.createRequest(method, 2); + } - assertRequestLineEquals(request, "GET http://serverManagementUrl/shared_ip_groups/2?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + public void testCreateSharedIpGroupWithIpGroup() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("createSharedIpGroup", String.class, + createSharedIpGroupOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, "ralphie", withServer(2)); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/shared_ip_groups?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, "{\"sharedIpGroup\":{\"name\":\"ralphie\",\"server\":2}}", + MediaType.APPLICATION_JSON, false); - checkFilters(request); - } + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - private static final Class createSharedIpGroupOptionsVarargsClass = new CreateSharedIpGroupOptions[] {} - .getClass(); + checkFilters(request); + } - public void testCreateSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("createSharedIpGroup", String.class, - createSharedIpGroupOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, "ralphie"); + public void testDeleteSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("deleteSharedIpGroup", int.class); + HttpRequest request = processor.createRequest(method, 2); - assertRequestLineEquals(request, "POST http://serverManagementUrl/shared_ip_groups?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, "{\"sharedIpGroup\":{\"name\":\"ralphie\"}}", MediaType.APPLICATION_JSON, false); + assertRequestLineEquals(request, "DELETE http://endpoint/vapiversion/shared_ip_groups/2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class); - checkFilters(request); + checkFilters(request); + } - } + public void testListAddresses() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("getAddresses", int.class); + HttpRequest request = processor.createRequest(method, 2); - public void testCreateSharedIpGroupWithIpGroup() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("createSharedIpGroup", String.class, - createSharedIpGroupOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, "ralphie", withServer(2)); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/servers/2/ips?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, "POST http://serverManagementUrl/shared_ip_groups?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, "{\"sharedIpGroup\":{\"name\":\"ralphie\",\"server\":2}}", - MediaType.APPLICATION_JSON, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + checkFilters(request); + } - checkFilters(request); - } + public void testListPublicAddresses() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listPublicAddresses", int.class); + HttpRequest request = processor.createRequest(method, 2); - public void testDeleteSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("deleteSharedIpGroup", int.class); - HttpRequest request = processor.createRequest(method, 2); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/servers/2/ips/public?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, "DELETE http://serverManagementUrl/shared_ip_groups/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class); + checkFilters(request); + } - checkFilters(request); - } + @Test + public void testListPrivateAddresses() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listPrivateAddresses", int.class); + HttpRequest request = processor.createRequest(method, 2); - public void testListAddresses() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("getAddresses", int.class); - HttpRequest request = processor.createRequest(method, 2); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/servers/2/ips/private?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, "GET http://serverManagementUrl/servers/2/ips?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + checkFilters(request); + } - checkFilters(request); - } + @Test + public void testListBackupSchedule() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("getBackupSchedule", int.class); + HttpRequest request = processor.createRequest(method, 2); - public void testListPublicAddresses() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listPublicAddresses", int.class); - HttpRequest request = processor.createRequest(method, 2); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/servers/2/backup_schedule?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, "GET http://serverManagementUrl/servers/2/ips/public?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + checkFilters(request); + } - checkFilters(request); - } + @Test + public void testCreateImageWithIpGroup() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("createImageFromServer", String.class, int.class); + HttpRequest request = processor.createRequest(method, "ralphie", 2); - public void testListPrivateAddresses() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listPrivateAddresses", int.class); - HttpRequest request = processor.createRequest(method, 2); + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/images?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, "{\"image\":{\"serverId\":2,\"name\":\"ralphie\"}}", MediaType.APPLICATION_JSON, + false); - assertRequestLineEquals(request, "GET http://serverManagementUrl/servers/2/ips/private?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + checkFilters(request); - checkFilters(request); - } + } - public void testListBackupSchedule() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("getBackupSchedule", int.class); - HttpRequest request = processor.createRequest(method, 2); + private static final Class rebuildServerOptionsVarargsClass = new RebuildServerOptions[]{} + .getClass(); - assertRequestLineEquals(request, "GET http://serverManagementUrl/servers/2/backup_schedule?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + @Test + public void testRebuildServer() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("rebuildServer", int.class, + rebuildServerOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, 3); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class); + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/3/action?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, "{\"rebuild\":{}}", MediaType.APPLICATION_JSON, false); - checkFilters(request); - } + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - public void testCreateImageWithIpGroup() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("createImageFromServer", String.class, int.class); - HttpRequest request = processor.createRequest(method, "ralphie", 2); + checkFilters(request); + } - assertRequestLineEquals(request, "POST http://serverManagementUrl/images?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, "{\"image\":{\"serverId\":2,\"name\":\"ralphie\"}}", MediaType.APPLICATION_JSON, - false); + @Test + public void testRebuildServerWithImage() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("rebuildServer", int.class, + rebuildServerOptionsVarargsClass); + HttpRequest request = processor.createRequest(method, 3, withImage(2)); - assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/3/action?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, "{\"rebuild\":{\"imageId\":2}}", MediaType.APPLICATION_JSON, false); - checkFilters(request); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - } + checkFilters(request); + } - private static final Class rebuildServerOptionsVarargsClass = new RebuildServerOptions[] {} - .getClass(); + @Test + public void testReboot() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("rebootServer", int.class, RebootType.class); + HttpRequest request = processor.createRequest(method, 2, RebootType.HARD); - public void testRebuildServer() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("rebuildServer", int.class, - rebuildServerOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, 3); + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, "{\"reboot\":{\"type\":\"HARD\"}}", MediaType.APPLICATION_JSON, false); - assertRequestLineEquals(request, "POST http://serverManagementUrl/servers/3/action?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, "{\"rebuild\":{}}", MediaType.APPLICATION_JSON, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testRebuildServerWithImage() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("rebuildServer", int.class, - rebuildServerOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, 3, withImage(2)); - - assertRequestLineEquals(request, "POST http://serverManagementUrl/servers/3/action?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, "{\"rebuild\":{\"imageId\":2}}", MediaType.APPLICATION_JSON, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testReboot() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("rebootServer", int.class, RebootType.class); - HttpRequest request = processor.createRequest(method, 2, RebootType.HARD); - - assertRequestLineEquals(request, "POST http://serverManagementUrl/servers/2/action?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, "{\"reboot\":{\"type\":\"HARD\"}}", MediaType.APPLICATION_JSON, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testResize() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("resizeServer", int.class, int.class); - HttpRequest request = processor.createRequest(method, 2, 3); - - assertRequestLineEquals(request, "POST http://serverManagementUrl/servers/2/action?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, "{\"resize\":{\"flavorId\":3}}", MediaType.APPLICATION_JSON, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - - } - - public void testConfirmResize() throws IOException, IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("confirmResizeServer", int.class); - HttpRequest request = processor.createRequest(method, 2); - - assertRequestLineEquals(request, "POST http://serverManagementUrl/servers/2/action?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, "{\"confirmResize\":null}", MediaType.APPLICATION_JSON, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testRevertResize() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("revertResizeServer", int.class); - HttpRequest request = processor.createRequest(method, 2); - - assertRequestLineEquals(request, "POST http://serverManagementUrl/servers/2/action?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, "{\"revertResize\":null}", MediaType.APPLICATION_JSON, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - @Override - protected TypeLiteral> createTypeLiteral() { - return new TypeLiteral>() { - }; - } - - @Override - protected void checkFilters(HttpRequest request) { - assertEquals(request.getFilters().size(), 2); - assertEquals(request.getFilters().get(0).getClass(), AuthenticateRequest.class); - assertEquals(request.getFilters().get(1).getClass(), AddTimestampQuery.class); - - } - - @Override - protected Module createModule() { - return new TestNovaRestClientModule(); - } - - @ConfiguresRestClient - @RequiresHttp - protected static class TestNovaRestClientModule extends NovaRestClientModule { - private TestNovaRestClientModule() { - super(new TestOpenStackAuthenticationModule()); - } - - @Override - protected URI provideServerUrl(AuthenticationResponse response) { - return URI.create("http://serverManagementUrl"); - } - - } - - protected String provider = "nova"; - - @Override - public RestContextSpec createContextSpec() { - return new RestContextFactory(getProperties()).createContextSpec(provider, "user", "password", new Properties()); - } - - @Override - protected Properties getProperties() { - Properties overrides = new Properties(); - overrides.setProperty(PROPERTY_REGIONS, "US"); - overrides.setProperty(PROPERTY_API_VERSION, "1"); - overrides.setProperty(provider + ".endpoint", "https://auth"); - overrides.setProperty(provider + ".contextbuilder", NovaContextBuilder.class.getName()); - return overrides; - } + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + @Test + public void testResize() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("resizeServer", int.class, int.class); + HttpRequest request = processor.createRequest(method, 2, 3); + + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, "{\"resize\":{\"flavorId\":3}}", MediaType.APPLICATION_JSON, false); + + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + + } + + public void testConfirmResize() throws IOException, IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("confirmResizeServer", int.class); + HttpRequest request = processor.createRequest(method, 2); + + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, "{\"confirmResize\":null}", MediaType.APPLICATION_JSON, false); + + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testRevertResize() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("revertResizeServer", int.class); + HttpRequest request = processor.createRequest(method, 2); + + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, "{\"revertResize\":null}", MediaType.APPLICATION_JSON, false); + + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + + @Override + protected void checkFilters(HttpRequest request) { + assertEquals(request.getFilters().size(), 2); + assertEquals(request.getFilters().get(0).getClass(), AuthenticateRequest.class); + assertEquals(request.getFilters().get(1).getClass(), AddTimestampQuery.class); + + } + + @Override + protected Module createModule() { + return new TestNovaRestClientModule(); + } + + @ConfiguresRestClient + @RequiresHttp + protected static class TestNovaRestClientModule extends NovaRestClientModule { + private TestNovaRestClientModule() { + super(new TestOpenStackAuthenticationModule()); + } + + @Override + protected URI provideServerUrl(AuthenticationResponse response) { + return URI.create("http://endpoint"); + } + + } + + protected String provider = "nova"; + + @Override + public RestContextSpec createContextSpec() { + return new RestContextFactory(getProperties()).createContextSpec(provider, "user", "password", new Properties()); + } + + @Override + protected Properties getProperties() { + Properties overrides = new Properties(); + overrides.setProperty(PROPERTY_REGIONS, "US"); + overrides.setProperty(PROPERTY_API_VERSION, "apiversion"); + overrides.setProperty(provider + ".endpoint", "http://endpoint"); + overrides.setProperty(provider + ".contextbuilder", NovaContextBuilder.class.getName()); + return overrides; + } }