You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2014/03/27 23:45:52 UTC

[04/13] Forking jclouds provider/aws-ec2 for STRATOS-559

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java
new file mode 100644
index 0000000..7766d17
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.aws.ec2.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.Set;
+
+import org.jclouds.ec2.domain.SecurityGroup;
+import org.jclouds.ec2.domain.UserIdGroupPair;
+import org.jclouds.ec2.features.SecurityGroupApiLiveTest;
+import org.jclouds.ec2.util.IpPermissions;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMultimap;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true)
+public class AWSSecurityGroupApiLiveTest extends SecurityGroupApiLiveTest {
+   public AWSSecurityGroupApiLiveTest() {
+      provider = "aws-ec2";
+   }
+
+   @Test
+   void testAuthorizeSecurityGroupIngressSourceGroup() {
+      final String group1Name = PREFIX + "ingress1";
+      String group2Name = PREFIX + "ingress2";
+      cleanupAndSleep(group2Name);
+      cleanupAndSleep(group1Name);
+      try {
+         final String group1Id = AWSSecurityGroupApi.class.cast(client).createSecurityGroupInRegionAndReturnId(null,
+                 group1Name, group1Name);
+         String group2Id = AWSSecurityGroupApi.class.cast(client).createSecurityGroupInRegionAndReturnId(null,
+                 group2Name, group2Name);
+         ensureGroupsExist(group1Name, group2Name);
+         client.authorizeSecurityGroupIngressInRegion(null, group1Name, IpProtocol.TCP, 80, 80, "0.0.0.0/0");
+         assertEventually(new GroupHasPermission(client, group1Name, new TCPPort80AllIPs()));
+         Set<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(null, group1Name);
+         assertNotNull(oneResult);
+         assertEquals(oneResult.size(), 1);
+         final SecurityGroup group = oneResult.iterator().next();
+         assertEquals(group.getName(), group1Name);
+         final UserIdGroupPair to = new UserIdGroupPair(group.getOwnerId(), group1Name);
+         client.authorizeSecurityGroupIngressInRegion(null, group2Name, to);
+         assertEventually(new GroupHasPermission(client, group2Name, new Predicate<IpPermission>() {
+            @Override
+            public boolean apply(IpPermission arg0) {
+               return arg0.getTenantIdGroupNamePairs().equals(ImmutableMultimap.of(group.getOwnerId(), group1Id));
+            }
+         }));
+
+         client.revokeSecurityGroupIngressInRegion(null, group2Name,
+                 new UserIdGroupPair(group.getOwnerId(), group1Name));
+         assertEventually(new GroupHasNoPermissions(client, group2Name));
+      } finally {
+         client.deleteSecurityGroupInRegion(null, group2Name);
+         client.deleteSecurityGroupInRegion(null, group1Name);
+      }
+   }
+
+   @Test
+   void testAuthorizeSecurityGroupIngressIpPermission() throws InterruptedException {
+      final String group1Name = PREFIX + "ingress11";
+      String group2Name = PREFIX + "ingress12";
+      cleanupAndSleep(group2Name);
+      cleanupAndSleep(group1Name);
+      try {
+         final String group1Id = AWSSecurityGroupApi.class.cast(client).createSecurityGroupInRegionAndReturnId(null,
+               group1Name, group1Name);
+         final String group2Id = AWSSecurityGroupApi.class.cast(client).createSecurityGroupInRegionAndReturnId(null,
+               group2Name, group2Name);
+         Thread.sleep(100);// eventual consistent
+         ensureGroupsExist(group1Name, group2Name);
+         AWSSecurityGroupApi.class.cast(client).authorizeSecurityGroupIngressInRegion(null, group1Id,
+               IpPermissions.permit(IpProtocol.TCP).port(80));
+         assertEventually(new GroupHasPermission(client, group1Name, new TCPPort80AllIPs()));
+         Set<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(null, group1Name);
+         assertNotNull(oneResult);
+         assertEquals(oneResult.size(), 1);
+         final SecurityGroup group = oneResult.iterator().next();
+         assertEquals(group.getName(), group1Name);
+         IpPermissions group2CanHttpGroup1 = IpPermissions.permit(IpProtocol.TCP).port(80)
+               .originatingFromSecurityGroupId(group1Id);
+         AWSSecurityGroupApi.class.cast(client).authorizeSecurityGroupIngressInRegion(null, group2Id,
+               group2CanHttpGroup1);
+         assertEventually(new GroupHasPermission(client, group2Name, new Predicate<IpPermission>() {
+            @Override
+            public boolean apply(IpPermission arg0) {
+               return arg0.getTenantIdGroupNamePairs().equals(ImmutableMultimap.of(group.getOwnerId(), group1Id))
+                     && arg0.getFromPort() == 80 && arg0.getToPort() == 80 && arg0.getIpProtocol() == IpProtocol.TCP;
+            }
+         }));
+
+         AWSSecurityGroupApi.class.cast(client).revokeSecurityGroupIngressInRegion(null, group2Id,
+               group2CanHttpGroup1);
+         assertEventually(new GroupHasNoPermissions(client, group2Name));
+      } finally {
+         client.deleteSecurityGroupInRegion(null, group2Name);
+         client.deleteSecurityGroupInRegion(null, group1Name);
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java
new file mode 100644
index 0000000..8b696ef
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.aws.ec2.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.aws.ec2.xml.AWSEC2DescribeSecurityGroupsResponseHandler;
+import org.jclouds.ec2.util.IpPermissions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code AWSSecurityGroupApi}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "AWSSecurityGroupApiTest")
+public class AWSSecurityGroupApiTest extends BaseAWSEC2ApiTest<AWSSecurityGroupApi> {
+   public AWSSecurityGroupApiTest() {
+      provider = "aws-ec2";
+   }
+
+   public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "deleteSecurityGroupInRegionById", String.class,
+            String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "id"));
+
+      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=DeleteSecurityGroup&GroupId=id",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   public void testDescribeSecurityGroups() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "describeSecurityGroupsInRegionById", 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=DescribeSecurityGroups",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, AWSEC2DescribeSecurityGroupsResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   public void testDescribeSecurityGroupsArgs() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "describeSecurityGroupsInRegionById", 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=DescribeSecurityGroups&GroupId.1=1&GroupId.2=2",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, AWSEC2DescribeSecurityGroupsResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   HttpRequest createSecurityGroup = HttpRequest.builder().method("POST")
+                                                .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                .addFormParam("Action", "CreateSecurityGroup")
+                                                .addFormParam("GroupDescription", "description")
+                                                .addFormParam("GroupName", "name").build();
+
+   public void testCreateSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "createSecurityGroupInRegion", String.class,
+            String.class, String.class);
+      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, filter.filter(createSecurityGroup).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testAuthorizeSecurityGroupIpPermission() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "authorizeSecurityGroupIngressInRegion",
+            String.class, String.class, IpPermission.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "group", IpPermissions.permitAnyProtocol()));
+
+      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=AuthorizeSecurityGroupIngress&GroupId=group&IpPermissions.0.IpProtocol=-1&IpPermissions.0.FromPort=1&IpPermissions.0.ToPort=65535&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testAuthorizeSecurityGroupIpPermissions() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "authorizeSecurityGroupIngressInRegion",
+            String.class, String.class, Iterable.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "group", ImmutableSet.<IpPermission> of(IpPermissions
+            .permit(IpProtocol.TCP).originatingFromCidrBlock("1.1.1.1/32"), IpPermissions.permitICMP().type(8).andCode(0)
+            .originatingFromSecurityGroupId("groupId"))));
+
+      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=AuthorizeSecurityGroupIngress&GroupId=group&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=1&IpPermissions.0.ToPort=65535&IpPermissions.0.IpRanges.0.CidrIp=1.1.1.1/32&IpPermissions.1.IpProtocol=icmp&IpPermissions.1.FromPort=8&IpPermissions.1.ToPort=0&IpPermissions.1.Groups.0.GroupId=groupId",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testRevokeSecurityGroupIpPermission() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "revokeSecurityGroupIngressInRegion", String.class,
+            String.class, IpPermission.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "group", IpPermissions.permitAnyProtocol()));
+
+      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=RevokeSecurityGroupIngress&GroupId=group&IpPermissions.0.IpProtocol=-1&IpPermissions.0.FromPort=1&IpPermissions.0.ToPort=65535&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testRevokeSecurityGroupIpPermissions() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "revokeSecurityGroupIngressInRegion", String.class,
+            String.class, Iterable.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "group", ImmutableSet.<IpPermission> of(IpPermissions
+            .permit(IpProtocol.TCP).originatingFromCidrBlock("1.1.1.1/32"), IpPermissions.permitICMP().type(8).andCode(0)
+            .originatingFromSecurityGroupId("groupId"))));
+
+      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=RevokeSecurityGroupIngress&GroupId=group&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=1&IpPermissions.0.ToPort=65535&IpPermissions.0.IpRanges.0.CidrIp=1.1.1.1/32&IpPermissions.1.IpProtocol=icmp&IpPermissions.1.FromPort=8&IpPermissions.1.ToPort=0&IpPermissions.1.Groups.0.GroupId=groupId",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSubnetApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSubnetApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSubnetApiLiveTest.java
new file mode 100644
index 0000000..74d4839
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSubnetApiLiveTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.aws.ec2.features;
+
+import org.jclouds.ec2.features.SubnetApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", testName = "AWSSubnetApiLiveTest")
+public class AWSSubnetApiLiveTest extends SubnetApiLiveTest {
+   public AWSSubnetApiLiveTest() {
+      provider = "aws-ec2";
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java
new file mode 100644
index 0000000..f617c9b
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.aws.ec2.features;
+
+import static com.google.common.collect.Maps.transformValues;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Singleton;
+
+import org.jclouds.aws.domain.Region;
+import org.jclouds.aws.ec2.AWSEC2ProviderMetadata;
+import org.jclouds.aws.ec2.config.AWSEC2HttpApiModule;
+import org.jclouds.aws.filters.FormSigner;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.date.DateService;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.location.config.LocationModule;
+import org.jclouds.location.suppliers.RegionIdToURISupplier;
+import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier;
+import org.jclouds.rest.ConfiguresHttpApi;
+import org.jclouds.rest.internal.BaseAsyncApiTest;
+import org.jclouds.util.Suppliers2;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+import com.google.inject.Provides;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public abstract class BaseAWSEC2ApiTest<T> extends BaseAsyncApiTest<T> {
+
+      @ConfiguresHttpApi
+   protected static class StubAWSEC2HttpApiModule extends AWSEC2HttpApiModule {
+
+      @Override
+      protected String provideTimeStamp(DateService dateService) {
+         return "2009-11-08T15:54:08.897Z";
+      }
+
+      @Provides
+      @Singleton
+      LoadingCache<RegionAndName, Image> provide() {
+         return CacheBuilder.newBuilder().build(new CacheLoader<RegionAndName, Image>() {
+
+            @Override
+            public Image load(RegionAndName key) throws Exception {
+               return null;
+            }
+
+         });
+      }
+
+      @Override
+      protected void installLocations() {
+         install(new LocationModule());
+         bind(RegionIdToURISupplier.class).toInstance(new RegionIdToURISupplier() {
+
+            @Override
+            public Map<String, Supplier<URI>> get() {
+               return transformValues(ImmutableMap.<String, URI> of(Region.EU_WEST_1, URI
+                        .create("https://ec2.eu-west-1.amazonaws.com"), Region.US_EAST_1, URI
+                        .create("https://ec2.us-east-1.amazonaws.com"), Region.US_WEST_1, URI
+                        .create("https://ec2.us-west-1.amazonaws.com")), Suppliers2.<URI> ofInstanceFunction());
+            }
+
+         });
+         bind(RegionIdToZoneIdsSupplier.class).toInstance(new RegionIdToZoneIdsSupplier() {
+
+            @Override
+            public Map<String, Supplier<Set<String>>> get() {
+               return transformValues(ImmutableMap.<String, Set<String>> of("us-east-1", ImmutableSet.of("us-east-1a",
+                        "us-east-1b", "us-east-1c", "us-east-1b")), Suppliers2.<Set<String>> ofInstanceFunction());
+            }
+
+         });
+      }
+   }
+
+   protected FormSigner filter;
+
+   @Override
+   protected void checkFilters(HttpRequest request) {
+      assertEquals(request.getFilters().size(), 1);
+      assertEquals(request.getFilters().get(0).getClass(), FormSigner.class);
+   }
+
+   @Override
+   @BeforeTest
+   protected void setupFactory() throws IOException {
+      super.setupFactory();
+      this.filter = injector.getInstance(FormSigner.class);
+   }
+
+   @Override
+   protected Module createModule() {
+      return new StubAWSEC2HttpApiModule();
+   }
+
+   protected String provider = "aws-ec2";
+
+   @Override
+   public AWSEC2ProviderMetadata createProviderMetadata() {
+      return new AWSEC2ProviderMetadata();
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiLiveTest.java
new file mode 100644
index 0000000..65c6ebd
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiLiveTest.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.aws.ec2.features;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Map;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.MonitoringState;
+import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code MonitoringApi}
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true)
+public class MonitoringApiLiveTest extends BaseComputeServiceContextLiveTest {
+   public MonitoringApiLiveTest() {
+      provider = "aws-ec2";
+   }
+
+   private MonitoringApi client;
+   private static final String DEFAULT_INSTANCE = "i-TODO";
+
+   
+   @Override
+   @BeforeClass(groups = { "integration", "live" })
+   public void setupContext() {
+      super.setupContext();
+      client = view.unwrapApi(AWSEC2Api.class).getMonitoringApi().get();
+   }
+
+   @Test(enabled = false)
+   // TODO get instance
+   public void testMonitorInstances() {
+      Map<String, MonitoringState> monitoringState = client.monitorInstancesInRegion(null, DEFAULT_INSTANCE);
+      assertEquals(monitoringState.get(DEFAULT_INSTANCE), MonitoringState.PENDING);
+   }
+
+   @Test(enabled = false)
+   // TODO get instance
+   public void testUnmonitorInstances() {
+      Map<String, MonitoringState> monitoringState = client.unmonitorInstancesInRegion(null, DEFAULT_INSTANCE);
+      assertEquals(monitoringState.get(DEFAULT_INSTANCE), MonitoringState.PENDING);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiTest.java
new file mode 100644
index 0000000..1d10906
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiTest.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.aws.ec2.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.aws.ec2.xml.MonitoringStateHandler;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Lists;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code MonitoringApi}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "MonitoringApiTest")
+public class MonitoringApiTest extends BaseAWSEC2ApiTest<MonitoringApi> {
+
+   public void testUnmonitorInstances() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(MonitoringApi.class, "unmonitorInstancesInRegion", String.class, String.class,
+            String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "instance1", "instance2"));
+
+      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      String payload = "Action=UnmonitorInstances&InstanceId.0=instance1&InstanceId.1=instance2";
+      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
+      assertPayloadEquals(request, payload, "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, MonitoringStateHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testMonitorInstances() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(MonitoringApi.class, "monitorInstancesInRegion", String.class, String.class,
+            String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "instance1", "instance2"));
+
+      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=MonitorInstances&InstanceId.0=instance1&InstanceId.1=instance2",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, MonitoringStateHandler.class);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiExpectTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiExpectTest.java
new file mode 100644
index 0000000..c48e6a8
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiExpectTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.aws.ec2.features;
+
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.compute.internal.BaseAWSEC2ComputeServiceExpectTest;
+import org.jclouds.aws.ec2.domain.PlacementGroup;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * @author Andrew Bayer
+ */
+@Test(groups = "unit", testName = "PlacementGroupApiExpectTest")
+public class PlacementGroupApiExpectTest extends BaseAWSEC2ComputeServiceExpectTest {
+
+   HttpRequest filter = HttpRequest.builder().method("POST")
+           .endpoint("https://ec2.us-east-1.amazonaws.com/")
+           .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+           .addFormParam("Action", "DescribePlacementGroups")
+           .addFormParam("Filter.1.Name", "strategy")
+           .addFormParam("Filter.1.Value.1", "cluster")
+           .addFormParam("Signature", "SaA7Un1BE3m9jIEKyjXNdQPzFh/QAJSCebvKXiwUEK0%3D")
+           .addFormParam("SignatureMethod", "HmacSHA256")
+           .addFormParam("SignatureVersion", "2")
+           .addFormParam("Timestamp", "2012-04-16T15%3A54%3A08.897Z")
+           .addFormParam("Version", "2012-06-01")
+           .addFormParam("AWSAccessKeyId", "identity").build();
+
+   public void testFilterWhenResponseIs2xx() {
+      HttpResponse filterResponse = HttpResponse.builder().statusCode(200)
+              .payload(payloadFromResourceWithContentType("/describe_placement_groups.xml", "text/xml")).build();
+
+      AWSEC2Api apiWhenExist = requestsSendResponses(describeRegionsRequest, describeRegionsResponse, filter, filterResponse)
+              .getContext().unwrapApi(AWSEC2Api.class);
+
+      PlacementGroup group = getOnlyElement(apiWhenExist.getPlacementGroupApi().get().describePlacementGroupsInRegionWithFilter("us-east-1",
+              ImmutableMultimap.<String, String>builder()
+                      .put("strategy", "cluster")
+                      .build()));
+
+      assertEquals(group.getName(), "XYZ-cluster");
+   }
+
+   public void testFilterWhenResponseIs404() {
+      HttpResponse filterResponse = HttpResponse.builder().statusCode(404).build();
+
+      AWSEC2Api apiWhenNotExist = requestsSendResponses(describeRegionsRequest, describeRegionsResponse, filter, filterResponse)
+              .getContext().unwrapApi(AWSEC2Api.class);
+
+      assertEquals(apiWhenNotExist.getPlacementGroupApi().get().describePlacementGroupsInRegionWithFilter("us-east-1",
+              ImmutableMultimap.<String, String>builder()
+                      .put("strategy", "cluster")
+                      .build()),
+              ImmutableSet.of());
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java
new file mode 100644
index 0000000..ae4d842
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java
@@ -0,0 +1,221 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.aws.ec2.features;
+
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static com.google.common.collect.Lists.newArrayList;
+import static com.google.common.collect.Sets.newTreeSet;
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.jclouds.util.Predicates2.retry;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.SortedSet;
+
+import org.jclouds.aws.AWSResponseException;
+import org.jclouds.aws.domain.Region;
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.PlacementGroup;
+import org.jclouds.aws.ec2.domain.PlacementGroup.State;
+import org.jclouds.aws.ec2.predicates.PlacementGroupAvailable;
+import org.jclouds.aws.ec2.predicates.PlacementGroupDeleted;
+import org.jclouds.compute.RunNodesException;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
+import org.jclouds.compute.predicates.NodePredicates;
+import org.jclouds.ec2.compute.domain.EC2HardwareBuilder;
+import org.jclouds.ec2.domain.InstanceType;
+import org.jclouds.scriptbuilder.domain.Statements;
+import org.jclouds.scriptbuilder.statements.java.InstallJDK;
+import org.jclouds.scriptbuilder.statements.login.AdminAccess;
+import org.jclouds.sshj.config.SshjSshClientModule;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.inject.Module;
+
+/**
+ * Tests behavior of {@code PlacementGroupApi}
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "PlacementGroupApiLiveTest")
+public class PlacementGroupApiLiveTest extends BaseComputeServiceContextLiveTest {
+   ArrayList<String> supportedRegions = newArrayList(Region.US_EAST_1, Region.US_WEST_2, Region.EU_WEST_1,
+           Region.US_WEST_2, Region.AP_NORTHEAST_1, Region.AP_SOUTHEAST_1, Region.AP_SOUTHEAST_2);
+
+   public PlacementGroupApiLiveTest() {
+      provider = "aws-ec2";
+   }
+
+   private AWSEC2Api client;
+   private Predicate<PlacementGroup> availableTester;
+   private Predicate<PlacementGroup> deletedTester;
+   private PlacementGroup group;
+
+   @Override
+   @BeforeClass(groups = { "integration", "live" })
+   public void setupContext() {
+      super.setupContext();
+      client = view.unwrapApi(AWSEC2Api.class);
+      availableTester = retry(new PlacementGroupAvailable(client), 60, 1, SECONDS);
+      deletedTester = retry(new PlacementGroupDeleted(client), 60, 1, SECONDS);
+   }
+
+   @Test
+   public void testDescribe() {
+      for (String region : supportedRegions) {
+         SortedSet<PlacementGroup> allResults = newTreeSet(client.getPlacementGroupApi().get()
+                  .describePlacementGroupsInRegion(region));
+         assertNotNull(allResults);
+         if (allResults.size() >= 1) {
+            PlacementGroup group = allResults.last();
+            SortedSet<PlacementGroup> result = newTreeSet(client.getPlacementGroupApi().get()
+                     .describePlacementGroupsInRegion(region, group.getName()));
+            assertNotNull(result);
+            PlacementGroup compare = result.last();
+            assertEquals(compare, group);
+         }
+      }
+
+      for (String region : client.getAvailabilityZoneAndRegionApi().get().describeRegions().keySet()) {
+         if (!supportedRegions.contains(region))
+            try {
+               client.getPlacementGroupApi().get().describePlacementGroupsInRegion(region);
+               fail("should be unsupported for region: " + region);
+            } catch (UnsupportedOperationException e) {
+            }
+      }
+   }
+
+   @Test
+   public void testFilter() {
+      for (String region : supportedRegions) {
+         SortedSet<PlacementGroup> allResults = newTreeSet(client.getPlacementGroupApi().get()
+                 .describePlacementGroupsInRegion(region));
+         assertNotNull(allResults);
+         if (allResults.size() >= 1) {
+            PlacementGroup group = allResults.last();
+            SortedSet<PlacementGroup> result = newTreeSet(client.getPlacementGroupApi().get()
+                    .describePlacementGroupsInRegionWithFilter(region,
+                            ImmutableMultimap.<String, String>builder()
+                            .put("group-name", group.getName()).build()));
+            assertNotNull(result);
+            PlacementGroup compare = result.last();
+            assertEquals(compare, group);
+         }
+      }
+   }
+
+   @Test(expectedExceptions = AWSResponseException.class)
+   public void testFilterInvalid() {
+      for (String region : supportedRegions) {
+         SortedSet<PlacementGroup> allResults = newTreeSet(client.getPlacementGroupApi().get()
+                 .describePlacementGroupsInRegion(region));
+         assertNotNull(allResults);
+         if (allResults.size() >= 1) {
+            PlacementGroup group = allResults.last();
+            SortedSet<PlacementGroup> result = newTreeSet(client.getPlacementGroupApi().get()
+                    .describePlacementGroupsInRegionWithFilter(region,
+                            ImmutableMultimap.<String, String>builder()
+                                    .put("invalid-filter", group.getName()).build()));
+         }
+      }
+   }
+
+   @Test
+   public void testCreatePlacementGroup() {
+      String groupName = PREFIX + "1";
+      for (String region : supportedRegions) {
+
+         client.getPlacementGroupApi().get().deletePlacementGroupInRegion(region, groupName);
+         client.getPlacementGroupApi().get().createPlacementGroupInRegion(region, groupName);
+
+         verifyPlacementGroup(region, groupName);
+      }
+   }
+
+   private void verifyPlacementGroup(String region, String groupName) {
+      assert availableTester.apply(new PlacementGroup(region, groupName, "cluster", State.PENDING)) : group;
+      Set<PlacementGroup> oneResult = client.getPlacementGroupApi().get().describePlacementGroupsInRegion(region,
+               groupName);
+      assertNotNull(oneResult);
+      assertEquals(oneResult.size(), 1);
+      group = oneResult.iterator().next();
+      assertEquals(group.getName(), groupName);
+      assertEquals(group.getStrategy(), "cluster");
+      assert availableTester.apply(group) : group;
+   }
+
+   public void testStartCCInstance() throws Exception {
+
+      Template template = view.getComputeService().templateBuilder()
+               .fromHardware(EC2HardwareBuilder.cc2_8xlarge().build()).osFamily(OsFamily.AMZN_LINUX).build();
+      assert template != null : "The returned template was null, but it should have a value.";
+      assertEquals(template.getHardware().getProviderId(), InstanceType.CC2_8XLARGE);
+      assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
+      assertEquals(template.getImage().getUserMetadata().get("virtualizationType"), "hvm");
+      assertEquals(template.getImage().getUserMetadata().get("hypervisor"), "xen");
+
+      template.getOptions().runScript(Statements.newStatementList(AdminAccess.standard(), InstallJDK.fromOpenJDK()));
+
+      String group = PREFIX + "cccluster";
+      view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
+      // TODO make this not lookup an explicit region
+      client.getPlacementGroupApi().get().deletePlacementGroupInRegion(null, "jclouds#" + group + "#us-east-1");
+
+      try {
+         Set<? extends NodeMetadata> nodes = view.getComputeService().createNodesInGroup(group, 1, template);
+         NodeMetadata node = getOnlyElement(nodes);
+
+         getOnlyElement(getOnlyElement(client.getInstanceApi().get().describeInstancesInRegion(null,
+                  node.getProviderId())));
+
+      } catch (RunNodesException e) {
+         System.err.println(e.getNodeErrors().keySet());
+         Throwables.propagate(e);
+      } finally {
+         view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
+      }
+   }
+
+   public static final String PREFIX = System.getProperty("user.name") + "ec2";
+
+   @Override
+   @AfterClass(groups = { "integration", "live" })
+   protected void tearDownContext() {
+      if (group != null) {
+         client.getPlacementGroupApi().get().deletePlacementGroupInRegion(group.getRegion(), group.getName());
+         assert deletedTester.apply(group) : group;
+      }
+      super.tearDownContext();
+   }
+
+   @Override
+   protected Module getSshModule() {
+      return new SshjSshClientModule();
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java
new file mode 100644
index 0000000..69eb068
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.aws.ec2.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.aws.ec2.xml.DescribePlacementGroupsResponseHandler;
+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.Lists;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code PlacementGroupApi}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "PlacementGroupApiTest")
+public class PlacementGroupApiTest extends BaseAWSEC2ApiTest<PlacementGroupApi> {
+
+   public void testDeletePlacementGroup() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(PlacementGroupApi.class, "deletePlacementGroupInRegion", String.class,
+               String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name"));
+
+      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=DeletePlacementGroup&GroupName=name",
+               "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   HttpRequest createPlacementGroup = HttpRequest.builder().method("POST")
+                                                 .endpoint("https://ec2.us-east-1.amazonaws.com/")
+                                                 .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                 .addFormParam("Action", "CreatePlacementGroup")
+                                                 .addFormParam("GroupName", "name")
+                                                 .addFormParam("Strategy", "cluster").build();
+
+   public void testCreatePlacementGroup() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(PlacementGroupApi.class, "createPlacementGroupInRegion", String.class,
+               String.class, String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "cluster"));
+
+      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, filter.filter(createPlacementGroup).getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testCreatePlacementGroupDefault() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(PlacementGroupApi.class, "createPlacementGroupInRegion", String.class,
+               String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name"));
+
+      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=CreatePlacementGroup&Strategy=cluster&GroupName=name",
+               "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testDescribePlacementGroups() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(PlacementGroupApi.class, "describePlacementGroupsInRegion", 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=DescribePlacementGroups",
+               "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, DescribePlacementGroupsResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   public void testDescribePlacementGroupsArgs() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(PlacementGroupApi.class, "describePlacementGroupsInRegion", 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=DescribePlacementGroups&GroupName.1=1&GroupName.2=2",
+               "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, DescribePlacementGroupsResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiExpectTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiExpectTest.java
new file mode 100644
index 0000000..f15c7c7
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiExpectTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.aws.ec2.features;
+
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.compute.internal.BaseAWSEC2ComputeServiceExpectTest;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * @author Andrew Bayer
+ */
+@Test(groups = "unit", testName = "SpotInstanceApiExpectTest")
+public class SpotInstanceApiExpectTest extends BaseAWSEC2ComputeServiceExpectTest {
+
+   HttpRequest filter = HttpRequest.builder().method("POST")
+           .endpoint("https://ec2.us-east-1.amazonaws.com/")
+           .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+           .addFormParam("Action", "DescribeSpotInstanceRequests")
+           .addFormParam("Filter.1.Name", "instance-id")
+           .addFormParam("Filter.1.Value.1", "i-ef308e8e")
+           .addFormParam("Signature", "wQtGpumMCDEzvlldKepCKeEjD9iE7eAyiRBlQztcJMA%3D")
+           .addFormParam("SignatureMethod", "HmacSHA256")
+           .addFormParam("SignatureVersion", "2")
+           .addFormParam("Timestamp", "2012-04-16T15%3A54%3A08.897Z")
+           .addFormParam("Version", "2012-06-01")
+           .addFormParam("AWSAccessKeyId", "identity").build();
+
+   public void testFilterWhenResponseIs2xx() {
+      HttpResponse filterResponse = HttpResponse.builder().statusCode(200)
+              .payload(payloadFromResourceWithContentType("/describe_spot_instance.xml", "text/xml")).build();
+
+      AWSEC2Api apiWhenExist = requestsSendResponses(describeRegionsRequest, describeRegionsResponse, filter, filterResponse)
+              .getContext().unwrapApi(AWSEC2Api.class);
+
+      SpotInstanceRequest request = getOnlyElement(apiWhenExist.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegionWithFilter("us-east-1",
+              ImmutableMultimap.<String, String>builder()
+                      .put("instance-id", "i-ef308e8e")
+                      .build()));
+
+      assertEquals(request.getId(), "sir-1ede0012");
+   }
+
+   public void testFilterWhenResponseIs404() {
+      HttpResponse filterResponse = HttpResponse.builder().statusCode(404).build();
+
+      AWSEC2Api apiWhenNotExist = requestsSendResponses(describeRegionsRequest, describeRegionsResponse, filter, filterResponse)
+              .getContext().unwrapApi(AWSEC2Api.class);
+
+      assertEquals(apiWhenNotExist.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegionWithFilter("us-east-1",
+              ImmutableMultimap.<String, String>builder()
+                      .put("instance-id", "i-ef308e8e")
+                      .build()),
+              ImmutableSet.of());
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java
new file mode 100644
index 0000000..ca6ee0a
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java
@@ -0,0 +1,215 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.aws.ec2.features;
+
+import static com.google.common.base.Predicates.in;
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.jclouds.aws.ec2.options.DescribeSpotPriceHistoryOptions.Builder.from;
+import static org.jclouds.aws.ec2.options.RequestSpotInstancesOptions.Builder.launchGroup;
+import static org.jclouds.util.Predicates2.retry;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.Date;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.concurrent.TimeUnit;
+
+import org.jclouds.aws.AWSResponseException;
+import org.jclouds.aws.domain.Region;
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.domain.AWSRunningInstance;
+import org.jclouds.aws.ec2.domain.LaunchSpecification;
+import org.jclouds.aws.ec2.domain.Spot;
+import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
+import org.jclouds.aws.ec2.predicates.SpotInstanceRequestActive;
+import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
+import org.jclouds.ec2.domain.InstanceType;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSortedSet;
+
+/**
+ * Tests behavior of {@code SpotInstanceApi}
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true)
+public class SpotInstanceApiLiveTest  extends BaseComputeServiceContextLiveTest {
+   public SpotInstanceApiLiveTest() {
+      provider = "aws-ec2";
+   }
+
+   private static final int SPOT_DELAY_SECONDS = 600;
+   private AWSEC2Api client;
+   private Predicate<SpotInstanceRequest> activeTester;
+   private Set<SpotInstanceRequest> requests;
+   private AWSRunningInstance instance;
+   private long start;
+
+   @Override
+   @BeforeClass(groups = { "integration", "live" })
+   public void setupContext() {
+      super.setupContext();
+      client = view.unwrapApi(AWSEC2Api.class);
+      activeTester = retry(new SpotInstanceRequestActive(client), SPOT_DELAY_SECONDS, 1, 1, SECONDS);
+   }
+
+   @Test
+   public void testDescribeSpotRequestsInRegion() {
+      for (String region : Region.DEFAULT_REGIONS) {
+         SortedSet<SpotInstanceRequest> allResults = ImmutableSortedSet.copyOf(client.getSpotInstanceApi().get()
+                  .describeSpotInstanceRequestsInRegion(region));
+         assertNotNull(allResults);
+         if (allResults.size() >= 1) {
+            SpotInstanceRequest request = allResults.last();
+            SortedSet<SpotInstanceRequest> result = ImmutableSortedSet.copyOf(client.getSpotInstanceApi().get()
+                     .describeSpotInstanceRequestsInRegion(region, request.getId()));
+            assertNotNull(result);
+            SpotInstanceRequest compare = result.last();
+            assertEquals(compare, request);
+         }
+      }
+
+   }
+
+   @Test
+   public void testDescribeSpotRequestsInRegionFilter() {
+      for (String region : Region.DEFAULT_REGIONS) {
+         SortedSet<SpotInstanceRequest> allResults = ImmutableSortedSet.copyOf(client.getSpotInstanceApi().get()
+                 .describeSpotInstanceRequestsInRegion(region));
+         assertNotNull(allResults);
+         if (allResults.size() >= 1) {
+            SpotInstanceRequest request = allResults.last();
+            SortedSet<SpotInstanceRequest> result = ImmutableSortedSet.copyOf(client.getSpotInstanceApi().get()
+                    .describeSpotInstanceRequestsInRegionWithFilter(region,
+                            ImmutableMultimap.<String, String>builder()
+                                    .put("spot-instance-request-id", request.getId()).build()));
+
+            assertNotNull(result);
+            SpotInstanceRequest compare = result.last();
+            assertEquals(compare, request);
+         }
+      }
+
+   }
+
+   @Test(expectedExceptions = AWSResponseException.class)
+   public void testDescribeSpotRequestsInRegionFilterInvalid() {
+      for (String region : Region.DEFAULT_REGIONS) {
+         SortedSet<SpotInstanceRequest> allResults = ImmutableSortedSet.copyOf(client.getSpotInstanceApi().get()
+                 .describeSpotInstanceRequestsInRegion(region));
+         assertNotNull(allResults);
+         if (allResults.size() >= 1) {
+            SpotInstanceRequest request = allResults.last();
+            SortedSet<SpotInstanceRequest> result = ImmutableSortedSet.copyOf(client.getSpotInstanceApi().get()
+                    .describeSpotInstanceRequestsInRegionWithFilter(region,
+                            ImmutableMultimap.<String, String>builder()
+                                    .put("invalid-filter", request.getId()).build()));
+         }
+      }
+
+   }
+
+   @Test
+   public void testDescribeSpotPriceHistoryInRegion() {
+      for (String region : Region.DEFAULT_REGIONS) {
+         Set<Spot> spots = client.getSpotInstanceApi().get().describeSpotPriceHistoryInRegion(region, from(new Date()));
+         assertNotNull(spots);
+         assert spots.size() > 0;
+         for (Spot spot : spots) {
+            assert spot.getSpotPrice() > 0 : spots;
+            assertEquals(spot.getRegion(), region);
+            assert in(
+                     ImmutableSet.of("Linux/UNIX", "Linux/UNIX (Amazon VPC)", "SUSE Linux", "SUSE Linux (Amazon VPC)",
+                              "Windows", "Windows (Amazon VPC)")).apply(spot.getProductDescription()) : spot;
+            assert in(
+                     ImmutableSet.of("c1.medium", "c1.xlarge", "cc1.4xlarge", "cg1.4xlarge", "cc2.8xlarge", "m1.large",
+                              "m1.small", "m1.medium", "m1.xlarge", "m2.2xlarge", "m2.4xlarge", "m2.xlarge", "m3.xlarge", 
+                              "m3.2xlarge", "t1.micro", "cr1.8xlarge")).apply(
+                     spot.getInstanceType()) : spot;
+
+         }
+      }
+
+   }
+
+   @Test(enabled = true)
+   public void testCreateSpotInstance() {
+      String launchGroup = PREFIX + "1";
+      for (String region : Region.DEFAULT_REGIONS)
+         for (SpotInstanceRequest request : client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion(
+                  region))
+            if (launchGroup.equals(request.getLaunchGroup()))
+               client.getSpotInstanceApi().get().cancelSpotInstanceRequestsInRegion(region, request.getId());
+
+      start = System.currentTimeMillis();
+
+      requests = client.getSpotInstanceApi().get().requestSpotInstancesInRegion(
+               "sa-east-1",
+               0.09f,
+               1,
+               LaunchSpecification.builder().imageId("ami-3e3be423").instanceType(InstanceType.M1_SMALL).build(),
+               launchGroup(launchGroup).availabilityZoneGroup(launchGroup).validFrom(
+                        new Date(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(2))).validUntil(
+                        new Date(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(SPOT_DELAY_SECONDS))));
+      assertNotNull(requests);
+
+      for (SpotInstanceRequest request : requests)
+         verifySpotInstance(request);
+   }
+
+   private void verifySpotInstance(SpotInstanceRequest request) {
+      SpotInstanceRequest spot = refresh(request);
+      assertNotNull(spot);
+      assertEquals(spot, request);
+      assert activeTester.apply(request) : refresh(request);
+      System.out.println(System.currentTimeMillis() - start);
+      spot = refresh(request);
+      assert spot.getInstanceId() != null : spot;
+      instance = getOnlyElement(getOnlyElement(client.getInstanceApi().get().describeInstancesInRegion(spot.getRegion(),
+               spot.getInstanceId())));
+      assertEquals(instance.getSpotInstanceRequestId(), spot.getId());
+   }
+
+   public SpotInstanceRequest refresh(SpotInstanceRequest request) {
+      return getOnlyElement(client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion(request.getRegion(),
+               request.getId()));
+   }
+
+   public static final String PREFIX = System.getProperty("user.name") + "ec2";
+
+   @Override
+   @AfterClass(groups = { "integration", "live" })
+   protected void tearDownContext() {
+      if (requests != null) {
+         for (SpotInstanceRequest request : requests)
+            client.getSpotInstanceApi().get().cancelSpotInstanceRequestsInRegion(request.getRegion(), request.getId());
+         // assert deletedTester.apply(request) : request;
+      }
+      if (instance != null) {
+         client.getInstanceApi().get().terminateInstancesInRegion(instance.getRegion(), instance.getId());
+      }
+      super.tearDownContext();
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java
new file mode 100644
index 0000000..f8276e3
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.aws.ec2.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+import java.util.Date;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.aws.ec2.options.DescribeSpotPriceHistoryOptions;
+import org.jclouds.aws.ec2.xml.DescribeSpotPriceHistoryResponseHandler;
+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.Lists;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code SpotInstanceApi}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "SpotInstanceApiTest")
+public class SpotInstanceApiTest extends BaseAWSEC2ApiTest<SpotInstanceApi> {
+
+   public void testCancelSpotInstanceRequests() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SpotInstanceApi.class, "cancelSpotInstanceRequestsInRegion", String.class,
+            String[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "id"));
+
+      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=CancelSpotInstanceRequests&SpotInstanceRequestId.1=id",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   public void testDescribeSpotPriceHistory() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SpotInstanceApi.class, "describeSpotPriceHistoryInRegion", String.class,
+            DescribeSpotPriceHistoryOptions[].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=DescribeSpotPriceHistory",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, DescribeSpotPriceHistoryResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   Date from = new Date(12345678910l);
+   Date to = new Date(1234567891011l);
+
+   public void testDescribeSpotPriceHistoryArgs() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SpotInstanceApi.class, "describeSpotPriceHistoryInRegion", String.class,
+            DescribeSpotPriceHistoryOptions[].class);
+      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, DescribeSpotPriceHistoryOptions.Builder.from(from)
+            .to(to).productDescription("description").instanceType("m1.small")));
+
+      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=DescribeSpotPriceHistory&StartTime=1970-05-23T21%3A21%3A18.910Z&EndTime=2009-02-13T23%3A31%3A31.011Z&ProductDescription=description&InstanceType.1=m1.small",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, DescribeSpotPriceHistoryResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java
new file mode 100644
index 0000000..f5d6d4d
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.aws.ec2.features;
+
+import static org.jclouds.ec2.domain.Tag.ResourceType.SECURITY_GROUP;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.ec2.features.internal.BaseTagApiLiveTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true)
+public class TagSecurityGroupLiveTest extends BaseTagApiLiveTest {
+   public TagSecurityGroupLiveTest() {
+      provider = "aws-ec2";
+   }
+
+   @Override
+   protected Resource createResourceForTagging(String prefix) {
+      try {
+         return new Resource(securityGroupApi().createSecurityGroupInRegionAndReturnId(null, prefix, prefix),
+               SECURITY_GROUP);
+      } catch (IllegalStateException e) {
+         return new Resource(Iterables.get(securityGroupApi().describeSecurityGroupsInRegion(null, prefix), 0).getId(),
+               SECURITY_GROUP);
+      }
+   }
+
+   @Override
+   protected void cleanupResource(Resource resource) {
+      securityGroupApi().deleteSecurityGroupInRegionById(null, resource.id);
+   }
+
+   private AWSSecurityGroupApi securityGroupApi() {
+      return AWSEC2Api.class.cast(api).getSecurityGroupApi().get();
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/60b2f3fa/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java
new file mode 100644
index 0000000..cd6b3b7
--- /dev/null
+++ b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.aws.ec2.functions;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.jclouds.ssh.SshKeys.fingerprintPublicKey;
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.aws.ec2.AWSEC2Api;
+import org.jclouds.aws.ec2.features.AWSKeyPairApi;
+import org.jclouds.ec2.domain.KeyPair;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class ImportOrReturnExistingKeypairTest {
+   private static final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCcm8DjTHg4r72dVhNLQ33XpUyMLr+ph78i4NR3LqF1bXDP0g4xNLcI/GUTQq6g07X8zs7vIWyjoitqBPFSQ2onaZQ6pXQF/QISRQgrN5hEZ+nH5Aw+isdstBeOMWKdYrCJtm6/qWq2+rByyuNbtulazP3H7SqoozSjRSGNQyFNGpmhjGgTbNQftYDwlFq0T9tCSO/+dYF8j79bNIOEmfsCMiqXQ13hD5vGiEgkRm7zIPDUfpOl3ubDzebpRgGTh5kfv2vd3Z665AxQoi6fItvDu80knyphMlC41giIm5YqfPOPG4lR+6aF06p+NKhvOeECNMtRsD9u1kKJD9NqxXhx";
+
+   private static final KeyPair pair = KeyPair.builder().region("region").keyName("jclouds#group").sha1OfPrivateKey(
+            "foo").build();
+   private static final KeyPair pairWithFingerprint = pair.toBuilder().fingerprint(fingerprintPublicKey(PUBLIC_KEY))
+            .build();
+
+   @Test
+   public void testApply() {
+      AWSEC2Api client = createMock(AWSEC2Api.class);
+      AWSKeyPairApi keyApi = createMock(AWSKeyPairApi.class);
+
+      expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();
+
+      expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andReturn(pair);
+
+      replay(client);
+      replay(keyApi);
+
+      ImportOrReturnExistingKeypair parser = new ImportOrReturnExistingKeypair(client);
+
+      assertEquals(parser.importOrReturnExistingKeypair("region", "group", PUBLIC_KEY), pairWithFingerprint);
+
+      verify(client);
+      verify(keyApi);
+   }
+
+   @Test
+   public void testApplyWithIllegalStateExceptionReturnsExistingKey() {
+      AWSEC2Api client = createMock(AWSEC2Api.class);
+      AWSKeyPairApi keyApi = createMock(AWSKeyPairApi.class);
+
+      expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();
+
+      expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow(
+               new IllegalStateException());
+      expect(keyApi.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet.of(pair));
+
+      replay(client);
+      replay(keyApi);
+
+      ImportOrReturnExistingKeypair parser = new ImportOrReturnExistingKeypair(client);
+
+      // enriching to include the ssh fingerprint so that ssh logs are easier to correlate
+      assertEquals(parser.importOrReturnExistingKeypair("region", "group", PUBLIC_KEY), pairWithFingerprint);
+
+      verify(client);
+      verify(keyApi);
+
+   }
+
+   @Test
+   public void testApplyWithIllegalStateExceptionRetriesWhenExistingKeyNotFound() {
+      AWSEC2Api client = createMock(AWSEC2Api.class);
+      AWSKeyPairApi keyApi = createMock(AWSKeyPairApi.class);
+
+      expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();
+
+      expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow(
+               new IllegalStateException());
+      expect(keyApi.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet.<KeyPair> of());
+      expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow(
+               new IllegalStateException());
+      expect(keyApi.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet.<KeyPair> of(pair));
+
+      replay(client);
+      replay(keyApi);
+
+      ImportOrReturnExistingKeypair parser = new ImportOrReturnExistingKeypair(client);
+
+      assertEquals(parser.importOrReturnExistingKeypair("region", "group", PUBLIC_KEY), pairWithFingerprint);
+
+      verify(client);
+      verify(keyApi);
+
+   }
+}