From f52f331be9177ea55e260d026c64ce253c8c7215 Mon Sep 17 00:00:00 2001 From: vicglarson Date: Mon, 18 Apr 2011 15:12:40 +0400 Subject: [PATCH] Fixed tests. Added affinity id and dates. --- .../jclouds/openstack/nova/domain/Image.java | 43 +- .../openstack/nova/domain/Resource.java | 1 + .../jclouds/openstack/nova/domain/Server.java | 32 +- .../openstack/nova/NovaAsyncClientTest.java | 881 +++++++++--------- .../openstack/nova/NovaClientLiveTest.java | 132 ++- .../openstack/nova/PropertyHelper.java | 8 +- .../functions/FlavorToHardwareTest.java | 37 +- .../functions/NovaImageToImageTest.java | 43 +- .../functions/ServerToNodeMetadataTest.java | 158 ++-- .../openstack/nova/domain/ServerTest.java | 6 +- .../ParseAddressesFromJsonResponseTest.java | 51 +- .../ParseFaultFromJsonResponseTest.java | 145 ++- .../ParseFlavorFromJsonResponseTest.java | 52 +- .../ParseFlavorListFromJsonResponseTest.java | 54 +- .../ParseImageFromJsonResponseTest.java | 78 +- .../ParseImageListFromJsonResponseTest.java | 87 +- ...seInetAddressListFromJsonResponseTest.java | 54 +- .../openstack/nova/functions/ParseModule.java | 19 + .../ParseServerFromJsonResponseTest.java | 67 +- .../ParseServerListFromJsonResponseTest.java | 100 +- .../nova/options/CreateServerOptionsTest.java | 78 +- .../nova/options/ListOptionsTest.java | 18 +- .../options/RebuildServerOptionsTest.java | 20 +- .../resources/test_get_image_details.json | 4 +- .../test/resources/test_list_addresses.json | 22 +- .../test_list_addresses_private.json | 4 +- .../resources/test_list_addresses_public.json | 4 +- .../src/test/resources/test_list_flavors.json | 2 + .../src/test/resources/test_list_servers.json | 2 +- .../resources/test_list_servers_detail.json | 26 +- 30 files changed, 1144 insertions(+), 1084 deletions(-) create mode 100644 sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseModule.java diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Image.java b/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Image.java index b548f25ca8..8a3934ee6d 100644 --- a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Image.java +++ b/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Image.java @@ -18,28 +18,41 @@ */ package org.jclouds.openstack.nova.domain; +import com.google.common.collect.Maps; + import java.util.Collections; import java.util.Date; import java.util.Map; -import com.google.common.collect.Maps; - /** - * An image is a collection of files used to create or rebuild a server. - * + * An image is a collection of files used to create or rebuild a server. Rackspace provides a number + * of pre-built OS images by default. You may also create custom images from cloud servers you have + * launched. These custom images are useful for backup purposes or for producing gold server images + * if you plan to deploy a particular server configuration frequently. + * * @author Adrian Cole */ public class Image extends Resource { - private Date created; private int id; private String name; private Integer progress; private String serverRef; private ImageStatus status; - private Date updated; private Map metadata = Maps.newHashMap(); + private Date created; + private Date updated; + + public Date getCreated() { + return created; + } + + public Date getUpdated() { + return updated; + } + + public Image() { } @@ -48,13 +61,6 @@ public class Image extends Resource { this.name = name; } - public void setCreated(Date created) { - this.created = created; - } - - public Date getCreated() { - return created; - } public void setId(int id) { this.id = id; @@ -96,13 +102,6 @@ public class Image extends Resource { return status; } - public void setUpdated(Date updated) { - this.updated = updated; - } - - public Date getUpdated() { - return updated; - } public Map getMetadata() { return Collections.unmodifiableMap(metadata); @@ -149,8 +148,8 @@ public class Image extends Resource { @Override public String toString() { - return "Image [created=" + created + ", id=" + id + ", name=" + name + ", serverId=" - + serverRef + "]"; + return "Image [created=" + getCreated() + ", id=" + id + ", name=" + name + ", serverRef=" + + serverRef + "]"; } } diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Resource.java b/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Resource.java index ea6b09d3fa..b97f29f2f4 100644 --- a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Resource.java +++ b/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Resource.java @@ -11,6 +11,7 @@ import java.util.Map; * @author Dmitri Babaev */ public class Resource { + private List> links = Lists.newArrayList(); public URI getURI() { diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Server.java b/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Server.java index 69c3d841f5..c496210097 100644 --- a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Server.java +++ b/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Server.java @@ -18,14 +18,15 @@ */ package org.jclouds.openstack.nova.domain; -import java.util.Map; - import com.google.common.collect.Maps; +import java.util.Date; +import java.util.Map; + /** * A server is a virtual machine instance in the OpenStack Nova system. Flavor and image are * requisite elements when creating a server. - * + * * @author Adrian Cole */ public class Server extends Resource { @@ -39,6 +40,19 @@ public class Server extends Resource { private String flavorRef; private String hostId; private String imageRef; + private String affinityId; + + private Date created; + private Date updated; + + public Date getCreated() { + return created; + } + + public Date getUpdated() { + return updated; + } + private Integer progress; private ServerStatus status; @@ -51,6 +65,14 @@ public class Server extends Resource { this.name = name; } + public String getAffinityId() { + return affinityId; + } + + public void setAffinityId(String affinityId) { + this.affinityId = affinityId; + } + public void setMetadata(Map metadata) { this.metadata = metadata; } @@ -206,8 +228,8 @@ public class Server extends Resource { @Override public String toString() { return "Server [addresses=" + addresses + ", adminPass=" + adminPass + ", flavorRef=" - + flavorRef + ", hostId=" + hostId + ", id=" + id + ", imageRef=" + imageRef - + ", metadata=" + metadata + ", name=" + name + "]"; + + flavorRef + ", hostId=" + hostId + ", id=" + id + ", imageRef=" + imageRef + + ", metadata=" + metadata + ", name=" + name + "]"; } } 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 ad85ee505b..cf59a2cd75 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 @@ -54,7 +54,8 @@ 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.CreateServerOptions.Builder.withFile; +import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withMetadata; 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; @@ -68,562 +69,562 @@ import static org.testng.Assert.assertEquals; // 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(); + 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); + @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\",\"imageRef\":2,\"flavorRef\":1}}", - "application/json", false); + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, "{\"server\":{\"name\":\"ralphie\",\"imageRef\":2,\"flavorRef\":1}}", + "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); - } + } - @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())); + @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\",\"imageRef\":2,\"flavorRef\":1,\"personality\":[{\"path\":\"/etc/jclouds\",\"contents\":\"Zm9v\"}]}}", - "application/json", false); + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals( + request, + "{\"server\":{\"name\":\"ralphie\",\"imageRef\":2,\"flavorRef\":1,\"personality\":[{\"path\":\"/etc/jclouds\",\"contents\":\"Zm9v\"}]}}", + "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); - } + } - @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"))); + @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\",\"imageRef\":2,\"flavorRef\":1,\"metadata\":{\"foo\":\"bar\"}}}", - "application/json", false); + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); + assertPayloadEquals(request, + "{\"server\":{\"name\":\"ralphie\",\"imageRef\":2,\"flavorRef\":1,\"metadata\":{\"foo\":\"bar\"}}}", + "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 testDeleteImage() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("deleteImage", int.class); - HttpRequest request = processor.createRequest(method, 2); + public void testDeleteImage() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("deleteImage", int.class); + HttpRequest request = processor.createRequest(method, 2); - assertRequestLineEquals(request, "DELETE http://endpoint/vapiversion/images/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "DELETE http://endpoint/vapiversion/images/2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.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 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, "GET http://endpoint/vapiversion/servers?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); + Date now = new Date(10000000l); - 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)); + 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?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://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, 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 testListServersDetail() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listServers", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, withDetails()); + 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/servers/detail?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); + } - public void testGetServer() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("getServer", int.class); - HttpRequest request = processor.createRequest(method, 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/servers/2?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/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, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.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 testListFlavors() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); + HttpRequest request = processor.createRequest(method); - 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://endpoint/vapiversion/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 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 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?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://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); - 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 testListFlavorsDetail() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, withDetails()); + 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/detail?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/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, 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 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/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://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); - 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 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/flavors/2?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/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, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.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 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 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/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 testListImagesDetail() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listImages", listOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, withDetails()); + 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 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://endpoint/vapiversion/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 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 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?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://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); - 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 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, - "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://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); - 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 testGetImage() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("getImage", int.class); + HttpRequest request = processor.createRequest(method, 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://endpoint/vapiversion/images/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, ReturnNullOnNotFoundOr404.class); + 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 testDeleteServer() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("deleteServer", int.class); + HttpRequest request = processor.createRequest(method, 2); - assertRequestLineEquals(request, "DELETE http://endpoint/vapiversion/servers/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "DELETE http://endpoint/vapiversion/servers/2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class); - checkFilters(request); - } + 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"); + 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://endpoint/vapiversion/servers/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, "{\"server\":{\"adminPass\":\"foo\"}}", MediaType.APPLICATION_JSON, false); + assertRequestLineEquals(request, "PUT http://endpoint/vapiversion/servers/2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, "{\"server\":{\"adminPass\":\"foo\"}}", MediaType.APPLICATION_JSON, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); + 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 testChangeServerName() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("renameServer", int.class, String.class); + HttpRequest request = processor.createRequest(method, 2, "foo"); - assertRequestLineEquals(request, "PUT http://endpoint/vapiversion/servers/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, "{\"server\":{\"name\":\"foo\"}}", MediaType.APPLICATION_JSON, false); + assertRequestLineEquals(request, "PUT http://endpoint/vapiversion/servers/2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, "{\"server\":{\"name\":\"foo\"}}", MediaType.APPLICATION_JSON, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - 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 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?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + 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); - 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 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/ips/public?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); - assertPayloadEquals(request, null, null, false); + 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); - 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); + } - @Test - public void testListPrivateAddresses() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("listPrivateAddresses", int.class); - HttpRequest request = processor.createRequest(method, 2); + @Test + public void testListPrivateAddresses() throws IOException, SecurityException, NoSuchMethodException { + Method method = NovaAsyncClient.class.getMethod("listPrivateAddresses", 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://endpoint/vapiversion/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, ReturnEmptySetOnNotFoundOr404.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); + @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); - 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, "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); - 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); - } + } - private static final Class rebuildServerOptionsVarargsClass = new RebuildServerOptions[]{} - .getClass(); + private static final Class rebuildServerOptionsVarargsClass = new RebuildServerOptions[]{} + .getClass(); - @Test - public void testRebuildServer() throws IOException, SecurityException, NoSuchMethodException { - Method method = NovaAsyncClient.class.getMethod("rebuildServer", int.class, - rebuildServerOptionsVarargsClass); - HttpRequest request = processor.createRequest(method, 3); + @Test + 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/3/action?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, "{\"rebuild\":{}}", MediaType.APPLICATION_JSON, false); + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/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); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - @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")); + @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)); - assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/3/action?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, "{\"rebuild\":{\"imageRef\":2}}", MediaType.APPLICATION_JSON, false); + assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/3/action?format=json HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, "{\"rebuild\":{\"imageRef\":2}}", MediaType.APPLICATION_JSON, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - @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); + @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); - 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://endpoint/vapiversion/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); - } - - @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; - } + 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; + } } diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java index 1984d1a986..ef8735c34c 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java @@ -16,35 +16,23 @@ * limitations under the License. * ==================================================================== */ + package org.jclouds.openstack.nova; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.openstack.nova.PropertyHelper.overridePropertyFromSystemProperty; -import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withFile; -import static org.jclouds.openstack.nova.options.ListOptions.Builder.withDetails; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.io.IOException; -import java.security.SecureRandom; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.concurrent.TimeUnit; - +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.inject.Injector; +import com.google.inject.Module; import org.jclouds.Constants; +import org.jclouds.compute.domain.ExecResponse; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpResponseException; import org.jclouds.io.Payload; import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; import org.jclouds.net.IPSocket; -import org.jclouds.openstack.nova.domain.Flavor; -import org.jclouds.openstack.nova.domain.Image; -import org.jclouds.openstack.nova.domain.ImageStatus; -import org.jclouds.openstack.nova.domain.RebootType; -import org.jclouds.openstack.nova.domain.Server; -import org.jclouds.openstack.nova.domain.ServerStatus; +import org.jclouds.openstack.nova.domain.*; import org.jclouds.openstack.nova.options.RebuildServerOptions; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; @@ -56,12 +44,18 @@ import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.inject.Injector; -import com.google.inject.Module; +import java.io.IOException; +import java.security.SecureRandom; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.openstack.nova.PropertyHelper.overridePropertyFromSystemProperty; +import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withFile; +import static org.jclouds.openstack.nova.options.ListOptions.Builder.withDetails; +import static org.testng.Assert.*; /** * Tests behavior of {@code NovaClient} @@ -81,6 +75,15 @@ public class NovaClientLiveTest { protected String endpoint; protected String apiversion; + private String serverPrefix = System.getProperty("user.name") + ".cs"; + private int serverId; + private String adminPass; + Map metadata = ImmutableMap.of("jclouds", "rackspace"); + private String ip; + private int serverId2; + private String adminPass2; + private int imageId; + protected Properties setupProperties() throws IOException { Properties overrides = new Properties(); @@ -212,14 +215,14 @@ public class NovaClientLiveTest { public void testGetServersDetail() throws Exception { Set response = client.listServers(withDetails()); assert null != response; - long serverCount = response.size(); - assertTrue(serverCount >= 0); + assertTrue(response.size() >= 0); for (Server server : response) { Server newDetails = client.getServer(server.getId()); assertEquals(server, newDetails); } } + @Test public void testListFlavors() throws Exception { Set response = client.listFlavors(); assert null != response; @@ -232,6 +235,7 @@ public class NovaClientLiveTest { } + @Test public void testListFlavorsDetail() throws Exception { Set response = client.listFlavors(withDetails()); assert null != response; @@ -245,6 +249,7 @@ public class NovaClientLiveTest { } } + @Test public void testGetFlavorsDetail() throws Exception { Set response = client.listFlavors(withDetails()); assert null != response; @@ -261,17 +266,10 @@ public class NovaClientLiveTest { assert client.getFlavor(12312987) == null; } - private String serverPrefix = System.getProperty("user.name") + ".cs"; - private int serverId; - private String adminPass; - Map metadata = ImmutableMap.of("jclouds", "rackspace"); - private int serverId2; - private int imageId; - @Test(enabled = true) public void testCreateServer() throws Exception { - String imageRef = "3"; - String flavorRef = "1"; + String imageRef = client.getImage(13).getURI().toASCIIString(); + String flavorRef = client.getFlavor(1).getURI().toASCIIString(); String serverName = serverPrefix + "createserver" + new SecureRandom().nextInt(); Server server = client.createServer(serverName, imageRef, flavorRef, withFile("/etc/jclouds.txt", "rackspace".getBytes()).withMetadata(metadata)); @@ -281,7 +279,7 @@ public class NovaClientLiveTest { serverId = server.getId(); adminPass = server.getAdminPass(); blockUntilServerActive(serverId); - client.getServer(serverId).getAddresses().getPublicAddresses().iterator().next().getAddress(); + ip = client.getServer(serverId).getAddresses().getPublicAddresses().iterator().next().getAddress(); } private void blockUntilServerActive(int serverId) throws InterruptedException { @@ -311,16 +309,23 @@ public class NovaClientLiveTest { } } - @Test(enabled = false, timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateServer") + @Test(enabled = true, timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateServer") public void testServerDetails() throws Exception { Server server = client.getServer(serverId); assertNotNull(server.getHostId()); assertEquals(server.getStatus(), ServerStatus.ACTIVE); - assert server.getProgress() >= 0 : "newDetails.getProgress()" + server.getProgress(); - assertEquals("3", server.getImageRef()); - assertEquals("1", server.getFlavorRef()); + + assertNotNull(server.getAddresses()); + + + // check metadata + assertEquals(server.getMetadata(), metadata); + assertPassword(server, adminPass); + assertEquals(server.getFlavorRef(), endpoint + "/flavors/1"); + assert server.getProgress() >= 0 : "newDetails.getProgress()" + server.getProgress(); + assertEquals(server.getImageRef(), endpoint + "/images/13"); // listAddresses tests.. assertEquals(client.getAddresses(serverId), server.getAddresses()); assertEquals(server.getAddresses().getPublicAddresses().size(), 1); @@ -328,9 +333,6 @@ public class NovaClientLiveTest { assertEquals(server.getAddresses().getPrivateAddresses().size(), 1); assertEquals(client.listPrivateAddresses(serverId), server.getAddresses().getPrivateAddresses()); - // check metadata - assertEquals(server.getMetadata(), metadata); - assertPassword(server, adminPass); } @@ -350,6 +352,19 @@ public class NovaClientLiveTest { } } + private ExecResponse exec(Server details, String pass, String command) throws IOException { + IPSocket socket = new IPSocket(Iterables.get(details.getAddresses().getPublicAddresses(), 0).getAddress(), 22); + socketTester.apply(socket); + SshClient client = sshFactory.create(socket, new Credentials("root", pass)); + try { + client.connect(); + return client.exec(command); + } finally { + if (client != null) + client.disconnect(); + } + } + @Test(enabled = false, timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateServer") public void testRenameServer() throws Exception { Server server = client.getServer(serverId); @@ -367,18 +382,37 @@ public class NovaClientLiveTest { this.adminPass = "elmo"; } + private void assertIpConfigured(Server server, String password) { + try { + ExecResponse response = exec(server, password, "ifconfig -a"); + assert response.getOutput().indexOf(ip) > 0 : String.format("server %s didn't get ip %s%n%s", server, ip, + response); + } catch (Exception e) { + e.printStackTrace(); + } catch (AssertionError e) { + e.printStackTrace(); + } + } + + private void assertIpNotConfigured(Server server, String password) throws IOException { + ExecResponse response = exec(server, password, "ifconfig -a"); + assert response.getOutput().indexOf(ip) == -1 : String.format("server %s still has get ip %s%n%s", server, ip, + response); + } + + @Test(enabled = false, timeOut = 10 * 60 * 1000, dependsOnMethods = "testBackup") public void testCreateImage() throws Exception { Image image = client.createImageFromServer("hoofie", serverId); assertEquals("hoofie", image.getName()); - assertEquals(new Integer(serverId), image.getServerRef()); + assertEquals(serverId, image.getServerRef()); imageId = image.getId(); blockUntilImageActive(imageId); } @Test(enabled = false, timeOut = 10 * 60 * 1000, dependsOnMethods = "testCreateImage") public void testRebuildServer() throws Exception { - client.rebuildServer(serverId, new RebuildServerOptions().withImage(String.valueOf(imageId))); + client.rebuildServer(serverId, new RebuildServerOptions().withImage(imageId)); blockUntilServerActive(serverId); // issue Web Hosting #119580 imageId comes back incorrect after rebuild assertEquals(imageId, client.getServer(serverId).getImageRef()); @@ -442,7 +476,7 @@ public class NovaClientLiveTest { @AfterTest void deleteServersOnEnd() { if (serverId > 0) { - client.deleteServer(serverId); + //client.deleteServer(serverId); } if (serverId2 > 0) { client.deleteServer(serverId2); diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/PropertyHelper.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/PropertyHelper.java index f91d323ceb..0a0432420b 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/PropertyHelper.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/PropertyHelper.java @@ -11,10 +11,10 @@ import java.util.Properties; */ public class PropertyHelper { - public static void overridePropertyFromSystemProperty(final Properties properties, String propertyName) { - if ((System.getProperty(propertyName) != null) && !System.getProperty(propertyName).equals("${" + propertyName + "}")) - properties.setProperty(propertyName, System.getProperty(propertyName)); - } + public static void overridePropertyFromSystemProperty(final Properties properties, String propertyName) { + if ((System.getProperty(propertyName) != null) && !System.getProperty(propertyName).equals("${" + propertyName + "}")) + properties.setProperty(propertyName, System.getProperty(propertyName)); + } } diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/compute/functions/FlavorToHardwareTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/compute/functions/FlavorToHardwareTest.java index b1aada24be..fdab38a748 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/compute/functions/FlavorToHardwareTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/compute/functions/FlavorToHardwareTest.java @@ -16,27 +16,21 @@ * limitations under the License. * ==================================================================== */ + package org.jclouds.openstack.nova.compute.functions; -import static org.testng.Assert.assertEquals; - -import java.net.URI; -import java.net.URISyntaxException; -import java.net.UnknownHostException; - -import org.jclouds.openstack.nova.domain.Flavor; -import org.jclouds.openstack.nova.functions.ParseFlavorFromJsonResponseTest; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.domain.Processor; -import org.jclouds.compute.domain.Volume; -import org.jclouds.compute.domain.VolumeBuilder; +import com.google.common.collect.ImmutableList; +import org.jclouds.compute.domain.*; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationScope; +import org.jclouds.openstack.nova.domain.Flavor; +import org.jclouds.openstack.nova.functions.ParseFlavorFromJsonResponseTest; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableList; +import java.net.UnknownHostException; + +import static org.testng.Assert.assertEquals; /** * @author Adrian Cole @@ -46,16 +40,11 @@ public class FlavorToHardwareTest { Location provider = new LocationBuilder().scope(LocationScope.ZONE).id("dallas").description("description").build(); @Test - public void test() throws UnknownHostException, URISyntaxException { - Hardware flavor = convertFlavor(); - Hardware tempFlavor = new HardwareBuilder().ids("1").name("256 MB Server") - .processors(ImmutableList.of(new Processor(1.0, 1.0))) - .ram(256) - .volumes(ImmutableList.of( - new VolumeBuilder().type(Volume.Type.LOCAL).size(10.0f).durable(true).bootDevice(true).build())) - .uri(new URI("http://servers.api.openstack.org/v1.1/1234/flavors/1")) - .build(); - assertEquals(flavor, tempFlavor); + public void test() throws UnknownHostException { + assertEquals(convertFlavor(), new HardwareBuilder().ids("1").name("256 MB Server").processors( + ImmutableList.of(new Processor(1.0, 1.0))).ram(256).volumes( + ImmutableList.of(new VolumeBuilder().type(Volume.Type.LOCAL).size(10.0f).durable(true).bootDevice(true) + .build())).build()); } public static Hardware convertFlavor() { diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/compute/functions/NovaImageToImageTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/compute/functions/NovaImageToImageTest.java index e780ba0c2d..d5dc9151ea 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/compute/functions/NovaImageToImageTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/compute/functions/NovaImageToImageTest.java @@ -18,6 +18,7 @@ */ package org.jclouds.openstack.nova.compute.functions; +import com.google.inject.AbstractModule; import com.google.inject.Guice; import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.domain.Image; @@ -27,7 +28,6 @@ import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.domain.Credentials; import org.jclouds.json.Json; -import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.nova.functions.ParseImageFromJsonResponseTest; import org.testng.annotations.Test; @@ -41,25 +41,30 @@ import static org.testng.Assert.assertEquals; @Test(groups = "unit") public class NovaImageToImageTest { - @Test - public void testApplyWhereImageNotFound() throws UnknownHostException { - assertEquals( - convertImage(), - new ImageBuilder() - .name("CentOS 5.2") - .operatingSystem( - new OperatingSystem.Builder().family(OsFamily.CENTOS).version("5.2").description("CentOS 5.2").is64Bit(true) - .build()).description("CentOS 5.2").defaultCredentials(new Credentials("root", null)) - .ids("2").version("1286712000000").build()); - } + @Test + public void testApplyWhereImageNotFound() throws UnknownHostException { + assertEquals( + convertImage(), + new ImageBuilder() + .name("CentOS 5.2") + .operatingSystem( + new OperatingSystem.Builder().family(OsFamily.CENTOS).version("5.2").description("CentOS 5.2").is64Bit(true) + .build()).description("CentOS 5.2").defaultCredentials(new Credentials("root", null)) + .ids("2").version("1286712000000").build()); + } - public static Image convertImage() { - org.jclouds.openstack.nova.domain.Image image = ParseImageFromJsonResponseTest.parseImage(); + public static Image convertImage() { + org.jclouds.openstack.nova.domain.Image image = ParseImageFromJsonResponseTest.parseImage(); - NovaImageToImage parser = new NovaImageToImage(new NovaImageToOperatingSystem(new BaseComputeServiceContextModule() { - }.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(new GsonModule()) - .getInstance(Json.class)))); + NovaImageToImage parser = new NovaImageToImage(new NovaImageToOperatingSystem(new BaseComputeServiceContextModule() { + }.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(new AbstractModule() { + @Override + protected void configure() { + //To change body of implemented methods use File | Settings | File Templates. + } + }) + .getInstance(Json.class)))); - return parser.apply(image); - } + return parser.apply(image); + } } diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/compute/functions/ServerToNodeMetadataTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/compute/functions/ServerToNodeMetadataTest.java index 8ae3a15b54..674f75b38e 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/compute/functions/ServerToNodeMetadataTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/compute/functions/ServerToNodeMetadataTest.java @@ -44,102 +44,102 @@ import static org.testng.Assert.assertEquals; */ @Test(groups = "unit") public class ServerToNodeMetadataTest { - Location provider = new LocationBuilder().scope(LocationScope.ZONE).id("dallas").description("description").build(); + Location provider = new LocationBuilder().scope(LocationScope.ZONE).id("dallas").description("description").build(); - @Test - public void testApplyWhereImageAndHardwareNotFoundButCredentialsFound() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException { - Credentials creds = new Credentials("root", "abdce"); + @Test + public void testApplyWhereImageAndHardwareNotFoundButCredentialsFound() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException { + Credentials creds = new Credentials("root", "abdce"); - Map serverStateToNodeState = NovaComputeServiceDependenciesModule.serverToNodeState; - Set images = ImmutableSet.of(); - Set hardwares = ImmutableSet.of(); - Server server = ParseServerFromJsonResponseTest.parseServer(); + Map serverStateToNodeState = NovaComputeServiceDependenciesModule.serverToNodeState; + Set images = ImmutableSet.of(); + Set hardwares = ImmutableSet.of(); + Server server = ParseServerFromJsonResponseTest.parseServer(); - ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, ImmutableMap - .of("node#1234", creds), Suppliers.>ofInstance(images), - Suppliers.ofInstance(provider), Suppliers.>ofInstance(hardwares)); + ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, ImmutableMap + .of("node#1234", creds), Suppliers.>ofInstance(images), + Suppliers.ofInstance(provider), Suppliers.>ofInstance(hardwares)); - NodeMetadata metadata = parser.apply(server); + NodeMetadata metadata = parser.apply(server); - assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( - ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16")) - .imageId("2").id("1234").providerId("1234").name("sample-server").credentials(creds).location( - new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0") - .description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()) - .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); - } + assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( + ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16")) + .imageId("2").id("1234").providerId("1234").name("sample-server").credentials(creds).location( + new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0") + .description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()) + .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); + } - @Test - public void testApplyWhereImageAndHardwareNotFound() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException { - Map serverStateToNodeState = NovaComputeServiceDependenciesModule.serverToNodeState; - Set images = ImmutableSet.of(); - Set hardwares = ImmutableSet.of(); - Server server = ParseServerFromJsonResponseTest.parseServer(); + @Test + public void testApplyWhereImageAndHardwareNotFound() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException { + Map serverStateToNodeState = NovaComputeServiceDependenciesModule.serverToNodeState; + Set images = ImmutableSet.of(); + Set hardwares = ImmutableSet.of(); + Server server = ParseServerFromJsonResponseTest.parseServer(); - ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, ImmutableMap - .of(), Suppliers.>ofInstance(images), Suppliers - .ofInstance(provider), Suppliers.>ofInstance(hardwares)); + ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, ImmutableMap + .of(), Suppliers.>ofInstance(images), Suppliers + .ofInstance(provider), Suppliers.>ofInstance(hardwares)); - NodeMetadata metadata = parser.apply(server); + NodeMetadata metadata = parser.apply(server); - assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( - ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16")) - .imageId("2").id("1234").providerId("1234").name("sample-server").location( - new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0") - .description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()) - .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); + assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( + ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16")) + .imageId("2").id("1234").providerId("1234").name("sample-server").location( + new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0") + .description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()) + .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); - } + } - @Test - public void testApplyWhereImageFoundAndHardwareNotFound() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException { - Map serverStateToNodeState = NovaComputeServiceDependenciesModule.serverToNodeState; - org.jclouds.compute.domain.Image jcImage = NovaImageToImageTest.convertImage(); - Set images = ImmutableSet.of(jcImage); - Set hardwares = ImmutableSet.of(); - Server server = ParseServerFromJsonResponseTest.parseServer(); + @Test + public void testApplyWhereImageFoundAndHardwareNotFound() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException { + Map serverStateToNodeState = NovaComputeServiceDependenciesModule.serverToNodeState; + org.jclouds.compute.domain.Image jcImage = NovaImageToImageTest.convertImage(); + Set images = ImmutableSet.of(jcImage); + Set hardwares = ImmutableSet.of(); + Server server = ParseServerFromJsonResponseTest.parseServer(); - ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, ImmutableMap - .of(), Suppliers.>ofInstance(images), Suppliers - .ofInstance(provider), Suppliers.>ofInstance(hardwares)); + ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, ImmutableMap + .of(), Suppliers.>ofInstance(images), Suppliers + .ofInstance(provider), Suppliers.>ofInstance(hardwares)); - NodeMetadata metadata = parser.apply(server); + NodeMetadata metadata = parser.apply(server); - assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( - ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16")) - .imageId("2").operatingSystem( - new OperatingSystemBuilder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") - .is64Bit(true).build()).id("1234").providerId("1234").name("sample-server").location( - new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0") - .description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()) - .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); + assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( + ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16")) + .imageId("2").operatingSystem( + new OperatingSystemBuilder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") + .is64Bit(true).build()).id("1234").providerId("1234").name("sample-server").location( + new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0") + .description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()) + .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); - } + } - @Test - public void testApplyWhereImageAndHardwareFound() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException { - Map serverStateToNodeState = NovaComputeServiceDependenciesModule.serverToNodeState; - Set images = ImmutableSet.of(NovaImageToImageTest.convertImage()); - Set hardwares = ImmutableSet.of(FlavorToHardwareTest.convertFlavor()); - Server server = ParseServerFromJsonResponseTest.parseServer(); + @Test + public void testApplyWhereImageAndHardwareFound() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException { + Map serverStateToNodeState = NovaComputeServiceDependenciesModule.serverToNodeState; + Set images = ImmutableSet.of(NovaImageToImageTest.convertImage()); + Set hardwares = ImmutableSet.of(FlavorToHardwareTest.convertFlavor()); + Server server = ParseServerFromJsonResponseTest.parseServer(); - ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, ImmutableMap - .of(), Suppliers.>ofInstance(images), Suppliers - .ofInstance(provider), Suppliers.>ofInstance(hardwares)); + ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, ImmutableMap + .of(), Suppliers.>ofInstance(images), Suppliers + .ofInstance(provider), Suppliers.>ofInstance(hardwares)); - NodeMetadata metadata = parser.apply(server); + NodeMetadata metadata = parser.apply(server); - assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( - ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16")) - .imageId("2").hardware( - new HardwareBuilder().ids("1").name("256 MB Server").processors( - ImmutableList.of(new Processor(1.0, 1.0))).ram(256).volumes( - ImmutableList.of(new VolumeBuilder().type(Volume.Type.LOCAL).size(10.0f).durable(true) - .bootDevice(true).build())).build()).operatingSystem( - new OperatingSystemBuilder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") - .is64Bit(true).build()).id("1234").providerId("1234").name("sample-server").location( - new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0") - .description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()) - .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); - } + assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( + ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16")) + .imageId("2").hardware( + new HardwareBuilder().ids("1").name("256 MB Server").processors( + ImmutableList.of(new Processor(1.0, 1.0))).ram(256).volumes( + ImmutableList.of(new VolumeBuilder().type(Volume.Type.LOCAL).size(10.0f).durable(true) + .bootDevice(true).build())).build()).operatingSystem( + new OperatingSystemBuilder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") + .is64Bit(true).build()).id("1234").providerId("1234").name("sample-server").location( + new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0") + .description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()) + .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); + } } diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/domain/ServerTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/domain/ServerTest.java index bbeefa7dfe..e9e81f2800 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/domain/ServerTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/domain/ServerTest.java @@ -18,13 +18,13 @@ */ package org.jclouds.openstack.nova.domain; -import static org.testng.Assert.assertEquals; - import org.testng.annotations.Test; +import static org.testng.Assert.assertEquals; + /** * Tests behavior of {@code CreateImageBinder} - * + * * @author Adrian Cole */ @Test(groups = "unit") diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseAddressesFromJsonResponseTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseAddressesFromJsonResponseTest.java index ebf522ff81..de27b9931c 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseAddressesFromJsonResponseTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseAddressesFromJsonResponseTest.java @@ -18,12 +18,11 @@ */ package org.jclouds.openstack.nova.functions; -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.UnknownHostException; -import java.util.List; - +import com.google.common.collect.ImmutableSet; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.TypeLiteral; import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.io.Payloads; @@ -32,13 +31,10 @@ import org.jclouds.openstack.nova.domain.Address; import org.jclouds.openstack.nova.domain.Addresses; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Key; -import com.google.inject.TypeLiteral; +import java.io.InputStream; +import java.net.UnknownHostException; + +import static org.testng.Assert.assertEqualsNoOrder; /** * Tests behavior of {@code ParseAddressesFromJsonResponse} @@ -47,24 +43,23 @@ import com.google.inject.TypeLiteral; */ @Test(groups = "unit") public class ParseAddressesFromJsonResponseTest { - Injector i = Guice.createInjector(new GsonModule()); + Injector i = Guice.createInjector(new GsonModule()); - @Test - public void testApplyInputStreamDetails() throws UnknownHostException { - InputStream is = getClass().getResourceAsStream("/test_list_addresses.json"); + @Test + public void testApplyInputStreamDetails() throws UnknownHostException { + InputStream is = getClass().getResourceAsStream("/test_list_addresses.json"); - UnwrapOnlyJsonValue parser = i.getInstance(Key.get(new TypeLiteral>() {})); - Addresses response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); + UnwrapOnlyJsonValue parser = i.getInstance(Key.get(new TypeLiteral>() { + })); + Addresses response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); - List
publicAddresses = ImmutableList.copyOf( - Iterables.transform(ImmutableList.of("67.23.10.132", "::babe:67.23.10.132", "67.23.10.131", "::babe:4317:0A83"), - Address.newString2AddressFunction())); + ImmutableSet
publicAddresses = ImmutableSet.of(new Address("67.23.10.132", 4) + , new Address("::babe:67.23.10.132", 6), new Address("67.23.10.131", 4), new Address("::babe:4317:0A83", 6)); - List
privateAddresses = ImmutableList.copyOf( - Iterables.transform(ImmutableList.of("10.176.42.16", "::babe:10.176.42.16"), - Address.newString2AddressFunction())); + ImmutableSet
privateAddresses = ImmutableSet.of(new Address("10.176.42.16", 4), + new Address("::babe:10.176.42.16", 6)); - assertEquals(response.getPublicAddresses(), Sets.newHashSet(publicAddresses)); - assertEquals(response.getPrivateAddresses(), Sets.newHashSet(privateAddresses)); - } + assertEqualsNoOrder(response.getPublicAddresses().toArray(), publicAddresses.toArray()); + assertEqualsNoOrder(response.getPrivateAddresses().toArray(), privateAddresses.toArray()); + } } diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseFaultFromJsonResponseTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseFaultFromJsonResponseTest.java index 4881949d35..3b382b22fd 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseFaultFromJsonResponseTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseFaultFromJsonResponseTest.java @@ -19,11 +19,10 @@ package org.jclouds.openstack.nova.functions; -import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.List; - +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.TypeLiteral; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; @@ -34,10 +33,10 @@ import org.jclouds.openstack.nova.domain.Server; import org.jclouds.openstack.nova.handlers.ParseNovaErrorFromHttpResponse; import org.testng.annotations.Test; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Key; -import com.google.inject.TypeLiteral; +import java.io.InputStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; /** * Tests behavior of {@code ParseServerListFromJsonResponse} @@ -47,25 +46,25 @@ import com.google.inject.TypeLiteral; @Test(groups = "unit") public class ParseFaultFromJsonResponseTest { - Injector i = Guice.createInjector(new GsonModule()); + Injector i = Guice.createInjector(new GsonModule()); - @Test - public void testApplyInputStream() { - InputStream is = getClass().getResourceAsStream("/test_list_servers.json"); + @Test + public void testApplyInputStream() { + InputStream is = getClass().getResourceAsStream("/test_list_servers.json"); - UnwrapOnlyJsonValue> parser = i.getInstance(Key - .get(new TypeLiteral>>() { - })); - //List response = parser.apply(new HttpResponse(413, "Over limit", Payloads.newInputStreamPayload(is))); - new ParseNovaErrorFromHttpResponse().handleError(createHttpCommand(), new HttpResponse(413, "Over limit", Payloads.newInputStreamPayload(is))); + UnwrapOnlyJsonValue> parser = i.getInstance(Key + .get(new TypeLiteral>>() { + })); + //List response = parser.apply(new HttpResponse(413, "Over limit", Payloads.newInputStreamPayload(is))); + new ParseNovaErrorFromHttpResponse().handleError(createHttpCommand(), new HttpResponse(413, "Over limit", Payloads.newInputStreamPayload(is))); - //assertEquals(response, expects); - } + //assertEquals(response, expects); + } - @Test - public void testHandler() { - //InputStream is = getClass().getResourceAsStream("/test_error_handler.json"); + @Test + public void testHandler() { + //InputStream is = getClass().getResourceAsStream("/test_error_handler.json"); // // @@ -90,62 +89,62 @@ public class ParseFaultFromJsonResponseTest { // } catch (IOException e) { // // this is the excepted output // } - } + } - HttpCommand createHttpCommand() { - return new HttpCommand() { - private Exception exception; + HttpCommand createHttpCommand() { + return new HttpCommand() { + private Exception exception; - @Override - public int incrementRedirectCount() { - return 0; //To change body of implemented methods use File | Settings | File Templates. + @Override + public int incrementRedirectCount() { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public int getRedirectCount() { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public boolean isReplayable() { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public int incrementFailureCount() { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public int getFailureCount() { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public HttpRequest getCurrentRequest() { + try { + return new HttpRequest("method", new URI("http://endpoint")); + } catch (URISyntaxException e) { + throw new RuntimeException(e); } + } - @Override - public int getRedirectCount() { - return 0; //To change body of implemented methods use File | Settings | File Templates. - } + @Override + public void setCurrentRequest(HttpRequest request) { + //To change body of implemented methods use File | Settings | File Templates. + } - @Override - public boolean isReplayable() { - return false; //To change body of implemented methods use File | Settings | File Templates. - } + @Override + public void setException(Exception exception) { + this.exception = exception; + } - @Override - public int incrementFailureCount() { - return 0; //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public int getFailureCount() { - return 0; //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public HttpRequest getCurrentRequest() { - try { - return new HttpRequest("method", new URI("http://endpoint")); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } - - @Override - public void setCurrentRequest(HttpRequest request) { - //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public void setException(Exception exception) { - this.exception = exception; - } - - @Override - public Exception getException() { - return exception; - } - }; - } + @Override + public Exception getException() { + return exception; + } + }; + } } diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseFlavorFromJsonResponseTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseFlavorFromJsonResponseTest.java index 10ad7d36a9..7b9b01d8d9 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseFlavorFromJsonResponseTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseFlavorFromJsonResponseTest.java @@ -18,11 +18,11 @@ */ package org.jclouds.openstack.nova.functions; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.io.InputStream; - +import com.google.gson.Gson; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.TypeLiteral; import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.io.Payloads; @@ -30,10 +30,11 @@ import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.nova.domain.Flavor; import org.testng.annotations.Test; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Key; -import com.google.inject.TypeLiteral; +import java.io.IOException; +import java.io.InputStream; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; /** * Tests behavior of {@code ParseFlavorFromJsonResponse} @@ -43,24 +44,27 @@ import com.google.inject.TypeLiteral; @Test(groups = "unit") public class ParseFlavorFromJsonResponseTest { - @Test - public void testParseFlavorFromJsonResponseTest() throws IOException { - Flavor response = parseFlavor(); + @Test + public void testParseFlavorFromJsonResponseTest() throws IOException { + Flavor response = parseFlavor(); - assertEquals(response.getId(), 1); - assertEquals(response.getName(), "256 MB Server"); - assertEquals(response.getDisk().intValue(), 10); - assertEquals(response.getRam().intValue(), 256); - } + String json = new Gson().toJson(response); + assertNotNull(json); - public static Flavor parseFlavor() { - Injector i = Guice.createInjector(new GsonModule()); + assertEquals(response.getId(), 1); + assertEquals(response.getName(), "256 MB Server"); + assertEquals(response.getDisk().intValue(), 10); + assertEquals(response.getRam().intValue(), 256); + } - InputStream is = ParseFlavorFromJsonResponseTest.class.getResourceAsStream("/test_get_flavor_details.json"); + public static Flavor parseFlavor() { + Injector i = Guice.createInjector(new GsonModule()); - UnwrapOnlyJsonValue parser = i.getInstance(Key.get(new TypeLiteral>() { - })); - return parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); - } + InputStream is = ParseFlavorFromJsonResponseTest.class.getResourceAsStream("/test_get_flavor_details.json"); + + UnwrapOnlyJsonValue parser = i.getInstance(Key.get(new TypeLiteral>() { + })); + return parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); + } } diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseFlavorListFromJsonResponseTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseFlavorListFromJsonResponseTest.java index 064cac1561..1603185edd 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseFlavorListFromJsonResponseTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseFlavorListFromJsonResponseTest.java @@ -44,39 +44,39 @@ import static org.testng.Assert.assertEquals; @Test(groups = "unit") public class ParseFlavorListFromJsonResponseTest { - Injector i = Guice.createInjector(new GsonModule()); + Injector i = Guice.createInjector(new GsonModule()); - @Test - public void testApplyInputStream() { - InputStream is = getClass().getResourceAsStream("/test_list_flavors.json"); + @Test + public void testApplyInputStream() { + InputStream is = getClass().getResourceAsStream("/test_list_flavors.json"); - List expects = ImmutableList.of(new Flavor(1, "256 MB Server"), new Flavor(2, "512 MB Server")); + List expects = ImmutableList.of(new Flavor(1, "256 MB Server"), new Flavor(2, "512 MB Server")); - UnwrapOnlyJsonValue> parser = i.getInstance(Key - .get(new TypeLiteral>>() { - })); - List response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); - assertEquals(response, expects); - } + UnwrapOnlyJsonValue> parser = i.getInstance(Key + .get(new TypeLiteral>>() { + })); + List response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); + assertEquals(response, expects); + } - @Test - public void testApplyInputStreamDetails() throws UnknownHostException { - InputStream is = getClass().getResourceAsStream("/test_list_flavors_detail.json"); + @Test + public void testApplyInputStreamDetails() throws UnknownHostException { + InputStream is = getClass().getResourceAsStream("/test_list_flavors_detail.json"); - UnwrapOnlyJsonValue> parser = i.getInstance(Key - .get(new TypeLiteral>>() { - })); - List response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); - assertEquals(response.get(0).getId(), 1); - assertEquals(response.get(0).getName(), "256 MB Server"); - assertEquals(response.get(0).getDisk(), new Integer(10)); - assertEquals(response.get(0).getRam(), new Integer(256)); + UnwrapOnlyJsonValue> parser = i.getInstance(Key + .get(new TypeLiteral>>() { + })); + List response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); + assertEquals(response.get(0).getId(), 1); + assertEquals(response.get(0).getName(), "256 MB Server"); + assertEquals(response.get(0).getDisk(), new Integer(10)); + assertEquals(response.get(0).getRam(), new Integer(256)); - assertEquals(response.get(1).getId(), 2); - assertEquals(response.get(1).getName(), "512 MB Server"); - assertEquals(response.get(1).getDisk(), new Integer(20)); - assertEquals(response.get(1).getRam(), new Integer(512)); + assertEquals(response.get(1).getId(), 2); + assertEquals(response.get(1).getName(), "512 MB Server"); + assertEquals(response.get(1).getDisk(), new Integer(20)); + assertEquals(response.get(1).getRam(), new Integer(512)); - } + } } diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseImageFromJsonResponseTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseImageFromJsonResponseTest.java index d9357d0e98..550406e300 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseImageFromJsonResponseTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseImageFromJsonResponseTest.java @@ -42,49 +42,49 @@ import static org.testng.Assert.assertEquals; */ @Test(groups = "unit") public class ParseImageFromJsonResponseTest { - Injector i = Guice.createInjector(new AbstractModule() { + Injector i = Guice.createInjector(new AbstractModule() { - @Override - protected void configure() { + @Override + protected void configure() { + bind(DateAdapter.class).to(Iso8601DateAdapter.class); + } + + }, new GsonModule()); + + DateService dateService = i.getInstance(DateService.class); + + @Test + public void testApplyInputStreamDetails() throws UnknownHostException { + Image response = parseImage(); + + assertEquals(response.getId(), 2); + assertEquals(response.getName(), "CentOS 5.2"); + assertEquals(response.getCreated(), dateService.iso8601SecondsDateParse("2010-08-10T12:00:00Z")); + assertEquals(response.getProgress(), new Integer(80)); + assertEquals(response.getStatus(), ImageStatus.SAVING); + assertEquals(response.getUpdated(), dateService.iso8601SecondsDateParse(("2010-10-10T12:00:00Z"))); + assertEquals(response.getServerRef(), "http://servers.api.openstack.org/v1.1/1234/servers/12"); + assertEquals(response.getMetadata().get("ImageVersion"), "1.5"); + assertEquals(response.getMetadata().get("ImageType"), "Gold"); + assertEquals(response.getMetadata().size(), 2); + } + + public static Image parseImage() { + Injector i = Guice.createInjector(new AbstractModule() { + + @Override + protected void configure() { bind(DateAdapter.class).to(Iso8601DateAdapter.class); - } + } - }, new GsonModule()); + }, new GsonModule()); - DateService dateService = i.getInstance(DateService.class); + InputStream is = ParseImageFromJsonResponseTest.class.getResourceAsStream("/test_get_image_details.json"); - @Test - public void testApplyInputStreamDetails() throws UnknownHostException { - Image response = parseImage(); - - assertEquals(response.getId(), 1); - assertEquals(response.getName(), "CentOS 5.2"); - assertEquals(response.getCreated(), dateService.iso8601SecondsDateParse("2010-08-10T12:00:00Z")); - assertEquals(response.getProgress(), new Integer(80)); - assertEquals(response.getStatus(), ImageStatus.SAVING); - assertEquals(response.getUpdated(), dateService.iso8601SecondsDateParse(("2010-10-10T12:00:00Z"))); - assertEquals(response.getServerRef(), "http://servers.api.openstack.org/v1.1/1234/servers/12"); - assertEquals(response.getMetadata().get("ImageVersion"), "1.5"); - assertEquals(response.getMetadata().get("ImageType"), "Gold"); - assertEquals(response.getMetadata().size(), 2); - } - - public static Image parseImage() { - Injector i = Guice.createInjector(new AbstractModule() { - - @Override - protected void configure() { - bind(DateAdapter.class).to(Iso8601DateAdapter.class); - } - - }, new GsonModule()); - - InputStream is = ParseImageFromJsonResponseTest.class.getResourceAsStream("/test_get_image_details.json"); - - UnwrapOnlyJsonValue parser = i.getInstance(Key.get(new TypeLiteral>() { - })); - Image response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); - return response; - } + UnwrapOnlyJsonValue parser = i.getInstance(Key.get(new TypeLiteral>() { + })); + Image response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); + return response; + } } diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseImageListFromJsonResponseTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseImageListFromJsonResponseTest.java index 4de761a6ac..9fe0df1e36 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseImageListFromJsonResponseTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseImageListFromJsonResponseTest.java @@ -44,57 +44,62 @@ import static org.testng.Assert.assertEquals; */ @Test(groups = "unit") public class ParseImageListFromJsonResponseTest { - Injector i = Guice.createInjector(new AbstractModule() { + Injector i = Guice.createInjector(new AbstractModule() { - @Override - protected void configure() { - bind(DateAdapter.class).to(Iso8601DateAdapter.class); - } + @Override + protected void configure() { + bind(DateAdapter.class).to(Iso8601DateAdapter.class); + } - }, new GsonModule()); - DateService dateService = i.getInstance(DateService.class); + }, new GsonModule()); + DateService dateService = i.getInstance(DateService.class); - @Test - public void testApplyInputStream() { - InputStream is = getClass().getResourceAsStream("/test_list_images.json"); + @Test + public void testApplyInputStream() { + InputStream is = getClass().getResourceAsStream("/test_list_images.json"); - List expects = ImmutableList.of(new Image(1, "CentOS 5.2"), new Image(743, "My Server Backup")); + List expects = ImmutableList.of(new Image(1, "CentOS 5.2"), new Image(743, "My Server Backup")); - UnwrapOnlyJsonValue> parser = i.getInstance( - Key.get(new TypeLiteral>>() {})); - List response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); + UnwrapOnlyJsonValue> parser = i.getInstance(Key + .get(new TypeLiteral>>() { + })); + List response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); - assertEquals(response, expects); - } + assertEquals(response, expects); + } - @Test - public void testApplyInputStreamDetails() throws UnknownHostException { - InputStream is = getClass().getResourceAsStream("/test_list_images_detail.json"); + @Test + public void testApplyInputStreamDetails() throws UnknownHostException { + InputStream is = getClass().getResourceAsStream("/test_list_images_detail.json"); - UnwrapOnlyJsonValue> parser = i.getInstance(Key - .get(new TypeLiteral>>() { - })); - List response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); + UnwrapOnlyJsonValue> parser = i.getInstance(Key + .get(new TypeLiteral>>() { + })); + List response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); - assertEquals(response.get(0).getId(), 1); - assertEquals(response.get(0).getName(), "CentOS 5.2"); - assertEquals(response.get(0).getCreated(), dateService.iso8601SecondsDateParse("2010-08-10T12:00:00Z")); - assertEquals(response.get(0).getProgress(), null); - assertEquals(response.get(0).getServerRef(), null); - assertEquals(response.get(0).getStatus(), ImageStatus.ACTIVE); - assertEquals(response.get(0).getUpdated(), dateService.iso8601SecondsDateParse("2010-10-10T12:00:00Z")); - assertEquals(response.get(0).getMetadata().get("ImageType"), "Gold"); - assertEquals(response.get(0).getMetadata().get("ImageVersion"), "1.5"); - assertEquals(response.get(0).getMetadata().size(), 2); + assertEquals(response.get(0).getId(), 1); + assertEquals(response.get(0).getName(), "CentOS 5.2"); + assertEquals(response.get(0).getCreated(), dateService.iso8601SecondsDateParse("2010-08-10T12:00:00Z")); + assertEquals(response.get(0).getProgress(), null); + assertEquals(response.get(0).getServerRef(), null); + assertEquals(response.get(0).getStatus(), ImageStatus.ACTIVE); + assertEquals(response.get(0).getUpdated(), dateService.iso8601SecondsDateParse("2010-10-10T12:00:00Z")); + assertEquals(response.get(0).getMetadata().get("ImageType"), "Gold"); + assertEquals(response.get(0).getMetadata().get("ImageVersion"), "1.5"); + assertEquals(response.get(0).getMetadata().size(), 2); - assertEquals(response.get(1).getId(), 743); - assertEquals(response.get(1).getName(), "My Server Backup"); - assertEquals(response.get(1).getCreated(), dateService.iso8601SecondsDateParse("2009-07-07T09:56:16Z")); - assertEquals(response.get(1).getProgress(), new Integer(80)); - assertEquals(response.get(1).getStatus(), ImageStatus.SAVING); - assertEquals(response.get(1).getUpdated(), dateService.iso8601SecondsDateParse("2010-10-10T12:00:00Z")); - assertEquals(response.get(1).getServerRef(), "http://servers.api.openstack.org/v1.1/1234/servers/12"); - } + assertEquals(response.get(1).getId(), 743); + assertEquals(response.get(1).getName(), "My Server Backup"); + assertEquals(response.get(1).getCreated(), dateService.iso8601SecondsDateParse("2009-07-07T09:56:16Z")); + + assertEquals(response.get(1).getProgress(), new Integer(80)); + assertEquals(response.get(1).getStatus(), ImageStatus.SAVING); + assertEquals(response.get(1).getUpdated(), dateService.iso8601SecondsDateParse("2010-10-10T12:00:00Z")); + assertEquals(response.get(1).getServerRef(), "http://servers.api.openstack.org/v1.1/1234/servers/12"); + + //short form of reference + assertEquals(response.get(2).getServerRef(), "12"); + } } diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseInetAddressListFromJsonResponseTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseInetAddressListFromJsonResponseTest.java index 12d7980a55..e34ffaf23b 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseInetAddressListFromJsonResponseTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseInetAddressListFromJsonResponseTest.java @@ -19,7 +19,6 @@ package org.jclouds.openstack.nova.functions; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; @@ -27,14 +26,12 @@ import com.google.inject.TypeLiteral; import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.io.Payloads; -import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.nova.domain.Address; import org.testng.annotations.Test; import java.io.InputStream; import java.net.UnknownHostException; import java.util.List; -import java.util.Map; import static org.testng.Assert.assertEquals; @@ -46,36 +43,35 @@ import static org.testng.Assert.assertEquals; @Test(groups = "unit") public class ParseInetAddressListFromJsonResponseTest { - Injector i = Guice.createInjector(new GsonModule()); + Injector i = Guice.createInjector(new ParserModule()); - @Test - public void testPublic() throws UnknownHostException { - InputStream is = getClass().getResourceAsStream("/test_list_addresses_public.json"); + @Test + public void testPublic() throws UnknownHostException { + InputStream is = getClass().getResourceAsStream("/test_list_addresses_public.json"); - UnwrapOnlyJsonValue>> parser = i.getInstance( - Key.get(new TypeLiteral>>>() {})); - List
response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))) - .get("public"); + UnwrapOnlyJsonValue> parser = i.getInstance(Key + .get(new TypeLiteral>>() { + })); + List
response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); - List
addresses = ImmutableList.copyOf(Iterables.transform( - ImmutableList.of("67.23.10.132", "::babe:67.23.10.132", "67.23.10.131", "::babe:4317:0A83"), - Address.newString2AddressFunction())); - assertEquals(response, addresses); - } + assertEquals(response, ImmutableList.of(Address.valueOf("67.23.10.132"), + Address.valueOf("::babe:67.23.10.132"), + Address.valueOf("67.23.10.131"), Address.valueOf("::babe:4317:0A83"))); + } - @Test - public void testPrivate() throws UnknownHostException { - InputStream is = getClass().getResourceAsStream("/test_list_addresses_private.json"); + @Test + public void testPrivate() throws UnknownHostException { + InputStream is = getClass().getResourceAsStream("/test_list_addresses_private.json"); - UnwrapOnlyJsonValue>> parser = i.getInstance( - Key.get(new TypeLiteral>>>() {})); - List
response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))) - .get("private"); - - List
addresses = ImmutableList.copyOf(Iterables.transform( - ImmutableList.of("67.23.10.132", "::babe:67.23.10.132", "67.23.10.131", "::babe:4317:0A83"), - Address.newString2AddressFunction())); + UnwrapOnlyJsonValue> parser = i.getInstance(Key + .get(new TypeLiteral>>() { + })); + List
response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); - assertEquals(response, addresses); - } + assertEquals(response, ImmutableList.of(Address.valueOf("67.23.10.132"), + Address.valueOf("::babe:67.23.10.132"), + Address.valueOf("67.23.10.131"), Address.valueOf("::babe:4317:0A83"))); + + + } } diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseModule.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseModule.java new file mode 100644 index 0000000000..8392b741c6 --- /dev/null +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseModule.java @@ -0,0 +1,19 @@ +package org.jclouds.openstack.nova.functions; + +import org.jclouds.json.config.GsonModule; + +/** + * Created by IntelliJ IDEA. + * User: VGalkin + * Date: 4/16/11 + * Time: 7:47 AM + * To change this template use File | Settings | File Templates. + */ +class ParserModule extends GsonModule { + + @Override + protected void configure() { + super.configure(); + bind(DateAdapter.class).to(Iso8601DateAdapter.class); + } +} diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerFromJsonResponseTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerFromJsonResponseTest.java index 7fd3e8f94d..70e12db6e0 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerFromJsonResponseTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerFromJsonResponseTest.java @@ -28,7 +28,6 @@ import com.google.inject.TypeLiteral; import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.io.Payloads; -import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.nova.domain.Address; import org.jclouds.openstack.nova.domain.Addresses; import org.jclouds.openstack.nova.domain.Server; @@ -37,8 +36,12 @@ import org.testng.annotations.Test; import java.io.InputStream; import java.net.UnknownHostException; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.HashSet; import java.util.List; +import java.util.Locale; +import java.util.SimpleTimeZone; import static org.testng.Assert.assertEquals; @@ -50,38 +53,46 @@ import static org.testng.Assert.assertEquals; @Test(groups = "unit") public class ParseServerFromJsonResponseTest { - @Test - public void testApplyInputStreamDetails() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException { - Server response = parseServer(); + @Test + public void testApplyInputStreamDetails() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException, ParseException { + Server response = parseServer(); - assertEquals(response.getId(), 1234); - assertEquals(response.getName(), "sample-server"); - assertEquals(response.getImageRef(), "https://servers.api.rackspacecloud.com/v1.1/32278/images/1234"); - assertEquals(response.getFlavorRef(), "https://servers.api.rackspacecloud.com/v1.1/32278/flavors/1"); - assertEquals(response.getHostId(), "e4d909c290d0fb1ca068ffaddf22cbd0"); - assertEquals(response.getStatus(), ServerStatus.BUILD); - assertEquals(response.getProgress(), new Integer(60)); + assertEquals(response.getId(), 1234); + assertEquals(response.getName(), "sample-server"); + assertEquals(response.getImageRef(), "https://servers.api.rackspacecloud.com/v1.1/32278/images/1234"); + assertEquals(response.getFlavorRef(), "https://servers.api.rackspacecloud.com/v1.1/32278/flavors/1"); + assertEquals(response.getHostId(), "e4d909c290d0fb1ca068ffaddf22cbd0"); + assertEquals(response.getStatus(), ServerStatus.BUILD); + assertEquals(response.getProgress(), new Integer(60)); + SimpleDateFormat dateFormat = new SimpleDateFormat( + "yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); + dateFormat.setTimeZone(new SimpleTimeZone(0, "GMT")); + assertEquals(response.getCreated(), + dateFormat.parse("2010-08-10T12:00:00Z")); + assertEquals(response.getUpdated(), + dateFormat.parse("2010-10-10T12:00:00Z")); - List
publicAddresses = ImmutableList.copyOf(Iterables.transform( - ImmutableList.of("67.23.10.132", "::babe:67.23.10.132", "67.23.10.131", "::babe:4317:0A83"), - Address.newString2AddressFunction())); - List
privateAddresses = ImmutableList.copyOf(Iterables.transform( - ImmutableList.of("10.176.42.16", "::babe:10.176.42.16"), - Address.newString2AddressFunction())); - Addresses addresses1 = new Addresses(new HashSet
(publicAddresses), new HashSet
(privateAddresses)); - assertEquals(response.getAddresses(), addresses1); - assertEquals(response.getMetadata(), ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")); - assertEquals(response.getAddresses(), addresses1); - } - public static Server parseServer() throws NoSuchMethodException, ClassNotFoundException { - Injector i = Guice.createInjector(new GsonModule()); + List
publicAddresses = ImmutableList.copyOf(Iterables.transform(ImmutableList.of("67.23.10.132", "::babe:67.23.10.132", "67.23.10.131", "::babe:4317:0A83"), Address.newString2AddressFunction())); + List
privateAddresses = ImmutableList.copyOf(Iterables.transform(ImmutableList.of("10.176.42.16", "::babe:10.176.42.16"), Address.newString2AddressFunction())); + Addresses addresses1 = new Addresses(new HashSet
(publicAddresses), new HashSet
(privateAddresses)); + assertEquals(response.getAddresses(), addresses1); + assertEquals(response.getMetadata(), ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")); + assertEquals(response.getAddresses(), addresses1); + } - InputStream is = ParseServerFromJsonResponseTest.class.getResourceAsStream("/test_get_server_detail.json"); - UnwrapOnlyJsonValue parser = i.getInstance(Key.get(new TypeLiteral>() {})); + public static Server parseServer() throws NoSuchMethodException, ClassNotFoundException { - return (Server) parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); - } + Injector i = Guice.createInjector(new ParserModule()); + + InputStream is = ParseServerFromJsonResponseTest.class.getResourceAsStream("/test_get_server_detail.json"); + + UnwrapOnlyJsonValue parser = i.getInstance(Key.get(new TypeLiteral>() { + })); + + //Function parser = i.getInstance(getParserOrThrowException(NovaClient.class.getMethod("getServer", int.class))); + return (Server) parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); + } } diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerListFromJsonResponseTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerListFromJsonResponseTest.java index f9bb444875..0c61c1deb7 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerListFromJsonResponseTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerListFromJsonResponseTest.java @@ -28,7 +28,6 @@ import com.google.inject.TypeLiteral; import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.io.Payloads; -import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.nova.domain.Address; import org.jclouds.openstack.nova.domain.Addresses; import org.jclouds.openstack.nova.domain.Server; @@ -36,8 +35,6 @@ import org.jclouds.openstack.nova.domain.ServerStatus; import org.testng.annotations.Test; import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; import java.net.UnknownHostException; import java.util.HashSet; import java.util.List; @@ -52,69 +49,62 @@ import static org.testng.Assert.assertEquals; @Test(groups = "unit") public class ParseServerListFromJsonResponseTest { - Injector i = Guice.createInjector(new GsonModule()); + Injector i = Guice.createInjector(new ParserModule()); - @Test - public void testApplyInputStream() { - InputStream is = getClass().getResourceAsStream("/test_list_servers.json"); + @Test + public void testApplyInputStream() { + InputStream is = getClass().getResourceAsStream("/test_list_servers.json"); - List expects = ImmutableList.of(new Server(1234, "sample-server"), new Server(5678, "sample-server2")); + List expects = ImmutableList.of(new Server(1234, "sample-server"), new Server(5678, "sample-server2")); - UnwrapOnlyJsonValue> parser = i.getInstance(Key - .get(new TypeLiteral>>() { - })); - List response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); + UnwrapOnlyJsonValue> parser = i.getInstance(Key + .get(new TypeLiteral>>() { + })); + List response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); - assertEquals(response, expects); - } + assertEquals(response, expects); + } - @Test - public void testApplyInputStreamDetails() throws UnknownHostException, URISyntaxException { - InputStream is = getClass().getResourceAsStream("/test_list_servers_detail.json"); + @Test + public void testApplyInputStreamDetails() throws UnknownHostException { + InputStream is = getClass().getResourceAsStream("/test_list_servers_detail.json"); - UnwrapOnlyJsonValue> parser = i.getInstance(Key - .get(new TypeLiteral>>() { - })); - List response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); + UnwrapOnlyJsonValue> parser = i.getInstance(Key + .get(new TypeLiteral>>() { + })); + List response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); - assertEquals(response.get(0).getId(), 1234); - assertEquals(response.get(0).getName(), "sample-server"); - assertEquals(response.get(0).getImageRef(), "https://servers.api.rackspacecloud.com/v1.1/32278/images/1234"); - assertEquals(response.get(0).getFlavorRef(), "https://servers.api.rackspacecloud.com/v1.1/32278/flavors/1"); - assertEquals(response.get(0).getHostId(), "e4d909c290d0fb1ca068ffaddf22cbd0"); - assertEquals(response.get(0).getStatus(), ServerStatus.BUILD); - assertEquals(response.get(0).getProgress(), new Integer(60)); + assertEquals(response.get(0).getId(), 1234); + assertEquals(response.get(0).getName(), "sample-server"); + assertEquals(response.get(0).getImageRef(), "https://servers.api.rackspacecloud.com/v1.1/32278/images/1234"); + assertEquals(response.get(0).getFlavorRef(), "https://servers.api.rackspacecloud.com/v1.1/32278/flavors/1"); + assertEquals(response.get(0).getHostId(), "e4d909c290d0fb1ca068ffaddf22cbd0"); + assertEquals(response.get(0).getStatus(), ServerStatus.BUILD); + assertEquals(response.get(0).getProgress(), new Integer(60)); - List
publicAddresses = ImmutableList.copyOf(Iterables.transform( - ImmutableList.of("67.23.10.132", "::babe:67.23.10.132", "67.23.10.131", "::babe:4317:0A83"), - Address.newString2AddressFunction())); - List
privateAddresses = ImmutableList.copyOf(Iterables.transform( - ImmutableList.of("10.176.42.16", "::babe:10.176.42.16"), - Address.newString2AddressFunction())); - Addresses addresses1 = new Addresses(new HashSet
(publicAddresses), new HashSet
(privateAddresses)); + List
publicAddresses = ImmutableList.copyOf(Iterables.transform(ImmutableList.of("67.23.10.132", "::babe:67.23.10.132", "67.23.10.131", "::babe:4317:0A83"), Address.newString2AddressFunction())); + List
privateAddresses = ImmutableList.copyOf(Iterables.transform(ImmutableList.of("10.176.42.16", "::babe:10.176.42.16"), Address.newString2AddressFunction())); + Addresses addresses1 = new Addresses(new HashSet
(publicAddresses), new HashSet
(privateAddresses)); - assertEquals(response.get(0).getAddresses(), addresses1); - assertEquals(response.get(0).getMetadata(), ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")); - assertEquals(response.get(1).getId(), 5678); - assertEquals(response.get(1).getName(), "sample-server2"); - assertEquals(response.get(0).getImageRef(), "https://servers.api.rackspacecloud.com/v1.1/32278/images/1234"); - assertEquals(response.get(0).getFlavorRef(), "https://servers.api.rackspacecloud.com/v1.1/32278/flavors/1"); - assertEquals(response.get(1).getHostId(), "9e107d9d372bb6826bd81d3542a419d6"); - assertEquals(response.get(1).getStatus(), ServerStatus.ACTIVE); - assertEquals(response.get(1).getProgress(), null); + assertEquals(response.get(0).getAddresses(), addresses1); + assertEquals(response.get(0).getMetadata(), ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")); + assertEquals(response.get(1).getId(), 5678); + assertEquals(response.get(1).getName(), "sample-server2"); + assertEquals(response.get(1).getImageRef(), "https://servers.api.rackspacecloud.com/v1.1/32278/images/1"); + assertEquals(response.get(1).getFlavorRef(), "https://servers.api.rackspacecloud.com/v1.1/32278/flavors/1"); + assertEquals(response.get(1).getAffinityId(), "b414fa41cb37b97dcb58d6c76112af1258e9eae2"); + assertEquals(response.get(1).getHostId(), "9e107d9d372bb6826bd81d3542a419d6"); + assertEquals(response.get(1).getStatus(), ServerStatus.ACTIVE); + assertEquals(response.get(1).getProgress(), null); - List
publicAddresses2 = ImmutableList.copyOf(Iterables.transform( - ImmutableList.of("67.23.10.133", "::babe:67.23.10.133"), - Address.newString2AddressFunction())); - List
privateAddresses2 = ImmutableList.copyOf(Iterables.transform( - ImmutableList.of("10.176.42.17", "::babe:10.176.42.17"), - Address.newString2AddressFunction())); - Addresses addresses2 = new Addresses(new HashSet
(publicAddresses2), new HashSet
(privateAddresses2)); + List
publicAddresses2 = ImmutableList.of(new Address("67.23.10.133", 4), new Address("::babe:67.23.10.133", 6)); + List
privateAddresses2 = ImmutableList.of(new Address("10.176.42.17", 4), new Address("::babe:10.176.42.17", 6)); + Addresses addresses2 = new Addresses(new HashSet
(publicAddresses2), new HashSet
(privateAddresses2)); - assertEquals(response.get(1).getAddresses(), addresses2); - assertEquals(response.get(1).getMetadata(), ImmutableMap.of("Server Label", "DB 1")); - assertEquals(response.get(1).getURI(), new URI("http://servers.api.openstack.org/v1.1/1234/servers/5678")); + assertEquals(response.get(1).getAddresses(), addresses2); + assertEquals(response.get(1).getMetadata(), ImmutableMap.of("Server Label", "DB 1")); + assertEquals(response.get(1).getURI(), "http://servers.api.openstack.org/1234/servers/56789"); - } + } } diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/options/CreateServerOptionsTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/options/CreateServerOptionsTest.java index cd198667ce..11ace1d635 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/options/CreateServerOptionsTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/options/CreateServerOptionsTest.java @@ -18,20 +18,18 @@ */ package org.jclouds.openstack.nova.options; -import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withFile; -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import javax.ws.rs.HttpMethod; - +import com.google.common.collect.ImmutableMap; +import com.google.inject.Guice; +import com.google.inject.Injector; import org.jclouds.http.HttpRequest; import org.jclouds.json.config.GsonModule; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableMap; -import com.google.inject.Guice; -import com.google.inject.Injector; +import javax.ws.rs.HttpMethod; +import java.net.URI; + +import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withFile; +import static org.testng.Assert.assertEquals; /** * Tests behavior of {@code ParseFlavorFromJsonResponse} @@ -41,41 +39,41 @@ import com.google.inject.Injector; @Test(groups = "unit") public class CreateServerOptionsTest { - Injector injector = Guice.createInjector(new GsonModule()); + Injector injector = Guice.createInjector(new GsonModule()); - @Test - public void testAddPayloadToRequestMapOfStringStringHttpRequest() { - CreateServerOptions options = new CreateServerOptions(); - HttpRequest request = buildRequest(options); - assertEquals("{\"server\":{\"name\":\"foo\",\"imageRef\":\"1\",\"flavorRef\":\"2\"}}", request.getPayload().getRawContent()); - } + @Test + public void testAddPayloadToRequestMapOfStringStringHttpRequest() { + CreateServerOptions options = new CreateServerOptions(); + HttpRequest request = buildRequest(options); + assertEquals("{\"server\":{\"name\":\"foo\",\"imageRef\":1,\"flavorRef\":2}}", request.getPayload().getRawContent()); + } - private HttpRequest buildRequest(CreateServerOptions options) { - injector.injectMembers(options); - HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost")); - options.bindToRequest(request, ImmutableMap.of("name", "foo", "imageRef", "1", "flavorRef", "2")); - return request; - } + private HttpRequest buildRequest(CreateServerOptions options) { + injector.injectMembers(options); + HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost")); + options.bindToRequest(request, ImmutableMap.of("name", "foo", "imageRef", "1", "flavorRef", "2")); + return request; + } - @Test - public void testWithFile() { - CreateServerOptions options = new CreateServerOptions(); - options.withFile("/tmp/rhubarb", "foo".getBytes()); - HttpRequest request = buildRequest(options); - assertFile(request); - } + @Test + public void testWithFile() { + CreateServerOptions options = new CreateServerOptions(); + options.withFile("/tmp/rhubarb", "foo".getBytes()); + HttpRequest request = buildRequest(options); + assertFile(request); + } - @Test - public void testWithFileStatic() { - CreateServerOptions options = withFile("/tmp/rhubarb", "foo".getBytes()); - HttpRequest request = buildRequest(options); - assertFile(request); - } + @Test + public void testWithFileStatic() { + CreateServerOptions options = withFile("/tmp/rhubarb", "foo".getBytes()); + HttpRequest request = buildRequest(options); + assertFile(request); + } - private void assertFile(HttpRequest request) { - assertEquals(request.getPayload().getRawContent(), - "{\"server\":{\"name\":\"foo\",\"imageRef\":\"1\",\"flavorRef\":\"2\",\"personality\":[{\"path\":\"/tmp/rhubarb\",\"contents\":\"Zm9v\"}]}}"); - } + private void assertFile(HttpRequest request) { + assertEquals(request.getPayload().getRawContent(), + "{\"server\":{\"name\":\"foo\",\"imageRef\":1,\"flavorRef\":2,\"personality\":[{\"path\":\"/tmp/rhubarb\",\"contents\":\"Zm9v\"}]}}"); + } @Test public void testWithMetadata() { diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/options/ListOptionsTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/options/ListOptionsTest.java index f87773cf17..27d92cbd87 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/options/ListOptionsTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/options/ListOptionsTest.java @@ -18,21 +18,17 @@ */ package org.jclouds.openstack.nova.options; -import static org.jclouds.openstack.nova.options.ListOptions.Builder.changesSince; -import static org.jclouds.openstack.nova.options.ListOptions.Builder.maxResults; -import static org.jclouds.openstack.nova.options.ListOptions.Builder.startAt; -import static org.jclouds.openstack.nova.options.ListOptions.Builder.withDetails; -import static org.testng.Assert.assertEquals; +import com.google.common.collect.ImmutableList; +import org.testng.annotations.Test; import java.util.Date; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; +import static org.jclouds.openstack.nova.options.ListOptions.Builder.*; +import static org.testng.Assert.assertEquals; /** * Tests behavior of {@code ListOptions} - * + * * @author Adrian Cole */ @Test(groups = "unit") @@ -52,7 +48,7 @@ public class ListOptionsTest { Date ifModifiedSince = new Date(); ListOptions options = new ListOptions().changesSince(ifModifiedSince); assertEquals(ImmutableList.of(ifModifiedSince.getTime() / 1000 + ""), options - .buildQueryParameters().get("changes-since")); + .buildQueryParameters().get("changes-since")); } public void testStartAt() { @@ -71,7 +67,7 @@ public class ListOptionsTest { Date ifModifiedSince = new Date(); ListOptions options = changesSince(ifModifiedSince); assertEquals(ImmutableList.of(ifModifiedSince.getTime() / 1000 + ""), options - .buildQueryParameters().get("changes-since")); + .buildQueryParameters().get("changes-since")); } public void testStartAtStatic() { diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/options/RebuildServerOptionsTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/options/RebuildServerOptionsTest.java index e3c33156fe..b70b6f06e5 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/options/RebuildServerOptionsTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/options/RebuildServerOptionsTest.java @@ -18,24 +18,22 @@ */ package org.jclouds.openstack.nova.options; -import static org.jclouds.openstack.nova.options.RebuildServerOptions.Builder.withImage; -import static org.testng.Assert.assertEquals; - -import java.net.URI; -import java.util.HashMap; - -import javax.ws.rs.HttpMethod; - +import com.google.inject.Guice; +import com.google.inject.Injector; import org.jclouds.http.HttpRequest; import org.jclouds.json.config.GsonModule; import org.testng.annotations.Test; -import com.google.inject.Guice; -import com.google.inject.Injector; +import javax.ws.rs.HttpMethod; +import java.net.URI; +import java.util.HashMap; + +import static org.jclouds.openstack.nova.options.RebuildServerOptions.Builder.withImage; +import static org.testng.Assert.assertEquals; /** * Tests behavior of {@code ParseFlavorFromJsonResponse} - * + * * @author Adrian Cole */ @Test(groups = "unit") diff --git a/sandbox-apis/nova/src/test/resources/test_get_image_details.json b/sandbox-apis/nova/src/test/resources/test_get_image_details.json index 035e3beffa..3e3b93fb02 100644 --- a/sandbox-apis/nova/src/test/resources/test_get_image_details.json +++ b/sandbox-apis/nova/src/test/resources/test_get_image_details.json @@ -1,6 +1,6 @@ { "image" : { - "id" : 1, + "id" : 2, "name" : "CentOS 5.2", "serverRef" : "http://servers.api.openstack.org/v1.1/1234/servers/12", "updated" : "2010-10-10T12:00:00Z", @@ -10,7 +10,7 @@ "metadata" : { "ImageVersion" : "1.5", "ImageType" : "Gold" - }, + }, "links": [ { "rel" : "self", diff --git a/sandbox-apis/nova/src/test/resources/test_list_addresses.json b/sandbox-apis/nova/src/test/resources/test_list_addresses.json index 14dd5e898d..8f3b3aab93 100644 --- a/sandbox-apis/nova/src/test/resources/test_list_addresses.json +++ b/sandbox-apis/nova/src/test/resources/test_list_addresses.json @@ -1,15 +1,15 @@ { "addresses" : { - "public" : [ - {"version" : 4, "addr" : "67.23.10.132"}, - {"version" : 6, "addr" : "::babe:67.23.10.132"}, - {"version" : 4, "addr" : "67.23.10.131"}, - {"version" : 6, "addr" : "::babe:4317:0A83"} - ], - "private" : [ - {"version" : 4, "addr" : "10.176.42.16"}, - {"version" : 6, "addr" : "::babe:10.176.42.16"} - ] - } + "public" : [ + {"version" : 4, "addr" : "67.23.10.132"}, + {"version" : 6, "addr" : "::babe:67.23.10.132"}, + {"version" : 4, "addr" : "67.23.10.131"}, + {"version" : 6, "addr" : "::babe:4317:0A83"} + ], + "private" : [ + {"version" : 4, "addr" : "10.176.42.16"}, + {"version" : 6, "addr" : "::babe:10.176.42.16"} + ] + } } diff --git a/sandbox-apis/nova/src/test/resources/test_list_addresses_private.json b/sandbox-apis/nova/src/test/resources/test_list_addresses_private.json index 62935ae947..eb49fbdf1e 100644 --- a/sandbox-apis/nova/src/test/resources/test_list_addresses_private.json +++ b/sandbox-apis/nova/src/test/resources/test_list_addresses_private.json @@ -1,10 +1,8 @@ { - "network" : { - "private" : [ + "private":[ {"version" : 4, "addr" : "67.23.10.132"}, {"version" : 6, "addr" : "::babe:67.23.10.132"}, {"version" : 4, "addr" : "67.23.10.131"}, {"version" : 6, "addr" : "::babe:4317:0A83"} ] - } } diff --git a/sandbox-apis/nova/src/test/resources/test_list_addresses_public.json b/sandbox-apis/nova/src/test/resources/test_list_addresses_public.json index 0c7a67a2b2..60bf20f718 100644 --- a/sandbox-apis/nova/src/test/resources/test_list_addresses_public.json +++ b/sandbox-apis/nova/src/test/resources/test_list_addresses_public.json @@ -1,10 +1,8 @@ { - "network" : { - "public" : [ + "public" : [ {"version" : 4, "addr" : "67.23.10.132"}, {"version" : 6, "addr" : "::babe:67.23.10.132"}, {"version" : 4, "addr" : "67.23.10.131"}, {"version" : 6, "addr" : "::babe:4317:0A83"} ] - } } diff --git a/sandbox-apis/nova/src/test/resources/test_list_flavors.json b/sandbox-apis/nova/src/test/resources/test_list_flavors.json index 51ef1bc28f..5953f252a2 100644 --- a/sandbox-apis/nova/src/test/resources/test_list_flavors.json +++ b/sandbox-apis/nova/src/test/resources/test_list_flavors.json @@ -20,6 +20,7 @@ } ] }, + { "id" : 2, "name" : "512 MB Server", @@ -42,3 +43,4 @@ } ] } + diff --git a/sandbox-apis/nova/src/test/resources/test_list_servers.json b/sandbox-apis/nova/src/test/resources/test_list_servers.json index 82c53075c7..8cf580c3fc 100644 --- a/sandbox-apis/nova/src/test/resources/test_list_servers.json +++ b/sandbox-apis/nova/src/test/resources/test_list_servers.json @@ -1,5 +1,5 @@ { - "servers" : [ + "servers" : [ { "id" : 1234, "name" : "sample-server", diff --git a/sandbox-apis/nova/src/test/resources/test_list_servers_detail.json b/sandbox-apis/nova/src/test/resources/test_list_servers_detail.json index 15bb6b491d..d428ced299 100644 --- a/sandbox-apis/nova/src/test/resources/test_list_servers_detail.json +++ b/sandbox-apis/nova/src/test/resources/test_list_servers_detail.json @@ -12,17 +12,17 @@ "status" : "BUILD", "progress" : 60, "addresses" : { - "public" : [ + "public" : [ {"version" : 4, "addr" : "67.23.10.132"}, {"version" : 6, "addr" : "::babe:67.23.10.132"}, {"version" : 4, "addr" : "67.23.10.131"}, {"version" : 6, "addr" : "::babe:4317:0A83"} ], "private" : [ - {"version" : 4, "addr" : "10.176.42.16"}, - {"version" : 6, "addr" : "::babe:10.176.42.16"} - ] - }, + {"version" : 4, "addr" : "10.176.42.16"}, + {"version" : 6, "addr" : "::babe:10.176.42.16"} + ] + }, "metadata" : { "Server Label" : "Web Head 1", "Image Version" : "2.1" @@ -55,14 +55,14 @@ "affinityId" : "b414fa41cb37b97dcb58d6c76112af1258e9eae2", "status" : "ACTIVE", "addresses" : { - "public" : [ - {"version" : 4, "addr" : "67.23.10.133"}, - {"version" : 6, "addr" : "::babe:67.23.10.133"} - ], - "private" : [ - {"version" : 4, "addr" : "10.176.42.17"}, - {"version" : 6, "addr" : "::babe:10.176.42.17"} - ] + "public" : [ + {"version" : 4, "addr" : "67.23.10.133"}, + {"version" : 6, "addr" : "::babe:67.23.10.133"} + ], + "private" : [ + {"version" : 4, "addr" : "10.176.42.17"}, + {"version" : 6, "addr" : "::babe:10.176.42.17"} + ] }, "metadata" : { "Server Label" : "DB 1"