unhooked version dependency from ec2 async tests

This commit is contained in:
Adrian Cole 2013-02-25 17:04:32 -08:00
parent 6dc03a7993
commit ac7a4b5354
10 changed files with 95 additions and 339 deletions

View File

@ -21,6 +21,8 @@ package org.jclouds.ec2.binders;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.lang.String.format;
import static org.jclouds.http.utils.Queries.queryParser;
import static org.jclouds.io.Payloads.newUrlEncodedFormPayload;
import java.util.Map;
import java.util.Map.Entry;
@ -29,9 +31,8 @@ import org.jclouds.ec2.domain.BlockDevice;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.Binder;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
/**
* @author Oleksiy Yarmula
@ -40,28 +41,29 @@ import com.google.common.collect.Multimaps;
public class BindBlockDeviceMappingToIndexedFormParams implements Binder {
private static final String deviceNamePattern = "BlockDeviceMapping.%d.DeviceName";
private static final String volumeIdPattern = "BlockDeviceMapping.%d.Ebs.VolumeId";
private static final String deleteOnTerminationPattern = "BlockDeviceMapping.%d.Ebs.DeleteOnTermination";
private static final String volumeIdPattern = "BlockDeviceMapping.%d.Ebs.VolumeId";
@SuppressWarnings("unchecked")
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
checkArgument(checkNotNull(input, "input") instanceof Map, "this binder is only valid for Map");
Map<String, BlockDevice> blockDeviceMapping = (Map<String, BlockDevice>) input;
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
Multimap<String, String> original = queryParser().apply(request.getPayload().getRawContent().toString());
ImmutableMultimap.Builder<String, String> builder = ImmutableMultimap.builder();
builder.putAll("Action", "ModifyInstanceAttribute");
int amazonOneBasedIndex = 1; // according to docs, counters must start with 1
for (Entry<String, BlockDevice> ebsBlockDeviceName : blockDeviceMapping.entrySet()) {
// not null by contract
builder.put(format(volumeIdPattern, amazonOneBasedIndex), ebsBlockDeviceName.getValue().getVolumeId());
builder.put(format(deviceNamePattern, amazonOneBasedIndex), ebsBlockDeviceName.getKey());
builder.put(format(deleteOnTerminationPattern, amazonOneBasedIndex),
String.valueOf(ebsBlockDeviceName.getValue().isDeleteOnTermination()));
builder.put(format(volumeIdPattern, amazonOneBasedIndex), ebsBlockDeviceName.getValue().getVolumeId());
amazonOneBasedIndex++;
}
Multimap<String, String> forms = Multimaps.forMap(builder.build());
return forms.size() == 0 ? request : (R) request.toBuilder().replaceFormParams(forms).build();
builder.putAll("InstanceId", original.get("InstanceId"));
request.setPayload(newUrlEncodedFormPayload(builder.build()));
return request;
}
}

View File

@ -44,17 +44,18 @@ public class BindBlockDeviceMappingToIndexedFormParamsTest {
BindBlockDeviceMappingToIndexedFormParams binder = injector
.getInstance(BindBlockDeviceMappingToIndexedFormParams.class);
public void testMapping() {
public void testMappingOrdersLexicographically() {
Map<String, BlockDevice> mapping = Maps.newLinkedHashMap();
mapping.put("apple", new BlockDevice("appleId", true));
Date date = new Date(999999l);
mapping.put("cranberry", new BlockDevice("cranberry", Status.ATTACHED, date, false));
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost")
.addFormParam("InstanceId", "i-foo").build();
request = binder.bindToRequest(request, mapping);
assertEquals(
request.getPayload().getRawContent(),
"BlockDeviceMapping.1.Ebs.VolumeId=appleId&BlockDeviceMapping.1.DeviceName=apple&BlockDeviceMapping.1.Ebs.DeleteOnTermination=true&BlockDeviceMapping.2.Ebs.VolumeId=cranberry&BlockDeviceMapping.2.DeviceName=cranberry&BlockDeviceMapping.2.Ebs.DeleteOnTermination=false");
"Action=ModifyInstanceAttribute&BlockDeviceMapping.1.DeviceName=apple&BlockDeviceMapping.1.Ebs.DeleteOnTermination=true&BlockDeviceMapping.1.Ebs.VolumeId=appleId&BlockDeviceMapping.2.DeviceName=cranberry&BlockDeviceMapping.2.Ebs.DeleteOnTermination=false&BlockDeviceMapping.2.Ebs.VolumeId=cranberry&InstanceId=i-foo");
}
@Test(expectedExceptions = IllegalArgumentException.class)

View File

@ -547,6 +547,15 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
checkFilters(request);
}
HttpRequest setBlockDeviceMapping = HttpRequest.builder().method("POST")
.endpoint("https://ec2.us-east-1.amazonaws.com/")
.addHeader("Host", "ec2.us-east-1.amazonaws.com")
.addFormParam("Action", "ModifyInstanceAttribute")
.addFormParam("BlockDeviceMapping.1.DeviceName", "/dev/sda1")
.addFormParam("BlockDeviceMapping.1.Ebs.DeleteOnTermination", "true")
.addFormParam("BlockDeviceMapping.1.Ebs.VolumeId", "vol-test1")
.addFormParam("InstanceId", "1").build();
public void testSetBlockDeviceMappingForInstanceInRegion() throws SecurityException, NoSuchMethodException,
IOException {
Invokable<?, ?> method = method(InstanceAsyncClient.class, "setBlockDeviceMappingForInstanceInRegion", String.class,
@ -556,20 +565,13 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
mapping.put("/dev/sda1", new BlockDevice("vol-test1", true));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", mapping));
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Action=ModifyInstanceAttribute&InstanceId=1&BlockDeviceMapping.1.Ebs.VolumeId=vol-test1&BlockDeviceMapping.1.DeviceName=/dev/sda1&BlockDeviceMapping.1.Ebs.DeleteOnTermination=true",
"application/x-www-form-urlencoded", false);
filter.filter(request);// ensure encoding worked properly
assertPayloadEquals(
request,
"Action=ModifyInstanceAttribute&BlockDeviceMapping.1.DeviceName=/dev/sda1&BlockDeviceMapping.1.Ebs.DeleteOnTermination=true&BlockDeviceMapping.1.Ebs.VolumeId=vol-test1&InstanceId=1&Signature=RwY8lVPHSQxQkd5efUKccHdSTkN4OxMIMFiYAe3rrUE%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&Version=2010-06-15&AWSAccessKeyId=identity",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
assertFallbackClassEquals(method, null);
assertPayloadEquals(request, filter.filter(setBlockDeviceMapping).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
checkFilters(request);
}

View File

@ -34,7 +34,7 @@ import org.jclouds.rest.annotations.Delegate;
* @author Adrian Cole
*/
public interface AWSEC2AsyncClient extends EC2AsyncClient {
public static final String VERSION = "2011-05-15";
public static final String VERSION = "2012-06-01";
/**
* {@inheritDoc}

View File

@ -59,13 +59,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
.addHeader("Host", "ec2.us-east-1.amazonaws.com")
.addFormParam("Action", "CreateImage")
.addFormParam("InstanceId", "instanceId")
.addFormParam("Name", "name")
.addFormParam("Signature", "ISQJKjDmhy9Vyc5zKYfkSk%2B2zIu%2Bfm6nc4H0a4mvmcU=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("Name", "name").build();
public void testCreateImage() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSAMIAsyncClient.class, "createImageInRegion", String.class, String.class, String.class,
@ -76,7 +70,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, createImage.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(createImage).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
@ -92,13 +86,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
.addFormParam("Description", "description")
.addFormParam("InstanceId", "instanceId")
.addFormParam("Name", "name")
.addFormParam("NoReboot", "true")
.addFormParam("Signature", "nEpcd4m4UGl7OUm3sIlknV98HzHRUg4WYd/doIJ9S84=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("NoReboot", "true").build();
public void testCreateImageOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSAMIAsyncClient.class, "createImageInRegion", String.class, String.class, String.class,
@ -110,7 +98,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, createImageOptions.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(createImageOptions).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -123,13 +111,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
HttpRequest describeImages = HttpRequest.builder().method("POST")
.endpoint("https://ec2.us-east-1.amazonaws.com/")
.addHeader("Host", "ec2.us-east-1.amazonaws.com")
.addFormParam("Action", "DescribeImages")
.addFormParam("Signature", "tMg44xaebrZMOYS6EOf2RvvrOEJMacSlNAJaQruj100=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("Action", "DescribeImages").build();
public void testDescribeImages() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSAMIAsyncClient.class, "describeImagesInRegion", String.class,
@ -140,7 +122,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, describeImages.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(describeImages).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -158,13 +140,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
.addFormParam("ImageId.1", "1")
.addFormParam("ImageId.2", "2")
.addFormParam("Owner.1", "fred")
.addFormParam("Owner.2", "nancy")
.addFormParam("Signature", "WeMm/2znlzxYhwQqbcLr74qXreoQ60WI76T6NKZ071Q=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("Owner.2", "nancy").build();
public void testDescribeImagesOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSAMIAsyncClient.class, "describeImagesInRegion", String.class,
@ -176,7 +152,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, describeImagesOptions.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(describeImagesOptions).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -190,13 +166,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
.endpoint("https://ec2.us-east-1.amazonaws.com/")
.addHeader("Host", "ec2.us-east-1.amazonaws.com")
.addFormParam("Action", "DeregisterImage")
.addFormParam("ImageId", "imageId")
.addFormParam("Signature", "89plCGzc15vXmjO38/B430Pwz5/Zv6%2BxLwIQivUJIQ8=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("ImageId", "imageId").build();
public void testDeregisterImage() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSAMIAsyncClient.class, "deregisterImageInRegion", String.class, String.class);
@ -206,7 +176,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, deregisterImage.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(deregisterImage).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -221,13 +191,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
.addHeader("Host", "ec2.us-east-1.amazonaws.com")
.addFormParam("Action", "RegisterImage")
.addFormParam("ImageLocation", "pathToManifest")
.addFormParam("Name", "name")
.addFormParam("Signature", "XnUpMvw7tz6PEngDmt%2Bx2XKFFfV1HWg54rxv5DrudrQ=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("Name", "name").build();
public void testRegisterImageFromManifest() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSAMIAsyncClient.class, "registerImageFromManifestInRegion", String.class, String.class,
@ -238,7 +202,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, registerImageFromManifest.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(registerImageFromManifest).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
@ -253,13 +217,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
.addFormParam("Action", "RegisterImage")
.addFormParam("Description", "description")
.addFormParam("ImageLocation", "pathToManifest")
.addFormParam("Name", "name")
.addFormParam("Signature", "/nJBP27hFsDual7ZRIK8fQsWiNNA8hWaVY7AFIuismE=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("Name", "name").build();
public void testRegisterImageFromManifestOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSAMIAsyncClient.class, "registerImageFromManifestInRegion", String.class, String.class,
@ -271,8 +229,8 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, registerImageFromManifestOptions.getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertPayloadEquals(request, filter.filter(registerImageFromManifestOptions).getPayload().getRawContent()
.toString(), "application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
@ -288,13 +246,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
.addFormParam("BlockDeviceMapping.0.DeviceName", "/dev/sda1")
.addFormParam("BlockDeviceMapping.0.Ebs.SnapshotId", "snapshotId")
.addFormParam("Name", "imageName")
.addFormParam("RootDeviceName", "/dev/sda1")
.addFormParam("Signature", "Pj242OpjbY4NXvaVYzQdjTud4N68NIxQP0oRZtdjd%2BY=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("RootDeviceName", "/dev/sda1").build();
public void testRegisterImageBackedByEBS() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSAMIAsyncClient.class, "registerUnixImageBackedByEbsInRegion", String.class,
@ -305,7 +257,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, registerImageBackedByEBS.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(registerImageBackedByEBS).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
@ -329,13 +281,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
.addFormParam("BlockDeviceMapping.2.VirtualName", "newblock")
.addFormParam("Description", "description")
.addFormParam("Name", "imageName")
.addFormParam("RootDeviceName", "/dev/sda1")
.addFormParam("Signature", "QGwHRDis98NSU2KU9W52srltVyAQrDtj3MQ5YlzNX3I=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("RootDeviceName", "/dev/sda1").build();
public void testRegisterImageBackedByEBSOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSAMIAsyncClient.class, "registerUnixImageBackedByEbsInRegion", String.class,
@ -348,8 +294,8 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, registerImageBackedByEBSOptions.getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertPayloadEquals(request, filter.filter(registerImageBackedByEBSOptions).getPayload().getRawContent()
.toString(), "application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
@ -363,13 +309,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
.addHeader("Host", "ec2.us-east-1.amazonaws.com")
.addFormParam("Action", "DescribeImageAttribute")
.addFormParam("Attribute", "blockDeviceMapping")
.addFormParam("ImageId", "imageId")
.addFormParam("Signature", "aJjRBDJvQ91Zw33%2BLqyhDsfQdWxF2xdN3KlV90pGCb0=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("ImageId", "imageId").build();
public void testGetBlockDeviceMappingsForImage() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSAMIAsyncClient.class, "getBlockDeviceMappingsForImageInRegion", String.class,
@ -380,8 +320,8 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, getBlockDeviceMappingsForImage.getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertPayloadEquals(request, filter.filter(getBlockDeviceMappingsForImage).getPayload().getRawContent()
.toString(), "application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, BlockDeviceMappingHandler.class);
@ -395,13 +335,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
.addHeader("Host", "ec2.us-east-1.amazonaws.com")
.addFormParam("Action", "DescribeImageAttribute")
.addFormParam("Attribute", "launchPermission")
.addFormParam("ImageId", "imageId")
.addFormParam("Signature", "qVRsCNECPCvnU340sv7yLVCDzRYIMGCyAypl4ioWKVU=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("ImageId", "imageId").build();
public void testGetLaunchPermissionForImage() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSAMIAsyncClient.class, "getLaunchPermissionForImageInRegion", String.class, String.class);
@ -411,7 +345,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, getLaunchPermissionForImage.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(getLaunchPermissionForImage).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -428,15 +362,9 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
.addFormParam("Attribute", "launchPermission")
.addFormParam("ImageId", "imageId")
.addFormParam("OperationType", "add")
.addFormParam("Signature", "CpCCffn%2BuR5LjbI/iCTl7%2BsrPxbrYEYvVZue%2BmWgRgE=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("UserGroup.1", "all")
.addFormParam("UserId.1", "bob")
.addFormParam("UserId.2", "sue")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("UserId.2", "sue").build();
public void testAddLaunchPermissionsToImage() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSAMIAsyncClient.class, "addLaunchPermissionsToImageInRegion", String.class,
@ -448,7 +376,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, addLaunchPermission.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(addLaunchPermission).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -465,15 +393,9 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
.addFormParam("Attribute", "launchPermission")
.addFormParam("ImageId", "imageId")
.addFormParam("OperationType", "remove")
.addFormParam("Signature", "ScuPcaRhVy/Je%2BXUGIo1mB4IUevDBW/0tAod4FHQQS8=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("UserGroup.1", "all")
.addFormParam("UserId.1", "bob")
.addFormParam("UserId.2", "sue")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("UserId.2", "sue").build();
public void testRemoveLaunchPermissionsFromImage() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSAMIAsyncClient.class, "removeLaunchPermissionsFromImageInRegion", String.class,
@ -485,7 +407,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, removeLaunchPermission.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(removeLaunchPermission).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
@ -499,13 +421,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
.addHeader("Host", "ec2.us-east-1.amazonaws.com")
.addFormParam("Action", "ResetImageAttribute")
.addFormParam("Attribute", "launchPermission")
.addFormParam("ImageId", "imageId")
.addFormParam("Signature", "l9F9IalCsYbGGf8O/35lLhttJ4vLLgoZZHUpmCCH9tI=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("ImageId", "imageId").build();
public void testResetLaunchPermissionsOnImage() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSAMIAsyncClient.class, "resetLaunchPermissionsOnImageInRegion", String.class,
@ -516,7 +432,8 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, resetLaunchPermissionsOnImage.getPayload().getRawContent().toString(),
assertPayloadEquals(request,
filter.filter(resetLaunchPermissionsOnImage).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);

View File

@ -349,13 +349,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
.addFormParam("Action", "ModifyInstanceAttribute")
.addFormParam("Attribute", "userData")
.addFormParam("InstanceId", "1")
.addFormParam("Signature", "nArJlrtyAfgqDnXxv%2B2y0r9O%2BIfUcitpQMjfQR0oeRM=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Value", "dGVzdA%3D%3D")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("Value", "dGVzdA%3D%3D").build();
public void testSetUserDataForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSInstanceAsyncClient.class, "setUserDataForInstanceInRegion", String.class, String.class,
@ -366,7 +360,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, setUserDataForInstance.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(setUserDataForInstance).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -382,13 +376,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
.addFormParam("Action", "ModifyInstanceAttribute")
.addFormParam("Attribute", "ramdisk")
.addFormParam("InstanceId", "1")
.addFormParam("Signature", "y9xr294R57Pjzzafq90Xi2LMi0JKj/Jwy5HL%2BYWyTvo=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Value", "test")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("Value", "test").build();
public void testSetRamdiskForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSInstanceAsyncClient.class, "setRamdiskForInstanceInRegion", String.class, String.class,
@ -399,7 +387,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, setRamdiskForInstance.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(setRamdiskForInstance).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -415,13 +403,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
.addFormParam("Action", "ModifyInstanceAttribute")
.addFormParam("Attribute", "kernel")
.addFormParam("InstanceId", "1")
.addFormParam("Signature", "vqAuTOcX6i8UfiVGAO/2yz2HHTqZyayiy/SiEU4ySws=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Value", "test")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("Value", "test").build();
public void testSetKernelForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSInstanceAsyncClient.class, "setKernelForInstanceInRegion", String.class, String.class,
@ -432,7 +414,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, setKernelForInstance.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(setKernelForInstance).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -448,13 +430,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
.addFormParam("Action", "ModifyInstanceAttribute")
.addFormParam("Attribute", "disableApiTermination")
.addFormParam("InstanceId", "1")
.addFormParam("Signature", "tOgWZ2rJ2KDgV55oMEa3RXKHvroiuqZfGfugBCV7ZLk=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Value", "true")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("Value", "true").build();
public void testSetApiTerminationDisabledForInstanceInRegion() throws SecurityException, NoSuchMethodException,
IOException {
@ -466,7 +442,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, setApiTerminationDisabled.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(setApiTerminationDisabled).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -482,13 +458,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
.addFormParam("Action", "ModifyInstanceAttribute")
.addFormParam("Attribute", "instanceType")
.addFormParam("InstanceId", "1")
.addFormParam("Signature", "DC1r80OrSLCVcVt/y3gUPWxRWrPK8T96FXjNfmCMwRY=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Value", "c1.medium")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("Value", "c1.medium").build();
public void testSetInstanceTypeForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSInstanceAsyncClient.class, "setInstanceTypeForInstanceInRegion", String.class,
@ -499,7 +469,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, instanceTypeForInstance.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(instanceTypeForInstance).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -515,13 +485,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
.addFormParam("Action", "ModifyInstanceAttribute")
.addFormParam("Attribute", "instanceInitiatedShutdownBehavior")
.addFormParam("InstanceId", "1")
.addFormParam("Signature", "HLu0ufuCEUPUrNzjMsmFvjqEFbdawad/7Hufdg9flbc=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Value", "terminate")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("Value", "terminate").build();
public void testSetInstanceInitiatedShutdownBehaviorForInstanceInRegion() throws SecurityException,
NoSuchMethodException, IOException {
@ -533,8 +497,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, setInstanceInitiatedShutdownBehavior.getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertPayloadEquals(request, filter.filter(setInstanceInitiatedShutdownBehavior).getPayload().getRawContent()
.toString(), "application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
@ -543,6 +507,15 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
checkFilters(request);
}
HttpRequest setBlockDeviceMapping = HttpRequest.builder().method("POST")
.endpoint("https://ec2.us-east-1.amazonaws.com/")
.addHeader("Host", "ec2.us-east-1.amazonaws.com")
.addFormParam("Action", "ModifyInstanceAttribute")
.addFormParam("BlockDeviceMapping.1.DeviceName", "/dev/sda1")
.addFormParam("BlockDeviceMapping.1.Ebs.DeleteOnTermination", "true")
.addFormParam("BlockDeviceMapping.1.Ebs.VolumeId", "vol-test1")
.addFormParam("InstanceId", "1").build();
public void testSetBlockDeviceMappingForInstanceInRegion() throws SecurityException, NoSuchMethodException,
IOException {
Invokable<?, ?> method = method(AWSInstanceAsyncClient.class, "setBlockDeviceMappingForInstanceInRegion", String.class,
@ -551,14 +524,12 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
Map<String, BlockDevice> mapping = Maps.newLinkedHashMap();
mapping.put("/dev/sda1", new BlockDevice("vol-test1", true));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", mapping));
filter.filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Action=ModifyInstanceAttribute&BlockDeviceMapping.1.DeviceName=/dev/sda1&BlockDeviceMapping.1.Ebs.DeleteOnTermination=true&BlockDeviceMapping.1.Ebs.VolumeId=vol-test1&InstanceId=1&Signature=qqJpPk8UmhPY9Jica0JSADEZiY3eHf9WETm%2B5tLT0NE%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&Version=2011-05-15&AWSAccessKeyId=identity",
assertPayloadEquals(request, filter.filter(setBlockDeviceMapping).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);

View File

@ -63,13 +63,7 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSKeyP
.addHeader("Host", "ec2.us-east-1.amazonaws.com")
.addFormParam("Action", "ImportKeyPair")
.addFormParam("KeyName", "mykey")
.addFormParam("PublicKeyMaterial", "c3NoLXJzYSBBQQ%3D%3D")
.addFormParam("Signature", "hI3Y8ggtVzXrEMmHp4Kem2/HCAX9hYN2NKjhDBz9SkY=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("PublicKeyMaterial", "c3NoLXJzYSBBQQ%3D%3D").build();
public void testImportKeyPair() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSKeyPairAsyncClient.class, "importKeyPairInRegion", String.class, String.class,
@ -80,7 +74,7 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSKeyP
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, importKeyPair.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(importKeyPair).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);

View File

@ -106,13 +106,7 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest<A
.addHeader("Host", "ec2.us-east-1.amazonaws.com")
.addFormParam("Action", "CreateSecurityGroup")
.addFormParam("GroupDescription", "description")
.addFormParam("GroupName", "name")
.addFormParam("Signature", "4uhrFtF0ppjWPJU6MUto3iQ8z3e5WKMUuPCE294hrg4=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("GroupName", "name").build();
public void testCreateSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSSecurityGroupAsyncClient.class, "createSecurityGroupInRegion", String.class,
@ -120,10 +114,10 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest<A
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "description"));
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, createSecurityGroup.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(createSecurityGroup).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);

View File

@ -64,13 +64,7 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest<Pla
.addHeader("Host", "ec2.us-east-1.amazonaws.com")
.addFormParam("Action", "CreatePlacementGroup")
.addFormParam("GroupName", "name")
.addFormParam("Signature", "V3o3tjvFQfI1zdP4iZJLnlusP3dSpPFx7bJVJlJbs2w=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("Strategy", "cluster")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
.addFormParam("Strategy", "cluster").build();
public void testCreatePlacementGroup() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(PlacementGroupAsyncClient.class, "createPlacementGroupInRegion", String.class,
@ -81,7 +75,7 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest<Pla
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, createPlacementGroup.getPayload().getRawContent().toString(),
assertPayloadEquals(request, filter.filter(createPlacementGroup).getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);

View File

@ -25,19 +25,13 @@ import java.util.Date;
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
import org.jclouds.aws.ec2.domain.LaunchSpecification;
import org.jclouds.aws.ec2.options.DescribeSpotPriceHistoryOptions;
import org.jclouds.aws.ec2.options.RequestSpotInstancesOptions;
import org.jclouds.aws.ec2.xml.DescribeSpotPriceHistoryResponseHandler;
import org.jclouds.aws.ec2.xml.SpotInstanceHandler;
import org.jclouds.aws.ec2.xml.SpotInstancesHandler;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.reflect.Invokable;
/**
@ -49,83 +43,6 @@ import com.google.common.reflect.Invokable;
@Test(groups = "unit", testName = "SpotInstanceAsyncClientTest")
public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<SpotInstanceAsyncClient> {
HttpRequest requestSpotInstances = HttpRequest.builder().method("POST")
.endpoint("https://ec2.us-east-1.amazonaws.com/")
.addHeader("Host", "ec2.us-east-1.amazonaws.com")
.addFormParam("Action", "RequestSpotInstances")
.addFormParam("LaunchSpecification.ImageId", "m1.small")
.addFormParam("LaunchSpecification.InstanceType", "ami-voo")
.addFormParam("Signature", "5PZRT8xXMugx1ku/NxQpaGWqYLLbKwJksBbeldGLO2s=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("SpotPrice", "0.01")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
public void testRequestSpotInstance() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(SpotInstanceAsyncClient.class, "requestSpotInstanceInRegion", String.class,
float.class, String.class, String.class);
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, 0.01f, "m1.small", "ami-voo"));
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, requestSpotInstances.getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, SpotInstanceHandler.class);
assertFallbackClassEquals(method, null);
checkFilters(request);
}
HttpRequest requestSpotInstancesOptions = HttpRequest.builder().method("POST")
.endpoint("https://ec2.us-east-1.amazonaws.com/")
.addHeader("Host", "ec2.us-east-1.amazonaws.com")
.addFormParam("Action", "RequestSpotInstances")
.addFormParam("AvailabilityZoneGroup", "availabilityZoneGroup")
.addFormParam("InstanceCount", "3")
.addFormParam("LaunchGroup", "launchGroup")
.addFormParam("LaunchSpecification.ImageId", "ami-voo")
.addFormParam("LaunchSpecification.InstanceType", "m1.small")
.addFormParam("LaunchSpecification.KernelId", "kernelId")
.addFormParam("LaunchSpecification.Placement.AvailabilityZone", "eu-west-1a")
.addFormParam("LaunchSpecification.SecurityGroup.1", "group1")
.addFormParam("Signature", "94pCsdmfYVMbMzofCeTvfvpQozIY6iDu0LewXvHl1ao=")
.addFormParam("SignatureMethod", "HmacSHA256")
.addFormParam("SignatureVersion", "2")
.addFormParam("SpotPrice", "0.01")
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
.addFormParam("ValidFrom", "1970-05-23T21%3A21%3A18Z")
.addFormParam("ValidUntil", "2009-02-13T23%3A31%3A31Z")
.addFormParam("Version", "2011-05-15")
.addFormParam("AWSAccessKeyId", "identity").build();
public void testRequestSpotInstancesOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(SpotInstanceAsyncClient.class, "requestSpotInstancesInRegion", String.class,
float.class, int.class, LaunchSpecification.class, RequestSpotInstancesOptions[].class);
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("eu-west-1", 0.01, 3,
LaunchSpecification.builder().instanceType("m1.small").imageId("ami-voo").availabilityZone("eu-west-1a")
.kernelId("kernelId").securityGroupName("group1").build(), new RequestSpotInstancesOptions().validFrom(from)
.validUntil(to).availabilityZoneGroup("availabilityZoneGroup").launchGroup("launchGroup")));
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.eu-west-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.eu-west-1.amazonaws.com\n");
assertPayloadEquals(request, requestSpotInstancesOptions.getPayload().getRawContent().toString(),
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, SpotInstancesHandler.class);
assertFallbackClassEquals(method, null);
checkFilters(request);
}
public void testCancelSpotInstanceRequests() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(SpotInstanceAsyncClient.class, "cancelSpotInstanceRequestsInRegion", String.class,
String[].class);
@ -143,42 +60,6 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<SpotI
checkFilters(request);
}
public void testDescribeSpotInstanceRequests() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(SpotInstanceAsyncClient.class, "describeSpotInstanceRequestsInRegion", String.class,
String[].class);
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, "Action=DescribeSpotInstanceRequests",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, SpotInstancesHandler.class);
assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
checkFilters(request);
}
public void testDescribeSpotInstanceRequestsArgs() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(SpotInstanceAsyncClient.class, "describeSpotInstanceRequestsInRegion", String.class,
String[].class);
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Action=DescribeSpotInstanceRequests&SpotInstanceRequestId.1=1&SpotInstanceRequestId.2=2",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, SpotInstancesHandler.class);
assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
checkFilters(request);
}
public void testDescribeSpotPriceHistory() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(SpotInstanceAsyncClient.class, "describeSpotPriceHistoryInRegion", String.class,
DescribeSpotPriceHistoryOptions[].class);