diff --git a/common/openstack/src/main/java/org/jclouds/openstack/services/Extension.java b/common/openstack/src/main/java/org/jclouds/openstack/services/Extension.java new file mode 100644 index 0000000000..06965f8048 --- /dev/null +++ b/common/openstack/src/main/java/org/jclouds/openstack/services/Extension.java @@ -0,0 +1,77 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.openstack.services; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + * An extension of a {@link ServiceType service}. In order for us to understand + * the context of the extension, we must consider the extensions call. + * + *
+ * For our purposes, the minimal context of an extension is the type of the + * service it extends ex. {@link ServiceType#COMPUTE}, and its namespace ex. http://docs.openstack.org + * /ext/keypairs/api/v1.1. + * + * @author Adrian Cole + * + * @see ServiceType + * @see + * @see + * @see + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface Extension { + + /** + * the service type this is an extension of. + * + *

note

+ * + * This isn't necessarily one of the built-in {@link ServiceType services}, + * it could be an extension of a custom service. + * + * @return the service type this is an extension of. + * + */ + String of(); + + /** + * namespace ex.
http + * ://docs.openstack.org /ext/keypairs/api/v1.1. + * + * @return the namespace of the extension + */ + String namespace(); + +} \ No newline at end of file diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaAsyncClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaAsyncClient.java index 71534e7aef..10c8e6db5d 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaAsyncClient.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaAsyncClient.java @@ -33,6 +33,7 @@ import org.jclouds.openstack.nova.v1_1.features.ServerAsyncClient; import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; +import com.google.common.base.Optional; import com.google.inject.Provides; /** @@ -85,7 +86,7 @@ public interface NovaAsyncClient { * Provides asynchronous access to Floating IP features. */ @Delegate - FloatingIPAsyncClient getFloatingIPClientForRegion( + Optional getFloatingIPExtensionForRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); /** diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaClient.java index 2cf57d5f40..e2e899e48b 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaClient.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaClient.java @@ -35,6 +35,7 @@ import org.jclouds.openstack.nova.v1_1.features.ServerClient; import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; +import com.google.common.base.Optional; import com.google.inject.Provides; /** @@ -87,7 +88,7 @@ public interface NovaClient { * Provides synchronous access to Floating IP features. */ @Delegate - FloatingIPClient getFloatingIPClientForRegion( + Optional getFloatingIPExtensionForRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); /** diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/ExtensionNamespaces.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/ExtensionNamespaces.java index 7cf5ef9611..725622493a 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/ExtensionNamespaces.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/ExtensionNamespaces.java @@ -18,7 +18,6 @@ */ package org.jclouds.openstack.nova.v1_1.extensions; -import java.net.URI; /** * Extension namespaces @@ -27,8 +26,8 @@ import java.net.URI; * @see */ public interface ExtensionNamespaces { - public static URI KEYPAIRS = URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1"); - public static URI VOLUMES = URI.create("http://docs.openstack.org/ext/volumes/api/v1.1"); - public static URI SECURITY_GROUPS = URI.create("http://docs.openstack.org/ext/securitygroups/api/v1.1"); - public static URI FLOATING_IPS = URI.create("http://docs.openstack.org/ext/floating_ips/api/v1.1"); + public static final String KEYPAIRS = "http://docs.openstack.org/ext/keypairs/api/v1.1"; + public static final String VOLUMES = "http://docs.openstack.org/ext/volumes/api/v1.1"; + public static final String SECURITY_GROUPS = "http://docs.openstack.org/ext/securitygroups/api/v1.1"; + public static final String FLOATING_IPS = "http://docs.openstack.org/ext/floating_ips/api/v1.1"; } diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPAsyncClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPAsyncClient.java index 9bbb413dfa..93e3df0d24 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPAsyncClient.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPAsyncClient.java @@ -32,6 +32,8 @@ import javax.ws.rs.core.MediaType; import org.jclouds.openstack.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.FloatingIP; import org.jclouds.openstack.nova.v1_1.features.ExtensionAsyncClient; +import org.jclouds.openstack.services.Extension; +import org.jclouds.openstack.services.ServiceType; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.Payload; import org.jclouds.rest.annotations.PayloadParam; @@ -50,10 +52,13 @@ import com.google.common.util.concurrent.ListenableFuture; * @see FloatingIPClient * @author Jeremy Daggett * @see ExtensionAsyncClient - * @see + * @see * @see * @see */ +@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.FLOATING_IPS) @SkipEncoding({ '/', '=' }) @RequestFilters(AuthenticateRequest.class) public interface FloatingIPAsyncClient { @@ -98,7 +103,7 @@ public interface FloatingIPAsyncClient { @ExceptionParser(ReturnNullOnNotFoundOr404.class) @Path("/os-floating-ips/{id}") ListenableFuture deallocate(@PathParam("id") String id); - + /** * @see FloatingIPClient#addFloatingIP */ @@ -107,9 +112,7 @@ public interface FloatingIPAsyncClient { @Consumes @Produces(MediaType.APPLICATION_JSON) @Payload("%7B\"addFloatingIp\":%7B\"address\":\"{address}\"%7D%7D") - ListenableFuture addFloatingIP( - @PathParam("server") String serverId, - @PayloadParam("address") String address); + ListenableFuture addFloatingIP(@PathParam("server") String serverId, @PayloadParam("address") String address); /** * @see FloatingIPClient#removeFloatingIP @@ -119,8 +122,6 @@ public interface FloatingIPAsyncClient { @Consumes @Produces(MediaType.APPLICATION_JSON) @Payload("%7B\"removeFloatingIp\":%7B\"address\":\"{address}\"%7D%7D") - ListenableFuture removeFloatingIP( - @PathParam("server") String serverId, - @PayloadParam("address") String address); + ListenableFuture removeFloatingIP(@PathParam("server") String serverId, @PayloadParam("address") String address); } diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClient.java index 59934d94f3..6c53a719e9 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClient.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClient.java @@ -23,6 +23,8 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.openstack.nova.v1_1.domain.FloatingIP; +import org.jclouds.openstack.services.Extension; +import org.jclouds.openstack.services.ServiceType; /** * Provides synchronous access to Floating IPs. @@ -31,6 +33,7 @@ import org.jclouds.openstack.nova.v1_1.domain.FloatingIP; * @see FloatingIPAsyncClient * @author Jeremy Daggett */ +@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.FLOATING_IPS) @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) public interface FloatingIPClient { diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairAsyncClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairAsyncClient.java index 5c7eaf7aa5..1635f50ad6 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairAsyncClient.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairAsyncClient.java @@ -33,6 +33,8 @@ import javax.ws.rs.core.MediaType; import org.jclouds.openstack.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.KeyPair; import org.jclouds.openstack.nova.v1_1.features.ExtensionAsyncClient; +import org.jclouds.openstack.services.Extension; +import org.jclouds.openstack.services.ServiceType; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.Payload; import org.jclouds.rest.annotations.PayloadParam; @@ -55,6 +57,7 @@ import com.google.common.util.concurrent.ListenableFuture; * @see * @see */ +@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.KEYPAIRS) @SkipEncoding({ '/', '=' }) @RequestFilters(AuthenticateRequest.class) public interface KeyPairAsyncClient { diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairClient.java index 075272b3a8..cca7c89bbd 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairClient.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairClient.java @@ -24,6 +24,8 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.openstack.nova.v1_1.domain.KeyPair; +import org.jclouds.openstack.services.Extension; +import org.jclouds.openstack.services.ServiceType; /** * Provides synchronous access to Security Groups. @@ -32,6 +34,7 @@ import org.jclouds.openstack.nova.v1_1.domain.KeyPair; * @see KeyPairAsyncClient * @author Jeremy Daggett */ +@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.KEYPAIRS) @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) public interface KeyPairClient { diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupAsyncClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupAsyncClient.java index a163861a58..c7c7a7c313 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupAsyncClient.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupAsyncClient.java @@ -32,6 +32,8 @@ import javax.ws.rs.core.MediaType; import org.jclouds.openstack.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.SecurityGroup; import org.jclouds.openstack.nova.v1_1.domain.SecurityGroupRule; +import org.jclouds.openstack.services.Extension; +import org.jclouds.openstack.services.ServiceType; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.Payload; import org.jclouds.rest.annotations.PayloadParam; @@ -54,6 +56,7 @@ import com.google.common.util.concurrent.ListenableFuture; * @see * @see */ +@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.SECURITY_GROUPS) @SkipEncoding({ '/', '=' }) @RequestFilters(AuthenticateRequest.class) public interface SecurityGroupAsyncClient { diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupClient.java index 8b78950119..fc14bf12ef 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupClient.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupClient.java @@ -24,6 +24,8 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.openstack.nova.v1_1.domain.SecurityGroup; import org.jclouds.openstack.nova.v1_1.domain.SecurityGroupRule; +import org.jclouds.openstack.services.Extension; +import org.jclouds.openstack.services.ServiceType; /** * Provides synchronous access to Security Groups. @@ -32,6 +34,7 @@ import org.jclouds.openstack.nova.v1_1.domain.SecurityGroupRule; * @see SecurityGroupAsyncClient * @author Jeremy Daggett */ +@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.SECURITY_GROUPS) @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) public interface SecurityGroupClient { diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/PasswordAuthenticationExpectTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/PasswordAuthenticationExpectTest.java index 47ce6a984b..a1c9846fed 100644 --- a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/PasswordAuthenticationExpectTest.java +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/PasswordAuthenticationExpectTest.java @@ -26,7 +26,7 @@ import java.util.Properties; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; -import org.jclouds.openstack.nova.v1_1.internal.BaseNovaRestClientExpectTest; +import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientExpectTest; import org.jclouds.openstack.nova.v1_1.parse.ParseServerListTest; import org.testng.annotations.Test; @@ -39,7 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "unit", testName = "PasswordAuthenticationExpectTest") -public class PasswordAuthenticationExpectTest extends BaseNovaRestClientExpectTest { +public class PasswordAuthenticationExpectTest extends BaseNovaClientExpectTest { /** * this reflects the properties that a user would pass to createContext diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPAsyncClientExpectTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPAsyncClientExpectTest.java new file mode 100644 index 0000000000..73540324ee --- /dev/null +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPAsyncClientExpectTest.java @@ -0,0 +1,160 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.openstack.nova.v1_1.extensions; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +import java.net.URI; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; +import org.jclouds.openstack.nova.v1_1.internal.BaseNovaAsyncClientExpectTest; +import org.jclouds.openstack.nova.v1_1.parse.ParseFloatingIPListTest; +import org.jclouds.openstack.nova.v1_1.parse.ParseFloatingIPTest; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableSet; + +/** + * Tests annotation parsing of {@code FloatingIPAsyncClient} + * + * @author Michael Arnold + */ +@Test(groups = "unit", testName = "FloatingIPAsyncClientExpectTest") +public class FloatingIPAsyncClientExpectTest extends BaseNovaAsyncClientExpectTest { + + public void testListFloatingIPsWhenResponseIs2xx() throws Exception { + HttpRequest listFloatingIPs = HttpRequest + .builder() + .method("GET") + .endpoint(URI.create("https://compute.north.host/v1.1/3456/os-floating-ips")) + .headers( + ImmutableMultimap. builder().put("Accept", "application/json") + .put("X-Auth-Token", authToken).build()).build(); + + HttpResponse listFloatingIPsResponse = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/floatingip_list.json")).build(); + + NovaAsyncClient clientWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey, + responseWithKeystoneAccess, listFloatingIPs, listFloatingIPsResponse); + + assertEquals(clientWhenFloatingIPsExist.getConfiguredRegions(), ImmutableSet.of("North")); + + assertEquals(clientWhenFloatingIPsExist.getFloatingIPExtensionForRegion("North").get().listFloatingIPs().get() + .toString(), new ParseFloatingIPListTest().expected().toString()); + } + + public void testListFloatingIPsWhenResponseIs404() throws Exception { + HttpRequest listFloatingIPs = HttpRequest + .builder() + .method("GET") + .endpoint(URI.create("https://compute.north.host/v1.1/3456/os-floating-ips")) + .headers( + ImmutableMultimap. builder().put("Accept", "application/json") + .put("X-Auth-Token", authToken).build()).build(); + + HttpResponse listFloatingIPsResponse = HttpResponse.builder().statusCode(404).build(); + + NovaAsyncClient clientWhenNoServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey, + responseWithKeystoneAccess, listFloatingIPs, listFloatingIPsResponse); + + assertTrue(clientWhenNoServersExist.getFloatingIPExtensionForRegion("North").get().listFloatingIPs().get() + .isEmpty()); + } + + public void testGetFloatingIPWhenResponseIs2xx() throws Exception { + HttpRequest getFloatingIP = HttpRequest + .builder() + .method("GET") + .endpoint(URI.create("https://compute.north.host/v1.1/3456/os-floating-ips/1")) + .headers( + ImmutableMultimap. builder().put("Accept", "application/json") + .put("X-Auth-Token", authToken).build()).build(); + + HttpResponse getFloatingIPResponse = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/floatingip_details.json")).build(); + + NovaAsyncClient clientWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey, + responseWithKeystoneAccess, getFloatingIP, getFloatingIPResponse); + + assertEquals(clientWhenFloatingIPsExist.getFloatingIPExtensionForRegion("North").get().getFloatingIP("1").get() + .toString(), new ParseFloatingIPTest().expected().toString()); + } + + public void testGetFloatingIPWhenResponseIs404() throws Exception { + HttpRequest getFloatingIP = HttpRequest + .builder() + .method("GET") + .endpoint(URI.create("https://compute.north.host/v1.1/3456/os-floating-ips/1")) + .headers( + ImmutableMultimap. builder().put("Accept", "application/json") + .put("X-Auth-Token", authToken).build()).build(); + + HttpResponse getFloatingIPResponse = HttpResponse.builder().statusCode(404).build(); + + NovaAsyncClient clientWhenNoServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey, + responseWithKeystoneAccess, getFloatingIP, getFloatingIPResponse); + + assertNull(clientWhenNoServersExist.getFloatingIPExtensionForRegion("North").get().getFloatingIP("1").get()); + } + + public void testAllocateWhenResponseIs2xx() throws Exception { + HttpRequest allocateFloatingIP = HttpRequest + .builder() + .method("POST") + .endpoint(URI.create("https://compute.north.host/v1.1/3456/os-floating-ips")) + .headers( + ImmutableMultimap. builder().put("Accept", "application/json") + .put("X-Auth-Token", authToken).build()) + .payload(payloadFromStringWithContentType("{}", "application/json")).build(); + + HttpResponse allocateFloatingIPResponse = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/floatingip_details.json")).build(); + + NovaAsyncClient clientWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey, + responseWithKeystoneAccess, allocateFloatingIP, allocateFloatingIPResponse); + + assertEquals(clientWhenFloatingIPsExist.getFloatingIPExtensionForRegion("North").get().allocate().get() + .toString(), new ParseFloatingIPTest().expected().toString()); + + } + + public void testAllocateWhenResponseIs404() throws Exception { + HttpRequest allocateFloatingIP = HttpRequest + .builder() + .method("POST") + .endpoint(URI.create("https://compute.north.host/v1.1/3456/os-floating-ips")) + .headers( + ImmutableMultimap. builder().put("Accept", "application/json") + .put("X-Auth-Token", authToken).build()) + .payload(payloadFromStringWithContentType("{}", "application/json")).build(); + + HttpResponse allocateFloatingIPResponse = HttpResponse.builder().statusCode(404).build(); + + NovaAsyncClient clientWhenNoServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey, + responseWithKeystoneAccess, allocateFloatingIP, allocateFloatingIPResponse); + + assertNull(clientWhenNoServersExist.getFloatingIPExtensionForRegion("North").get().allocate().get()); + } + +} \ No newline at end of file diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClientExpectTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClientExpectTest.java index e373ed1295..1c345af2ca 100644 --- a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClientExpectTest.java +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClientExpectTest.java @@ -27,7 +27,7 @@ import java.net.URI; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.openstack.nova.v1_1.NovaClient; -import org.jclouds.openstack.nova.v1_1.internal.BaseNovaRestClientExpectTest; +import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientExpectTest; import org.jclouds.openstack.nova.v1_1.parse.ParseFloatingIPListTest; import org.jclouds.openstack.nova.v1_1.parse.ParseFloatingIPTest; import org.testng.annotations.Test; @@ -41,7 +41,7 @@ import com.google.common.collect.ImmutableSet; * @author Michael Arnold */ @Test(groups = "unit", testName = "FloatingIPClientExpectTest") -public class FloatingIPClientExpectTest extends BaseNovaRestClientExpectTest { +public class FloatingIPClientExpectTest extends BaseNovaClientExpectTest { public void testListFloatingIPsWhenResponseIs2xx() throws Exception { HttpRequest listFloatingIPs = HttpRequest @@ -64,7 +64,7 @@ public class FloatingIPClientExpectTest extends BaseNovaRestClientExpectTest { assertEquals(clientWhenFloatingIPsExist.getConfiguredRegions(), ImmutableSet.of("North")); - assertEquals(clientWhenFloatingIPsExist.getFloatingIPClientForRegion("North") + assertEquals(clientWhenFloatingIPsExist.getFloatingIPExtensionForRegion("North").get() .listFloatingIPs().toString(), new ParseFloatingIPListTest().expected() .toString()); } @@ -87,7 +87,7 @@ public class FloatingIPClientExpectTest extends BaseNovaRestClientExpectTest { keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess, listFloatingIPs, listFloatingIPsResponse); - assertTrue(clientWhenNoServersExist.getFloatingIPClientForRegion("North") + assertTrue(clientWhenNoServersExist.getFloatingIPExtensionForRegion("North").get() .listFloatingIPs().isEmpty()); } @@ -109,7 +109,7 @@ public class FloatingIPClientExpectTest extends BaseNovaRestClientExpectTest { keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess, getFloatingIP, getFloatingIPResponse); - assertEquals(clientWhenFloatingIPsExist.getFloatingIPClientForRegion("North") + assertEquals(clientWhenFloatingIPsExist.getFloatingIPExtensionForRegion("North").get() .getFloatingIP("1").toString(), new ParseFloatingIPTest().expected().toString()); } @@ -131,7 +131,7 @@ public class FloatingIPClientExpectTest extends BaseNovaRestClientExpectTest { keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess, getFloatingIP, getFloatingIPResponse); - assertNull(clientWhenNoServersExist.getFloatingIPClientForRegion("North") + assertNull(clientWhenNoServersExist.getFloatingIPExtensionForRegion("North").get() .getFloatingIP("1")); } @@ -154,7 +154,7 @@ public class FloatingIPClientExpectTest extends BaseNovaRestClientExpectTest { keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess, allocateFloatingIP, allocateFloatingIPResponse); - assertEquals(clientWhenFloatingIPsExist.getFloatingIPClientForRegion("North") + assertEquals(clientWhenFloatingIPsExist.getFloatingIPExtensionForRegion("North").get() .allocate().toString(), new ParseFloatingIPTest().expected().toString()); @@ -178,7 +178,7 @@ public class FloatingIPClientExpectTest extends BaseNovaRestClientExpectTest { keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess, allocateFloatingIP, allocateFloatingIPResponse); - assertNull(clientWhenNoServersExist.getFloatingIPClientForRegion("North") + assertNull(clientWhenNoServersExist.getFloatingIPExtensionForRegion("North").get() .allocate()); } diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClientLiveTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClientLiveTest.java index da46fdff87..b4508bf549 100644 --- a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClientLiveTest.java +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClientLiveTest.java @@ -25,6 +25,7 @@ import static org.testng.Assert.assertTrue; import java.util.Set; +import com.google.common.base.Optional; import com.google.common.collect.Iterables; import org.jclouds.openstack.nova.v1_1.domain.Address; import org.jclouds.openstack.nova.v1_1.domain.FloatingIP; @@ -52,8 +53,10 @@ public class FloatingIPClientLiveTest extends BaseNovaClientLiveTest { @Test public void testListFloatingIPs() throws Exception { for (String regionId : context.getApi().getConfiguredRegions()) { - - FloatingIPClient client = context.getApi().getFloatingIPClientForRegion(regionId); + Optional clientOption = context.getApi().getFloatingIPExtensionForRegion(regionId); + if (!clientOption.isPresent()) + continue; + FloatingIPClient client = clientOption.get(); Set response = client.listFloatingIPs(); assert null != response; assertTrue(response.size() >= 0); @@ -73,7 +76,10 @@ public class FloatingIPClientLiveTest extends BaseNovaClientLiveTest { @Test public void testAllocateAndDeallocateFloatingIPs() throws Exception { for (String regionId : context.getApi().getConfiguredRegions()) { - FloatingIPClient client = context.getApi().getFloatingIPClientForRegion(regionId); + Optional clientOption = context.getApi().getFloatingIPExtensionForRegion(regionId); + if (!clientOption.isPresent()) + continue; + FloatingIPClient client = clientOption.get(); FloatingIP floatingIP = client.allocate(); assertNotNull(floatingIP); @@ -101,7 +107,10 @@ public class FloatingIPClientLiveTest extends BaseNovaClientLiveTest { @Test public void testAddAndRemoveFloatingIp() throws Exception { for (String regionId : context.getApi().getConfiguredRegions()) { - FloatingIPClient client = context.getApi().getFloatingIPClientForRegion(regionId); + Optional clientOption = context.getApi().getFloatingIPExtensionForRegion(regionId); + if (!clientOption.isPresent()) + continue; + FloatingIPClient client = clientOption.get(); ServerClient serverClient = context.getApi().getServerClientForRegion(regionId); Server server = serverClient.createServer("test", imageIdForRegion(regionId), flavorRefForRegion(regionId)); blockUntilServerActive(server.getId(), serverClient); diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairClientExpectTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairClientExpectTest.java index c9a7b70d43..f6f3fdab33 100644 --- a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairClientExpectTest.java +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairClientExpectTest.java @@ -23,7 +23,7 @@ import com.google.common.collect.ImmutableSet; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.openstack.nova.v1_1.NovaClient; -import org.jclouds.openstack.nova.v1_1.internal.BaseNovaRestClientExpectTest; +import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientExpectTest; import org.jclouds.openstack.nova.v1_1.parse.ParseKeyPairListTest; import org.jclouds.openstack.nova.v1_1.parse.ParseKeyPairTest; import org.testng.annotations.Test; @@ -40,7 +40,7 @@ import static org.testng.Assert.assertTrue; * @author Michael Arnold */ @Test(groups = "unit", testName = "KeyPairClientExpectTest") -public class KeyPairClientExpectTest extends BaseNovaRestClientExpectTest { +public class KeyPairClientExpectTest extends BaseNovaClientExpectTest { public void testListKeyPairsWhenResponseIs2xx() throws Exception { HttpRequest listKeyPairs = HttpRequest diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupClientExpectTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupClientExpectTest.java index c67ed8dd72..57a99410c5 100644 --- a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupClientExpectTest.java +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupClientExpectTest.java @@ -18,19 +18,19 @@ */ package org.jclouds.openstack.nova.v1_1.extensions; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; +import static org.testng.Assert.assertEquals; + +import java.net.URI; + import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.openstack.nova.v1_1.NovaClient; -import org.jclouds.openstack.nova.v1_1.internal.BaseNovaRestClientExpectTest; +import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientExpectTest; import org.jclouds.openstack.nova.v1_1.parse.ParseSecurityGroupListTest; import org.testng.annotations.Test; -import java.net.URI; -import java.util.logging.Logger; - -import static org.testng.Assert.assertEquals; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableSet; /** * Tests annotation parsing of {@code SecurityGroupAsyncClient} @@ -38,7 +38,7 @@ import static org.testng.Assert.assertEquals; * @author Michael Arnold */ @Test(groups = "unit", testName = "SecurityGroupClientExpectTest") -public class SecurityGroupClientExpectTest extends BaseNovaRestClientExpectTest { +public class SecurityGroupClientExpectTest extends BaseNovaClientExpectTest { public void testListSecurityGroupsWhenResponseIs2xx() throws Exception { HttpRequest listSecurityGroups = HttpRequest .builder() diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ExtensionClientExpectTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ExtensionClientExpectTest.java index 259c9732ba..8becc98cd2 100644 --- a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ExtensionClientExpectTest.java +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ExtensionClientExpectTest.java @@ -27,7 +27,7 @@ import java.net.URI; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.openstack.nova.v1_1.NovaClient; -import org.jclouds.openstack.nova.v1_1.internal.BaseNovaRestClientExpectTest; +import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientExpectTest; import org.jclouds.openstack.nova.v1_1.parse.ParseExtensionListTest; import org.jclouds.openstack.nova.v1_1.parse.ParseExtensionTest; import org.testng.annotations.Test; @@ -41,7 +41,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "unit", testName = "ExtensionClientExpectTest") -public class ExtensionClientExpectTest extends BaseNovaRestClientExpectTest { +public class ExtensionClientExpectTest extends BaseNovaClientExpectTest { public void testListExtensionsWhenResponseIs2xx() throws Exception { HttpRequest listExtensions = HttpRequest diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientExpectTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientExpectTest.java index 134082d018..9fe65ccb6c 100644 --- a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientExpectTest.java +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientExpectTest.java @@ -27,7 +27,7 @@ import java.net.URI; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.openstack.nova.v1_1.NovaClient; -import org.jclouds.openstack.nova.v1_1.internal.BaseNovaRestClientExpectTest; +import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientExpectTest; import org.jclouds.openstack.nova.v1_1.parse.ParseFlavorListTest; import org.jclouds.openstack.nova.v1_1.parse.ParseFlavorTest; import org.testng.annotations.Test; @@ -41,7 +41,7 @@ import com.google.common.collect.ImmutableSet; * @author Jeremy Daggett */ @Test(groups = "unit", testName = "FlavorClientExpectTest") -public class FlavorClientExpectTest extends BaseNovaRestClientExpectTest { +public class FlavorClientExpectTest extends BaseNovaClientExpectTest { public void testListFlavorsWhenResponseIs2xx() throws Exception { HttpRequest listFlavors = HttpRequest diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ImageClientExpectTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ImageClientExpectTest.java index bad3704f80..ccdbeae5aa 100644 --- a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ImageClientExpectTest.java +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ImageClientExpectTest.java @@ -23,7 +23,7 @@ import com.google.common.collect.ImmutableSet; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.openstack.nova.v1_1.NovaClient; -import org.jclouds.openstack.nova.v1_1.internal.BaseNovaRestClientExpectTest; +import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientExpectTest; import org.jclouds.openstack.nova.v1_1.parse.ParseImageTest; import org.jclouds.openstack.nova.v1_1.parse.ParseImageListTest; import org.testng.annotations.Test; @@ -40,7 +40,7 @@ import static org.testng.Assert.assertTrue; * @author Michael Arnold */ @Test(groups = "unit", testName = "ImageAsyncClientTest") -public class ImageClientExpectTest extends BaseNovaRestClientExpectTest { +public class ImageClientExpectTest extends BaseNovaClientExpectTest { public void testListImagesWhenResponseIs2xx() throws Exception { HttpRequest listImages = HttpRequest .builder() diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ServerClientExpectTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ServerClientExpectTest.java index 37eae40461..ddaf66b9ba 100644 --- a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ServerClientExpectTest.java +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ServerClientExpectTest.java @@ -26,7 +26,7 @@ import java.net.URI; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.openstack.nova.v1_1.NovaClient; -import org.jclouds.openstack.nova.v1_1.internal.BaseNovaRestClientExpectTest; +import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientExpectTest; import org.jclouds.openstack.nova.v1_1.parse.ParseServerListTest; import org.testng.annotations.Test; @@ -39,7 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "unit", testName = "ServerAsyncClientTest") -public class ServerClientExpectTest extends BaseNovaRestClientExpectTest { +public class ServerClientExpectTest extends BaseNovaClientExpectTest { public void testListServersWhenResponseIs2xx() throws Exception { HttpRequest listServers = HttpRequest.builder().method("GET").endpoint( diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaAsyncClientTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaAsyncClientExpectTest.java similarity index 56% rename from labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaAsyncClientTest.java rename to labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaAsyncClientExpectTest.java index 70a99fc69e..00720cdce1 100644 --- a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaAsyncClientTest.java +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaAsyncClientExpectTest.java @@ -18,33 +18,32 @@ */ package org.jclouds.openstack.nova.v1_1.internal; -import static org.testng.Assert.assertEquals; +import static org.jclouds.rest.RestContextFactory.createContext; import java.util.Properties; import org.jclouds.http.HttpRequest; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.http.HttpResponse; +import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; import org.jclouds.openstack.nova.v1_1.NovaClient; -import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextSpec; +import com.google.common.base.Function; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; + /** + * Base class for writing KeyStone Rest Client Expect tests + * * @author Adrian Cole */ -public abstract class BaseNovaAsyncClientTest extends RestClientTest { - - @Override - protected void checkFilters(HttpRequest request) { - assertEquals(request.getFilters().size(), 1); - assertEquals(request.getFilters().get(0).getClass(), AuthenticateRequest.class); +public class BaseNovaAsyncClientExpectTest extends BaseNovaExpectTest { + public NovaAsyncClient createClient(Function fn, Module module, Properties props) { + RestContextSpec contextSpec = new RestContextFactory(setupRestProperties()) + .createContextSpec(provider, identity, credential, new Properties()); + return createContext(contextSpec, + ImmutableSet. of(new ExpectModule(fn), new NullLoggingModule(), module), props).getAsyncApi(); } - - @Override - public RestContextSpec createContextSpec() { - Properties props = new Properties(); - return new RestContextFactory().createContextSpec("openstack-nova", "accountId", "accessKey", props); - } - } diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientExpectTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientExpectTest.java new file mode 100644 index 0000000000..08c6c9052a --- /dev/null +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientExpectTest.java @@ -0,0 +1,30 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.openstack.nova.v1_1.internal; + +import org.jclouds.openstack.nova.v1_1.NovaClient; + +/** + * Base class for writing KeyStone Rest Client Expect tests + * + * @author Adrian Cole + */ +public class BaseNovaClientExpectTest extends BaseNovaExpectTest { + +} diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceExpectTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceExpectTest.java index 8979c839b9..4c032e0196 100644 --- a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceExpectTest.java +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceExpectTest.java @@ -25,43 +25,22 @@ import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.openstack.keystone.v2_0.internal.KeystoneFixture; -import org.jclouds.rest.BaseRestClientExpectTest; import com.google.common.base.Function; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; /** - * Base class for writing KeyStone Expect tests with the ComputeService abstraction - * + * Base class for writing KeyStone Expect tests with the ComputeService + * abstraction + * * @author Matt Stephenson */ -public class BaseNovaComputeServiceExpectTest extends BaseRestClientExpectTest -{ - protected HttpRequest keystoneAuthWithUsernameAndPassword; - protected HttpRequest keystoneAuthWithAccessKeyAndSecretKey; - protected String authToken; - protected HttpResponse responseWithKeystoneAccess; - - public BaseNovaComputeServiceExpectTest() - { - provider = "openstack-nova"; - keystoneAuthWithUsernameAndPassword = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPassword(identity, - credential); - keystoneAuthWithAccessKeyAndSecretKey = KeystoneFixture.INSTANCE.initialAuthWithAccessKeyAndSecretKey(identity, - credential); - authToken = KeystoneFixture.INSTANCE.getAuthToken(); - responseWithKeystoneAccess = KeystoneFixture.INSTANCE.responseWithAccess(); - // now, createContext arg will need tenant prefix - identity = KeystoneFixture.INSTANCE.getTenantName() + ":" + identity; - } - +public class BaseNovaComputeServiceExpectTest extends BaseNovaExpectTest { @Override - public ComputeService createClient(Function fn, Module module, Properties props) - { + public ComputeService createClient(Function fn, Module module, Properties props) { return new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, identity, credential, - ImmutableSet.of(new ExpectModule(fn), new NullLoggingModule(), module), props).getComputeService(); + ImmutableSet. of(new ExpectModule(fn), new NullLoggingModule(), module), props).getComputeService(); } } diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaRestClientExpectTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaExpectTest.java similarity index 88% rename from labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaRestClientExpectTest.java rename to labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaExpectTest.java index 7afeb2985d..c3ee24c12d 100644 --- a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaRestClientExpectTest.java +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaExpectTest.java @@ -21,21 +21,20 @@ package org.jclouds.openstack.nova.v1_1.internal; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.openstack.keystone.v2_0.internal.KeystoneFixture; -import org.jclouds.openstack.nova.v1_1.NovaClient; import org.jclouds.rest.BaseRestClientExpectTest; /** - * Base class for writing KeyStone Rest Client Expect tests + * Base class for writing Nova Expect tests * * @author Adrian Cole */ -public class BaseNovaRestClientExpectTest extends BaseRestClientExpectTest { +public class BaseNovaExpectTest extends BaseRestClientExpectTest { protected HttpRequest keystoneAuthWithUsernameAndPassword; protected HttpRequest keystoneAuthWithAccessKeyAndSecretKey; protected String authToken; protected HttpResponse responseWithKeystoneAccess; - public BaseNovaRestClientExpectTest() { + public BaseNovaExpectTest() { provider = "openstack-nova"; keystoneAuthWithUsernameAndPassword = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPassword(identity, credential);