mirror of https://github.com/apache/jclouds.git
Issue 980:timestamp on ec2 requests are in the future
This commit is contained in:
parent
593a09045b
commit
fe72bb3531
|
@ -28,9 +28,6 @@ import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Named;
|
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
import org.jclouds.aws.filters.FormSigner;
|
||||||
import org.jclouds.cloudwatch.config.CloudWatchRestClientModule;
|
import org.jclouds.cloudwatch.config.CloudWatchRestClientModule;
|
||||||
|
@ -114,8 +111,7 @@ public class CloudWatchAsyncClientTest extends RestClientTest<CloudWatchAsyncCli
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String provideTimeStamp(final DateService dateService,
|
protected String provideTimeStamp(final DateService dateService) {
|
||||||
@Named(Constants.PROPERTY_SESSION_INTERVAL) int expiration) {
|
|
||||||
return "2009-11-08T15:54:08.897Z";
|
return "2009-11-08T15:54:08.897Z";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.ec2.config;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
import org.jclouds.aws.config.WithZonesFormSigningRestClientModule;
|
import org.jclouds.aws.config.WithZonesFormSigningRestClientModule;
|
||||||
import org.jclouds.ec2.EC2AsyncClient;
|
import org.jclouds.ec2.EC2AsyncClient;
|
||||||
import org.jclouds.ec2.EC2Client;
|
import org.jclouds.ec2.EC2Client;
|
||||||
|
@ -41,12 +40,16 @@ import org.jclouds.ec2.services.SecurityGroupClient;
|
||||||
import org.jclouds.ec2.services.WindowsAsyncClient;
|
import org.jclouds.ec2.services.WindowsAsyncClient;
|
||||||
import org.jclouds.ec2.services.WindowsClient;
|
import org.jclouds.ec2.services.WindowsClient;
|
||||||
import org.jclouds.ec2.suppliers.DescribeAvailabilityZonesInRegion;
|
import org.jclouds.ec2.suppliers.DescribeAvailabilityZonesInRegion;
|
||||||
import org.jclouds.ec2.suppliers.DescribeRegionsForConfiguredRegions;
|
import org.jclouds.ec2.suppliers.DescribeRegionsForRegionURIs;
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
import org.jclouds.location.config.LocationModule;
|
import org.jclouds.location.config.LocationModule;
|
||||||
import org.jclouds.location.suppliers.RegionIdToURISupplier;
|
import org.jclouds.location.suppliers.RegionIdToURISupplier;
|
||||||
import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier;
|
import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier;
|
||||||
|
import org.jclouds.location.suppliers.RegionIdsSupplier;
|
||||||
|
import org.jclouds.location.suppliers.ZoneIdToURISupplier;
|
||||||
import org.jclouds.location.suppliers.ZoneIdsSupplier;
|
import org.jclouds.location.suppliers.ZoneIdsSupplier;
|
||||||
|
import org.jclouds.location.suppliers.derived.RegionIdsFromRegionIdToURIKeySet;
|
||||||
|
import org.jclouds.location.suppliers.derived.ZoneIdToURIFromJoinOnRegionIdToURI;
|
||||||
import org.jclouds.location.suppliers.derived.ZoneIdsFromRegionIdToZoneIdsValues;
|
import org.jclouds.location.suppliers.derived.ZoneIdsFromRegionIdToZoneIdsValues;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
|
|
||||||
|
@ -77,7 +80,13 @@ public class EC2RestClientModule<S extends EC2Client, A extends EC2AsyncClient>
|
||||||
public static EC2RestClientModule<EC2Client, EC2AsyncClient> create() {
|
public static EC2RestClientModule<EC2Client, EC2AsyncClient> create() {
|
||||||
return new EC2RestClientModule<EC2Client, EC2AsyncClient>(EC2Client.class, EC2AsyncClient.class, DELEGATE_MAP);
|
return new EC2RestClientModule<EC2Client, EC2AsyncClient>(EC2Client.class, EC2AsyncClient.class, DELEGATE_MAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public EC2RestClientModule() {
|
||||||
|
super(Class.class.cast(EC2Client.class), Class.class
|
||||||
|
.cast(EC2AsyncClient.class), DELEGATE_MAP);
|
||||||
|
}
|
||||||
|
|
||||||
public EC2RestClientModule(Class<S> sync, Class<A> async, Map<Class<?>, Class<?>> delegateMap) {
|
public EC2RestClientModule(Class<S> sync, Class<A> async, Map<Class<?>, Class<?>> delegateMap) {
|
||||||
super(sync, async, delegateMap);
|
super(sync, async, delegateMap);
|
||||||
}
|
}
|
||||||
|
@ -86,7 +95,9 @@ public class EC2RestClientModule<S extends EC2Client, A extends EC2AsyncClient>
|
||||||
protected void installLocations() {
|
protected void installLocations() {
|
||||||
install(new LocationModule());
|
install(new LocationModule());
|
||||||
bind(RegionIdToZoneIdsSupplier.class).to(DescribeAvailabilityZonesInRegion.class).in(Scopes.SINGLETON);
|
bind(RegionIdToZoneIdsSupplier.class).to(DescribeAvailabilityZonesInRegion.class).in(Scopes.SINGLETON);
|
||||||
bind(RegionIdToURISupplier.class).to(DescribeRegionsForConfiguredRegions.class).in(Scopes.SINGLETON);
|
bind(RegionIdToURISupplier.class).to(DescribeRegionsForRegionURIs.class).in(Scopes.SINGLETON);
|
||||||
bind(ZoneIdsSupplier.class).to(ZoneIdsFromRegionIdToZoneIdsValues.class).in(Scopes.SINGLETON);
|
bind(ZoneIdsSupplier.class).to(ZoneIdsFromRegionIdToZoneIdsValues.class).in(Scopes.SINGLETON);
|
||||||
|
bind(RegionIdsSupplier.class).to(RegionIdsFromRegionIdToURIKeySet.class).in(Scopes.SINGLETON);
|
||||||
|
bind(ZoneIdToURISupplier.class).to(ZoneIdToURIFromJoinOnRegionIdToURI.class).in(Scopes.SINGLETON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class Volume implements Comparable<Volume> {
|
||||||
private String availabilityZone;
|
private String availabilityZone;
|
||||||
private Status status;
|
private Status status;
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
private Set<Attachment> attachments;
|
private Set<Attachment> attachments = ImmutableSet.of();
|
||||||
|
|
||||||
public Builder region(String region) {
|
public Builder region(String region) {
|
||||||
this.region = region;
|
this.region = region;
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.ec2.suppliers;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
@ -31,29 +30,23 @@ import org.jclouds.location.Region;
|
||||||
import org.jclouds.location.suppliers.RegionIdToURISupplier;
|
import org.jclouds.location.suppliers.RegionIdToURISupplier;
|
||||||
import org.jclouds.util.Suppliers2;
|
import org.jclouds.util.Suppliers2;
|
||||||
|
|
||||||
import com.google.common.base.Predicates;
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class DescribeRegionsForConfiguredRegions implements RegionIdToURISupplier {
|
public class DescribeRegionsForRegionURIs implements RegionIdToURISupplier {
|
||||||
private final AvailabilityZoneAndRegionClient client;
|
private final AvailabilityZoneAndRegionClient client;
|
||||||
private final Supplier<Set<String>> regions;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DescribeRegionsForConfiguredRegions(EC2Client client, @Region Supplier<Set<String>> regions) {
|
public DescribeRegionsForRegionURIs(EC2Client client) {
|
||||||
this.client = client.getAvailabilityZoneAndRegionServices();
|
this.client = client.getAvailabilityZoneAndRegionServices();
|
||||||
this.regions = regions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Region
|
@Region
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Supplier<URI>> get() {
|
public Map<String, Supplier<URI>> get() {
|
||||||
Set<String> regionWhiteList = regions.get();
|
|
||||||
Map<String, URI> regionToUris = client.describeRegions();
|
Map<String, URI> regionToUris = client.describeRegions();
|
||||||
if (regionWhiteList.size() > 0)
|
|
||||||
regionToUris = Maps.filterKeys(regionToUris, Predicates.in(regionWhiteList));
|
|
||||||
return Maps.transformValues(regionToUris, Suppliers2.<URI> ofInstanceFunction());
|
return Maps.transformValues(regionToUris, Suppliers2.<URI> ofInstanceFunction());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,148 @@
|
||||||
|
/**
|
||||||
|
* 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.ec2.config;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.ec2.internal.BaseEC2ExpectTest;
|
||||||
|
import org.jclouds.ec2.services.BaseEC2AsyncClientTest.StubEC2RestClientModule;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.HttpResponse;
|
||||||
|
import org.jclouds.location.Region;
|
||||||
|
import org.jclouds.location.Zone;
|
||||||
|
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
|
||||||
|
import org.jclouds.location.functions.ZoneToEndpoint;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableMap.Builder;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
import com.google.inject.Key;
|
||||||
|
import com.google.inject.Module;
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "EC2RestClientModuleExpectTest")
|
||||||
|
public class EC2RestClientModuleExpectTest extends BaseEC2ExpectTest<Injector> {
|
||||||
|
private Injector injector;
|
||||||
|
|
||||||
|
public EC2RestClientModuleExpectTest() {
|
||||||
|
Builder<HttpRequest, HttpResponse> builder = ImmutableMap.<HttpRequest, HttpResponse> builder();
|
||||||
|
builder.put(describeRegionsRequest, describeRegionsResponse);
|
||||||
|
builder.putAll(describeAvailabilityZonesRequestResponse);
|
||||||
|
|
||||||
|
injector = requestsSendResponses(builder.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testLocationIdAndURIBindings() {
|
||||||
|
|
||||||
|
assertEquals(injector.getInstance(Key.get(new TypeLiteral<Supplier<Set<String>>>() {
|
||||||
|
}, Region.class)).get(), ImmutableSet.<String> of("sa-east-1", "ap-northeast-1", "eu-west-1", "us-east-1",
|
||||||
|
"us-west-1", "us-west-2", "ap-southeast-1"));
|
||||||
|
|
||||||
|
assertEquals(injector.getInstance(Key.get(new TypeLiteral<Supplier<Set<String>>>() {
|
||||||
|
}, Zone.class)).get(), ImmutableSet.<String> of("sa-east-1a", "sa-east-1b", "ap-northeast-1a", "ap-northeast-1b",
|
||||||
|
"eu-west-1a", "eu-west-1b", "eu-west-1c", "us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d",
|
||||||
|
"us-east-1e", "us-west-1a", "us-west-1b", "us-west-1c", "us-west-2a", "us-west-2b", "us-west-2c",
|
||||||
|
"ap-southeast-1a", "ap-southeast-1b"));
|
||||||
|
|
||||||
|
Map<String, Supplier<URI>> regionToURISupplier = injector.getInstance(
|
||||||
|
Key.get(new TypeLiteral<Supplier<Map<String, Supplier<URI>>>>() {
|
||||||
|
}, Region.class)).get();
|
||||||
|
|
||||||
|
assertEquals(regionToURISupplier.get("sa-east-1").get(), URI.create("https://ec2.sa-east-1.amazonaws.com"));
|
||||||
|
assertEquals(regionToURISupplier.get("ap-northeast-1").get(),
|
||||||
|
URI.create("https://ec2.ap-northeast-1.amazonaws.com"));
|
||||||
|
assertEquals(regionToURISupplier.get("eu-west-1").get(), URI.create("https://ec2.eu-west-1.amazonaws.com"));
|
||||||
|
assertEquals(regionToURISupplier.get("us-east-1").get(), URI.create("https://ec2.us-east-1.amazonaws.com"));
|
||||||
|
assertEquals(regionToURISupplier.get("us-west-1").get(), URI.create("https://ec2.us-west-1.amazonaws.com"));
|
||||||
|
assertEquals(regionToURISupplier.get("us-west-2").get(), URI.create("https://ec2.us-west-2.amazonaws.com"));
|
||||||
|
assertEquals(regionToURISupplier.get("ap-southeast-1").get(),
|
||||||
|
URI.create("https://ec2.ap-southeast-1.amazonaws.com"));
|
||||||
|
|
||||||
|
Map<String, Supplier<Set<String>>> regionToZoneIdSupplier = injector.getInstance(
|
||||||
|
Key.get(new TypeLiteral<Supplier<Map<String, Supplier<Set<String>>>>>() {
|
||||||
|
}, Zone.class)).get();
|
||||||
|
|
||||||
|
assertEquals(regionToZoneIdSupplier.get("sa-east-1").get(), ImmutableSet.of("sa-east-1a", "sa-east-1b"));
|
||||||
|
assertEquals(regionToZoneIdSupplier.get("ap-northeast-1").get(),
|
||||||
|
ImmutableSet.of("ap-northeast-1a", "ap-northeast-1b"));
|
||||||
|
assertEquals(regionToZoneIdSupplier.get("eu-west-1").get(),
|
||||||
|
ImmutableSet.of("eu-west-1a", "eu-west-1b", "eu-west-1c"));
|
||||||
|
assertEquals(regionToZoneIdSupplier.get("us-east-1").get(),
|
||||||
|
ImmutableSet.of("us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d", "us-east-1e"));
|
||||||
|
assertEquals(regionToZoneIdSupplier.get("us-west-1").get(),
|
||||||
|
ImmutableSet.of("us-west-1a", "us-west-1b", "us-west-1c"));
|
||||||
|
assertEquals(regionToZoneIdSupplier.get("us-west-2").get(),
|
||||||
|
ImmutableSet.of("us-west-2a", "us-west-2b", "us-west-2c"));
|
||||||
|
assertEquals(regionToZoneIdSupplier.get("ap-southeast-1").get(),
|
||||||
|
ImmutableSet.of("ap-southeast-1a", "ap-southeast-1b"));
|
||||||
|
|
||||||
|
Map<String, Supplier<URI>> zoneToURISupplier = injector.getInstance(
|
||||||
|
Key.get(new TypeLiteral<Supplier<Map<String, Supplier<URI>>>>() {
|
||||||
|
}, Zone.class)).get();
|
||||||
|
|
||||||
|
assertEquals(zoneToURISupplier.get("sa-east-1a").get(), URI.create("https://ec2.sa-east-1.amazonaws.com"));
|
||||||
|
|
||||||
|
assertEquals(zoneToURISupplier.get("ap-northeast-1a").get(),
|
||||||
|
URI.create("https://ec2.ap-northeast-1.amazonaws.com"));
|
||||||
|
|
||||||
|
assertEquals(zoneToURISupplier.get("eu-west-1a").get(), URI.create("https://ec2.eu-west-1.amazonaws.com"));
|
||||||
|
|
||||||
|
assertEquals(zoneToURISupplier.get("us-east-1a").get(), URI.create("https://ec2.us-east-1.amazonaws.com"));
|
||||||
|
|
||||||
|
assertEquals(zoneToURISupplier.get("us-west-1a").get(), URI.create("https://ec2.us-west-1.amazonaws.com"));
|
||||||
|
|
||||||
|
assertEquals(zoneToURISupplier.get("us-west-2a").get(), URI.create("https://ec2.us-west-2.amazonaws.com"));
|
||||||
|
|
||||||
|
assertEquals(zoneToURISupplier.get("ap-southeast-1a").get(),
|
||||||
|
URI.create("https://ec2.ap-southeast-1.amazonaws.com"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testZoneToEndpoint() {
|
||||||
|
assertEquals(injector.getInstance(ZoneToEndpoint.class).apply("us-west-2a"),
|
||||||
|
URI.create("https://ec2.us-west-2.amazonaws.com"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRegionToEndpointOrProviderIfNull() {
|
||||||
|
assertEquals(injector.getInstance(RegionToEndpointOrProviderIfNull.class).apply("us-west-2"),
|
||||||
|
URI.create("https://ec2.us-west-2.amazonaws.com"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Injector createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
|
||||||
|
return createInjector(fn, module, props);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Module createModule() {
|
||||||
|
return new StubEC2RestClientModule();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,99 @@
|
||||||
|
/**
|
||||||
|
* 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.ec2.internal;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
import org.jclouds.aws.filters.FormSigner;
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
|
import org.jclouds.ec2.EC2AsyncClient;
|
||||||
|
import org.jclouds.ec2.EC2Client;
|
||||||
|
import org.jclouds.ec2.config.EC2RestClientModule;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.HttpResponse;
|
||||||
|
import org.jclouds.rest.BaseRestClientExpectTest;
|
||||||
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
|
|
||||||
|
import com.google.common.base.Functions;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableMap.Builder;
|
||||||
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.inject.Module;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
|
public abstract class BaseEC2ExpectTest<T> extends BaseRestClientExpectTest<T> {
|
||||||
|
protected static final String CONSTANT_DATE = "2012-04-16T15:54:08.897Z";
|
||||||
|
|
||||||
|
protected DateService dateService = new SimpleDateFormatDateService();
|
||||||
|
|
||||||
|
protected HttpRequest describeRegionsRequest = HttpRequest
|
||||||
|
.builder()
|
||||||
|
.method("POST")
|
||||||
|
.endpoint(URI.create("https://ec2.us-east-1.amazonaws.com/"))
|
||||||
|
.headers(ImmutableMultimap.of("Host", "ec2.us-east-1.amazonaws.com"))
|
||||||
|
.payload(payloadFromStringWithContentType(
|
||||||
|
"Action=DescribeRegions&Signature=s5OXKqaaeKhJW5FVrRntuMsUL4Ed5fjzgUWeukU96ko%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2010-06-15&AWSAccessKeyId=identity",
|
||||||
|
MediaType.APPLICATION_FORM_URLENCODED)).build();
|
||||||
|
protected HttpResponse describeRegionsResponse = HttpResponse.builder().statusCode(200)
|
||||||
|
.payload(payloadFromResourceWithContentType("/regionEndpoints-all.xml", MediaType.APPLICATION_XML))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
protected final Map<HttpRequest, HttpResponse> describeAvailabilityZonesRequestResponse;
|
||||||
|
|
||||||
|
public BaseEC2ExpectTest() {
|
||||||
|
provider = "ec2";
|
||||||
|
FormSigner formSigner = createInjector(Functions.forMap(ImmutableMap.<HttpRequest, HttpResponse> of()),
|
||||||
|
createModule(), setupProperties()).getInstance(FormSigner.class);
|
||||||
|
Builder<HttpRequest, HttpResponse> builder = ImmutableMap.<HttpRequest, HttpResponse> builder();
|
||||||
|
for (String region : ImmutableSet.of("ap-northeast-1", "ap-southeast-1", "eu-west-1", "sa-east-1", "us-east-1", "us-west-1", "us-west-2")){
|
||||||
|
builder.put(
|
||||||
|
formSigner.filter(HttpRequest.builder()
|
||||||
|
.method("POST")
|
||||||
|
.endpoint(URI.create("https://ec2." + region + ".amazonaws.com/"))
|
||||||
|
.headers(ImmutableMultimap.of("Host", "ec2." + region + ".amazonaws.com"))
|
||||||
|
.payload(payloadFromStringWithContentType(
|
||||||
|
"Action=DescribeAvailabilityZones&Version=2010-06-15",
|
||||||
|
MediaType.APPLICATION_FORM_URLENCODED)).build()),
|
||||||
|
HttpResponse.builder().statusCode(200)
|
||||||
|
.payload(payloadFromResourceWithContentType(
|
||||||
|
"/availabilityZones-" + region + ".xml", MediaType.APPLICATION_XML)).build());
|
||||||
|
|
||||||
|
}
|
||||||
|
describeAvailabilityZonesRequestResponse = builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfiguresRestClient
|
||||||
|
private static final class TestEC2RestClientModule extends EC2RestClientModule<EC2Client, EC2AsyncClient> {
|
||||||
|
@Override
|
||||||
|
@Provides
|
||||||
|
protected String provideTimeStamp(DateService dateService) {
|
||||||
|
return CONSTANT_DATE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Module createModule() {
|
||||||
|
return new TestEC2RestClientModule();
|
||||||
|
}
|
||||||
|
}
|
|
@ -67,7 +67,7 @@ import com.google.inject.Provides;
|
||||||
public abstract class BaseEC2AsyncClientTest<T> extends RestClientTest<T> {
|
public abstract class BaseEC2AsyncClientTest<T> extends RestClientTest<T> {
|
||||||
@RequiresHttp
|
@RequiresHttp
|
||||||
@ConfiguresRestClient
|
@ConfiguresRestClient
|
||||||
protected static class StubEC2RestClientModule extends EC2RestClientModule<EC2Client, EC2AsyncClient> {
|
public static class StubEC2RestClientModule extends EC2RestClientModule<EC2Client, EC2AsyncClient> {
|
||||||
|
|
||||||
public StubEC2RestClientModule() {
|
public StubEC2RestClientModule() {
|
||||||
super(EC2Client.class, EC2AsyncClient.class, DELEGATE_MAP);
|
super(EC2Client.class, EC2AsyncClient.class, DELEGATE_MAP);
|
||||||
|
@ -87,7 +87,7 @@ public abstract class BaseEC2AsyncClientTest<T> extends RestClientTest<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String provideTimeStamp(DateService dateService, int expiration) {
|
protected String provideTimeStamp(DateService dateService) {
|
||||||
return "2009-11-08T15:54:08.897Z";
|
return "2009-11-08T15:54:08.897Z";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
/**
|
||||||
|
* 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.ec2.services;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.jclouds.ec2.EC2Client;
|
||||||
|
import org.jclouds.ec2.domain.Volume;
|
||||||
|
import org.jclouds.ec2.internal.BaseEC2ExpectTest;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.HttpResponse;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableMap.Builder;
|
||||||
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "EC2ElasticBlockStoreClientExpectTest")
|
||||||
|
public class EC2ElasticBlockStoreClientExpectTest extends BaseEC2ExpectTest<EC2Client> {
|
||||||
|
|
||||||
|
public void testCreateVolumeInAvailabilityZone() {
|
||||||
|
Builder<HttpRequest, HttpResponse> builder = ImmutableMap.<HttpRequest, HttpResponse>builder();
|
||||||
|
builder.put(describeRegionsRequest, describeRegionsResponse);
|
||||||
|
builder.putAll(describeAvailabilityZonesRequestResponse);
|
||||||
|
builder.put(
|
||||||
|
HttpRequest.builder()
|
||||||
|
.method("POST")
|
||||||
|
.endpoint(URI.create("https://ec2.us-east-1.amazonaws.com/"))
|
||||||
|
.headers(ImmutableMultimap.of("Host", "ec2.us-east-1.amazonaws.com"))
|
||||||
|
.payload(payloadFromStringWithContentType("Action=CreateVolume&AvailabilityZone=us-east-1a&Signature=FB5hTZHKSAuiygoafIdJh1EnfTu0ogC2VfRQOar85mg%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Size=4&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2010-06-15&AWSAccessKeyId=identity", "application/x-www-form-urlencoded")).build(),
|
||||||
|
HttpResponse.builder()
|
||||||
|
.statusCode(200)
|
||||||
|
.payload(payloadFromResource("/created_volume.xml")).build());
|
||||||
|
|
||||||
|
ElasticBlockStoreClient client = requestsSendResponses(builder.build()).getElasticBlockStoreServices();
|
||||||
|
Volume expected = Volume
|
||||||
|
.builder()
|
||||||
|
.id("vol-2a21e543")
|
||||||
|
.status(Volume.Status.CREATING)
|
||||||
|
.availabilityZone("us-east-1a")
|
||||||
|
.region("us-east-1")
|
||||||
|
.id("vol-2a21e543")
|
||||||
|
.size(1)
|
||||||
|
.createTime(dateService.iso8601DateParse("2009-12-28T05:42:53.000Z"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(client.createVolumeInAvailabilityZone("us-east-1a", 4), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||||
|
<requestId>24251909-7fb6-4080-8ca3-fbb5a1ddb02d</requestId>
|
||||||
|
<availabilityZoneInfo>
|
||||||
|
<item>
|
||||||
|
<zoneName>ap-northeast-1a</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>ap-northeast-1</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<zoneName>ap-northeast-1b</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>ap-northeast-1</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
</availabilityZoneInfo>
|
||||||
|
</DescribeAvailabilityZonesResponse>
|
|
@ -0,0 +1,17 @@
|
||||||
|
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||||
|
<requestId>22c5332d-c331-4310-b695-e21e76c3fdb0</requestId>
|
||||||
|
<availabilityZoneInfo>
|
||||||
|
<item>
|
||||||
|
<zoneName>ap-southeast-1a</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>ap-southeast-1</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<zoneName>ap-southeast-1b</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>ap-southeast-1</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
</availabilityZoneInfo>
|
||||||
|
</DescribeAvailabilityZonesResponse>
|
|
@ -0,0 +1,23 @@
|
||||||
|
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||||
|
<requestId>386c8215-6ec8-4495-aaa6-8c4175688093</requestId>
|
||||||
|
<availabilityZoneInfo>
|
||||||
|
<item>
|
||||||
|
<zoneName>eu-west-1a</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>eu-west-1</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<zoneName>eu-west-1b</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>eu-west-1</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<zoneName>eu-west-1c</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>eu-west-1</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
</availabilityZoneInfo>
|
||||||
|
</DescribeAvailabilityZonesResponse>
|
|
@ -0,0 +1,17 @@
|
||||||
|
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||||
|
<requestId>d2e09bd5-b2ec-4c6b-aac9-6bf1fa217cb5</requestId>
|
||||||
|
<availabilityZoneInfo>
|
||||||
|
<item>
|
||||||
|
<zoneName>sa-east-1a</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>sa-east-1</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<zoneName>sa-east-1b</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>sa-east-1</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
</availabilityZoneInfo>
|
||||||
|
</DescribeAvailabilityZonesResponse>
|
|
@ -0,0 +1,35 @@
|
||||||
|
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||||
|
<requestId>ed825abf-edbb-4677-83d5-0fbd86ce5a5d</requestId>
|
||||||
|
<availabilityZoneInfo>
|
||||||
|
<item>
|
||||||
|
<zoneName>us-east-1a</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>us-east-1</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<zoneName>us-east-1b</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>us-east-1</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<zoneName>us-east-1c</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>us-east-1</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<zoneName>us-east-1d</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>us-east-1</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<zoneName>us-east-1e</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>us-east-1</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
</availabilityZoneInfo>
|
||||||
|
</DescribeAvailabilityZonesResponse>
|
|
@ -0,0 +1,23 @@
|
||||||
|
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||||
|
<requestId>dbfb2a5f-ce75-49fb-846b-e2cf2fc5cdbb</requestId>
|
||||||
|
<availabilityZoneInfo>
|
||||||
|
<item>
|
||||||
|
<zoneName>us-west-1a</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>us-west-1</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<zoneName>us-west-1b</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>us-west-1</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<zoneName>us-west-1c</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>us-west-1</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
</availabilityZoneInfo>
|
||||||
|
</DescribeAvailabilityZonesResponse>
|
|
@ -0,0 +1,23 @@
|
||||||
|
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||||
|
<requestId>e40c2bc4-7231-4df1-a604-202bb8333332</requestId>
|
||||||
|
<availabilityZoneInfo>
|
||||||
|
<item>
|
||||||
|
<zoneName>us-west-2a</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>us-west-2</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<zoneName>us-west-2b</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>us-west-2</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<zoneName>us-west-2c</zoneName>
|
||||||
|
<zoneState>available</zoneState>
|
||||||
|
<regionName>us-west-2</regionName>
|
||||||
|
<messageSet/>
|
||||||
|
</item>
|
||||||
|
</availabilityZoneInfo>
|
||||||
|
</DescribeAvailabilityZonesResponse>
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<DescribeRegionsResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||||
|
<requestId>8392a998-c7bb-41fc-be15-045f528d7627</requestId>
|
||||||
|
<regionInfo>
|
||||||
|
<item>
|
||||||
|
<regionName>eu-west-1</regionName>
|
||||||
|
<regionEndpoint>ec2.eu-west-1.amazonaws.com</regionEndpoint>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<regionName>sa-east-1</regionName>
|
||||||
|
<regionEndpoint>ec2.sa-east-1.amazonaws.com</regionEndpoint>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<regionName>us-east-1</regionName>
|
||||||
|
<regionEndpoint>ec2.us-east-1.amazonaws.com</regionEndpoint>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<regionName>ap-northeast-1</regionName>
|
||||||
|
<regionEndpoint>ec2.ap-northeast-1.amazonaws.com</regionEndpoint>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<regionName>us-west-2</regionName>
|
||||||
|
<regionEndpoint>ec2.us-west-2.amazonaws.com</regionEndpoint>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<regionName>us-west-1</regionName>
|
||||||
|
<regionEndpoint>ec2.us-west-1.amazonaws.com</regionEndpoint>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<regionName>ap-southeast-1</regionName>
|
||||||
|
<regionEndpoint>ec2.ap-southeast-1.amazonaws.com</regionEndpoint>
|
||||||
|
</item>
|
||||||
|
</regionInfo>
|
||||||
|
</DescribeRegionsResponse>
|
|
@ -21,10 +21,8 @@ package org.jclouds.aws.config;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.inject.Named;
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
import org.jclouds.aws.filters.FormSigner;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.date.TimeStamp;
|
import org.jclouds.date.TimeStamp;
|
||||||
|
@ -53,9 +51,8 @@ public class FormSigningRestClientModule<S, A> extends AWSRestClientModule<S, A>
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@TimeStamp
|
@TimeStamp
|
||||||
protected String provideTimeStamp(final DateService dateService,
|
protected String provideTimeStamp(final DateService dateService) {
|
||||||
@Named(Constants.PROPERTY_SESSION_INTERVAL) final int expiration) {
|
return dateService.iso8601DateFormat(new Date(System.currentTimeMillis()));
|
||||||
return dateService.iso8601DateFormat(new Date(System.currentTimeMillis() + (expiration * 1000)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
/**
|
||||||
|
* 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.location.suppliers.derived;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.location.Region;
|
||||||
|
import org.jclouds.location.Zone;
|
||||||
|
import org.jclouds.location.suppliers.ZoneIdToURISupplier;
|
||||||
|
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableMap.Builder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class ZoneIdToURIFromJoinOnRegionIdToURI implements ZoneIdToURISupplier {
|
||||||
|
|
||||||
|
private final Supplier<Map<String, Supplier<URI>>> regionIdToURISupplier;
|
||||||
|
private final Supplier<Map<String, Supplier<Set<String>>>> regionIdToZoneIdsSupplier;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
protected ZoneIdToURIFromJoinOnRegionIdToURI(@Region Supplier<Map<String, Supplier<URI>>> regionIdToURISupplier,
|
||||||
|
@Zone Supplier<Map<String, Supplier<Set<String>>>> regionIdToZoneIdsSupplier) {
|
||||||
|
this.regionIdToURISupplier = regionIdToURISupplier;
|
||||||
|
this.regionIdToZoneIdsSupplier = regionIdToZoneIdsSupplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Supplier<URI>> get() {
|
||||||
|
Builder<String, Supplier<URI>> builder = ImmutableMap.<String, Supplier<URI>> builder();
|
||||||
|
for (Entry<String, Supplier<URI>> regionToURI : regionIdToURISupplier.get().entrySet()) {
|
||||||
|
for (String zone : regionIdToZoneIdsSupplier.get().get(regionToURI.getKey()).get()) {
|
||||||
|
builder.put(zone, regionToURI.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -23,6 +23,7 @@ import static java.lang.annotation.ElementType.TYPE;
|
||||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
import static org.jclouds.rest.RestContextFactory.contextSpec;
|
import static org.jclouds.rest.RestContextFactory.contextSpec;
|
||||||
import static org.jclouds.rest.RestContextFactory.createContext;
|
import static org.jclouds.rest.RestContextFactory.createContext;
|
||||||
|
import static org.jclouds.rest.RestContextFactory.createContextBuilder;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -30,8 +31,8 @@ import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
@ -68,6 +69,7 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Binder;
|
import com.google.inject.Binder;
|
||||||
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
import com.google.inject.name.Names;
|
import com.google.inject.name.Names;
|
||||||
|
@ -414,6 +416,13 @@ public abstract class BaseRestClientExpectTest<S> {
|
||||||
return createContext(contextSpec,
|
return createContext(contextSpec,
|
||||||
ImmutableSet.<Module> of(new ExpectModule(fn), new NullLoggingModule(), module), props).getApi();
|
ImmutableSet.<Module> of(new ExpectModule(fn), new NullLoggingModule(), module), props).getApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Injector createInjector(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
|
||||||
|
RestContextSpec<S, ?> contextSpec = makeContextSpec();
|
||||||
|
|
||||||
|
return createContextBuilder(contextSpec,
|
||||||
|
ImmutableSet.<Module> of(new ExpectModule(fn), new NullLoggingModule(), module), props).buildInjector();
|
||||||
|
}
|
||||||
|
|
||||||
protected String identity = "identity";
|
protected String identity = "identity";
|
||||||
protected String credential = "credential";
|
protected String credential = "credential";
|
||||||
|
|
|
@ -68,7 +68,7 @@ public abstract class BaseAWSEC2AsyncClientTest<T> extends RestClientTest<T> {
|
||||||
protected static class StubAWSEC2RestClientModule extends AWSEC2RestClientModule {
|
protected static class StubAWSEC2RestClientModule extends AWSEC2RestClientModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String provideTimeStamp(DateService dateService, int expiration) {
|
protected String provideTimeStamp(DateService dateService) {
|
||||||
return "2009-11-08T15:54:08.897Z";
|
return "2009-11-08T15:54:08.897Z";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue